public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* __atfct_seterrno() or futimesat() broken
@ 2006-01-28 16:55 Thorsten Kukuk
  2006-02-02 10:15 ` Roland McGrath
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Kukuk @ 2006-01-28 16:55 UTC (permalink / raw)
  To: libc-hacker


Hi,

if you call futimesat() without kernel syscall support and without
/proc mounted you will get a seg.fault in __atfct_seterrno():

(gdb) down
#0  0x400d8f53 in __atfct_seterrno (errval=2, fd=0,
    buf=0xbfffe4e0 "/proc/self/fd/0") at openat.c:61
61                *(char *) strchr (buf + sizeof "/proc/self/fd", '/') = '\0';


The problem is that all *at.c files uses:
static const char procfd[] = "/proc/self/fd/%d/%s";

except futimesat.c, which does not append the filename after the
file descriptor (as you can see from gdb output).
So the strchr will not find a "/" and the return value is NULL.

First question is: Should futimesat.c append the filename, too, or
should it not call __atfct_seterrno?

Second question about __atfct_seterrno: This function only checks for
ENOTDIR if /proc is mounted. Why? utime() in futimesat.c returns
ENOENT for this case:

utimes("/proc/self/fd/0", NULL)         = -1 ENOENT (No such file or directory)

Shouldn't the check, if /proc is mounted, be the first on in 
__atfct_seterrno?

  Thorsten

-- 
Thorsten Kukuk         http://www.suse.de/~kukuk/      kukuk@suse.de
SUSE LINUX Products GmbH       Maxfeldstr. 5       D-90409 Nuernberg
--------------------------------------------------------------------    
Key fingerprint = A368 676B 5E1B 3E46 CFCE  2D97 F8FD 4E23 56C6 FB4B

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: __atfct_seterrno() or futimesat() broken
  2006-01-28 16:55 __atfct_seterrno() or futimesat() broken Thorsten Kukuk
@ 2006-02-02 10:15 ` Roland McGrath
  0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2006-02-02 10:15 UTC (permalink / raw)
  To: Thorsten Kukuk; +Cc: libc-hacker

I don't see how the lstat check that did the problematic string twiddling
was actually doing anything for us not better done by the fstat check for
the EBADF case.  I changed it to use the simple fstat check for EBADF on
ENOENT as well as ENOTDIR, which gets rid of the code with the bad
assumptions about the contents of BUF.  I also made it do the check for
missing /proc on ENOENT as well.  There are in fact many other potential
error codes that could be /proc is not mounted as expected, but ENOENT is
in fact the most likely one (and ENOTDIR possible, but not perhaps any more
likely than several others).


Thanks,
Roland

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-02 10:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-28 16:55 __atfct_seterrno() or futimesat() broken Thorsten Kukuk
2006-02-02 10:15 ` Roland McGrath

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).