From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44287 invoked by alias); 22 Nov 2017 00:14:31 -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 44270 invoked by uid 89); 22 Nov 2017 00:14:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,KB_WAM_FROM_NAME_SINGLEWORD,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=H*r:MSK X-HELO: vmicros1.altlinux.org Date: Wed, 22 Nov 2017 00:14:00 -0000 From: "Dmitry V. Levin" To: Martin Sebor Cc: Carlos O'Donell , GNU C Library Subject: Re: nonstrings in Glibc Message-ID: <20171122001425.GA5120@altlinux.org> Mail-Followup-To: Martin Sebor , Carlos O'Donell , GNU C Library References: <797b60f7-1bd0-2b05-c25b-385ea3b04e68@redhat.com> <2d1095ea-a158-f3ff-2cc4-006dea8387e6@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Nq2Wo0NMKNjxTN9z" Content-Disposition: inline In-Reply-To: <2d1095ea-a158-f3ff-2cc4-006dea8387e6@gmail.com> X-SW-Source: 2017-11/txt/msg00778.txt.bz2 --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1770 On Tue, Nov 21, 2017 at 04:41:27PM -0700, Martin Sebor wrote: > On 11/20/2017 11:20 AM, Carlos O'Donell wrote: > > On 11/20/2017 08:54 AM, Martin Sebor wrote: > >> I'm done testing my update to the -Wstringop-truncation GCC patch > >> to find misuses of non-string arrays. With the very limited use > >> of attribute nonstring it only found one potential bug (22447). > >> I've been looking at other uses of strncpy in Glibc to see if there > >> are other arrays that would benefit from the attribute. I'm not > >> sufficiently familiar with Glibc data structures so it's a very > >> slow going. Could someone help suggests data structures with > >> array members that might be candidates? > > > > struct sockaddr's sun_path? > > > > http://thread.gmane.org/gmane.comp.standards.posix.austin.general/5735 > > > > Is that what you need help finding? >=20 > Yes, that's what I'm looking for, thanks! >=20 > From the referenced thread it sounds like POSIX doesn't require > sun_path to be nul-terminated and BSD UNIX doesn't terminate it. > But I'm not sure what happens on Linux. According to Michael > Kerrisk's response it sounds like it is nul-terminated, but > then according to the longer discussion on linux.kernel.api > it sounds like it isn't. Which is it? When struct sockaddr_un is passed to linux kernel, the kernel doesn't treat sun_path as nul-terminated, see net/unix/af_unix.c:unix_mkname for implementation details. However, when linux kernel returns struct sockaddr_un, sun_path is nul-terminated if there is enough room provided by userspace, e.g. it may need sizeof(struct sockaddr_un) + 1 bytes to write that NUL beyond struct sockaddr_un.sun_path. strace test suite contains a test (sun_path.test) for this linux kernel behavior. --=20 ldv --Nq2Wo0NMKNjxTN9z Content-Type: application/pgp-signature; name="signature.asc" Content-length: 801 -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJaFMFhAAoJEAVFT+BVnCUIPWsQAK47xxj9vyGL+dcrKTKIt8du FiL/FWnJkfj28o7jQClSObBmKe1HC1hZQw1+zISAc0+dGEXMnpZWyCqX4lMG4FGX eQFpArw4dqwCjj+in1kWqMKtmPB0tmBoT0PVJB0vwXa2nBX2/3ozc7rW+aiY/9J3 NpFBsWrZZzyIQpWFy63Tvd+CHacEPDZF1vwuUgVU9T71KRjL1YaAYg36ABBUXB1v 1ilXYrfyokwUjpb2G40mXGrPcAXCTTpTFxMwi4QVKwh6PSO293lJc2ktcgMqfk17 dxQgr/4FboWOXPCGNEHVRJmH2ZqjUqI7cS1wrpFUpTrmcr2eNwO4qfA6dVwVgCGt 8C0JdaBNxr8k+kj4TWiCcIxgS+S8vwiDaGXRoQ0MD7w4T/RByHJChZzci78xZ2qr Obm12ocM3B8Aef6oI6PIrHQ6DZfAyeQ0dHRpkC0IOiPHGpq7vj4jb2DT4REcEAnC dw7x05dUN4LZTb/z2cbQXPVqHdTPktdF9qc44JG0wL7mgzTRoILtXeCgmWNpKMXX nkyri/wZhvocODO18HKXMdLP1OGVjQQHpVxGtMT4uGAqkjwd79Iw90/wUI/dbM5N w0gs4OQfH7bqa5yuW+OXTdUif9tJOn/znIjUSWHnzDMNiO/6CJKwZOr1+ZDK8flX bWHTc0AbT1Wlbhl4GpmH =rzWU -----END PGP SIGNATURE----- --Nq2Wo0NMKNjxTN9z--