summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 599b0bf)
raw | patch | inline | side by side (parent: 599b0bf)
author | Erik Faye-Lund <kusmabite@gmail.com> | |
Tue, 23 Nov 2010 18:38:25 +0000 (19:38 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 24 Nov 2010 00:06:46 +0000 (16:06 -0800) |
The defintion of DIR expects the allocating function to extend
dd_name by over-allocating. This is not currently done in our
implementation of opendir. Fix this.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dd_name by over-allocating. This is not currently done in our
implementation of opendir. Fix this.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/msvc.c | patch | blob | history |
diff --git a/compat/msvc.c b/compat/msvc.c
index d6096e4bd96ddb82da7eb653cbde0e73172e0391..c195365d2cf77348b0646f210adb984ae75d07bc 100644 (file)
--- a/compat/msvc.c
+++ b/compat/msvc.c
DIR *opendir(const char *name)
{
- int len;
+ int len = strlen(name);
DIR *p;
- p = malloc(sizeof(DIR));
+ p = malloc(sizeof(DIR) + len + 2);
if (!p)
return NULL;
- memset(p, 0, sizeof(DIR));
- strncpy(p->dd_name, name, PATH_MAX);
- len = strlen(p->dd_name);
+ memset(p, 0, sizeof(DIR) + len + 2);
+ strcpy(p->dd_name, name);
p->dd_name[len] = '/';
p->dd_name[len+1] = '*';