From owner-freebsd-stable Tue Feb 25 03:57:10 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id DAA17629 for stable-outgoing; Tue, 25 Feb 1997 03:57:10 -0800 (PST) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id DAA17621 for ; Tue, 25 Feb 1997 03:57:06 -0800 (PST) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.3/8.6.9) id WAA08366; Tue, 25 Feb 1997 22:53:04 +1100 Date: Tue, 25 Feb 1997 22:53:04 +1100 From: Bruce Evans Message-Id: <199702251153.WAA08366@godzilla.zeta.org.au> To: agifford@infowest.com, freebsd-stable@freebsd.org Subject: Re: 2.1.7 and Tripwire ftruncate() fun (MORE INFO) Sender: owner-stable@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >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 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