From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 4386B3938C1E for ; Fri, 1 May 2020 22:02:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4386B3938C1E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-041HRtKqN1mV3X_MtzuiMQ-1; Fri, 01 May 2020 18:02:20 -0400 X-MC-Unique: 041HRtKqN1mV3X_MtzuiMQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 559C6835B43; Fri, 1 May 2020 22:02:19 +0000 (UTC) Received: from greed.delorie.com (ovpn-112-52.phx2.redhat.com [10.3.112.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26EA361528; Fri, 1 May 2020 22:02:19 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.14.7/8.14.7) with ESMTP id 041M2IJr020759; Fri, 1 May 2020 18:02:18 -0400 From: DJ Delorie To: Martin Sebor Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] improve out-of-bounds checking with GCC 10 attribute access [BZ #25219] In-Reply-To: (message from Martin Sebor on Fri, 1 May 2020 13:54:00 -0600) Date: Fri, 01 May 2020 18:02:18 -0400 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_1, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2020 22:02:23 -0000 Martin Sebor writes: > Thanks for the careful review! This new version LGTM. Reviewed-by: DJ Delorie (but IMHO a second set of eyes would be good for this one) > Yes, that's wrong. Good catch! I completely missed stdio when > testing so I also didn't notice I forgot to add the attribute to > fgets() itself. I've fixed that in the updated patch. Ok. >> IMHO comment should state that the first argument is index 1. >>=20 >> IMHO should document what happens when size-index is missing. > > I've tweaked the comment a bit. I hesitate to go into a lot of > detail here and would expect people needing it to read the manual. Right, but there should be just enough info for someone adding a new use of it to know what to do, without requiring the gcc docs. The new comment is fine. >> __buf[???] > > When size-index is missing at least one byte of the array must be > accessible (or the pointer must be null). There's no way to specify > a constant size with the current syntax. In the future I'd like to > try to teach GCC to get it from the argument itself (for ordinary > arrays as well as for VLAs): Makes sense, just didn't know. >> NOTE: does not use the __attr_access macro > > Fixed, thanks. Ok.