jp3d: Replace sprintf() by snprintf() in volumetobin() 1101/head
authorKarol Babioch <karol@babioch.de>
Sat, 3 Mar 2018 09:10:32 +0000 (10:10 +0100)
committerKarol Babioch <karol@babioch.de>
Sat, 3 Mar 2018 09:11:39 +0000 (10:11 +0100)
This replaces the unsafe sprintf() invocation by the safer snprintf()
one, with the correct buffer size to prevent buffer overflows.

This fixes #1085.

src/bin/jp3d/convert.c

index 7d802445d64846b3530e0214b1373f80ce940bee..23fd70b04365ea0d2628b2e17b10b5e7f4fcf50b 100644 (file)
@@ -788,7 +788,7 @@ int volumetobin(opj_volume_t * volume, char *outfile)
 
     fclose(fdest);
 
-    sprintf(name, "%s.img", outfile);
+    snprintf(name, sizeof(name), "%s.img", outfile);
     fimgdest = fopen(name, "w");
     if (!fimgdest) {
         fprintf(stdout, "[ERROR] Failed to open %s for writing\n", name);