Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp241205imm; Thu, 12 Jul 2018 18:26:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcaz5lDdVvXIJuE11tOxxkuL5A8vkVTF6lAgxD72EuP2Qg/krwgBU2MsRKykAISaBMLU0Ic X-Received: by 2002:a62:d444:: with SMTP id u4-v6mr4824408pfl.142.1531445171747; Thu, 12 Jul 2018 18:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531445171; cv=none; d=google.com; s=arc-20160816; b=G8E79kZ1j7qg4/Fg0WUxaRLjoNs0ohr3AnPTsgqGDH9jkkMZgpmwwMVLa/SYJxpbgP k9AvNrg2cj4ZV0SPp7Y+gNpphQB1TiAL0l8IANHkpubnUgUvBMLwWiiEli88KSRwSLXc g25REQBTvtzz19nEyh2KZCp/2xEiphNbv3DdVG2Q60JFbr1OeWNNb3LtvSP/snRB6vBQ A2wRSUnodikCA7cMk0AI667H5Z3wYC4bl0aKaEDPk5wJOuLEn0WZ0U0GeKRC926+7m0C /10SAPrXgeokf7LYQdHqtN808UlsW5qjixEvxf1zWlCjesvguDcJ11AQYjpuUFJ5hEfz fVSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :arc-authentication-results; bh=l2SeLmVgaOEuMqDPuPVTmUToWNfLbHy5quBbPikSlgo=; b=ziXqY/ULgYaNFBI8OrStHVUEPuh1JLwhG31IsCqi+grM9PED1nbhsKOsPy9hCGU+9x dnVWI3Z+lLN41Q/n5BSRt2v20IU+3tEjlk0EhV4pYOVYfraNaShllQkFQF6YD4Q5MZWQ 6q13WCsi9QEll4EXIfGEHpT3axvUunyMKDU7869i7PkMkZEuetXQ8d/dkkuiOyJNnkuT HHIIB9OWetNUtoF9dMAjWPj8YhN1xbaJFBJk22m8/oGRVBNfsNYHeFLSIkeUkLPG3g/a yC6uJiC4LLadLMeUvgOo5SLjXEnAy71lIAZ3O2iEiG5Xbq+N5jsOE0npehnNYf0OUMb2 TMRw== 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 p13-v6si13466708pgg.616.2018.07.12.18.25.56; Thu, 12 Jul 2018 18:26:11 -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 S2387957AbeGMBha (ORCPT + 99 others); Thu, 12 Jul 2018 21:37:30 -0400 Received: from nautica.notk.org ([91.121.71.147]:42976 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387896AbeGMBha (ORCPT ); Thu, 12 Jul 2018 21:37:30 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id C41A0C01B; Fri, 13 Jul 2018 03:25:17 +0200 (CEST) From: Dominique Martinet Cc: Dominique Martinet , Gustavo Padovan , Maarten Lankhorst , Sean Paul , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: =?UTF-8?q?=5BPATCH=2003/18=5D=20drm=5Fproperty=3A=20change=20strncpy+truncation=20to=20strlcpy?= Date: Fri, 13 Jul 2018 03:25:16 +0200 Message-Id: <1531445116-19150-1-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> References: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using strlcpy fixes this new gcc warning: drivers/gpu/drm/drm_property.c: In function ‘drm_property_create’: drivers/gpu/drm/drm_property.c:125:2: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] strncpy(property->name, name, DRM_PROP_NAME_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generated by scripts/coccinelle/misc/strncpy_truncation.cocci Signed-off-by: Dominique Martinet --- Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the first patch of the serie) for the motivation behind this patch drivers/gpu/drm/drm_property.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c index cdb10f885a4f..8f0ccfa91f8b 100644 --- a/drivers/gpu/drm/drm_property.c +++ b/drivers/gpu/drm/drm_property.c @@ -122,8 +122,7 @@ struct drm_property *drm_property_create(struct drm_device *dev, property->num_values = num_values; INIT_LIST_HEAD(&property->enum_list); - strncpy(property->name, name, DRM_PROP_NAME_LEN); - property->name[DRM_PROP_NAME_LEN-1] = '\0'; + strlcpy(property->name, name, DRM_PROP_NAME_LEN); list_add_tail(&property->head, &dev->mode_config.property_list); @@ -416,8 +415,7 @@ int drm_property_add_enum(struct drm_property *property, if (!prop_enum) return -ENOMEM; - strncpy(prop_enum->name, name, DRM_PROP_NAME_LEN); - prop_enum->name[DRM_PROP_NAME_LEN-1] = '\0'; + strlcpy(prop_enum->name, name, DRM_PROP_NAME_LEN); prop_enum->value = value; property->values[index] = value; -- 2.17.1