[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: fortune bug ?



Le mardi 31 mai 2005 à 14:52 +0100, Lee Braiden a écrit :
> On Tuesday 31 May 2005 14:41, Aurélien Campéas wrote:
> >     if (stat(file, &staat) == 0)
> > 	default:
> > 	    perror("fortune: bad juju in is_existant");
> > 	    exit(1);
> > Do someone knows a tool to expose the call graph of a C program ?
> 
> The easiest way might be to run it through strace (strace 2>log fortune), find 
> (near the end of the log) where it writes that error message, then look for 
> the first stat() call before that in the same log.  Hopefully it'll show what 
> it's trying to access.
> 

good idea !


execve("/usr/games/fortune", ["fortune"], [/* 28 vars */]) = 0
uname({sys="Linux", node="eve", ...})   = 0
brk(0)                                  = 0x8050000
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fe9000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=59815, ...}) = 0
old_mmap(NULL, 59815, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7fda000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/usr/lib/librecode.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p/\3\000"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=1279588, ...}) = 0
old_mmap(NULL, 1279048, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xb7ea1000
old_mmap(0xb7fac000, 188416, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x10b000) = 0xb7fac000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/tls/libc.so.6", O_RDONLY)    = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`Z\1\000"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1254468, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7ea0000
old_mmap(NULL, 1264780, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xb7d6b000
old_mmap(0xb7e95000, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x129000) = 0xb7e95000
old_mmap(0xb7e9e000, 7308, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7e9e000
close(3)                                = 0
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7ea0800, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
munmap(0xb7fda000, 59815)               = 0
stat64("fr_FR.UTF-8@euro", 0xbfffcc5c)  = -1 ENOENT (No such file or directory)
open("fr_FR.UTF-8@euro", O_RDONLY)      = -1 ENOENT (No such file or directory)
brk(0)                                  = 0x8050000
brk(0x8071000)                          = 0x8071000
brk(0)                                  = 0x8071000
stat64("/usr/local/share/games/fortunes/fr_FR.UTF-8@euro", 0xbfffc7ac) = -1 EACCES (Permission denied)
dup(2)                                  = 3
fcntl64(3, F_GETFL)                     = 0x2 (flags O_RDWR)
fstat64(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fe8000
_llseek(3, 0, 0xbfffc6a8, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
write(3, "fortune: bad juju in is_existant"..., 52fortune: bad juju in is_existant: Permission denied
) = 52
close(3)                                = 0
munmap(0xb7fe8000, 4096)                = 0
exit_group(1)                           = ?



a lot of crap here, but look at the last stat64 syscalls near the end :
it looks like a bug related to localisation (fortune tries to open a
file named "fr_FR.UTF ..." instead of a real file). Indeed for this
system I had the funny idea to ask for encoding of all files in UTF-8
instead of iso-latin-1 as I usually do.






**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.clearswift.com
**********************************************************************




Reply to: