Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp748244imm; Wed, 11 Jul 2018 10:15:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpezj/UwZFaa3ROm1TFJjGabUJEXpT8oWJwe2haBSIgNMh/l39yWYjn2QxOTQhEJFhnZJQOP X-Received: by 2002:a62:5582:: with SMTP id j124-v6mr31086163pfb.20.1531329321968; Wed, 11 Jul 2018 10:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531329321; cv=none; d=google.com; s=arc-20160816; b=YOlOimMJwa2vejQ3VTJHxlqZzRq4ufsnMq1ZLg0dKc5zOs9yzZMMdSwOxBmf85HF9+ l7fBQYmglgUFtFzaAPf5ZAvDprQHP/Fvi+qtoaJzg/Axc/Tb+l/iu/Oh6z0p+L56eQdm 4R2KxyhUyE0gphKxT0WBibz8acWxVUb80TuLOrNEGauxJGORl0dfU/k5nAi+p7SldpHq XRoKDtQ+EETlaKwffPUZZo07+0cZiqPeZFsakSYARSqKmj9u5wtTzH7OXq31dpFMhJ/Q a4jW2lqTjo3uook/yLi+uu0M5M9oy8uuSg8s6WRPCDSNJEGz98zY7Q6ccloOlJugiJ9B tLKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:arc-authentication-results; bh=8vg7waqiqcsSsaPNvrceK/GWR+pyX/JE8kzzgOm5l5Y=; b=Z8uS4vjiPTWDY5Na1v36/P5HHVCPs6gTcyQmMbP9W0Pqw19iLRC/QH8a2QaVwiJr3s pQJYZ1w/vfVfaeo5Ec99NW5lr6g85EFyy7bdvntwtGbGXKixHO+bGrO8MR/D5h/Kl+yr bZ3GY1Dc8KCpdQdBGLeVAjBu9EPP5dfu6PvqcpDAyFffCaooailwP294md0lUGr4zGL1 yORWD0mNDaiLfItlzqmydfeoPAp0UXHL2Gn7uCQG0/nmOL4QlFosnvAvrpr6Eebb3pf0 OZWeIM7UUc8leSARxVWSMDnxXMGnfmuaMPt7XDI1INSRCv4hS3qUgoYs1YLrjvgicXKZ fQqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si19089356pgj.128.2018.07.11.10.15.06; Wed, 11 Jul 2018 10:15:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732941AbeGKOxj convert rfc822-to-8bit (ORCPT + 99 others); Wed, 11 Jul 2018 10:53:39 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:57565 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732321AbeGKOxj (ORCPT ); Wed, 11 Jul 2018 10:53:39 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 12321868-1500050 for multiple; Wed, 11 Jul 2018 15:48:35 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Dominique Martinet , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi From: Chris Wilson In-Reply-To: <1531295175-24052-1-git-send-email-asmadeus@codewreck.org> Cc: David Airlie , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dominique Martinet References: <1531295175-24052-1-git-send-email-asmadeus@codewreck.org> Message-ID: <153132051066.18500.1587767829295271001@skylake-alporthouse-com> User-Agent: alot/0.6 Subject: Re: [PATCH] i915/intel_tv_get_modes: fix strncpy truncation warning Date: Wed, 11 Jul 2018 15:48:40 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Dominique Martinet (2018-07-11 08:46:15) > This is effectively no-op as the next line writes a nul at the final > byte of the buffer, so copying one letter less does not change the > behaviour. > > Signed-off-by: Dominique Martinet > --- > > gcc 8 gives the following warning, which I am not sure why is treated > as error for this file, thus making me fix it: > drivers/gpu/drm/i915/intel_tv.c: In function ‘intel_tv_get_modes’: > drivers/gpu/drm/i915/intel_tv.c:1358:3: error: ‘strncpy’ specified bound 32 equals destination size [-Werror=stringop-truncation] > strncpy(mode_ptr->name, input->name, DRM_DISPLAY_MODE_LEN); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > cc1: all warnings being treated as errors > > > Also, as a side note, while checking if this was already sent I stumbled > uppon this: https://lists.freedesktop.org/archives/intel-gfx/2018-July/170638.html > ([Intel-gfx] [PATCH i-g-t 6/7] Fix truncate string in the strncpy) > which replaces strncpy(dest, src, sizeof(dest)) by strncpy(dest, src, > strlen(dest))... This isn't for linux but this looks like a pretty bad > idea to me... (I'm not on the list to reply there, sorry) > > drivers/gpu/drm/i915/intel_tv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c > index b55b5c157e38..f5614d07b10d 100644 > --- a/drivers/gpu/drm/i915/intel_tv.c > +++ b/drivers/gpu/drm/i915/intel_tv.c > @@ -1355,7 +1355,7 @@ intel_tv_get_modes(struct drm_connector *connector) > mode_ptr = drm_mode_create(connector->dev); > if (!mode_ptr) > continue; > - strncpy(mode_ptr->name, input->name, DRM_DISPLAY_MODE_LEN); > + strncpy(mode_ptr->name, input->name, DRM_DISPLAY_MODE_LEN - 1); strlcpy -Chris