diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2009-04-05 18:39:10 +0100 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2009-04-05 18:39:10 +0100 |
commit | a6bc7ed17d202107208bbe637ca92d5886c3d686 (patch) | |
tree | 2dfb9980680204b9362e6e5cbb66c4ef78d1b167 /src/demuxers | |
parent | 240889c0d0a7ead9df29c5d154403490fb09e8c7 (diff) | |
download | xine-lib-a6bc7ed17d202107208bbe637ca92d5886c3d686.tar.gz xine-lib-a6bc7ed17d202107208bbe637ca92d5886c3d686.tar.bz2 |
Fix handling of the length of UTF-16 content sourced from, e.g., ID3 tags.
This avoids use of strlen(), which doesn't cope well with UTF-16, and
also has the ID3 parser double-NUL-terminate the buffered string.
Diffstat (limited to 'src/demuxers')
-rw-r--r-- | src/demuxers/id3.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c index 1aebbc817..0d0ee7231 100644 --- a/src/demuxers/id3.c +++ b/src/demuxers/id3.c @@ -275,8 +275,8 @@ static int id3v22_interp_frame(input_plugin_t *input, id3v22_frame_header_t *frame_header) { char *buf; int enc; - const size_t bufsize = frame_header->size +1; - if ( bufsize <= 2 ) /* frames has to be _at least_ 1 byte */ + const size_t bufsize = frame_header->size + 2; + if ( bufsize <= 3 ) /* frames has to be _at least_ 1 byte */ return 0; buf = malloc(bufsize); @@ -287,6 +287,7 @@ static int id3v22_interp_frame(input_plugin_t *input, if (input->read (input, buf, frame_header->size) == frame_header->size) { buf[frame_header->size] = 0; + buf[frame_header->size + 1] = 0; enc = buf[0]; if( enc >= ID3_ENCODING_COUNT ) enc = 0; @@ -472,8 +473,8 @@ static int id3v23_interp_frame(input_plugin_t *input, id3v23_frame_header_t *frame_header) { char *buf; int enc; - const size_t bufsize = frame_header->size +1; - if ( bufsize <= 2 ) /* frames has to be _at least_ 1 byte */ + const size_t bufsize = frame_header->size + 2; + if ( bufsize <= 3 ) /* frames has to be _at least_ 1 byte */ return 0; buf = malloc(bufsize); @@ -484,6 +485,7 @@ static int id3v23_interp_frame(input_plugin_t *input, if (input->read (input, buf, frame_header->size) == frame_header->size) { buf[frame_header->size] = 0; + buf[frame_header->size + 1] = 0; enc = buf[0]; if( enc >= ID3_ENCODING_COUNT ) enc = 0; @@ -726,8 +728,8 @@ static int id3v24_interp_frame(input_plugin_t *input, id3v24_frame_header_t *frame_header) { char *buf; int enc; - const size_t bufsize = frame_header->size +1; - if ( bufsize <= 2 ) /* frames has to be _at least_ 1 byte */ + const size_t bufsize = frame_header->size + 2; + if ( bufsize <= 3 ) /* frames has to be _at least_ 1 byte */ return 0; buf = malloc(bufsize); @@ -738,6 +740,7 @@ static int id3v24_interp_frame(input_plugin_t *input, if (input->read (input, buf, frame_header->size) == frame_header->size) { buf[frame_header->size] = 0; + buf[frame_header->size + 1] = 0; enc = buf[0]; if( enc >= ID3_ENCODING_COUNT ) enc = 0; |