Date: Tue, 25 Feb 1997 22:53:04 +1100 From: Bruce Evans <bde@zeta.org.au> To: agifford@infowest.com, freebsd-stable@freebsd.org Subject: Re: 2.1.7 and Tripwire ftruncate() fun (MORE INFO) Message-ID: <199702251153.WAA08366@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>I must say I was (and I still am) very puzzled. A quick 'man errno' >informed me: > 22 EINVAL Invalid argument. Some invalid argument was supplied. (For ex- > ample, specifying an undefined signal to a signal or kill func- > tion). >Then a quick 'man ftruncate' returned: > Ftruncate() succeeds unless: > [EBADF] The fd is not a valid descriptor. > [EINVAL] The fd references a socket, not a file. > [EINVAL] The fd is not open for writing. > >>From my test code and from looking at the tripwire source, the fd is a FILE >(not a socket) and is open for WRITING, so why is ftruncate() returning >EINVAL? I cannot understand it. From looking at the contents of the temp ftruncate also fails with errno EINVAL if the requested length is negative. This may be caused by not including <unistd.h> so that there is no prototype in scope and the behaviour is undefined (the actual behaviour is to pick up semi-random garbage from the stack for the high 32 bits of the length). Use `ktrace tripwire ... kdump >foo' to see what the actual ftruncate args are. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702251153.WAA08366>
