diff options
author | Paul B Mahol <onemda@gmail.com> | 2013-05-29 14:01:15 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2013-05-29 14:01:15 +0000 |
commit | be5a55535edd96034ba012dae328075d10107b20 (patch) | |
tree | 7b0e2ce4e9d568ad0afd39a3bd468f37c0278385 /libavformat/apetag.c | |
parent | 7984ed87c13df89030c85a531047e6514d9fcdc6 (diff) | |
download | ffmpeg-be5a55535edd96034ba012dae328075d10107b20.tar.gz |
apetag: do not create invalid APE tags
APEv2 specifications forbids non-ascii keys.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavformat/apetag.c')
-rw-r--r-- | libavformat/apetag.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libavformat/apetag.c b/libavformat/apetag.c index e74ed26347..c89b78d3a2 100644 --- a/libavformat/apetag.c +++ b/libavformat/apetag.c @@ -170,6 +170,12 @@ int64_t ff_ape_parse_tag(AVFormatContext *s) return tag_start; } +static int string_is_ascii(const uint8_t *str) +{ + while (*str && *str >= 0x20 && *str <= 0x7e ) str++; + return !*str; +} + int ff_ape_write_tag(AVFormatContext *s) { AVDictionaryEntry *e = NULL; @@ -193,8 +199,14 @@ int ff_ape_write_tag(AVFormatContext *s) ffio_fill(s->pb, 0, 8); // reserved while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) { - int val_len = strlen(e->value); + int val_len; + + if (!string_is_ascii(e->key)) { + av_log(s, AV_LOG_WARNING, "Non ASCII keys are not allowed\n"); + continue; + } + val_len = strlen(e->value); avio_wl32(s->pb, val_len); // value length avio_wl32(s->pb, 0); // item flags avio_put_str(s->pb, e->key); // key |