From nobody Tue Feb 10 20:48:41 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1557473026; cv=none; d=zoho.com; s=zohoarc; b=YDIHViaHg77lpqfPED03V4A8maQjaqWgkTnIVg82OZ6wXeqD3eoSEPb1cSRfkPZLtEGAglnkKJq2PzPQfxGwZuGjYsu4uyPq4dstvucqvNPMbfBIp+773B2NE4yPFAe7t2kBtVbSm2XbBN//5reVZo+0ulYG1jkcOMiuSWh+b+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557473026; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=DfLTNEv2rNLcJy/Gi2YxgST0E3oC+JjrSb8zJkIZSVs=; b=ixYs3QgiLJ/3YZqOPTpnPcE5oJKSJFZ0kgSF2RJmHvWXLxsuyvY05oZ3t5TdRgvsE2+4YU5rt6ZYYtKpntQJNYp7Us+/CS6IjicqPks96Qzq1o6H4kKrabjodh6IsSzYTwuLE/InyJOOsE5Xo1e69npIh3E4ZHuTVsLIqU0+28k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557473026674623.8197168657405; Fri, 10 May 2019 00:23:46 -0700 (PDT) Received: from localhost ([127.0.0.1]:38258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOzsR-0003S0-HA for importer@patchew.org; Fri, 10 May 2019 03:23:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOzlT-0005nq-Pi for qemu-devel@nongnu.org; Fri, 10 May 2019 03:16:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOzlS-0001l0-Tu for qemu-devel@nongnu.org; Fri, 10 May 2019 03:16:19 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:44547) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOzlS-0001kT-KI for qemu-devel@nongnu.org; Fri, 10 May 2019 03:16:18 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MPXpU-1h3dQ418gE-00Mcjx; Fri, 10 May 2019 09:16:06 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 09:15:53 +0200 Message-Id: <20190510071557.30126-4-laurent@vivier.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190510071557.30126-1-laurent@vivier.eu> References: <20190510071557.30126-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:MmIg/GBEgOPrGam1T82sI5ZEbuQbmmLb0GqQFWMMcebxb5G8aO9 /q/4VO1vas7qd6C+B1nH8YojBViw+puG0zMG04yyO2aFYpFN1VVLis+UtbQpZAMdJBN+y3D GEqqwpWl8WJPKAVh24cZYJKHWkVBctGCq9E+xm7KIfDGP/MPNE7ApYCrFu6KTMAYQO/EBSi Z8V9Bdpim3xwmnzfNYWgQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:39ZglJTmz5A=:74csuOgxyu29sjQw6RrW86 1fIUhodlqy6do/obfo/WyhPxxFvFXrOE8tL8zz4aybr3xsTzo4hN48CBgRZDecdGaj9guL2K2 ARYnAcr6xzex5Flugtx91Jjyl/bwQFrpadXZFNQuq9UiBc/PJWsgb3/IeIzJJedsN/8WzgvdN My3tPI70wYfuA504ugbPOvlAzVyGprhk3O4ie5VFiaJ2iU9sl6Bp+bTl8n68LTZ0FxZsVlQXj 6LlXc5eo3gR8R+frVMAsovdnOGVrClrko1W7KZ/O6vH3uv6XggK0emW3o4iOQYL9PaZsxpxzp +48bRRGas6zI35HKE/LQAaL74wTv5auM/jSR+xfQDmOU0Gq+1Jc69FnsdkGBrz8Xd2jD0M46H b6b7HbPxTRWNKmfH3S702xPz/DRbzkz1pfF7ijh3NPGtbj8gM43VBQrSHGnisw3hr5G9nXLc5 hGZcQsBSFhB9pAOVcrD9Yol0cyqlVEpfd08n8P3BXg+jRa8lAbLamcw4sqGKSPjpUNzZ0eDXW hg59o/uWAgXzODRBsea4tB3Q8a8RvvtzhTRGN8r9W1+CJg2R76WA8YT8fEV0z7JrT1iMhEQl9 Do4/eK8yAdO3zPwSkKw8XFZ/PGcSxOqcTLlL9kwqv/MVsSrSmdzTjO7YzAIGeYsK6WDrDRy46 CWGAgZMFPGhMkC0SBj5IiQfa4iFlsdhF/BFG9UCly+dcC2xb3AJprFURg/wv2P0mUIfB6CkkE YZmBHdvHNOmI16xt01mSLJSe3QI9hlZSjc70unZ6iHP/OEhf37Y+/VboOUs= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.24 Subject: [Qemu-devel] [PULL 3/7] linux-user: avoid string truncation warnings in uname field copying X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Daniel P. Berrang=C3=A9 In file included from /usr/include/string.h:494, from include/qemu/osdep.h:101, from linux-user/uname.c:20: In function =E2=80=98strncpy=E2=80=99, inlined from =E2=80=98sys_uname=E2=80=99 at linux-user/uname.c:94:3: /usr/include/bits/string_fortified.h:106:10: warning: =E2=80=98__builtin_st= rncpy=E2=80=99 output may be truncated copying 64 bytes from a string of le= ngth 64 [-Wstringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__de= st)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~ We don't care where the NUL terminator in the original uname field was. It suffices to copy the entire original field and simply force a NUL terminator at the end of the new field. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20190501144646.4851-1-berrange@redhat.com> Signed-off-by: Laurent Vivier --- linux-user/uname.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linux-user/uname.c b/linux-user/uname.c index 313b79dbad47..1c05f95387f4 100644 --- a/linux-user/uname.c +++ b/linux-user/uname.c @@ -72,9 +72,8 @@ const char *cpu_to_uname_machine(void *cpu_env) =20 #define COPY_UTSNAME_FIELD(dest, src) \ do { \ - /* __NEW_UTS_LEN doesn't include terminating null */ \ - (void) strncpy((dest), (src), __NEW_UTS_LEN); \ - (dest)[__NEW_UTS_LEN] =3D '\0'; \ + memcpy((dest), (src), MIN(sizeof(src), sizeof(dest))); \ + (dest)[sizeof(dest) - 1] =3D '\0'; \ } while (0) =20 int sys_uname(struct new_utsname *buf) --=20 2.20.1