Message ID | 1516409970-16621-1-git-send-email-redmcg@redmandi.dyndns.org |
---|---|
State | Accepted |
Commit | 2472dbc7a770a908a2f511ec337ec392ca3e3afa |
Headers | show |
On 1/20/18 6:29 AM, Brendan McGrath wrote: > If codecpar->extradata is not set (for example, when the stream goes > through the 'tee' muxer), then a segfault occurs. > > This patch ensures the data variable is not null before attempting > to access it > > Signed-off-by: Brendan McGrath <redmcg@redmandi.dyndns.org> > --- > Before the var_stream_map option was available - I was using the tee > muxer to create each resolution as an individual stream. > > When running this configuration after the most recent hlsenc change > I hit a segfault > > The most simple command which recreates the segfault is: > ffmpeg -i in.ts -map 0:a -map 0:v -c:a aac -c:v h264 \ > -f tee [select=\'a,v\':f=hls]tv_hls_hd.m3u8 > > libavformat/hlsenc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index 8ad906a..42e437f 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -308,7 +308,7 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) { > > if (st->codecpar->codec_id == AV_CODEC_ID_H264) { > uint8_t *data = st->codecpar->extradata; > - if ((data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) { > + if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) { > snprintf(attr, sizeof(attr), > "avc1.%02x%02x%02x", data[5], data[6], data[7]); > } else { LGTM. Thanks for the fix. Regards, Kaarthick
> 在 2018年1月20日,上午10:35,Jeyapal, Karthick <kjeyapal@akamai.com> 写道: > > > >> On 1/20/18 6:29 AM, Brendan McGrath wrote: >> If codecpar->extradata is not set (for example, when the stream goes >> through the 'tee' muxer), then a segfault occurs. >> >> This patch ensures the data variable is not null before attempting >> to access it >> >> Signed-off-by: Brendan McGrath <redmcg@redmandi.dyndns.org> >> --- >> Before the var_stream_map option was available - I was using the tee >> muxer to create each resolution as an individual stream. >> >> When running this configuration after the most recent hlsenc change >> I hit a segfault >> >> The most simple command which recreates the segfault is: >> ffmpeg -i in.ts -map 0:a -map 0:v -c:a aac -c:v h264 \ >> -f tee [select=\'a,v\':f=hls]tv_hls_hd.m3u8 >> >> libavformat/hlsenc.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c >> index 8ad906a..42e437f 100644 >> --- a/libavformat/hlsenc.c >> +++ b/libavformat/hlsenc.c >> @@ -308,7 +308,7 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) { >> >> if (st->codecpar->codec_id == AV_CODEC_ID_H264) { >> uint8_t *data = st->codecpar->extradata; >> - if ((data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) { >> + if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) { >> snprintf(attr, sizeof(attr), >> "avc1.%02x%02x%02x", data[5], data[6], data[7]); >> } else { > > LGTM. Thanks for the fix will apply
2018-01-20 23:56 GMT+08:00 Steven Liu <lq@chinaffmpeg.org>: > > >> 在 2018年1月20日,上午10:35,Jeyapal, Karthick <kjeyapal@akamai.com> 写道: >> >> >> >>> On 1/20/18 6:29 AM, Brendan McGrath wrote: >>> If codecpar->extradata is not set (for example, when the stream goes >>> through the 'tee' muxer), then a segfault occurs. >>> >>> This patch ensures the data variable is not null before attempting >>> to access it >>> >>> Signed-off-by: Brendan McGrath <redmcg@redmandi.dyndns.org> >>> --- >>> Before the var_stream_map option was available - I was using the tee >>> muxer to create each resolution as an individual stream. >>> >>> When running this configuration after the most recent hlsenc change >>> I hit a segfault >>> >>> The most simple command which recreates the segfault is: >>> ffmpeg -i in.ts -map 0:a -map 0:v -c:a aac -c:v h264 \ >>> -f tee [select=\'a,v\':f=hls]tv_hls_hd.m3u8 >>> >>> libavformat/hlsenc.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c >>> index 8ad906a..42e437f 100644 >>> --- a/libavformat/hlsenc.c >>> +++ b/libavformat/hlsenc.c >>> @@ -308,7 +308,7 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) { >>> >>> if (st->codecpar->codec_id == AV_CODEC_ID_H264) { >>> uint8_t *data = st->codecpar->extradata; >>> - if ((data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) { >>> + if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) { >>> snprintf(attr, sizeof(attr), >>> "avc1.%02x%02x%02x", data[5], data[6], data[7]); >>> } else { >> >> LGTM. Thanks for the fix > > will apply > > Pushed Thanks Steven
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 8ad906a..42e437f 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -308,7 +308,7 @@ static void write_codec_attr(AVStream *st, VariantStream *vs) { if (st->codecpar->codec_id == AV_CODEC_ID_H264) { uint8_t *data = st->codecpar->extradata; - if ((data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) { + if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 0x1F) == 7) { snprintf(attr, sizeof(attr), "avc1.%02x%02x%02x", data[5], data[6], data[7]); } else {
If codecpar->extradata is not set (for example, when the stream goes through the 'tee' muxer), then a segfault occurs. This patch ensures the data variable is not null before attempting to access it Signed-off-by: Brendan McGrath <redmcg@redmandi.dyndns.org> --- Before the var_stream_map option was available - I was using the tee muxer to create each resolution as an individual stream. When running this configuration after the most recent hlsenc change I hit a segfault The most simple command which recreates the segfault is: ffmpeg -i in.ts -map 0:a -map 0:v -c:a aac -c:v h264 \ -f tee [select=\'a,v\':f=hls]tv_hls_hd.m3u8 libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)