From: Dominique Martinet <asmadeus@codewreck.org>
To: Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: David Airlie <airlied@linux.ie>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Dominique Martinet <asmadeus@codewreck.org>
Subject: [PATCH] i915/intel_tv_get_modes: fix strncpy truncation warning
Date: Wed, 11 Jul 2018 09:46:15 +0200 [thread overview]
Message-ID: <1531295175-24052-1-git-send-email-asmadeus@codewreck.org> (raw)
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 <asmadeus@codewreck.org>
---
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);
mode_ptr->name[DRM_DISPLAY_MODE_LEN - 1] = '\0';
mode_ptr->hdisplay = hactive_s;
--
2.17.1
next reply other threads:[~2018-07-11 7:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-11 7:46 Dominique Martinet [this message]
2018-07-11 14:48 ` [PATCH] i915/intel_tv_get_modes: fix strncpy truncation warning Chris Wilson
2018-07-11 14:48 ` Chris Wilson
2018-07-11 14:58 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-07-11 23:24 ` [PATCH v2] " Dominique Martinet
2018-07-12 7:39 ` Chris Wilson
2018-07-12 7:39 ` Chris Wilson
2018-07-12 9:19 ` Chris Wilson
2018-07-12 9:19 ` Chris Wilson
2018-07-12 12:44 ` [Intel-gfx] [PATCH] " Ville Syrjälä
2018-07-12 13:55 ` Dominique Martinet
2018-07-12 14:10 ` Ville Syrjälä
2018-07-12 14:10 ` [Intel-gfx] " Ville Syrjälä
2018-07-12 14:30 ` Dominique Martinet
2018-07-12 23:33 ` ✗ Fi.CI.BAT: failure for i915/intel_tv_get_modes: fix strncpy truncation warning (rev2) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1531295175-24052-1-git-send-email-asmadeus@codewreck.org \
--to=asmadeus@codewreck.org \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.