From unknown Tue Jun 17 21:56:49 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#11675 <11675@debbugs.gnu.org> To: bug#11675 <11675@debbugs.gnu.org> Subject: Status: stty bad C semantics Reply-To: bug#11675 <11675@debbugs.gnu.org> Date: Wed, 18 Jun 2025 04:56:49 +0000 retitle 11675 stty bad C semantics reassign 11675 coreutils submitter 11675 Edward Schwartz severity 11675 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 11 15:26:31 2012 Received: (at submit) by debbugs.gnu.org; 11 Jun 2012 19:26:31 +0000 Received: from localhost ([127.0.0.1]:38225 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeAFy-0001u0-Ko for submit@debbugs.gnu.org; Mon, 11 Jun 2012 15:26:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40982) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeA97-0001jr-Qt for submit@debbugs.gnu.org; Mon, 11 Jun 2012 15:19:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SeA6Y-0002yz-8g for submit@debbugs.gnu.org; Mon, 11 Jun 2012 15:16:47 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:53025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeA6Y-0002yW-2G for submit@debbugs.gnu.org; Mon, 11 Jun 2012 15:16:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeA6W-0003gg-DH for bug-coreutils@gnu.org; Mon, 11 Jun 2012 15:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SeA6U-0002x1-HX for bug-coreutils@gnu.org; Mon, 11 Jun 2012 15:16:43 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:54562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeA6U-0002w5-8y for bug-coreutils@gnu.org; Mon, 11 Jun 2012 15:16:42 -0400 Received: by wgbds1 with SMTP id ds1so2529821wgb.30 for ; Mon, 11 Jun 2012 12:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=AQ9ng1tmDr8q0QdXktznYlhthIM4dQv4gRHEuhtPjZ4=; b=WqG6xEyBNAzic2rnQ3tuLvrsJfWpuAej8j2qgIAm53aqsSMtak5joJd3Z8QlnYIP7j E9TgmQ/SDI3YjW2C+6RHg0az1LMNEutvCd3ZzIMvAheU9b02gvgLTa6j4qcyZnk/1rG7 gGiTk+vL1kJz97Rq/+jnv5Bx3h/Ll1cwAAYCbLDoTXLTgNlh8L1xai+RfwOFpaxdQT7k 4ZPYqSV38F7HpjZ48ogl7zqVJbWHYncvybndZtX2/Dca/ojB4Ir9arhJUawd0Z17+y/k sstcWGg1a/ClPtIP1Oki0mGYX96O+jde4ux257HhXFAcyqc/Xv4LcfoPhDscMxGYdIxV 6MKQ== MIME-Version: 1.0 Received: by 10.216.214.155 with SMTP id c27mr7989564wep.116.1339442199371; Mon, 11 Jun 2012 12:16:39 -0700 (PDT) Received: by 10.216.162.195 with HTTP; Mon, 11 Jun 2012 12:16:39 -0700 (PDT) Date: Mon, 11 Jun 2012 15:16:39 -0400 X-Google-Sender-Auth: g8StDNDCA3NuZJJEffpb-34d9V0 Message-ID: Subject: stty bad C semantics From: Edward Schwartz To: bug-coreutils@gnu.org Content-Type: multipart/mixed; boundary=0016e6dd89d57da18504c2373003 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 11 Jun 2012 15:26:28 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) --0016e6dd89d57da18504c2373003 Content-Type: text/plain; charset=ISO-8859-1 Hi, I think there is a bug in main() of stty in coreutils 8.17. The gist of the problem is that two structures are initialized: struct termios mode = { 0, }; and struct termios new_mode = { 0, }; They are then both modified, and then compared with memcmp. The problem is that the structs contain padding bytes. The C99 standard says "The value of padding bytes when storing values in structures or unions (6.2.6.1)." is unspecified, so the padding bytes may not be set to zero. I don't have any problem compiling with gcc. On my machine, gcc initializes the entire struct memory with a loop that writes 0. I came across the bug when compiling coreutils under CIL, which rewrites many C language constructs to make them easier to analyze. CIL writes 0 to each struct field, leaving padding bytes untouched. Both are correct, under my interpretation of the C99 standard. However, CIL's behavior violates the assumptions of stty's memcmp, which assumes padding bytes are set to zero. The problem is easily fixed by using memset, instead of implied initializations. I am attaching a patch that does this. While it won't affect most coreutils users, it might save some time for someone using a non-standard compiler or analysis platform. Thanks, Ed --0016e6dd89d57da18504c2373003 Content-Type: application/octet-stream; name="stty.patch" Content-Disposition: attachment; filename="stty.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_h3bxalcl0 SW5kZXg6IHN0dHkuYwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzdHR5LmMJKHJldmlzaW9uIDExMDE5KQorKysg c3R0eS5jCSh3b3JraW5nIGNvcHkpCkBAIC03MjksNyArNzI5LDggQEAKIHsKICAgLyogSW5pdGlh bGl6ZSB0byBhbGwgemVyb2VzIHNvIHRoZXJlIGlzIG5vIHJpc2sgbWVtY21wIHdpbGwgcmVwb3J0 IGEKICAgICAgc3B1cmlvdXMgZGlmZmVyZW5jZSBpbiBhbiB1bmluaXRpYWxpemVkIHBvcnRpb24g b2YgdGhlIHN0cnVjdHVyZS4gICovCi0gIHN0cnVjdCB0ZXJtaW9zIG1vZGUgPSB7IDAsIH07Cisg IHN0cnVjdCB0ZXJtaW9zIG1vZGU7CisgIG1lbXNldCgmbW9kZSwgMCwgc2l6ZW9mKG1vZGUpKTsK IAogICBlbnVtIG91dHB1dF90eXBlIG91dHB1dF90eXBlOwogICBpbnQgb3B0YzsKQEAgLTEwMDIs OCArMTAwMyw5IEBACiAgICAgewogICAgICAgLyogSW5pdGlhbGl6ZSB0byBhbGwgemVyb2VzIHNv IHRoZXJlIGlzIG5vIHJpc2sgbWVtY21wIHdpbGwgcmVwb3J0IGEKICAgICAgICAgIHNwdXJpb3Vz IGRpZmZlcmVuY2UgaW4gYW4gdW5pbml0aWFsaXplZCBwb3J0aW9uIG9mIHRoZSBzdHJ1Y3R1cmUu ICAqLwotICAgICAgc3RydWN0IHRlcm1pb3MgbmV3X21vZGUgPSB7IDAsIH07Ci0KKyAgICAgIHN0 cnVjdCB0ZXJtaW9zIG5ld19tb2RlOworICAgICAgbWVtc2V0KCZuZXdfbW9kZSwgMCwgc2l6ZW9m KG5ld19tb2RlKSk7CisgICAgICAKICAgICAgIGlmICh0Y3NldGF0dHIgKFNURElOX0ZJTEVOTywg VENTQURSQUlOLCAmbW9kZSkpCiAgICAgICAgIGVycm9yIChFWElUX0ZBSUxVUkUsIGVycm5vLCAi JXMiLCBkZXZpY2VfbmFtZSk7CiAK --0016e6dd89d57da18504c2373003-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 11 15:52:55 2012 Received: (at 11675) by debbugs.gnu.org; 11 Jun 2012 19:52:55 +0000 Received: from localhost ([127.0.0.1]:38242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeAfX-0002U4-A3 for submit@debbugs.gnu.org; Mon, 11 Jun 2012 15:52:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30984) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeAfT-0002Ts-Rb for 11675@debbugs.gnu.org; Mon, 11 Jun 2012 15:52:53 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5BJo8p1021846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 11 Jun 2012 15:50:08 -0400 Received: from [10.3.113.88] (ovpn-113-88.phx2.redhat.com [10.3.113.88]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5BJo7P8021881; Mon, 11 Jun 2012 15:50:08 -0400 Message-ID: <4FD64BEE.3020204@redhat.com> Date: Mon, 11 Jun 2012 13:50:06 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Edward Schwartz Subject: Re: bug#11675: stty bad C semantics References: In-Reply-To: X-Enigmail-Version: 1.4.2 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig11F272325D294B36470E3005" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 11675 Cc: 11675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig11F272325D294B36470E3005 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 06/11/2012 01:16 PM, Edward Schwartz wrote: > Hi, >=20 > I think there is a bug in main() of stty in coreutils 8.17. The gist > of the problem is that two structures are initialized: >=20 > struct termios mode =3D { 0, }; >=20 > and >=20 > struct termios new_mode =3D { 0, }; >=20 > They are then both modified, and then compared with memcmp. The > problem is that the structs contain padding bytes. The C99 standard > says "The value of padding bytes when storing values in structures or > unions (6.2.6.1)." is unspecified, so the padding bytes may not be set > to zero. I disagree with your interpretation of C99, and claim instead that your CIL compiler is buggy. C99 6.7.8 para. 21: "If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than there are elements in the array, the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration." And while there is no way to zero out padding bits by direct assignment, I think we _are_ guaranteed that padding bits are zero when doing the same initialization as static storage duration if we did not call out all the named members. > The problem is easily fixed by using memset, instead of implied > initializations. I am attaching a patch that does this. While it > won't affect most coreutils users, it might save some time for someone > using a non-standard compiler or analysis platform. If I understand correctly, gcc is also able to optimize out the memset, so that your patch has no net impact and would allow us to work around your buggy compiler; but I will leave it up to Jim whether it is worth applying. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig11F272325D294B36470E3005 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.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJP1kvvAAoJEKeha0olJ0NqtBUIAJeSocdBmoWrsesQEuh7yOy+ mMvyg4oxyY87mN2bSQ9XLiwb5BpbV5MfubfP7zikTU5D0HUAy8GTr53CqHVZYmFF 0OrThwBVZvm4ntD7uhcq2f7thCtl51biZd2+c9McIUCXVTLzt9uWuXbAIsb0Z/gM bU6YPk2u7QXqHui6E77/JrIeTzS7yBG3eNqudE1M4Vox+Y5fyaG+4qB6boAxtv0o Ems+hTxo2EPXUcaIaF1RkaTefWtgEHEYzQM1+6dvK6w2K9Ob/pbNKfY/LvVTI+ie 3nBUFaw+8wYqvfjtZX8FPUV8adjbBnuHaHK6PPIpGR4Ft+crQ/cNhXAk0JPe1wc= =Hrd+ -----END PGP SIGNATURE----- --------------enig11F272325D294B36470E3005-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 11 16:11:38 2012 Received: (at 11675) by debbugs.gnu.org; 11 Jun 2012 20:11:38 +0000 Received: from localhost ([127.0.0.1]:38265 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeAxd-0002th-JT for submit@debbugs.gnu.org; Mon, 11 Jun 2012 16:11:38 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:47219) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeAxa-0002tY-Dm for 11675@debbugs.gnu.org; Mon, 11 Jun 2012 16:11:35 -0400 Received: by wgbdq10 with SMTP id dq10so3414157wgb.15 for <11675@debbugs.gnu.org>; Mon, 11 Jun 2012 13:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=jdbEV00z+IuNMI7OplmNyDazyXpaq4BV7X+F/3FT8sE=; b=N9aIOSONGZWnToNmHS5hxR1qEQa4ouRzgqlGZrCdfoVLs5Ax6LhBnCbIt67igTqGiw OE0UTRoBKuhCgFL1Kqhcg7YhhqJszT1U+MqCwITNif1MwU6OSF/3oAWQ/g+I0XJ16lEZ prpjkL/q74Eoq08kgioGsNgJqz/JOBqzl7KwYdbNtWX0ThI0Wt9CZ885O2I1C75cbli4 jCApiNqN7ReCrJqv62nYL4NCSmzqPeTukDkL2H2FKV571RWMQADcWZoTAMoClXORwF9y bWwuEk0C4nRFdMLHX+K+yT8/netbrBvUp5NWfEHHr/M/2iJhr5F4z8/aMviIzR3EIn7B NKmg== MIME-Version: 1.0 Received: by 10.180.20.137 with SMTP id n9mr23433436wie.3.1339445335351; Mon, 11 Jun 2012 13:08:55 -0700 (PDT) Received: by 10.216.162.195 with HTTP; Mon, 11 Jun 2012 13:08:55 -0700 (PDT) In-Reply-To: <4FD64BEE.3020204@redhat.com> References: <4FD64BEE.3020204@redhat.com> Date: Mon, 11 Jun 2012 16:08:55 -0400 X-Google-Sender-Auth: QO4wkPHc1vj0Bp_gtIlGYpUe2bg Message-ID: Subject: Re: bug#11675: stty bad C semantics From: Edward Schwartz To: Eric Blake Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 11675 Cc: 11675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On Mon, Jun 11, 2012 at 3:50 PM, Eric Blake wrote: > On 06/11/2012 01:16 PM, Edward Schwartz wrote: > > I disagree with your interpretation of C99, and claim instead that your > CIL compiler is buggy. > > C99 6.7.8 para. 21: > > "If there are fewer initializers in a brace-enclosed list than there are > elements or members of an aggregate, or fewer characters in a string > literal used to initialize an array of known size than there are > elements in the array, the remainder of the aggregate shall be > initialized implicitly the same as objects that have static storage > duration." > > And while there is no way to zero out padding bits by direct assignment, > I think we _are_ guaranteed that padding bits are zero when doing the > same initialization as static storage duration if we did not call out > all the named members. Why do you think that? The standard is pretty vague here, but I interpret the "remainder of the aggregate" as the remaining fields, since the initializer list is a list of fields. I just want to make sure the bug is filed in the proper place. If it's a CIL bug, I'll file it with them. > >> The problem is easily fixed by using memset, instead of implied >> initializations. =A0I am attaching a patch that does this. =A0While it >> won't affect most coreutils users, it might save some time for someone >> using a non-standard compiler or analysis platform. > > If I understand correctly, gcc is also able to optimize out the memset, > so that your patch has no net impact and would allow us to work around > your buggy compiler; but I will leave it up to Jim whether it is worth > applying. Thanks, Ed From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 11 16:31:36 2012 Received: (at 11675) by debbugs.gnu.org; 11 Jun 2012 20:31:36 +0000 Received: from localhost ([127.0.0.1]:38281 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeBGx-0003LL-Ug for submit@debbugs.gnu.org; Mon, 11 Jun 2012 16:31:36 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:49972) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeBGv-0003LD-47 for 11675@debbugs.gnu.org; Mon, 11 Jun 2012 16:31:34 -0400 Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3WB5RN2KDJz3hhXj; Mon, 11 Jun 2012 22:29:03 +0200 (CEST) Received: from igel.home (ppp-88-217-105-24.dynamic.mnet-online.de [88.217.105.24]) by mail.mnet-online.de (Postfix) with ESMTPA id 3WB5R6742cz4KK2s; Mon, 11 Jun 2012 22:28:50 +0200 (CEST) Received: by igel.home (Postfix, from userid 501) id 1C80BCA2A2; Mon, 11 Jun 2012 22:28:49 +0200 (CEST) From: Andreas Schwab To: Eric Blake Subject: Re: bug#11675: stty bad C semantics References: <4FD64BEE.3020204@redhat.com> X-Yow: Everybody gets free BORSCHT! Date: Mon, 11 Jun 2012 22:28:49 +0200 In-Reply-To: <4FD64BEE.3020204@redhat.com> (Eric Blake's message of "Mon, 11 Jun 2012 13:50:06 -0600") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11675 Cc: Edward Schwartz , 11675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Eric Blake writes: > And while there is no way to zero out padding bits by direct assignment, > I think we _are_ guaranteed that padding bits are zero when doing the > same initialization as static storage duration if we did not call out > all the named members. I think the standard is very clear about the state of padding bytes [6.2.6.1#6]: When a value is stored in an object of structure or union type, including in a member object, the bytes of the object representation that correspond to any padding bytes take unspecified values. (6.7.8#10 says nothing about the initial value of any padding bytes.) Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 11 16:31:50 2012 Received: (at 11675) by debbugs.gnu.org; 11 Jun 2012 20:31:50 +0000 Received: from localhost ([127.0.0.1]:38284 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeBHB-0003Lk-SF for submit@debbugs.gnu.org; Mon, 11 Jun 2012 16:31:50 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:40383) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeBH9-0003Lc-Kc for 11675@debbugs.gnu.org; Mon, 11 Jun 2012 16:31:48 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id ADFC239E8008; Mon, 11 Jun 2012 13:29:08 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id obUvmbxizyce; Mon, 11 Jun 2012 13:29:08 -0700 (PDT) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 5159A39E8007; Mon, 11 Jun 2012 13:29:08 -0700 (PDT) Message-ID: <4FD65514.3020009@cs.ucla.edu> Date: Mon, 11 Jun 2012 13:29:08 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#11675: stty bad C semantics References: <4FD64BEE.3020204@redhat.com> In-Reply-To: <4FD64BEE.3020204@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11675 Cc: Edward Schwartz , 11675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) This area is a bit of a mess in the standard, but I think Edward Schwartz is right that initializers of auto variables are not guaranteed to clear padding. As I understand it under Eric Blake's interpretation, a complete initializer for an auto variable is not guaranteed to clear the padding, but an incomplete initializer is guaranteed to do so. This would be pretty strange. I think Edward's interpretation of the incomplete-initializer wording is more likely to be the correct one: namely, that missing initializers are treated as if they were zero. Even if the standard was intended to clear the padding, clearly in practice we have an implementation that doesn't do so, and it no doubt performs better that way, so I'd say something like Edward's patch is advisable. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 11 19:50:42 2012 Received: (at 11675) by debbugs.gnu.org; 11 Jun 2012 23:50:42 +0000 Received: from localhost ([127.0.0.1]:38492 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeENd-0003Sw-Q5 for submit@debbugs.gnu.org; Mon, 11 Jun 2012 19:50:42 -0400 Received: from mail1.vodafone.ie ([213.233.128.43]:18768) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeENa-0003Sl-Om for 11675@debbugs.gnu.org; Mon, 11 Jun 2012 19:50:39 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBADSD1k9tTH0t/2dsb2JhbAANOA64KQEBAQMBMgFGBQsLDQsJFg8JAwIBAgFFBg0BBwEBBYd9ELh8iySGEQObE4wtOg Received: from unknown (HELO [192.168.1.79]) ([109.76.125.45]) by mail1.vodafone.ie with ESMTP; 12 Jun 2012 00:47:58 +0100 Message-ID: <4FD683AD.5040007@draigBrady.com> Date: Tue, 12 Jun 2012 00:47:57 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#11675: stty bad C semantics References: <4FD64BEE.3020204@redhat.com> <4FD65514.3020009@cs.ucla.edu> In-Reply-To: <4FD65514.3020009@cs.ucla.edu> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11675 Cc: Edward Schwartz , Eric Blake , 11675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 06/11/2012 09:29 PM, Paul Eggert wrote: > This area is a bit of a mess in the standard, but I think > Edward Schwartz is right that initializers of auto variables > are not guaranteed to clear padding. > > As I understand it under Eric Blake's interpretation, a > complete initializer for an auto variable is not guaranteed > to clear the padding, but an incomplete initializer is > guaranteed to do so. This would be pretty strange. I agree with Eric's interpretation. There are ambiguous statements in the standard, but IMHO the _init_ requirement (C99 6.7.8 para. 21) trumps the _assignment_ requirement (6.2.6.1#6). I see it as a language standard way to init auto vars, so that they match static vars of the same type, and so can be compared. http://www.pixelbeat.org/programming/gcc/auto_init.html > I think Edward's interpretation of the incomplete-initializer > wording is more likely to be the correct one: namely, that > missing initializers are treated as if they were zero. > > Even if the standard was intended to clear the padding, > clearly in practice we have an implementation that doesn't > do so, and it no doubt performs better that way, so I'd say > something like Edward's patch is advisable. Well we've not had an issue in nearly 6 years with the existing form: http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commit;h=e245a66 If this was an isolated statement then I'd change for pragmatic reasons, but since it touches multiple places in the code I'd suggest patching coreutils locally (with essentially the reverse of the above), until CIL is fixed to conform to the standard. cheers, Pįdraig. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 11 20:16:39 2012 Received: (at 11675) by debbugs.gnu.org; 12 Jun 2012 00:16:39 +0000 Received: from localhost ([127.0.0.1]:38501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeEml-000420-4N for submit@debbugs.gnu.org; Mon, 11 Jun 2012 20:16:39 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:50143) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeEmi-00041s-8G for 11675@debbugs.gnu.org; Mon, 11 Jun 2012 20:16:37 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 6216039E8007; Mon, 11 Jun 2012 17:13:56 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Bg5Jftbx9YLA; Mon, 11 Jun 2012 17:13:56 -0700 (PDT) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id E4C3B39E8006; Mon, 11 Jun 2012 17:13:55 -0700 (PDT) Message-ID: <4FD689BF.5020802@cs.ucla.edu> Date: Mon, 11 Jun 2012 17:13:51 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#11675: stty bad C semantics References: <4FD64BEE.3020204@redhat.com> <4FD65514.3020009@cs.ucla.edu> <4FD683AD.5040007@draigBrady.com> In-Reply-To: <4FD683AD.5040007@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11675 Cc: Edward Schwartz , Eric Blake , 11675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 06/11/2012 04:47 PM, P=C3=A1draig Brady wrote: > it touches multiple places in the code Which other places? We do use =3D { FOO } to initialize in many places in the code, but I don't recall any other places that rely on initializing padding to zero. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 11 20:44:56 2012 Received: (at 11675) by debbugs.gnu.org; 12 Jun 2012 00:44:56 +0000 Received: from localhost ([127.0.0.1]:38513 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeFE8-0004fm-96 for submit@debbugs.gnu.org; Mon, 11 Jun 2012 20:44:56 -0400 Received: from mail1.vodafone.ie ([213.233.128.43]:39610) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeFE6-0004fe-CY for 11675@debbugs.gnu.org; Mon, 11 Jun 2012 20:44:55 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtEBAAeQ1k9tTH0t/2dsb2JhbAANOA6FSatphncBAQEEIw8BRhALDQsCAgUWCwICCQMCAQIBRQYNAQcBAa5Ckl+BIIoEhH+BEgObE4wtOg Received: from unknown (HELO [192.168.1.79]) ([109.76.125.45]) by mail1.vodafone.ie with ESMTP; 12 Jun 2012 01:42:13 +0100 Message-ID: <4FD69065.6040806@draigBrady.com> Date: Tue, 12 Jun 2012 01:42:13 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#11675: stty bad C semantics References: <4FD64BEE.3020204@redhat.com> <4FD65514.3020009@cs.ucla.edu> <4FD683AD.5040007@draigBrady.com> <4FD689BF.5020802@cs.ucla.edu> In-Reply-To: <4FD689BF.5020802@cs.ucla.edu> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11675 Cc: Edward Schwartz , Eric Blake , 11675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 06/12/2012 01:13 AM, Paul Eggert wrote: > On 06/11/2012 04:47 PM, PĆ”draig Brady wrote: >> it touches multiple places in the code > > Which other places? We do use = { FOO } > to initialize in many places in the code, but > I don't recall any other places that rely on > initializing padding to zero. Oh right, sorry. So if this is the only instance then I guess it's pragmatic to memset here (with an appropriate comment). It's still a bug I think in CIL, so it would be great to report there too. cheers, PĆ”draig. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 12 10:36:35 2012 Received: (at 11675) by debbugs.gnu.org; 12 Jun 2012 14:36:35 +0000 Received: from localhost ([127.0.0.1]:39544 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeSCw-00017O-Et for submit@debbugs.gnu.org; Tue, 12 Jun 2012 10:36:35 -0400 Received: from mx.meyering.net ([88.168.87.75]:45024) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeSCt-00017F-4W for 11675@debbugs.gnu.org; Tue, 12 Jun 2012 10:36:33 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 2DEB76005C; Tue, 12 Jun 2012 16:33:47 +0200 (CEST) From: Jim Meyering To: Edward Schwartz Subject: Re: bug#11675: stty bad C semantics In-Reply-To: (Edward Schwartz's message of "Mon, 11 Jun 2012 15:16:39 -0400") References: Date: Tue, 12 Jun 2012 16:33:47 +0200 Message-ID: <87ehpk4n1w.fsf@rho.meyering.net> Lines: 122 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11675 Cc: 11675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Edward Schwartz wrote: > Hi, > > I think there is a bug in main() of stty in coreutils 8.17. The gist > of the problem is that two structures are initialized: > > struct termios mode = { 0, }; > > and > > struct termios new_mode = { 0, }; > > They are then both modified, and then compared with memcmp. The > problem is that the structs contain padding bytes. The C99 standard > says "The value of padding bytes when storing values in structures or > unions (6.2.6.1)." is unspecified, so the padding bytes may not be set > to zero. > > I don't have any problem compiling with gcc. On my machine, gcc > initializes the entire struct memory with a loop that writes 0. > > I came across the bug when compiling coreutils under CIL, which > rewrites many C language constructs to make them easier to analyze. > CIL writes 0 to each struct field, leaving padding bytes untouched. > Both are correct, under my interpretation of the C99 standard. > However, CIL's behavior violates the assumptions of stty's memcmp, > which assumes padding bytes are set to zero. > > The problem is easily fixed by using memset, instead of implied > initializations. I am attaching a patch that does this. While it > won't affect most coreutils users, it might save some time for someone > using a non-standard compiler or analysis platform. > > Thanks, > Ed > > Index: stty.c > =================================================================== > --- stty.c (revision 11019) > +++ stty.c (working copy) > @@ -729,7 +729,8 @@ > { > /* Initialize to all zeroes so there is no risk memcmp will report a > spurious difference in an uninitialized portion of the structure. */ > - struct termios mode = { 0, }; > + struct termios mode; > + memset(&mode, 0, sizeof(mode)); > > enum output_type output_type; > int optc; > @@ -1002,8 +1003,9 @@ > { > /* Initialize to all zeroes so there is no risk memcmp will report a > spurious difference in an uninitialized portion of the structure. */ > - struct termios new_mode = { 0, }; > - > + struct termios new_mode; > + memset(&new_mode, 0, sizeof(new_mode)); > + > if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode)) > error (EXIT_FAILURE, errno, "%s", device_name); Hi Ed, Thank you for the report and the patch. That has prompted a nicely animated debate ;-) Here's a way to solve the problem that doesn't require restoring the memset calls. It feels slightly hackish, but there's already a comment in each case, so it seems ok. >From 5c2181c870f4bc1abaee8ffd0b088ab05f87a61c Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 12 Jun 2012 16:13:43 +0200 Subject: [PATCH] stty: portability: accommodate CIL * src/stty.c (main): Declare locals "mode" and "new_mode" to be static to ensure that each is initialized to zero, *including* all padding. While gcc clears padding of a local automatic initialized to "{ 0, }", CIL does not, and the C99 standard is not clear on this issue. Reported by Edward Schwartz. See http://bugs.gnu.org/11675 for details. --- THANKS.in | 1 + src/stty.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/THANKS.in b/THANKS.in index b9a6c64..51b2c7d 100644 --- a/THANKS.in +++ b/THANKS.in @@ -172,6 +172,7 @@ Doug Coleman coleman@iarc1.ece.utexas.edu Doug McLaren dougmc@comco.com Dragos Harabor dharabor@us.oracle.com Duncan Roe duncanr@optimation.com.au +Edward Schwartz edmcman@cmu.edu Edward Welbourne eddy@opera.com Edzer Pebesma Edzer.Pebesma@rivm.nl Egmont Koblinger egmont@uhulinux.hu diff --git a/src/stty.c b/src/stty.c index a3fc3dd..83b502c 100644 --- a/src/stty.c +++ b/src/stty.c @@ -730,7 +730,7 @@ main (int argc, char **argv) { /* Initialize to all zeroes so there is no risk memcmp will report a spurious difference in an uninitialized portion of the structure. */ - struct termios mode = { 0, }; + static struct termios mode; enum output_type output_type; int optc; @@ -1003,7 +1003,7 @@ main (int argc, char **argv) { /* Initialize to all zeroes so there is no risk memcmp will report a spurious difference in an uninitialized portion of the structure. */ - struct termios new_mode = { 0, }; + static struct termios new_mode; if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode)) error (EXIT_FAILURE, errno, "%s", device_name); -- 1.7.11.rc2.5.g68f532f From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 12 10:54:50 2012 Received: (at 11675) by debbugs.gnu.org; 12 Jun 2012 14:54:50 +0000 Received: from localhost ([127.0.0.1]:39558 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeSUb-0001Yg-Q3 for submit@debbugs.gnu.org; Tue, 12 Jun 2012 10:54:50 -0400 Received: from senmx12-mx.siemens-enterprise.com ([62.134.46.10]:54220) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeSUa-0001YZ-Gc for 11675@debbugs.gnu.org; Tue, 12 Jun 2012 10:54:49 -0400 Received: from MCHP01HTC.global-ad.net (unknown [172.29.42.234]) by senmx12-mx.siemens-enterprise.com (Server) with ESMTP id 0CC5023F04CB; Tue, 12 Jun 2012 16:52:05 +0200 (CEST) Received: from MCHP02MSX.global-ad.net ([169.254.4.138]) by MCHP01HTC.global-ad.net ([172.29.42.234]) with mapi id 14.01.0339.001; Tue, 12 Jun 2012 16:52:04 +0200 From: "Voelker, Bernhard" To: Jim Meyering , Edward Schwartz Subject: RE: bug#11675: stty bad C semantics Thread-Topic: bug#11675: stty bad C semantics Thread-Index: AQHNSKh/eIv0UrS6c0m7qfswOAh8sJb2wpcA Date: Tue, 12 Jun 2012 14:52:04 +0000 Message-ID: References: <87ehpk4n1w.fsf@rho.meyering.net> In-Reply-To: <87ehpk4n1w.fsf@rho.meyering.net> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.28.132.35] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11675 Cc: "11675@debbugs.gnu.org" <11675@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jim Meyering wrote: > That has prompted a nicely animated debate ;-) ... and it goes on ;-) What about these? find . -name '*.c' | xargs grep -F '0, };' ./src/ls.c: mbstate_t mbstate =3D { 0, }; ./src/shred.c: struct Options flags =3D { 0, }; ./src/tr.c: bool in_set[N_CHARS] =3D { 0, }; ./src/wc.c: mbstate_t state =3D { 0, }; ./src/pathchk.c: mbstate_t mbstate =3D { 0, }; Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 12 11:01:32 2012 Received: (at 11675) by debbugs.gnu.org; 12 Jun 2012 15:01:32 +0000 Received: from localhost ([127.0.0.1]:39570 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeSb5-0001ix-LG for submit@debbugs.gnu.org; Tue, 12 Jun 2012 11:01:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39809) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeSb2-0001io-BC for 11675@debbugs.gnu.org; Tue, 12 Jun 2012 11:01:30 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5CEwFHM004020 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 12 Jun 2012 10:58:15 -0400 Received: from [10.3.113.88] (ovpn-113-88.phx2.redhat.com [10.3.113.88]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5CEwEnW006653; Tue, 12 Jun 2012 10:58:14 -0400 Message-ID: <4FD75905.7030504@redhat.com> Date: Tue, 12 Jun 2012 08:58:13 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: "Voelker, Bernhard" Subject: Re: bug#11675: stty bad C semantics References: <87ehpk4n1w.fsf@rho.meyering.net> In-Reply-To: X-Enigmail-Version: 1.4.2 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigF313D897CB18BCD5B07862A3" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 11675 Cc: Edward Schwartz , Jim Meyering , "11675@debbugs.gnu.org" <11675@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigF313D897CB18BCD5B07862A3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 06/12/2012 08:52 AM, Voelker, Bernhard wrote: > Jim Meyering wrote: >=20 >> That has prompted a nicely animated debate ;-) >=20 > ... and it goes on ;-) >=20 > What about these? >=20 > find . -name '*.c' | xargs grep -F '0, };' > ./src/ls.c: mbstate_t mbstate =3D { 0, }; > ./src/shred.c: struct Options flags =3D { 0, }; > ./src/tr.c: bool in_set[N_CHARS] =3D { 0, }; > ./src/wc.c: mbstate_t state =3D { 0, }; > ./src/pathchk.c: mbstate_t mbstate =3D { 0, }; What about them? None of them are using memcmp(), so none of them care what the padding bytes (if any) got set to. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigF313D897CB18BCD5B07862A3 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.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJP11kGAAoJEKeha0olJ0NqBh0H/jvcFcMtJDO4fDxlKRcBAhJk H69wfqN+dh38Qe0p31gFS5q2zvwF6EBgffHSStYtLq80ek7Zesd78B7XvTOt2+dR BP00VHSxqbWmi+91DtmIdghtcHxq0D28afEVaymeej4HOEy1eqg6Sq6D7P/KP5HU t/hsCxk+pd9VBkJFaGXkZBy4XydpUw1xgbcjLLpAA9uxykeSl318DAoM2sphupUq oV0HBXLJ5JBu+cl2U2aIPIhDUeAUR6cwpW91XR4MbHyQlZB736AYf10WY2oheXqh XAtrodpJkFZVh04Q+MH73/++WF2Spxhuu54Q3roJrV7uk32+VXPf0sytLUeN5l8= =j7uA -----END PGP SIGNATURE----- --------------enigF313D897CB18BCD5B07862A3-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 12 12:36:38 2012 Received: (at 11675) by debbugs.gnu.org; 12 Jun 2012 16:36:39 +0000 Received: from localhost ([127.0.0.1]:39643 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeU58-0003sQ-O4 for submit@debbugs.gnu.org; Tue, 12 Jun 2012 12:36:38 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:47179) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeU56-0003sI-AI for 11675@debbugs.gnu.org; Tue, 12 Jun 2012 12:36:37 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id CB3CE39E8008; Tue, 12 Jun 2012 09:33:52 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gnds6GZpGy7M; Tue, 12 Jun 2012 09:33:52 -0700 (PDT) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 68C3A39E8007; Tue, 12 Jun 2012 09:33:52 -0700 (PDT) Message-ID: <4FD76F69.9010902@cs.ucla.edu> Date: Tue, 12 Jun 2012 09:33:45 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#11675: stty bad C semantics References: <87ehpk4n1w.fsf@rho.meyering.net> In-Reply-To: <87ehpk4n1w.fsf@rho.meyering.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11675 Cc: Edward Schwartz , 11675@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 06/12/2012 07:33 AM, Jim Meyering wrote: > Here's a way to solve the problem that doesn't require restoring > the memset calls. It feels slightly hackish But it's hackish in a good way! It's a bit faster and smaller and more portable than the existing code, and it's faster and smaller than all the other proposed fixes. It's clearly the best idea yet. Thanks for cutting the Gordian knot. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 12 12:44:09 2012 Received: (at 11675-done) by debbugs.gnu.org; 12 Jun 2012 16:44:10 +0000 Received: from localhost ([127.0.0.1]:39647 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeUCP-00044e-Ee for submit@debbugs.gnu.org; Tue, 12 Jun 2012 12:44:09 -0400 Received: from mx.meyering.net ([88.168.87.75]:45469) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeUCL-00044V-Nm for 11675-done@debbugs.gnu.org; Tue, 12 Jun 2012 12:44:07 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 39FC360061; Tue, 12 Jun 2012 18:41:21 +0200 (CEST) From: Jim Meyering To: Paul Eggert Subject: Re: bug#11675: stty bad C semantics In-Reply-To: <4FD76F69.9010902@cs.ucla.edu> (Paul Eggert's message of "Tue, 12 Jun 2012 09:33:45 -0700") References: <87ehpk4n1w.fsf@rho.meyering.net> <4FD76F69.9010902@cs.ucla.edu> Date: Tue, 12 Jun 2012 18:41:21 +0200 Message-ID: <87haug32ku.fsf@rho.meyering.net> Lines: 12 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11675-done Cc: Edward Schwartz , 11675-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Paul Eggert wrote: > On 06/12/2012 07:33 AM, Jim Meyering wrote: >> Here's a way to solve the problem that doesn't require restoring >> the memset calls. It feels slightly hackish > > But it's hackish in a good way! It's a bit faster > and smaller and more portable than the existing code, > and it's faster and smaller than all the other proposed > fixes. It's clearly the best idea yet. Thanks for > cutting the Gordian knot. Thanks. With that, I've pushed it and marked this as done. From unknown Tue Jun 17 21:56:49 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 11 Jul 2012 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator