more defensive aac scanning to fix bug #47
This commit is contained in:
parent
0028d16aa0
commit
b147348dbd
|
@ -75,6 +75,8 @@ off_t scan_aac_drilltoatom(FILE *aac_fp,char *atom_path,
|
||||||
char *cur_p, *end_p;
|
char *cur_p, *end_p;
|
||||||
char atom_name[5];
|
char atom_name[5];
|
||||||
|
|
||||||
|
DPRINTF(E_SPAM,L_SCAN,"Searching for %s\n",atom_path);
|
||||||
|
|
||||||
fseek(aac_fp, 0, SEEK_END);
|
fseek(aac_fp, 0, SEEK_END);
|
||||||
file_size = ftell(aac_fp);
|
file_size = ftell(aac_fp);
|
||||||
rewind(aac_fp);
|
rewind(aac_fp);
|
||||||
|
@ -204,6 +206,8 @@ int scan_get_aacinfo(char *filename, MP3FILE *pmp3) {
|
||||||
if(fread((void*)¤t_size,1,sizeof(int),fin) != sizeof(int))
|
if(fread((void*)¤t_size,1,sizeof(int),fin) != sizeof(int))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
DPRINTF(E_SPAM,L_SCAN,"Current size: %d\n");
|
||||||
|
|
||||||
current_size=ntohl(current_size);
|
current_size=ntohl(current_size);
|
||||||
|
|
||||||
if(current_size <= 7) /* something not right */
|
if(current_size <= 7) /* something not right */
|
||||||
|
@ -212,6 +216,14 @@ int scan_get_aacinfo(char *filename, MP3FILE *pmp3) {
|
||||||
if(fread(current_atom,1,4,fin) != 4)
|
if(fread(current_atom,1,4,fin) != 4)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
DPRINTF(E_SPAM,L_SCAN,"Current Atom: %c%c%c%c\n",
|
||||||
|
current_atom[0],current_atom[1],current_atom[2],
|
||||||
|
current_atom[3]);
|
||||||
|
|
||||||
|
if(current_size > 4096) { /* Does this break anything? */
|
||||||
|
/* too big! cover art, maybe? */
|
||||||
|
fseek(fin,current_size - 8 - 7,SEEK_CUR);
|
||||||
|
} else {
|
||||||
len=current_size-7; /* for ill-formed too-short tags */
|
len=current_size-7; /* for ill-formed too-short tags */
|
||||||
if(len < 22)
|
if(len < 22)
|
||||||
len=22;
|
len=22;
|
||||||
|
@ -279,6 +291,7 @@ int scan_get_aacinfo(char *filename, MP3FILE *pmp3) {
|
||||||
current_offset+=current_size;
|
current_offset+=current_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* got the tag info, now let's get bitrate, etc */
|
/* got the tag info, now let's get bitrate, etc */
|
||||||
atom_offset = scan_aac_drilltoatom(fin, "moov:mvhd", &atom_length);
|
atom_offset = scan_aac_drilltoatom(fin, "moov:mvhd", &atom_length);
|
||||||
|
@ -331,6 +344,12 @@ int scan_get_aacinfo(char *filename, MP3FILE *pmp3) {
|
||||||
atom_offset=scan_aac_drilltoatom(fin,
|
atom_offset=scan_aac_drilltoatom(fin,
|
||||||
"moov:trak:mdia:minf:stbl:stsd:mp4a",
|
"moov:trak:mdia:minf:stbl:stsd:mp4a",
|
||||||
&atom_length);
|
&atom_length);
|
||||||
|
if(atom_offset == -1) {
|
||||||
|
atom_offset=scan_aac_drilltoatom(fin,
|
||||||
|
"moov:trak:mdia:minf:stbl:stsd:drms",
|
||||||
|
&atom_length);
|
||||||
|
}
|
||||||
|
|
||||||
if (atom_offset != -1) {
|
if (atom_offset != -1) {
|
||||||
fseek(fin, atom_offset + 32, SEEK_SET);
|
fseek(fin, atom_offset + 32, SEEK_SET);
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,8 @@ int scan_get_mp4info(char *filename, MP3FILE *pmp3) {
|
||||||
if(fread((void*)¤t_size,1,sizeof(int),fin) != sizeof(int))
|
if(fread((void*)¤t_size,1,sizeof(int),fin) != sizeof(int))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
DPRINTF(E_SPAM,L_SCAN,"Current size: %d\n");
|
||||||
|
|
||||||
current_size=ntohl(current_size);
|
current_size=ntohl(current_size);
|
||||||
|
|
||||||
if(current_size <= 7) /* something not right */
|
if(current_size <= 7) /* something not right */
|
||||||
|
@ -102,6 +104,14 @@ int scan_get_mp4info(char *filename, MP3FILE *pmp3) {
|
||||||
if(fread(current_atom,1,4,fin) != 4)
|
if(fread(current_atom,1,4,fin) != 4)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
DPRINTF(E_SPAM,L_SCAN,"Current Atom: %c%c%c%c\n",
|
||||||
|
current_atom[0],current_atom[1],current_atom[2],
|
||||||
|
current_atom[3]);
|
||||||
|
|
||||||
|
if(current_size > 4096) { /* Does this break anything? */
|
||||||
|
/* too big! cover art, maybe? */
|
||||||
|
fseek(fin,current_size - 8 - 7,SEEK_CUR);
|
||||||
|
} else {
|
||||||
len=current_size-7; /* for ill-formed too-short tags */
|
len=current_size-7; /* for ill-formed too-short tags */
|
||||||
if(len < 22)
|
if(len < 22)
|
||||||
len=22;
|
len=22;
|
||||||
|
@ -169,6 +179,7 @@ int scan_get_mp4info(char *filename, MP3FILE *pmp3) {
|
||||||
current_offset+=current_size;
|
current_offset+=current_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* got the tag info, now let's get bitrate, etc */
|
/* got the tag info, now let's get bitrate, etc */
|
||||||
atom_offset = scan_aac_drilltoatom(fin, "moov:mvhd", &atom_length);
|
atom_offset = scan_aac_drilltoatom(fin, "moov:mvhd", &atom_length);
|
||||||
|
@ -208,6 +219,12 @@ int scan_get_mp4info(char *filename, MP3FILE *pmp3) {
|
||||||
atom_offset=scan_aac_drilltoatom(fin,
|
atom_offset=scan_aac_drilltoatom(fin,
|
||||||
"moov:trak:mdia:minf:stbl:stsd:mp4a",
|
"moov:trak:mdia:minf:stbl:stsd:mp4a",
|
||||||
&atom_length);
|
&atom_length);
|
||||||
|
if(atom_offset == -1) {
|
||||||
|
atom_offset=scan_aac_drilltoatom(fin,
|
||||||
|
"moov:trak:mdia:minf:stbl:stsd:drms",
|
||||||
|
&atom_length);
|
||||||
|
}
|
||||||
|
|
||||||
if (atom_offset != -1) {
|
if (atom_offset != -1) {
|
||||||
fseek(fin, atom_offset + 32, SEEK_SET);
|
fseek(fin, atom_offset + 32, SEEK_SET);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue