[Intel-gfx] [PATCH i-g-t 1/5] intel-gpu-overlay: Avoid theoretical string overflow
Tvrtko Ursulin
tursulin at ursulin.net
Wed Nov 8 12:06:50 UTC 2017
From: Tvrtko Ursulin <tvrtko.ursulin at 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 at 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
More information about the Intel-gfx
mailing list