From patchwork Thu Aug 4 14:15:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 73276 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1419227qga; Thu, 4 Aug 2016 07:17:23 -0700 (PDT) X-Received: by 10.55.20.90 with SMTP id e87mr6164876qkh.260.1470320243932; Thu, 04 Aug 2016 07:17:23 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z24si8362011qtb.68.2016.08.04.07.17.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 04 Aug 2016 07:17:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVJSd-0004MV-FB for patch@linaro.org; Thu, 04 Aug 2016 10:17:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVJQa-0003Xa-VE for qemu-devel@nongnu.org; Thu, 04 Aug 2016 10:15:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVJQX-0000T3-G4 for qemu-devel@nongnu.org; Thu, 04 Aug 2016 10:15:15 -0400 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]:34842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVJQX-0000Sy-7H for qemu-devel@nongnu.org; Thu, 04 Aug 2016 10:15:13 -0400 Received: by mail-lf0-x22f.google.com with SMTP id f93so183268050lfi.2 for ; Thu, 04 Aug 2016 07:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iQUm/J22xsdh4uxBRT3XY3banMPl6GxScgh5x6pQ6UQ=; b=i9PsL85hR4RCjNN29EuSksmZiBXpsCA5ieDDMkVWqnh3M0b3zJzDgUM9ujYbIJVeb7 3ec+kDs9zhZeyGzdQdBr7RAv3aXkXpjMY+CLUH/B/xbYpD0pZk1zTSiWKJf7UP6vA/H5 Qe47Tt+qHldNQSLWi8MOjWvkEgh/Q8ci6vgWI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iQUm/J22xsdh4uxBRT3XY3banMPl6GxScgh5x6pQ6UQ=; b=Pv66qiY9HqR+9FRcaUtCDS4KWNoAxUn+VoWjWpDGMnSTgcBA5Ga02ThXDxYglY7M4i 6G0qi3gc3xSqOqlIAsBQbbABoCQksg+n3JPXrg+PdSG+01wdpYjuYbCvpTwWPstdnSJ4 f5w4mQ6NTdpDiUohAVGYPS7zGGN84sWbufHw1VLG/9e0PZgZ3fQbijmIhD7ChjZGbjcf cHH02MFI1vFcfHmkR9S8RH4uEcMpkn6a3XFjRphSlX9Z9oqWBuyD4ct4+ZJlS5PdqkI2 tV34XxuWEEL4ua0STc7tITVKI6zEgoHAJ2CEjq+D6gJRlM8P92AHf7DbaRtXfs55ABFS 6Vgw== X-Gm-Message-State: AEkoousemNTeZtA5JCqXAHipJJ1jfh5PwQq9N1bwvzyw+InbLvRj6h+Lr7O9rfqmrAHJSkKs X-Received: by 10.25.133.212 with SMTP id h203mr25151481lfd.28.1470320112089; Thu, 04 Aug 2016 07:15:12 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id r76sm2407266lfi.35.2016.08.04.07.15.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Aug 2016 07:15:11 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 4 Aug 2016 17:15:03 +0300 Message-Id: <332c9781f6a7c496adf605a1be72776598c7adc2.1470319929.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22f Subject: [Qemu-devel] [PULL 3/5] linux-user: Don't write off end of new_utsname buffer 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Use g_strlcpy() rather than strcpy() to copy the uname string into the structure we return to the guest for the uname syscall. This avoids overrunning the buffer if the user passed us an overlong string via the QEMU command line. We fix a comment typo while we're in the neighbourhood. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 092ff4e..5bc42c0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9237,12 +9237,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, goto efault; ret = get_errno(sys_uname(buf)); if (!is_error(ret)) { - /* Overrite the native machine name with whatever is being + /* Overwrite the native machine name with whatever is being emulated. */ strcpy (buf->machine, cpu_to_uname_machine(cpu_env)); /* Allow the user to override the reported release. */ - if (qemu_uname_release && *qemu_uname_release) - strcpy (buf->release, qemu_uname_release); + if (qemu_uname_release && *qemu_uname_release) { + g_strlcpy(buf->release, qemu_uname_release, + sizeof(buf->release)); + } } unlock_user_struct(buf, arg1, 1); }