diff options
author | Pierre Joye <pajoye@php.net> | 2011-01-10 08:07:38 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2011-01-10 08:07:38 +0000 |
commit | 639d3fbcfb1f859cb29bbd251a6ff8113ccb9a97 (patch) | |
tree | b7a96e740d31c359511ac71e392720aaab7a6122 | |
parent | 10a1f90ab046bbca89c3cf4b8e843821b3b0260f (diff) | |
download | php-git-639d3fbcfb1f859cb29bbd251a6ff8113ccb9a97.tar.gz |
- possible NULL deref
-rw-r--r-- | win32/readdir.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/win32/readdir.c b/win32/readdir.c index 52ebe2fd09..9525fc0d6b 100644 --- a/win32/readdir.c +++ b/win32/readdir.c @@ -33,6 +33,9 @@ DIR *opendir(const char *dir) } filespec = (char *)malloc(strlen(resolved_path_buff) + 2 + 1); + if (filespec == NULL) { + return NULL; + } strcpy(filespec, resolved_path_buff); index = strlen(filespec) - 1; if (index >= 0 && (filespec[index] == '/' || @@ -41,6 +44,9 @@ DIR *opendir(const char *dir) strcat(filespec, "\\*"); dp = (DIR *) malloc(sizeof(DIR)); + if (dp == NULL) { + return NULL; + } dp->offset = 0; dp->finished = 0; @@ -140,6 +146,10 @@ int rewinddir(DIR *dp) dp->finished = 0; filespec = (char *)malloc(strlen(dp->dir) + 2 + 1); + if (filespec == NULL) { + return -1; + } + strcpy(filespec, dp->dir); index = strlen(filespec) - 1; if (index >= 0 && (filespec[index] == '/' || |