* [PATCH] realpath fix
@ 2000-02-03 8:17 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2000-02-03 8:17 UTC (permalink / raw)
To: libc-hacker
Hi!
While looking at util-linux realpath, I found that even glibc realpath can
do weird things. __getcwd if it fails does not have to NULL terminate rpath
(and in case of ENAMETOOLONG the path is not NULL terminated either), but
then at error: we strcpy(resource, rpath); which might be very long string.
2000-02-03 Jakub Jelinek <jakub@redhat.com>
* stdlib/canonicalize.c (canonicalize): Zero terminate
path to copy on error.
--- canonicalize.c.jj Tue Feb 9 10:35:10 1999
+++ canonicalize.c Thu Feb 3 16:24:16 2000
@@ -76,7 +76,10 @@ canonicalize (const char *name, char *re
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 *re
if (resolved)
{
__set_errno (ENAMETOOLONG);
+ if (dest > rpath + 1)
+ dest--;
+ *dest = '\0';
goto error;
}
new_size = rpath_limit - rpath;
Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.41 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-02-03 8:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-03 8:17 [PATCH] realpath fix Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).