]> 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:19:43 +0000 (08:19 -0700)
Use snprintf

(cherry picked from commit 67299770c013120ffdc4d86daffc9c48691ab802)

libhb/scan.c

index a6c5d2eaec18986ecc07ebf4a9f26305def2dce9..84566558ff008c3367d6b7082a0218062f89722c 100644 (file)
@@ -1298,21 +1298,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)