mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
http: Properly initialize icy headers string
The icy_metadata_headers string never gets initialized, so, during the first call to av_strlcatf() in parse_icy(), strlen() will be called on a pointer to uninitialized memory. At best this causes some garbage data to be left at the start of the string. By initializing icy_metadata_headers to the empty string, the first call to strlen() will always return 0, so that data is appended from the start of the string. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
parent
d15c536123
commit
6998a9f4c4
@ -405,6 +405,7 @@ static int parse_content_encoding(URLContext *h, const char *p)
|
|||||||
static int parse_icy(HTTPContext *s, const char *tag, const char *p)
|
static int parse_icy(HTTPContext *s, const char *tag, const char *p)
|
||||||
{
|
{
|
||||||
int len = 4 + strlen(p) + strlen(tag);
|
int len = 4 + strlen(p) + strlen(tag);
|
||||||
|
int is_first = !s->icy_metadata_headers;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (s->icy_metadata_headers)
|
if (s->icy_metadata_headers)
|
||||||
@ -413,6 +414,9 @@ static int parse_icy(HTTPContext *s, const char *tag, const char *p)
|
|||||||
if ((ret = av_reallocp(&s->icy_metadata_headers, len)) < 0)
|
if ((ret = av_reallocp(&s->icy_metadata_headers, len)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (is_first)
|
||||||
|
*s->icy_metadata_headers = '\0';
|
||||||
|
|
||||||
av_strlcatf(s->icy_metadata_headers, len, "%s: %s\n", tag, p);
|
av_strlcatf(s->icy_metadata_headers, len, "%s: %s\n", tag, p);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user