Skip to content

Commit

Permalink
avformat/id3v1: strip trailing whitespace
Browse files Browse the repository at this point in the history
ID3v1 fields have a fixed size, and they are padded either with zeros,
or with spaces. Handle the latter case, instead of putting strings with
trailing spaces into the AVDictionary.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
  • Loading branch information
wm4 authored and michaelni committed Jan 5, 2015
1 parent 08810a8 commit bd78010
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libavformat/id3v1.c
Expand Up @@ -179,7 +179,7 @@ static void get_string(AVFormatContext *s, const char *key,
const uint8_t *buf, int buf_size)
{
int i, c;
char *q, str[512];
char *q, str[512], *first_free_space = NULL;

q = str;
for(i = 0; i < buf_size; i++) {
Expand All @@ -188,10 +188,19 @@ static void get_string(AVFormatContext *s, const char *key,
break;
if ((q - str) >= sizeof(str) - 1)
break;
if (c == ' ') {
if (!first_free_space)
first_free_space = q;
} else {
first_free_space = NULL;
}
*q++ = c;
}
*q = '\0';

if (first_free_space)
*first_free_space = '\0';

if (*str)
av_dict_set(&s->metadata, key, str, 0);
}
Expand Down

0 comments on commit bd78010

Please sign in to comment.