]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(canonicalize): Zero terminate path to copy on error.
authorUlrich Drepper <drepper@redhat.com>
Fri, 11 Feb 2000 18:04:18 +0000 (18:04 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 11 Feb 2000 18:04:18 +0000 (18:04 +0000)
stdlib/canonicalize.c

index e4f7c9f62895a0b403783137641bc9859fd6937e..c4edb48734802008e17a2e49b4e35a618d0f40bd 100644 (file)
@@ -76,7 +76,10 @@ canonicalize (const char *name, char *resolved)
   if (name[0] != '/')
     {
       if (!__getcwd (rpath, path_max))
-       goto error;
+       {
+         rpath[0] = '\0';
+         goto error;
+       }
       dest = strchr (rpath, '\0');
     }
   else
@@ -122,6 +125,9 @@ canonicalize (const char *name, char *resolved)
              if (resolved)
                {
                  __set_errno (ENAMETOOLONG);
+                 if (dest > rpath + 1)
+                   dest--;
+                 *dest = '\0';
                  goto error;
                }
              new_size = rpath_limit - rpath;