From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9CF113858D1E for ; Tue, 20 Jun 2023 18:42:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9CF113858D1E 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=1687286522; 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=vGM1oIxrObQwduPk6pZ9WHa24iHAosBC+yt6XcIaodo=; b=HKUCI29B3Tm5azXVE3O5rYARURcOuyC94rfYW+qfTSyheDBrhDcj1uKS3mzcIC/oY+BAeb PEfZLhUgz0TcQc5B+G8JXCsOCLu/2oQYzZLX7jfS7KbbB/PA/fOTIWj5IwCtWXdaL2pPQD efwDVx7RSAFMuA5QLF2oibiU1Yuvn4Y= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-IGE6uSBHM_aIRAk3rtdFzg-1; Tue, 20 Jun 2023 14:41:59 -0400 X-MC-Unique: IGE6uSBHM_aIRAk3rtdFzg-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-763a3f66290so229559485a.0 for ; Tue, 20 Jun 2023 11:41:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687286518; x=1689878518; 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=vGM1oIxrObQwduPk6pZ9WHa24iHAosBC+yt6XcIaodo=; b=a30bIasGmvcPn5EcDSmdlA3K+3k0cFDgsuOT7J3O9AhhKY9FMwZO2Z5VdpqxM6kQU+ TgrSU5Guqi2/5kZGt8GAIittTtH7Tt7EPMvr1KBRkQaE/TwlMLa7s9RMdFmWbbW1gOWo CJH1Bw5Lkfdqo3LoCymGsXAfOlYZM1aQcQC1KptXH3EMWe5o5OaJY0FKctwxMUfHf+f5 CX67tFnPOqBR2XmWXPnDWNui0g1r5/6/QlARQq0K4XVBl0VOUW0MCPEKtJe48jqwZ2T8 ygjGZCR+cZ4YlhKy7pW7H63rjv4fTFLwq/QG+EqjI0cHp9zmh6D4TSJB00QfDSPz6fdM lLJw== X-Gm-Message-State: AC+VfDx7Uwf/QVsAHM5zcejZNycACrXlCmJefV5c28Df8BbRN6FE1NOQ KII+8j7Nd1blKQZMo+f0beMtG35iVdltRDORm8J4P96/joAhjM5Pxm7COoQQGoETbL5+/hQx4ek SyPVlLEEPJdmcnCz3C992pcTrom8cQn4sZ1JsqNvMXjFxcKTCmTuMpWXM/eby8Vbsut+/plGoG+ /KryaP X-Received: by 2002:a05:620a:2792:b0:763:9cf8:8707 with SMTP id g18-20020a05620a279200b007639cf88707mr5488932qkp.8.1687286517854; Tue, 20 Jun 2023 11:41:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6kUpEr7tM/2Uv1lszQctIRUQBDws+YI6Od9zR9LW/u3PineR7Uvsp3QF8BMKNKoYE60EKuEQ== X-Received: by 2002:a05:620a:2792:b0:763:9cf8:8707 with SMTP id g18-20020a05620a279200b007639cf88707mr5488920qkp.8.1687286517528; Tue, 20 Jun 2023 11:41:57 -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 25-20020a05620a06d900b0074e0e6aae1csm1413365qky.36.2023.06.20.11.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 11:41:57 -0700 (PDT) From: Joe Simmons-Talbott To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH] libc_fatal: Add comment regarding alloca usage. Date: Tue, 20 Jun 2023 14:41:54 -0400 Message-Id: <20230620184154.3804141-1-josimmon@redhat.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.5 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,SPF_HELO_NONE,SPF_NONE,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 List-Id: Since __libc_message is only used in a few places and always with a const char * format string and a small fixed-sized struct the usage of alloca here is safe. Add a comment explaining this for both alloca usages. --- sysdeps/posix/libc_fatal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c index 70edcc10c1..caa01bcbf6 100644 --- a/sysdeps/posix/libc_fatal.c +++ b/sysdeps/posix/libc_fatal.c @@ -100,6 +100,9 @@ __libc_message (const char *fmt, ...) cp = next; } + /* alloca is safe here since the current usage of __libc_message uses + relatively short const char * format strings and a small fixed size + struct. */ struct str_list *newp = alloca (sizeof (struct str_list)); newp->str = str; newp->len = len; @@ -110,6 +113,9 @@ __libc_message (const char *fmt, ...) if (nlist > 0) { + /* alloca is safe here since the current usage of __libc_message uses + relatively short const char * format strings and a small fixed size + struct. */ struct iovec *iov = alloca (nlist * sizeof (struct iovec)); ssize_t total = 0; -- 2.39.2