From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 6F9D33858419 for ; Wed, 10 Aug 2022 03:30:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6F9D33858419 Received: by mail-ej1-x634.google.com with SMTP id qn6so13652812ejc.11 for ; Tue, 09 Aug 2022 20:30:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=oirBSpYp/56chNokrHKP6bYHSXkmVJm4YUvzRXNXHik=; b=KxQXPxQFhW6ZI77lLhIIIhz8eKM1FnYrh9fpaCsbTP5WBo3M/nCY2tbnD0gEeu8QW/ xOXxh07cDewS7fBCM0mQtoTqVg8tkaHUwZjeLtH/WxhTDAtCn3wNhZ/ryxlqpvvywj6U 6HUxPDbr57pnJE9VOEW2AjivvyVCui2VK3tU4CKRKdnt7fp3CwiDalldIN86k/DWHffF khhDAybizAWa5jzxOythiH44AJClQ7/qNykBLD5b3T5kLk4TtOcrLtbr3qB68tKEv0sf W5iVMHRsto4idRBV1UkgyyvAJEYXOomGvBcS0ZIyIMbnr7AZ3bOqPYXa/flH35+uUBTw Ly+A== X-Gm-Message-State: ACgBeo3Qnpnd0EoYIAdd43085OL8PcgAoTH8cG8Q5VfSxLtV610n4fcf NEjlTQwxiMYw9kSS84Goi/VsisKVQFcMbR+yFPQ= X-Google-Smtp-Source: AA6agR4Y9LsVRuZafYu+cw0MKpYWFiWAZVkB0y/R6ino1lOt/lEuK+sJ8TXkBk1xUwbGK2C6wpaU7yIHvXcO8J4fpP8= X-Received: by 2002:a17:906:2bc7:b0:72f:dc70:a3c6 with SMTP id n7-20020a1709062bc700b0072fdc70a3c6mr18736639ejg.645.1660102201178; Tue, 09 Aug 2022 20:30:01 -0700 (PDT) MIME-Version: 1.0 References: <20220808032622.3804534-1-goldstein.w.n@gmail.com> <20220808032622.3804534-2-goldstein.w.n@gmail.com> In-Reply-To: From: Noah Goldstein Date: Wed, 10 Aug 2022 11:29:49 +0800 Message-ID: Subject: Re: [PATCH v1] elf: Replace `strcpy` call with `memcpy` [BZ #29454] To: "H.J. Lu" Cc: GNU C Library , "Carlos O'Donell" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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: Wed, 10 Aug 2022 03:30:04 -0000 On Mon, Aug 8, 2022 at 10:24 PM H.J. Lu wrote: > > On Sun, Aug 7, 2022 at 8:26 PM Noah Goldstein wrote: > > > > GCC normally does this optimization for us in > > strlen_pass::handle_builtin_strcpy but only for optimized > > build. To avoid needing to include strcpy.S in the rtld build to > > support the debug build, just do the optimization by hand. > > --- > > elf/dl-cache.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/elf/dl-cache.c b/elf/dl-cache.c > > index 8bbf110d02..b97c17b3a9 100644 > > --- a/elf/dl-cache.c > > +++ b/elf/dl-cache.c > > @@ -509,8 +509,9 @@ _dl_load_cache_lookup (const char *name) > > we are accessing. Therefore we must make the copy of the > > mapping data without using malloc. */ > > char *temp; > > - temp = alloca (strlen (best) + 1); > > - strcpy (temp, best); > > + size_t best_len = strlen (best) + 1; > > + temp = alloca (best_len); > > + memcpy (temp, best, best_len); > > return __strdup (temp); > > } > > > > -- > > 2.34.1 > > > > LGTM. > > Thanks. > > -- > H.J. Any objections to backporting this to 2.36?