]> granicus.if.org Git - handbrake/commitdiff
scan: fix potential buffer overflow in sprintf
authorJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 11 Feb 2019 15:04:24 +0000 (08:04 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 11 Feb 2019 15:04:24 +0000 (08:04 -0700)
Use snprintf

libhb/scan.c

index 5d97b27d18231ca51e086453a5df4a901afcb855..f1e0de2304adbed90e0e0896444fddc9e3685c51 100644 (file)
@@ -1297,21 +1297,20 @@ static void LookForAudio(hb_scan_t *scan, hb_title_t * title, hb_buffer_t * b)
                 break;
         }
     }
-
     if (codec_name != NULL && profile_name != NULL)
     {
-        sprintf(audio->config.lang.description, "%s (%s %s)",
-                audio->config.lang.simple, codec_name, profile_name);
+        snprintf(audio->config.lang.description, sizeof(audio->config.lang.description),
+                "%s (%s %s)", audio->config.lang.simple, codec_name, profile_name);
     }
     else if (codec_name != NULL)
     {
-        sprintf(audio->config.lang.description, "%s (%s)",
-                audio->config.lang.simple, codec_name);
+        snprintf(audio->config.lang.description, sizeof(audio->config.lang.description),
+                "%s (%s)", audio->config.lang.simple, codec_name);
     }
     else if (profile_name != NULL)
     {
-        sprintf(audio->config.lang.description, "%s (%s)",
-                audio->config.lang.simple, profile_name);
+        snprintf(audio->config.lang.description, sizeof(audio->config.lang.description),
+                "%s (%s)", audio->config.lang.simple, profile_name);
     }
 
     if (audio->config.lang.attributes & HB_AUDIO_ATTR_VISUALLY_IMPAIRED)