From a993273c0d4d1907028adee7a2ae012826fd316c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 31 Aug 1995 00:02:32 +0000 Subject: Wed Aug 30 16:44:55 1995 Roland McGrath * sysdeps/mach/hurd/select.c: Deal with out of order replies during io_select request loop. Handle MACH_RCV_TIMED_OUT error from requests. * hurd/intr-msg.c: If the user passed the MACH_RCV_TIMEOUT option, distinguish MACH_RCV_TIMED_OUT from EINTR. * posix/glob.c (glob): Use realloc to extend strings for GLOB_MARK slash. (glob_in_dir): Don't allocate extra byte here. * sysdeps/i386/dl-machine.h (ELF_MACHINE_BEFORE_RTLD_RELOC): Decrement the DT_RELSZ value for the skipped reloc. --- posix/glob.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'posix/glob.c') diff --git a/posix/glob.c b/posix/glob.c index 1354150..84fe194 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -417,7 +417,17 @@ glob (pattern, flags, errfunc, pglob) for (i = oldcount; i < pglob->gl_pathc; ++i) if (__lstat (pglob->gl_pathv[i], &st) == 0 && S_ISDIR (st.st_mode)) - strcat (pglob->gl_pathv[i], "/"); + { + size_t len = strlen (pglob->gl_pathv[i]) + 2; + char *new = realloc (pglob->gl_pathv[i], len); + if (new == NULL) + { + globfree (pglob); + return GLOB_NOSPACE; + } + strcpy (&new[len - 2], "/"); + pglob->gl_pathv[i] = new; + } } if (!(flags & GLOB_NOSORT)) @@ -617,7 +627,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob) if (len == 0) len = strlen (name); new->name - = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1); + = (char *) malloc (len + 1); if (new->name == NULL) goto memory_error; memcpy ((__ptr_t) new->name, name, len); @@ -635,7 +645,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob) nfound = 1; names = (struct globlink *) __alloca (sizeof (struct globlink)); names->next = NULL; - names->name = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1); + names->name = (char *) malloc (len + 1); if (names->name == NULL) goto memory_error; memcpy (names->name, pattern, len); -- cgit v1.1