summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compat/msvc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/compat/msvc.c b/compat/msvc.c
index d6096e4bd9..c195365d2c 100644
--- a/compat/msvc.c
+++ b/compat/msvc.c
@@ -5,15 +5,14 @@
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] = '*';