(canonicalize): Zero terminate path to copy on error.

This commit is contained in:
Ulrich Drepper 2000-02-11 18:04:18 +00:00
parent 8c201918bc
commit 8aa2f31c9a

View File

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