aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDHE <git@dehacked.net>2015-10-01 19:21:33 -0400
committerMichael Niedermayer <michael@niedermayer.cc>2015-10-08 13:15:42 +0200
commit83d75c70df2e1a155f97055268b1c19189b9fe1d (patch)
treeb8af1f82102b11527a15c4a05143fd7d969fa57d
parent818ebcbf5c52cf11e16cab6208b8d394c2fc9bba (diff)
downloadffmpeg-83d75c70df2e1a155f97055268b1c19189b9fe1d.tar.gz
libavformat/hlsenc: Use of uninitialized memory unlinking old files
Fixes ticket#4900 Signed-off-by: DHE <git@dehacked.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 76e3f8242d607ac0394b7894196f83f8d02ce5ca) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/hlsenc.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index d7bb0c1031..6827b796f4 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -163,12 +163,6 @@ static int hls_delete_old_segments(HLSContext *hls) {
ret = AVERROR(ENOMEM);
goto fail;
}
- sub_path_size = strlen(dirname) + strlen(segment->sub_filename) + 1;
- sub_path = av_malloc(sub_path_size);
- if (!sub_path) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
av_strlcpy(path, dirname, path_size);
av_strlcat(path, segment->filename, path_size);
@@ -177,14 +171,23 @@ static int hls_delete_old_segments(HLSContext *hls) {
path, strerror(errno));
}
- av_strlcpy(sub_path, dirname, sub_path_size);
- av_strlcat(sub_path, segment->sub_filename, sub_path_size);
- if (unlink(sub_path) < 0) {
- av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
- sub_path, strerror(errno));
+ if (segment->sub_filename[0] != '\0') {
+ sub_path_size = strlen(dirname) + strlen(segment->sub_filename) + 1;
+ sub_path = av_malloc(sub_path_size);
+ if (!sub_path) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
+ av_strlcpy(sub_path, dirname, sub_path_size);
+ av_strlcat(sub_path, segment->sub_filename, sub_path_size);
+ if (unlink(sub_path) < 0) {
+ av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
+ sub_path, strerror(errno));
+ }
+ av_free(sub_path);
}
av_freep(&path);
- av_free(sub_path);
previous_segment = segment;
segment = previous_segment->next;
av_free(previous_segment);
@@ -310,6 +313,8 @@ static int hls_append_segment(HLSContext *hls, double duration, int64_t pos,
if(hls->has_subtitle)
av_strlcpy(en->sub_filename, av_basename(hls->vtt_avf->filename), sizeof(en->sub_filename));
+ else
+ en->sub_filename[0] = '\0';
en->duration = duration;
en->pos = pos;