Permalink
Browse files

win: fix fs__readdir buffer overflow bug

Thanks Runner Mei for pointing this out. Closes GH-224.
  • Loading branch information...
1 parent 66f3925 commit 179f475b2ad64729feb0422f06ce133cb364482a @piscisaureus piscisaureus committed Oct 22, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/win/fs.c
View
@@ -424,7 +424,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
len = wcslen(name);
if (!buf) {
- buf = (wchar_t*)malloc(buf_size);
+ buf = (wchar_t*)malloc(buf_size * sizeof(wchar_t));
if (!buf) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
}
@@ -435,7 +435,7 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
while ((ptr - buf) + len + 1 > buf_size) {
buf_size *= 2;
path2 = buf;
- buf = (wchar_t*)realloc(buf, buf_size);
+ buf = (wchar_t*)realloc(buf, buf_size * sizeof(wchar_t));
if (!buf) {
uv_fatal_error(ERROR_OUTOFMEMORY, "realloc");
}

0 comments on commit 179f475

Please sign in to comment.