summaryrefslogtreecommitdiff
path: root/compat/msvc.c
diff options
context:
space:
mode:
authorErik Faye-Lund <kusmabite@gmail.com>2010-11-23 18:38:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-11-24 00:06:46 (GMT)
commit17194c1e96eddb43d2608fe7bd121256d17118ee (patch)
treec442288f3a016cf5ce5cf4ed19fa3474e92a5e29 /compat/msvc.c
parent599b0bf438e387dbaf00dbadcbe41b2a0de90db1 (diff)
downloadgit-17194c1e96eddb43d2608fe7bd121256d17118ee.zip
git-17194c1e96eddb43d2608fe7bd121256d17118ee.tar.gz
git-17194c1e96eddb43d2608fe7bd121256d17118ee.tar.bz2
msvc: opendir: allocate enough memory
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>
Diffstat (limited to 'compat/msvc.c')
-rw-r--r--compat/msvc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/compat/msvc.c b/compat/msvc.c
index d6096e4..c195365 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] = '*';