From patchwork Thu Sep 21 16:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Simmons-Talbott X-Patchwork-Id: 1837657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=E6QWfj6E; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rs0rt0qpXz1yhR for ; Fri, 22 Sep 2023 02:16:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E069F385828D for ; Thu, 21 Sep 2023 16:16:27 +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 883A03858D39 for ; Thu, 21 Sep 2023 16:16:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 883A03858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695312978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ryT7s9r02PdT81uL9uyPyzU6MvLxW6J8PAoGJz8TL10=; b=E6QWfj6EQPQO7EV2J5tRoRS3mg9j6Xvmu6pE/p6Ortu/Hfkbu8VGQogeCLqCqvQOyl0sMH sFd6iVexpMYm5AB6IFcnFo4r9+yFt5H37D2CRH87BpLK9nVuU8Bf65qTPONN7eig7+pB5h LecXAPDUqxDx26kwNsbvvIFhCJ489DI= Received: from mail-oa1-f70.google.com (mail-oa1-f70.google.com [209.85.160.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-G9uTlPWRPjGiCcZaKMTpWw-1; Thu, 21 Sep 2023 12:16:16 -0400 X-MC-Unique: G9uTlPWRPjGiCcZaKMTpWw-1 Received: by mail-oa1-f70.google.com with SMTP id 586e51a60fabf-1ad17b9fcd8so1579605fac.0 for ; Thu, 21 Sep 2023 09:16:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695312975; x=1695917775; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ryT7s9r02PdT81uL9uyPyzU6MvLxW6J8PAoGJz8TL10=; b=D4vawh6s1rm0G+vRbk6wu6E2pLGoHZzt/q+GsPXz9mtEQL77OoXK27LttXD7gVe0Tk VLqDNIbLpvw633RtL/7M6ccj4DPuNkZ4ZphiXan5AbdLYcuDp3twDY+rSeEOj/F5pbIP puLyE9u8urSPovFdNudPUqnIDwdWAhRaMK2qDkvjI45+cK4NfQTiuycfCBey9lGTVmyM O3fL+af6wq5cy6E3TKBIE705ChYs1i4bi3mRWB/3EbateG7c/eAUyyYgIN+gAgzMx3vp YmcJbkvoRdyVq/emN1rvJsd+AXINqrPwxdT0lBEFeO4OW+mbGEz4gp7i5l+wU09cl2ct WDaQ== X-Gm-Message-State: AOJu0Yz2SvwAay8WMmW5c7km3OIku3pcL6EfcedBNabht5vEqLEFX5D0 6UQIkSg26zNFjz2Y7qfr9PLFIl5dH2qZaDDrf5BJVf7Dk/+8n/D+U8h26lLFbxPvuKkdqWxzq6N a0Kr8jz+XEu5903BGB/Kabs1tP4e3+3ujiS/IPm6G92FW1FYLoJNq0CRoyyjDhSPVGKq7X2/DTW IQe2II X-Received: by 2002:a05:6870:808a:b0:1d4:d5a8:3d1a with SMTP id q10-20020a056870808a00b001d4d5a83d1amr6272735oab.30.1695312975425; Thu, 21 Sep 2023 09:16:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzpDSn5hSYasu6N961L+JvVwnmfulWlbhFEi+nPqw5xuZ6l1RxXtwR2LwhtMvXBEvTd199SA== X-Received: by 2002:a05:6870:808a:b0:1d4:d5a8:3d1a with SMTP id q10-20020a056870808a00b001d4d5a83d1amr6272714oab.30.1695312975106; Thu, 21 Sep 2023 09:16:15 -0700 (PDT) Received: from oak.redhat.com (c-71-206-142-238.hsd1.va.comcast.net. [71.206.142.238]) by smtp.gmail.com with ESMTPSA id d20-20020a0cdb14000000b00655ebd053dcsm685613qvk.82.2023.09.21.09.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 09:16:14 -0700 (PDT) From: Joe Simmons-Talbott To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH] resolv: Get rid of alloca usage. Date: Thu, 21 Sep 2023 12:16:08 -0400 Message-ID: <20230921161613.3609632-1-josimmon@redhat.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 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_H3, 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+incoming=patchwork.ozlabs.org@sourceware.org Replace alloca usage with char arrays in _nss_dns_getnetbyaddr_r and _nss_dns_getnetbyaddr_r. --- resolv/nss_dns/dns-network.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resolv/nss_dns/dns-network.c b/resolv/nss_dns/dns-network.c index 1e6511a4f4..b67542c078 100644 --- a/resolv/nss_dns/dns-network.c +++ b/resolv/nss_dns/dns-network.c @@ -116,6 +116,7 @@ _nss_dns_getnetbyname_r (const char *name, struct netent *result, querybuf *orig_net_buffer; int anslen; enum nss_status status; + char buf[1024]; struct resolv_context *ctx = __resolv_context_get (); if (ctx == NULL) @@ -125,7 +126,7 @@ _nss_dns_getnetbyname_r (const char *name, struct netent *result, return NSS_STATUS_UNAVAIL; } - net_buffer.buf = orig_net_buffer = (querybuf *) alloca (1024); + net_buffer.buf = orig_net_buffer = (querybuf *) &buf; anslen = __res_context_search (ctx, name, C_IN, T_PTR, net_buffer.buf->buf, @@ -170,6 +171,7 @@ _nss_dns_getnetbyaddr_r (uint32_t net, int type, struct netent *result, int cnt, anslen; uint32_t net2; int olderr = errno; + char buf[1024]; /* No net address lookup for IPv6 yet. */ if (type != AF_INET) @@ -209,7 +211,7 @@ _nss_dns_getnetbyaddr_r (uint32_t net, int type, struct netent *result, break; } - net_buffer.buf = orig_net_buffer = (querybuf *) alloca (1024); + net_buffer.buf = orig_net_buffer = (querybuf *) &buf; anslen = __res_context_query (ctx, qbuf, C_IN, T_PTR, net_buffer.buf->buf, 1024, &net_buffer.ptr, NULL, NULL, NULL, NULL);