From patchwork Sun Jun 17 00:34:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10468117 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 324D8601C2 for ; Sun, 17 Jun 2018 00:34:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2190E28ADE for ; Sun, 17 Jun 2018 00:34:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 165AD28AEC; Sun, 17 Jun 2018 00:34:37 +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 CD6C828ADE for ; Sun, 17 Jun 2018 00:34:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 739496E313; Sun, 17 Jun 2018 00:34:35 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qk0-x243.google.com (mail-qk0-x243.google.com [IPv6:2607:f8b0:400d:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id B5CEB6E312; Sun, 17 Jun 2018 00:34:33 +0000 (UTC) Received: by mail-qk0-x243.google.com with SMTP id 185-v6so7646420qkk.11; Sat, 16 Jun 2018 17:34:33 -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=aHMB8mXdB7jC1ZgtHkyp+w6gGec6pkISxUlU0Kg9Jsw=; b=gNW2rOdy39ttgTotxVKl+T9zhDvga6oyBQPtqdl1uteLkwkDS4Ic8KxWW6lGAc4AsP 8r6q6PDTjMpBDmJhteeapeXWjJVIPlaYVFcyNpswWWyyhxnBtmkmcZtASi3/fVBqi5LL 6oRo7QYVDSABBDNR/BoDcIutZKIloUWb6n8qahZiC5rZjVJf6+YyOCIvT4cUaMw6UhlC jtgICDt7qCh7sC+HCBNFH2U9TybUFlh2s1JZe/WfunFGsZx5/9g5yPzi2VeXzvPQyTIZ 6HhZ7iUUqfn26Nlcb++PE5leXxyNlbkGkLalklyYs9wNHkT5lquXLGr4dUHc65IPRrbF 1P6w== X-Gm-Message-State: APt69E05m1iKkd5rJ0zUGbyvqMdUIVyRSRmZzWDwsf6uYCT+eZ8I36PM Ow6+A5MSb5xFuE52xFhO3s4= X-Google-Smtp-Source: ADUXVKK/6Px8nkfyuFDkEuqkLLWcrIhY3ybDe+/Zh2h6tSG9RQiQUo8qdH1l+XheszQSUArHFAv/PA== X-Received: by 2002:a37:1fd4:: with SMTP id n81-v6mr5752452qkh.308.1529195672913; Sat, 16 Jun 2018 17:34:32 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id p56-v6sm7606030qtb.82.2018.06.16.17.34.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Jun 2018 17:34:32 -0700 (PDT) Date: Sat, 16 Jun 2018 21:34:29 -0300 From: Rodrigo Siqueira To: Petri Latvala , Arkadiusz Hiler Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180512 Subject: [Intel-gfx] [PATCH V2 i-g-t 2/3] Account for NULL character when using strncpy 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 This patch fix the following gcc warning: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] strncpy(data->name, name, PARAM_NAME_MAX_SZ); This error happens due to the '\0' character appended by strncpy. Notice that reduces by one in the total of bytes to be copied, in this case, is harmless because the strings received in the parameter already have '\0'. 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 1ea52efe..a605becc 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -1244,7 +1244,7 @@ static void igt_save_module_param(const char *name, const char *file_path) data = calloc(1, sizeof (*data)); igt_assert(data); - strncpy(data->name, name, PARAM_NAME_MAX_SZ); + strncpy(data->name, name, PARAM_NAME_MAX_SZ - 1); fd = open(file_path, O_RDONLY); igt_assert(fd >= 0);