summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-10-18 22:12:12 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-10-18 22:13:10 -0700
commit8a4d6f5bd95f5ad7608a7871bc6822935e4a191b (patch)
tree730f45029d1b6ef63b4dc983eaa0782106833e96
parentd61cb117c170b23b9fbaf619c2a1e54b9f987a90 (diff)
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 <alan.coopersmith@oracle.com>
-rw-r--r--xvinfo.c7
1 files 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);