From patchwork Wed May 30 00:46:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10437443 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 27A8F601E9 for ; Wed, 30 May 2018 00:46:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17596286F7 for ; Wed, 30 May 2018 00:46:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A9B428703; Wed, 30 May 2018 00:46:45 +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=-5.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9F93C286F7 for ; Wed, 30 May 2018 00:46:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE04E6E69E; Wed, 30 May 2018 00:46:43 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qt0-x242.google.com (mail-qt0-x242.google.com [IPv6:2607:f8b0:400d:c0d::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 634A16E69E; Wed, 30 May 2018 00:46:42 +0000 (UTC) Received: by mail-qt0-x242.google.com with SMTP id h5-v6so13152067qtm.13; Tue, 29 May 2018 17:46:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=tzI9t7djDKvRl31YN9m5K/VIQKkmMNRHCQJzQqbmxLI=; b=HqVDVGF1NN6aMuiMZt0hX/sOjlF9xuwN6bAkIJK4BoaAHMbsVkVuU0muqgxepBjVcv d6smmHE7g40U1BZRZQDPUMBrSLTP7lmJHi8kC6y714xnXsHNpTQ/3hEtrKQhQtyUpk6P fqvLMbKYdiy6D30V0qQnnE8vbBO124Nc8NBJx7oDtnrjGNFksPlG7UT4eCVu6I5040Gj CV5kH2wtPALvwwPTPtylcbZMQPuQ2AxEq9KBe1IdI0QeC3L8ufqcJ3oxN4hKAo468IVm /QCZqu8qRosXDLiuzipbQAm5acYRdYm7DzYyX0GsvtB2mzMShni4Bbf3tTal+jqeirFn BZBw== X-Gm-Message-State: APt69E2Te/v4qimTwd03e1x7U9/AyeRj1wi1DX52p+m/JHZ1fvNb8GuT I0/jXbH1Nu55GDQLpFvdo1uphw== X-Google-Smtp-Source: ADUXVKLzB6yWeYeXSeHXn3myAo6XJyytsw2jJJTdE3lp6MggJOW0fe+Kb6u12uXTKYOHcK3Rsqwc5Q== X-Received: by 2002:ac8:2789:: with SMTP id w9-v6mr601866qtw.168.1527641201319; Tue, 29 May 2018 17:46:41 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id x10-v6sm23024595qkl.8.2018.05.29.17.46.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 17:46:40 -0700 (PDT) Date: Tue, 29 May 2018 21:46:38 -0300 From: Rodrigo Siqueira To: Petri Latvala , Arkadiusz Hiler Message-ID: <03a936e0c4bca03f89e731d2cacaa3624a10147f.1527639529.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180512 Subject: [Intel-gfx] [PATCH i-g-t 1/3] Avoid truncate string in __igt_lsof_fds X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Note that 'proc_path' parameter in __igt_lsof_fds receives a string which was initialized with the size of PATH_MAX and the local variable 'path' has the same size, but it also have to append: '/', '\0', and the directory name. This situation caused the warning described below. warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Wformat-truncation=] snprintf(path, sizeof(path), "%s/%s", proc_path, d->d_name); note: ‘snprintf’ output between 2 and 4352 bytes into a destination of size 4096 [..] This patch fix the above problem. Signed-off-by: Rodrigo Siqueira --- lib/igt_aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index acafb713..5dd2761e 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -1425,7 +1425,7 @@ __igt_lsof_fds(proc_t *proc_info, int *state, char *proc_path, const char *dir) { struct dirent *d; struct stat st; - char path[PATH_MAX]; + char path[PATH_MAX + NAME_MAX + 2]; // 1 byte for '/' and another for '\0' char *fd_lnk; /* default fds or kernel threads */