All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 1/5] intel-gpu-overlay: Avoid theoretical string overflow
Date: Wed,  8 Nov 2017 12:06:50 +0000	[thread overview]
Message-ID: <20171108120654.680-2-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20171108120654.680-1-tvrtko.ursulin@linux.intel.com>

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

GCC 7 notices a theoretical string overflow. Use snprintf and increase
the buffer to avoid that.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 overlay/overlay.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/overlay/overlay.c b/overlay/overlay.c
index 5fc6958be2d9..2ec86609a464 100644
--- a/overlay/overlay.c
+++ b/overlay/overlay.c
@@ -743,7 +743,7 @@ static void init_gem_objects(struct overlay_context *ctx,
 static void show_gem_objects(struct overlay_context *ctx, struct overlay_gem_objects *go)
 {
 	struct gem_objects_comm *comm;
-	char buf[160];
+	char buf[360];
 	cairo_pattern_t *linear;
 	int x, y, y1, y2;
 
@@ -785,7 +785,7 @@ static void show_gem_objects(struct overlay_context *ctx, struct overlay_gem_obj
 	cairo_pattern_destroy(linear);
 	cairo_fill(ctx->cr);
 
-	sprintf(buf, "Total: %ldMB, %ld objects",
+	snprintf(buf, sizeof(buf), "Total: %luMB, %lu objects",
 		go->gem_objects.total_bytes >> 20, go->gem_objects.total_count);
 	cairo_set_source_rgba(ctx->cr, 1, 1, 1, 1);
 	cairo_move_to(ctx->cr, x, y);
@@ -798,7 +798,7 @@ static void show_gem_objects(struct overlay_context *ctx, struct overlay_gem_obj
 		if ((comm->bytes >> 20) == 0)
 			break;
 
-		sprintf(buf, "%s %ldMB, %ld objects",
+		snprintf(buf, sizeof(buf), "%s %luMB, %lu objects",
 			comm->name, comm->bytes >> 20, comm->count);
 		cairo_move_to(ctx->cr, x, y);
 		cairo_show_text(ctx->cr, buf);
-- 
2.14.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-11-08 12:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 12:06 [PATCH i-g-t 0/5] Assorted compile warnings fixes Tvrtko Ursulin
2017-11-08 12:06 ` Tvrtko Ursulin [this message]
2017-11-08 12:25   ` [PATCH i-g-t 1/5] intel-gpu-overlay: Avoid theoretical string overflow Petri Latvala
2017-11-08 12:06 ` [PATCH i-g-t 2/5] aubdump: Avoid mixing declarations and code Tvrtko Ursulin
2017-11-08 12:06 ` [PATCH i-g-t 3/5] lib/core: Avoid unused result in backtrace printing Tvrtko Ursulin
2017-11-22 17:44   ` Tvrtko Ursulin
2017-11-22 17:52     ` Chris Wilson
2017-11-08 12:06 ` [PATCH i-g-t 4/5] gem_syslatency: Avoid arithmetic on void * warning Tvrtko Ursulin
2017-11-08 12:28   ` Petri Latvala
2017-11-09 10:18     ` Tvrtko Ursulin
2017-11-08 12:06 ` [PATCH i-g-t 5/5] intel_gvtg_test: Handle system(3) return value Tvrtko Ursulin
2017-11-08 12:19   ` Chris Wilson
2017-11-08 12:50     ` Tvrtko Ursulin
2017-11-08 12:22   ` Petri Latvala
2017-11-08 12:47     ` [PATCH i-g-t v2] " Tvrtko Ursulin
2017-11-08 12:52       ` Petri Latvala
2017-11-09 10:16         ` Tvrtko Ursulin
2017-11-08 18:09     ` ✗ Fi.CI.BAT: warning for " Patchwork
2017-11-08 20:14     ` ✗ Fi.CI.IGT: " Patchwork
2017-11-08 17:36 ` ✗ Fi.CI.BAT: failure for Assorted compile warnings fixes 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=20171108120654.680-2-tvrtko.ursulin@linux.intel.com \
    --to=tursulin@ursulin.net \
    --cc=Intel-gfx@lists.freedesktop.org \
    /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.