From patchwork Thu Aug 10 15:57:22 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: 1819932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=TgWxjbEw; dkim-atps=neutral Received: from server2.sourceware.org (ip-8-43-85-97.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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RMBRs1hR5z1yYl for ; Fri, 11 Aug 2023 01:58:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 255933857700 for ; Thu, 10 Aug 2023 15:58:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 255933857700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691683127; bh=f+zPdawiQ/QE94kZYHIwIggsOGgyQAEB7/Ds3pv7oz8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=TgWxjbEwsgWtZZy8hV/cB4KlvXR0KJrGRa7Li72F26D+eAJB30YC+x+j905MWiKp4 hZvauZ/SagVqqz9JLA+q1RfWjBZmt38A6Wxu3c5/ZbfYcatcCcxE4nILp6D9uLN7ad ObS0DFU9aPnXDbWvx8iQxGr16CxcUQy4D0u0EqfY= 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 3BA043858005 for ; Thu, 10 Aug 2023 15:57:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3BA043858005 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-396-tH7CcK6wM9Wh-pJ-9X4Hrg-1; Thu, 10 Aug 2023 11:57:41 -0400 X-MC-Unique: tH7CcK6wM9Wh-pJ-9X4Hrg-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-40fe51a6fd5so10903591cf.2 for ; Thu, 10 Aug 2023 08:57:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691683061; x=1692287861; 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=f+zPdawiQ/QE94kZYHIwIggsOGgyQAEB7/Ds3pv7oz8=; b=Xh3krEtEx+JH7RH61Jj3zpK3Kxsp7V5yCxJRdRQAdamKpBKAQHmAY06vWNc6OQw3gd 4bvbnGTMhWXiDNvzKccp5CGN6Vk6O8VyabJlEy0ryNjCfM+CVY1gMCYUdamJolEJarS6 zaWS1vt0HtFmJQ0J6aYU4jym8wDKgPgU97/XyFygAnAXdbIXdzXmSh01caVUeiOleZsK itVNzWZZ77O+BJxk+29Nr+nDuNG0p8R5yF6oeiXgBOLXaC5VEJryi/iEHz3FYZInguHF wzHr/pDi2jD2LdOJtrig9DqsrAat7PC2DP2gSs7/wSwPboYFLCgcMQiYKFWEvzOtc58C mYtQ== X-Gm-Message-State: AOJu0Yy4DcsMH/Z5jEvsX+L9rqy4A6S9htatpjV5WPPVKIA+vfQkIBqr vESH+GHcIKJrH+Oi/IXXsuOJLrDA6U8zUCbvHpVIWzOtXESmX9T0B8Mt6Dpw99MvuRQPivMmgOG WgP1gDtxRrKn6Q+YDWrhRQ/29Ev01QhYodGkBASMH3zaf5FkyvakHaKH8cQ4F0y6QLtHKEVV0C5 rjVRr8 X-Received: by 2002:a0c:f502:0:b0:62d:eda3:4335 with SMTP id j2-20020a0cf502000000b0062deda34335mr2846390qvm.29.1691683061028; Thu, 10 Aug 2023 08:57:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IET6l1cGJzKJaGpBAWUZ3OGLziQyGelk16sEmHEoHiULXpB4rJwBqB3AobAFBJTHQLhe6ibNA== X-Received: by 2002:a0c:f502:0:b0:62d:eda3:4335 with SMTP id j2-20020a0cf502000000b0062deda34335mr2846370qvm.29.1691683060707; Thu, 10 Aug 2023 08:57:40 -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 h2-20020a0cf202000000b006300e1db3ecsm374484qvk.141.2023.08.10.08.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 08:57:40 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH v2] resolv/nss_dns/dns-host: Get rid of alloca. Date: Thu, 10 Aug 2023 11:57:22 -0400 Message-ID: <20230810155738.2645097-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_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.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Joe Simmons-Talbott via Libc-alpha From: Joe Simmons-Talbott Reply-To: Joe Simmons-Talbott Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Since the alloca is a small constant size use an array instead. --- Changes to v1: * Use sizeof (tmp) rather than NS_MAXDNAME resolv/nss_dns/dns-host.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 1d60c51f5e..c8b77bbc35 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -378,6 +378,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, int *herrnop, int32_t *ttlp) { enum nss_status status = check_name (name, herrnop); + char tmp[NS_MAXDNAME]; if (status != NSS_STATUS_SUCCESS) return status; struct resolv_context *ctx = __resolv_context_get (); @@ -395,8 +396,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, */ if (strchr (name, '.') == NULL) { - char *tmp = alloca (NS_MAXDNAME); - const char *cp = __res_context_hostalias (ctx, name, tmp, NS_MAXDNAME); + const char *cp = __res_context_hostalias (ctx, name, tmp, sizeof (tmp)); if (cp != NULL) name = cp; }