diff options
author | Carsten Haitzler <raster@rasterman.com> | 2009-01-19 05:39:29 +0000 |
---|---|---|
committer | Carsten Haitzler <raster@rasterman.com> | 2009-01-19 05:39:29 +0000 |
commit | d4577b5d4edbef848423341eeec22afe308e0716 (patch) | |
tree | b3e0d84d0cd8ecfe212ded6ca8bff5245839eea5 | |
parent | 01ffaf1a5949c96d4ce294cc67e5b8ca611dc28e (diff) | |
download | imlib2-d4577b5d4edbef848423341eeec22afe308e0716.tar.gz |
fix bufferoverflow in id3 loader.
SVN revision: 38642
-rw-r--r-- | src/modules/loaders/loader_id3.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/modules/loaders/loader_id3.c b/src/modules/loaders/loader_id3.c index ef4362a..40113c4 100644 --- a/src/modules/loaders/loader_id3.c +++ b/src/modules/loaders/loader_id3.c @@ -360,6 +360,9 @@ static char* id3_pic_types [] = { /* $14 */ "Publisher/Studio logotype" }; +#define NUM_OF_ID3_PIC_TYPES \ + (sizeof(id3_pic_types) / sizeof(id3_pic_types[0])) + static char* id3_text_encodings [] = { /* $00 */ "ISO-8859-1", /* $01 */ "UTF-16 encoded Unicode with BOM", @@ -367,6 +370,9 @@ static char* id3_text_encodings [] = { /* $03 */ "UTF-8 encoded Unicode" }; +#define NUM_OF_ID3_TEXT_ENCODINGS \ + (sizeof(id3_text_encodings) / sizeof(id3_text_encodings[0])) + static void write_tags (ImlibImage* im, lopt* opt) { struct id3_frame* frame @@ -396,12 +402,12 @@ static void write_tags (ImlibImage* im, lopt* opt) __imlib_AttachTag (im, "id3-description-text-encoding", (num_data = (int) id3_field_gettextencoding (field)), - num_data < sizeof (id3_text_encodings) ? + num_data < NUM_OF_ID3_TEXT_ENCODINGS ? id3_text_encodings[num_data] : NULL, NULL); if (field = id3_frame_field (frame, 2)) __imlib_AttachTag (im, "id3-picture-type", (num_data = id3_field_getint (field)), - num_data < sizeof (id3_pic_types) ? + num_data < NUM_OF_ID3_PIC_TYPES ? id3_pic_types[num_data] : NULL, NULL); __imlib_AttachTag (im, "count", id3_tag_get_numframes (opt->ctx->tag), NULL, NULL); |