kern/164793: 'write' system call violates POSIX standard

Nicolas Bourdaud nicolas.bourdaud at gmail.com
Wed Feb 15 13:40:11 UTC 2012


The following reply was made to PR standards/164793; it has been noted by GNATS.

From: Nicolas Bourdaud <nicolas.bourdaud at gmail.com>
To: Bruce Evans <brde at optusnet.com.au>
Cc: freebsd-gnats-submit at FreeBSD.org, freebsd-bugs at FreeBSD.org
Subject: Re: kern/164793: 'write' system call violates POSIX standard
Date: Wed, 15 Feb 2012 14:13:31 +0100

 This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
 --------------enig6C66010532ACA49C7A3CE91B
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable
 
 On 05/02/2012 19:54, Bruce Evans wrote:
 > I think this is actually a bug in POSIX (XSI).  Most programs aren't
 > prepared to deal with short writes, and returning an error like
 > truncate() is specified to is adequate.
 
 I disagree, I think that most programs that check that the write
 succeeded also check that the write was complete. Actually it was
 because my programs were assuming the POSIX behavior that I notice the
 bug. In addition, I think (this must be confirmed) that the bug don't
 affect the version 8.2... So the programs are already facing the POSIX
 behavior. Moreover the programs that are cross platform (in particular
 ported to Linux) are already facing this behavior.
 
 Whatever is decided, either freebsd should conform to the POSIX
 standard, either the standard should be changed.
 
 
 >> Patch attached with submission follows:
 >> ...
 >> int main(void)
 >> {
 >>     struct rlimit lim;
 >>     int fd;
 >>     ssize_t retc;
 >>     size_t count =3D 0;
 >>     const char pattern[PATTSIZE] =3D "Hello world!";
 >>
 >>     signal(SIGXFSZ, SIG_IGN);
 >>     lim.rlim_cur =3D LIMSIZE;
 >>     setrlimit(RLIMIT_FSIZE, &lim);
 >=20
 > This is missing initialization of at least lim.rlim_max in lim.  This
 > gave the bizarre behaviour that when the program was statically linked,=
 
 > it failed for the first write, because the stack garbage for
 > lim.rlim_max happened to be 0.
 
 Yes I forgot one line:
 	getrlimit(RLIMIT_FSIZE, &lim);
 just before "lim.rlim_cur =3D LIMSIZE;"
 
 Best regards
 
 Nicolas
 
 
 
 
 --------------enig6C66010532ACA49C7A3CE91B
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.10 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
 iQIcBAEBCAAGBQJPO697AAoJEMTcslrXGllyZA8P/3JXPOFJEXOq9oDGBZFbZ1dx
 EwD8lGjcEwFbw6ZhybBP/EDLldU2J41cOUQ2hI4CCgUrI5lG9FN5P0Nqqa9S4yVA
 06N3j0z2ZQuAPcQU6xgU6F4RkSRf8v4EdlAxXcqtP1UEIYwtETx6fkz8vM7hcgWV
 tIqbWUPmYJp5G3CtHbu29oPt3qUXNTRyO4um/zPbXGdAKVGlvoiv86L6GOrwFHCf
 iLni2W3hgKMBBzSAexHgNpb+bFlPJXSMePADL1HsFi350znwlscXZgLiyN7uHo2s
 GCzsckhOpyed40io6gM/md2QGn68U6csYetDEpn5O/YpUQXKJFjNodil3M8d1orV
 6O8JNCIbCLovlMZSBmZLRTdzBi1thmaLD/xBHTKoZbZ/950c1SY+u1/PKoO2PPxn
 9/QKEr7U9HNyMP5VqiUSnn6aidRnJX4dwdMKD5WF05Mf5C0HYPKBYDtB1CXIPwGr
 h4sAVc6paTCdj3m2G6Hu6cYY95WvnOkYeyOoVSgr1hKM+WXoMz3GWMAPKeuzSizO
 wN0BXVo0O7EvuXV68dpEe/jhmGfdipRKPxjoN6UNYP7Avwyex6fUxBJTDrrA8p7i
 hQ5YGS/nBWs1CQAgz9uga1iSmNjFmn+uHPqmIuxRtf5DHsHAW2I5BqFJ1o/YHyZZ
 E93qQBVtPOy29ixeMsqR
 =VNCr
 -----END PGP SIGNATURE-----
 
 --------------enig6C66010532ACA49C7A3CE91B--


More information about the freebsd-bugs mailing list