From patchwork Tue Apr 4 17:31:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Seraphime Kirkovski X-Patchwork-Id: 9662249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 77110602BA for ; Tue, 4 Apr 2017 17:34:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 665E328491 for ; Tue, 4 Apr 2017 17:34:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5973C284A3; Tue, 4 Apr 2017 17:34:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E999528491 for ; Tue, 4 Apr 2017 17:34:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvSJL-0007Zd-Dx; Tue, 04 Apr 2017 17:32:07 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvSJJ-0007ZS-MI for xen-devel@lists.xen.org; Tue, 04 Apr 2017 17:32:05 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 3F/BF-00609-498D3E85; Tue, 04 Apr 2017 17:32:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOIsWRWlGSWpSXmKPExsXiVRvkpDvlxuM Igxl9fBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aP1SfYCo7zVDz/+Iq5gfErRxcjF4eQwERG iYkTZrF2MXJysAg0s0p82cIGkpAQmM8q8XjfQjaQhIRAnMTvpa9YIewKiYftS8DiQgLKEvNOP mGDmNTDJPH59BomiESIxIbmN+xdjOwcbAIGEjdSQKIiAtIS1z5fZgSxmYHGHHg/F6iCg0NYwE di4olAiBNUJRpnrGIBsXkFLCVefwQpAdkqL7Gr7SIrRFxQ4uTMJywgrcwC6hLr5wlBTJSXaN4 6m3kCo9AsJFWzEKpmIalawMi8ilGjOLWoLLVI18hML6koMz2jJDcxM0fX0MBYLze1uDgxPTUn MalYLzk/dxMjMJDrGRgYdzA27PU7xCjJwaQkypu263GEEF9SfkplRmJxRnxRaU5q8SFGGQ4OJ Qlet+tAOcGi1PTUirTMHGBMwaQlOHiURHjngKR5iwsSc4sz0yFSpxh1OT70H37DJMSSl5+XKi XO6wlSJABSlFGaBzcCFt+XGGWlhHkZGRgYhHgKUotyM0tQ5V8xinMwKgnz/r4GNIUnM68EbtM roCOYgI54cuchyBEliQgpqQbGSZ8UuzR+y/2LiWmZ1/syb3LMGT2vR7NKs24Xasdmshe9+zLn rP3EhbbPonbqT8t7JP+xUX+GVOkbucZTik9O3cqzutf3RZFD4s/pu601UvuL9afdWDY37Zvvr MgnHIev7V1zs5s73/VI8XKfffa/J+xs9rsuvHQx05KL+fc2r1u5nUf71ryCOCWW4oxEQy3mou JEAOoe9BXqAgAA X-Env-Sender: kirkseraph@gmail.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1491327124!38645311!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42655 invoked from network); 4 Apr 2017 17:32:04 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-9.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 4 Apr 2017 17:32:04 -0000 Received: by mail-wm0-f66.google.com with SMTP id x124so7103367wmf.3 for ; Tue, 04 Apr 2017 10:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C57bLC3MbbhQKUcb/yAA4YgUqN2BitoijecRhGFccfU=; b=AzUTT5LMNDT3Or1krF7rwBaYBPaW4P2v01Do5uhOjYRq95Qg6NaePFHhWoA6sF7vCx 33TP1IVChVqB0Jn4GPUPN0+Etzghmww+MHTkZ4WPYvQ+d+nUD8U3pQhfQ+jT8BcmVma5 RtZfeFHnIlgdgSNgZauNpKaxXCYoT7Ksv04NCR8XT1LDOWo1Q7Lt1LNTUss+lTHUFyPK c88I92aHFyawlqovEaW1pjs4kFMlj3EuCLx3lVvKkNOztbHj2+SAd65K1C9G+qqVQsdf GAHeyxAwNBnp2eItxmQlcps67hUAw44jPzVsCIyJDs3KJH5R9tZ11D0yCqXn/a3xIk95 OSfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C57bLC3MbbhQKUcb/yAA4YgUqN2BitoijecRhGFccfU=; b=IgWByQaEqsvO1niyejaAtts+OSx7e6VLEt1tP9r5tPeps0xrmxuoxUClucwngjNxgH 6UNxg2ScHvJBWKT27eGjajPH2hlleGyzyeypG3cFksnl8sbsl017TCfz0679oxD7AiBX vkCB4stBb+TRsS8oEmDJwA7YLqvPJWTUQjKs0xgI9Z5s+Cn1eUA3kvLrQ+MW8EvnSHrm FS8OxcbGXFGTF7RHmCF17FFu8fGqJnM7dTvfOVNguQeC759JeeFVoeFJCGNeDFZw9uIP yIWI/2NQ4WHRoTGudtaEoh2vREUi/jGatDmF4FnqusyBjL/D+ij1Bgk06cKhn0PLEJL0 vHQA== X-Gm-Message-State: AFeK/H3ZY0ogZLPbXJYLT1AMbBclIgz/CfAydIOHLoMM1SYEEJGJRavI VplrTG5E0yiVUQ== X-Received: by 10.28.48.16 with SMTP id w16mr14623220wmw.10.1491327123810; Tue, 04 Apr 2017 10:32:03 -0700 (PDT) Received: from macchiaveli (cha92-19-78-239-153-115.fbx.proxad.net. [78.239.153.115]) by smtp.gmail.com with ESMTPSA id h65sm23097083wrh.32.2017.04.04.10.32.01 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 04 Apr 2017 10:32:03 -0700 (PDT) Received: by macchiaveli (sSMTP sendmail emulation); Tue, 04 Apr 2017 19:32:01 +0200 From: Seraphime Kirkovski To: xen-devel@lists.xen.org Date: Tue, 4 Apr 2017 19:31:59 +0200 Message-Id: <20170404173159.29762-1-kirkseraph@gmail.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Cc: Ian Jackson , Wei Liu , Seraphime Kirkovski Subject: [Xen-devel] [PATCH] tools:misc:xenlockprof: fix possible format string overflow X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP GCC7 complains about a possible overflow/truncation in xenlockprof. xenlockprof.c: In function ‘main’: xenlockprof.c:100:53: error: ‘%s’ directive writing up to 39 bytes into a region of size between 17 and 37 [-Werror=format-overflow=] sprintf(name, "unknown type(%d) %d lock %s", data[j].type, ^~ xenlockprof.c:100:13: note: ‘sprintf’ output between 24 and 83 bytes into a destination of size 60 sprintf(name, "unknown type(%d) %d lock %s", data[j].type, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ data[j].idx, data[j].name); ~~~~~~~~~~~~~~~~~~~~~~~~~~ This increases the size of name to 100. Not the most scalable solution, but certainly the "cheapest", as it doesn't add dependencies for asprintf. Signed-off-by: Seraphime Kirkovski Acked-by: Wei Liu --- tools/misc/xenlockprof.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/misc/xenlockprof.c b/tools/misc/xenlockprof.c index 41fcb792cc..df23c82912 100644 --- a/tools/misc/xenlockprof.c +++ b/tools/misc/xenlockprof.c @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) uint32_t i, j, n; uint64_t time; double l, b, sl, sb; - char name[60]; + char name[100]; DECLARE_HYPERCALL_BUFFER(xc_lockprof_data_t, data); if ( (argc > 2) || ((argc == 2) && (strcmp(argv[1], "-r") != 0)) )