diff options
author | John Stebbins <[email protected]> | 2018-06-13 10:11:30 -0700 |
---|---|---|
committer | John Stebbins <[email protected]> | 2018-06-13 10:11:30 -0700 |
commit | c85294a8f0bce69d5cb417f60a143663fb83772a (patch) | |
tree | e6f68e663722653d93b7069c8fc75a0425fd8d2c /libhb/encavcodec.c | |
parent | 256c9acab3e49d61bb3a48c8fe60c7b17c09bad6 (diff) |
libhb: fix snprintf compiler warnings
Our handling of temporary directory paths could truncate resulting
filenames. This fixes the warnings and prevents possible truncation.
Diffstat (limited to 'libhb/encavcodec.c')
-rw-r--r-- | libhb/encavcodec.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c index 805365ac2..ee914faba 100644 --- a/libhb/encavcodec.c +++ b/libhb/encavcodec.c @@ -368,17 +368,18 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) if( job->pass_id == HB_PASS_ENCODE_1ST || job->pass_id == HB_PASS_ENCODE_2ND ) { - char filename[1024]; memset( filename, 0, 1024 ); - hb_get_tempory_filename( job->h, filename, "ffmpeg.log" ); + char * filename = hb_get_temporary_filename("ffmpeg.log"); if( job->pass_id == HB_PASS_ENCODE_1ST ) { pv->file = hb_fopen(filename, "wb"); - if (!pv->file) { + if (!pv->file) + { if (strerror_r(errno, reason, 79) != 0) strcpy(reason, "unknown -- strerror_r() failed"); hb_error("encavcodecInit: Failed to open %s (reason: %s)", filename, reason); + free(filename); ret = 1; goto done; } @@ -395,6 +396,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) strcpy(reason, "unknown -- strerror_r() failed"); hb_error("encavcodecInit: Failed to open %s (reason: %s)", filename, reason); + free(filename); ret = 1; goto done; } @@ -412,6 +414,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) strcpy(reason, "unknown -- strerror_r() failed"); hb_error( "encavcodecInit: Failed to read %s (reason: %s)" , filename, reason); + free(filename); ret = 1; fclose( pv->file ); pv->file = NULL; @@ -424,12 +427,14 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) context->flags |= AV_CODEC_FLAG_PASS2; context->stats_in = log; } + free(filename); } if (hb_avcodec_open(context, codec, &av_opts, HB_FFMPEG_THREADS_AUTO)) { hb_log( "encavcodecInit: avcodec_open failed" ); - return 1; + ret = 1; + goto done; } if (job->pass_id == HB_PASS_ENCODE_1ST && |