From patchwork Wed Apr 24 16:08:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 88961 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B107F384772F for ; Wed, 24 Apr 2024 16:09:22 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A756E3849AC1 for ; Wed, 24 Apr 2024 16:08:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A756E3849AC1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A756E3849AC1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713974931; cv=none; b=D9n5GcFMcbJZtMYe0BLirYX3AMYfB+famp1TDnH03dJqQjgiBTK+g0aNJMFNuJrnzhDbTSW7DbF7z1WV2LqidpQNw8a5cLV9wPX/Jptp2Pes+xCGSttWnBa4adsW/CkVVDZrguZVS67Qpm628yUfZARLzcbqEiG7se4jAH4gmdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713974931; c=relaxed/simple; bh=MGjoa72Q724jQooNweBbmh1GHQmU01YtWdOyTq+i6yc=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=ORzaCI5nr4vL+MeEAX37s+F7lkO3Q2/dYnI3fVdxhxROIrYw/U6auAPkbcLgyCxRk5VAA3dvR208eXWn5WcWbXAk7WvKHhP0BZlIoOquaFcAueqeJueDOKMfrb4I52KGrZ1sfJHRRqJ9UVX5V38jTTKK1RIxcJqbxScY8y8FzB4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713974929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4Fdm+iWbM0iFS6/TbecF8ky2BihZ3zVY/UOcR3JflfM=; b=eUCQ1qW+9GUO+ERVXtegKaRmvaB/OZyBRhyOzn9J65tp0Y2F6WtsMHdbbQAFYm7KuHu+mW crzDBKd9AyKb/M7Y9Lp0p2PiwTawmzeBlXJEW8IBlxBkS0QQE0dfniGhwfsUaS4nSx+db+ rruYMTmuYZ+AuuqHeB56u4WDDQebaPg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-xhQUUNQ3NfejFmIzZhANvA-1; Wed, 24 Apr 2024 12:08:48 -0400 X-MC-Unique: xhQUUNQ3NfejFmIzZhANvA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B6B6D380670D for ; Wed, 24 Apr 2024 16:08:46 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.74]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A5D85C820 for ; Wed, 24 Apr 2024 16:08:46 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 2/4] nscd: Do not send missing not-found response in addgetnetgrentX (bug 31678) In-Reply-To: Message-ID: <90f1fccc39a22663a5c57c4e7c938480ada61d87.1713974801.git.fweimer@redhat.com> References: X-From-Line: 90f1fccc39a22663a5c57c4e7c938480ada61d87 Mon Sep 17 00:00:00 2001 Date: Wed, 24 Apr 2024 18:08:44 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org If we failed to add a not-found response to the cache, the dataset point can be null, resulting in a null pointer dereference. Reviewed-by: Siddhesh Poyarekar --- nscd/netgroupcache.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c index 24fbac7668..8709fb77b6 100644 --- a/nscd/netgroupcache.c +++ b/nscd/netgroupcache.c @@ -147,7 +147,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req, /* No such service. */ cacheable = do_notfound (db, fd, req, key, &dataset, &total, &timeout, &key_copy); - goto writeout; + goto maybe_cache_add; } memset (&data, '\0', sizeof (data)); @@ -348,7 +348,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req, { cacheable = do_notfound (db, fd, req, key, &dataset, &total, &timeout, &key_copy); - goto writeout; + goto maybe_cache_add; } total = buffilled; @@ -410,14 +410,12 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req, } if (he == NULL && fd != -1) - { - /* We write the dataset before inserting it to the database - since while inserting this thread might block and so would - unnecessarily let the receiver wait. */ - writeout: + /* We write the dataset before inserting it to the database since + while inserting this thread might block and so would + unnecessarily let the receiver wait. */ writeall (fd, &dataset->resp, dataset->head.recsize); - } + maybe_cache_add: if (cacheable) { /* If necessary, we also propagate the data to disk. */