diff options
author | Max Kellermann <max@duempel.org> | 2008-03-26 10:37:44 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-03-26 10:37:44 +0000 |
commit | c5e1bc39e95fb2423146e062c7efade70bac2c8f (patch) | |
tree | 49b58e9cd254781dc78e9751db4708e043859813 | |
parent | c9e6201df51dd6063fbdbdacb47cc4b9060597fd (diff) | |
download | mpd-c5e1bc39e95fb2423146e062c7efade70bac2c8f.tar.gz mpd-c5e1bc39e95fb2423146e062c7efade70bac2c8f.tar.xz mpd-c5e1bc39e95fb2423146e062c7efade70bac2c8f.zip |
fix segmentation fault in song info parser
The database parser does not check whether the song object has been
initialized yet, which may lead to a NULL pointer dereference. Add
this check.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7201 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r-- | src/song.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/song.c b/src/song.c index aece9d8e8..a8ab4284f 100644 --- a/src/song.c +++ b/src/song.c @@ -247,9 +247,11 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir) song->url = xstrdup(buffer + strlen(SONG_KEY)); song->type = SONG_TYPE_FILE; song->parentDir = parentDir; + } else if (*buffer == 0) { + /* ignore empty lines (starting with '\0') */ + } else if (song == NULL) { + FATAL("Problems reading song info\n"); } else if (0 == strncmp(SONG_FILE, buffer, strlen(SONG_FILE))) { - if (!song) - FATAL("Problems reading song info\n"); /* we don't need this info anymore song->url = xstrdup(&(buffer[strlen(SONG_FILE)])); */ @@ -267,8 +269,7 @@ void readSongInfoIntoList(FILE * fp, SongList * list, Directory * parentDir) } else if (0 == strncmp(SONG_MTIME, buffer, strlen(SONG_MTIME))) { song->mtime = atoi(&(buffer[strlen(SONG_MTIME)])); } - /* ignore empty lines (starting with '\0') */ - else if (*buffer) + else FATAL("songinfo: unknown line in db: %s\n", buffer); } |