diff --git a/ChangeLog b/ChangeLog index 6876cb92de..656e5dacd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jul 6 00:51:43 2000 WATANABE Hirofumi + + * win32/win32.c (NtCmdGlob): patterns should be separated and + NUL terminated. + Wed Jul 5 22:27:56 2000 WATANABE Hirofumi * cygwin/GNUmakefile: use ruby.def to make rubycw.dll. diff --git a/win32/win32.c b/win32/win32.c index 5780bff261..2bc633a214 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -872,13 +872,28 @@ insert(char *path, ListInfo *listinfo) } } +#ifdef HAVE_SYS_PARAM_H +# include +#else +# define MAXPATHLEN 512 +#endif + +void NtCmdGlob (NtCmdLineElement *patt) { ListInfo listinfo; + char buffer[MAXPATHLEN], *buf = buffer; listinfo.head = listinfo.tail = 0; - rb_glob(patt->str, insert, (VALUE)&listinfo); + if (patt->len >= MAXPATHLEN) + buf = ruby_xmalloc(patt->len + 1); + + strncpy(buf, patt->str, patt->len); + buf[patt->len] = 0; + rb_glob(buf, insert, (VALUE)&listinfo); + if (buf != buffer) + free(buf); if (listinfo.head && listinfo.tail) { listinfo.head->prev = patt->prev;