Re: Bug? "fstat64(f, &sb) < 0 && S_ISREG(sb.st_mode)"

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

 



I see the change was introduced here
http://git.kernel.org/cgit/utils/dash/dash.git/commit/?id=f78674ed6f95b594dcac0e96d6a76c5f64aa2cbf,
by importing code from FreeBSD's sh.

What I find interesting is testing the contents of 'sb', when the
fstat64 call failed. FreeBSD's code has the opposite:
https://github.com/freebsd/freebsd/blob/master/bin/sh/redir.c#L200,
i.e. they do:

    if (fstat(f, &sb) != -1 && S_ISREG(sb.st_mode)) {

BTW, that code was introduced here:
https://github.com/freebsd/freebsd/commit/e3cb9d1015e8283f4f9d116cf50f510741f8c0dd

Also, the way the open is performed has an interesting consequence,
i.e. the redirection operation on a FIFO blocks until something is
written to the FIFO:

hp% dash -Cc 'rm ff; mkfifo ff; echo a > ff'
^Cdash: 1: cannot create ff: Interrupted system call

It seems to be the same case for mksh, ksh93, posh, pdksh. Not that it
matters though.
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux