Bug#47254: libc6: realpath: resolving circular symlinks should return ELOOP, not dump core
Package: libc6
Version: 2.0.7.19981211-6
Hi,
These simple circular symlinks, when passed to realpath C
function, cause a core dump, instead ELOOP should be returned.
23 jeff /project/save/jeff/try $ realpath bb
Segmentation fault (core dumped)
The program `symlinks' has no problem handling these same circular
symlinks.
24 jeff /project/save/jeff/try $ ls -l bb dd/aa
lrwxrwxrwx 1 jeff jeff 5 Sep 22 17:26 bb -> dd/aa
lrwxrwxrwx 1 jeff jeff 5 Sep 22 17:26 dd/aa -> ../bb
25 jeff /project/save/jeff/try $ symlinks -rtv bb
/project/save/jeff/try/bb: Too many levels of symbolic links
Here is what gdb says about core, the program listing is included,
27 jeff /project/save/jeff/try $ gdb realpath core
GNU gdb 4.17.m68k.objc.threads.hwwp.fpu.gnat
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License,
and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i486-pc-linux-gnu"...
Core was generated by `realpath bb'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/ld-linux.so.2...done.
#0 0x400396ae in realpath ()
(gdb) bt
#0 0x400396ae in realpath ()
#1 0x80485ad in main (argc=2, argv=0xbffff39c)
at /home/jss/locl/src/realpath/realpath.c:37
(gdb) list 17,51
17 #include <sys/param.h>
18 #include <unistd.h>
19 #include <stdio.h>
20
21 char *realpath (const char *path, char *resolved_path);
22 char *strerror (int errnum);
23
24 static char resolved[MAXPATHLEN];
25 static int errcnt;
26 static char *errstr;
27 extern int errno;
28
29 int
30 main (int argc, char *argv[])
31 {
32 int i;
33 char *realstr;
34
35 for (i = 1; i < argc; i++)
36 {
37 realstr = realpath (argv[i], &resolved[0]);
38 if (realstr == NULL)
39 {
40 errstr = strerror (errno);
41 fprintf (stderr, "%s: %s: %s\n", argv[0], argv[i], errstr);
42 errcnt++;
43 }
44 else
45 {
46 printf ("%s %s\n", argv[i], realstr);
47 }
48 }
49
50 return (errcnt ? 1 : 0);
51 }
Thanks,
--
Jeff Sheinberg <jeffsh@erols.com>
-- System Information
Debian Release: 2.1
Kernel Version: Linux eden-hda7 2.0.36 #5 Sat Oct 2 22:18:12 EDT 1999 i586 unknown
Versions of the packages libc6 depends on:
ii ldso 1.9.10-1 The Linux dynamic linker, library and utilit
Reply to: