Fix various potential illegal access and memory leaks in error conditions.

This commit is contained in:
Justin Maggard
2014-04-07 11:20:19 -07:00
parent 6e43ab3c06
commit d492b43ef8
10 changed files with 34 additions and 21 deletions

View File

@ -103,11 +103,11 @@ _get_aactags(char *file, struct song_metadata *psong)
len = 22;
current_data = (char*)malloc(len); // extra byte
memset(current_data, 0x00, len);
if(fread(current_data, 1, current_size - 8, fin) != current_size - 8)
break;
current_data[len-1] = '\0';
if(!memcmp(current_atom, "\xA9" "nam", 4))
psong->title = strdup((char*)&current_data[16]);
else if(!memcmp(current_atom, "\xA9" "ART", 4) ||

View File

@ -226,6 +226,8 @@ _asf_read_media_stream(FILE *fp, struct song_metadata *psong, uint32_t size)
if(len > size)
len = size;
memset(&s, 0, sizeof(s));
if(len != fread(&s.MajorType, 1, len, fp))
return -1;
@ -257,6 +259,8 @@ _asf_read_stream_object(FILE *fp, struct song_metadata *psong, uint32_t size)
if(size < len)
return -1;
memset(&s, 0, sizeof(s));
if(len != fread(&s.StreamType, 1, len, fp))
return -1;
@ -285,6 +289,8 @@ _asf_read_extended_stream_object(FILE *fp, struct song_metadata *psong, uint32_t
if(size < sizeof(asf_extended_stream_object_t))
return -1;
memset(&xs, 0, sizeof(xs));
len = sizeof(xs) - offsetof(asf_extended_stream_object_t, StartTime);
if(len != fread(&xs.StartTime, 1, len, fp))
return -1;