From 8a4d6f5bd95f5ad7608a7871bc6822935e4a191b Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 18 Oct 2013 22:12:12 -0700 Subject: Convert sprintf call to use snprintf Should be impossible to overflow with previous sprintf code, but still safer to avoid bugs if something changes in the future. Signed-off-by: Alan Coopersmith --- xvinfo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xvinfo.c b/xvinfo.c index 2a43020..d24aa5b 100644 --- a/xvinfo.c +++ b/xvinfo.c @@ -200,8 +200,6 @@ main(int argc, char *argv[]) } if (ImageEncodings && (ainfo[j].type & XvImageMask)) { - char imageName[5]; - for (n = 0; n < nencode; n++) { if (!strcmp(encodings[n].name, "XV_IMAGE")) { fprintf(stdout, @@ -218,7 +216,10 @@ main(int argc, char *argv[]) numImages); for (n = 0; n < numImages; n++) { - sprintf(imageName, "%c%c%c%c", formats[n].id & 0xff, + char imageName[5]; + + snprintf(imageName, sizeof(imageName), "%c%c%c%c", + formats[n].id & 0xff, (formats[n].id >> 8) & 0xff, (formats[n].id >> 16) & 0xff, (formats[n].id >> 24) & 0xff); -- cgit v1.2.3