From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 719223858405 for ; Sat, 4 Jun 2022 03:48:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 719223858405 Content-Type: multipart/signed; boundary="Apple-Mail=_6D53B1D5-832D-494F-9E8D-4D4847E713C3"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: [PATCH 1/2] nss: add assert to DB_LOOKUP_FCT (BZ #28752) From: Sam James In-Reply-To: Date: Sat, 4 Jun 2022 04:48:28 +0100 Cc: libc-alpha@sourceware.org Message-Id: <7C406E65-9DAA-4D3F-95BF-F1ADB7CED5CE@gentoo.org> References: <20220526002045.1872855-1-sam@gentoo.org> To: Adhemerval Zanella X-Mailer: Apple Mail (2.3696.100.31) X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Sat, 04 Jun 2022 03:48:36 -0000 --Apple-Mail=_6D53B1D5-832D-494F-9E8D-4D4847E713C3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On 27 May 2022, at 18:07, Adhemerval Zanella via Libc-alpha = wrote: >=20 >=20 >=20 > On 25/05/2022 21:20, Sam James via Libc-alpha wrote: >> It's interesting if we have a null action list, >> so an assert is worthwhile. >>=20 >> Suggested-by: DJ Delorie >> Signed-off-by: Sam James >> --- >> nss/XXX-lookup.c | 5 +++++ >> 1 file changed, 5 insertions(+) >>=20 >> diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c >> index db95937674..793dde976e 100644 >> --- a/nss/XXX-lookup.c >> +++ b/nss/XXX-lookup.c >> @@ -15,6 +15,7 @@ >> License along with the GNU C Library; if not, see >> . */ >>=20 >> +#include >> #include "nsswitch.h" >>=20 >> /*******************************************************************\ >> @@ -54,6 +55,10 @@ DB_LOOKUP_FCT (nss_action_list *ni, const char = *fct_name, const char *fct2_name, >>=20 >> *ni =3D DATABASE_NAME_SYMBOL; >>=20 >> + // We want to know about it if we've somehow got a NULL action = list; >> + // in the past, we had bad state if seccomp interfered with setup. >=20 > I think the expected comment format is the usual C90 one (/* ... */). Right. >=20 >> + assert(*ni !=3D NULL); >> + >> return __nss_lookup (ni, fct_name, fct2_name, fctp); >> } >> libc_hidden_def (DB_LOOKUP_FCT) >=20 > Are you trying to assure that DATABASE_NAME_SYMBOL is not NULL here? = If > so I think it would be simpler to just use a _Static_assert. I'm sorry, I'm not sure what the expression ought to be in that case. I = get that some of it is figured out at build-time given we're using some macros, = but I don't see what to test against to check it's not NULL statically? Best, sam --Apple-Mail=_6D53B1D5-832D-494F-9E8D-4D4847E713C3 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iNUEARYKAH0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCYprWDF8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MAAKCRBzhAn1IN+R kIzlAQDxv85oxxhaMbZE/7kwNsLq3IpTvOpllzX3KzBNlwj19AEA+CKbuKLXLJ/y xV34zWdJOUfACGOB4CHpcNHZd4l/1gQ= =q5qs -----END PGP SIGNATURE----- --Apple-Mail=_6D53B1D5-832D-494F-9E8D-4D4847E713C3--