From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3820 invoked by alias); 12 Nov 2017 09:06:48 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 3809 invoked by uid 89); 12 Nov 2017 09:06:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=goal, 8s, modest, H*Ad:D*iana.org X-HELO: zimbra.cs.ucla.edu Subject: Re: [PATCH] add attribute nonstring To: Martin Sebor References: From: Paul Eggert Cc: GNU C Library , Time zone mailing list Message-ID: <85ee9ddd-0be5-04d3-7319-600bcf1eb8a6@cs.ucla.edu> Date: Sun, 12 Nov 2017 09:06:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------65693D68C6856841DBB3DFFC" X-SW-Source: 2017-11/txt/msg00375.txt.bz2 This is a multi-part message in MIME format. --------------65693D68C6856841DBB3DFFC Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-length: 1840 Thanks for mentioning the problem with GCC 8. If the intent of=20 __attribute__((__nonstring__)) is to consistently mark char arrays that are= not=20 necessarily null-terminated strings, then lots of data structures in the tz= db=20 code would need to be marked with this attribute. For example, every member= of=20 tzfile.h's 'struct tzhead' would have the attribute, because they are all c= har=20 arrays that might not be null-terminated. Looking at the proposed glibc patch, it seems its intent is more modest. Al= l=20 it's trying to do is to pacify GCC 8 so that GCC doesn't complain about cal= ls to=20 strncpy and strncat. In that case, a simpler and cleaner fix for tzdb is to= stop=20 using strncpy and strncat. (I suspect that the main reason tzdb uses strncp= y is=20 that its code is so old that it predates the widespread availability of mem= cpy.)=20 So I installed the attached patch into tzdb's zic.c and it should be part o= f the=20 next tzdb release. Perhaps you can this idea elsewhere in the rest of the glibc patch too. It = would=20 be a lot of work to consistently change glibc to use=20 __attribute__((__nonstring__)) for its documented purpose. If glibc can avo= id=20 calling strncpy and strncat, it won't need __NONSTRING; if not, then I sugg= est=20 changing this: /* Describes a char array that is not necessarily a NUL-terminated string. */ # define __NONSTRING __attribute__ ((__nonstring__)) to something more like this: /* Describes a char array whose address can safely be passed as the first argument to strncpy and strncat, as the char array is not necessarily a NUL-terminated string. */ # define __NONSTRING __attribute__ ((__nonstring__)) in sys/cdefs.h, so that the more-modest goal of the patch is clearer to the= reader. I'll CC: this to tz@iana.org as a heads-up there. --------------65693D68C6856841DBB3DFFC Content-Type: text/plain; charset=UTF-8; name="0001-Port-to-GCC-8-Wstringop-truncation.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0001-Port-to-GCC-8-Wstringop-truncation.txt" Content-length: 1875 RnJvbSA2NDFmMmM0OGIxMGRlYzVhYjZkZDkwZjU2MGI2NmUwNjFhYTY2MGJh IE1vbiBTZXAgMTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8 ZWdnZXJ0QGNzLnVjbGEuZWR1PgpEYXRlOiBTdW4sIDEyIE5vdiAyMDE3IDAw OjU3OjE5IC0wODAwClN1YmplY3Q6IFtQUk9QT1NFRF0gUG9ydCB0byBHQ0Mg OCAtV3N0cmluZ29wLXRydW5jYXRpb24KClByb2JsZW0gcmVwb3J0ZWQgYnkg TWFydGluIFNlYm9yIGluOgpodHRwczovL3NvdXJjZXdhcmUub3JnL21sL2xp YmMtYWxwaGEvMjAxNy0xMS9tc2cwMDMzNi5odG1sCiogTkVXUzogTWVudGlv biB0aGlzLgoqIHppYy5jICh3cml0ZXpvbmUpOiBVc2UgbWVtY3B5LCBub3Qg c3RybmNweS4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