cdda: CID 610847: possibly uninitialized fields

In two cases:
* Out of memory and strdup on fName failed. Nothing would be
initialized (mostly harmless: InitCheck would detect this)
* There are no frames in the track: the wav header would be left
uninitialized, and this would be readable from userland (bad thing, but
needs a specifically crafted malicious CD to happen).
This commit is contained in:
Adrien Destugues 2014-11-12 09:15:48 +01:00
parent 7b4084f717
commit 735ca4068d
1 changed files with 5 additions and 3 deletions

View File

@ -1165,9 +1165,7 @@ Inode::Inode(Volume* volume, Inode* parent, const char* name, uint64 start,
:
fNext(NULL)
{
fName = strdup(name);
if (fName == NULL)
return;
memset(&fWAVHeader, 0, sizeof(wav_header));
fID = volume->GetNextNodeID();
fType = type;
@ -1179,6 +1177,10 @@ Inode::Inode(Volume* volume, Inode* parent, const char* name, uint64 start,
fCreationTime = fModificationTime = time(NULL);
fName = strdup(name);
if (fName == NULL)
return;
if (frames) {
// initialize WAV header