Re: [PATCH i-g-t 1/5] intel-gpu-overlay: Avoid theoretical string overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 08, 2017 at 12:06:50PM +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
> 
> GCC 7 notices a theoretical string overflow. Use snprintf and increase
> the buffer to avoid that.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>

Reviewed-by: Petri Latvala <petri.latvala@xxxxxxxxx>


> ---
>  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@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux