Permalink
Browse files

fix cddb info parsing (closes #12801)

Reverse problems introduced by commit 50c678:
- Track title was always nulled.
- Track artist copy was not against proper bounds
  • Loading branch information...
1 parent a74d5cc commit f0f66c4fae95ef30e663c7777cb1606299d1711c @CrystalP committed Mar 16, 2012
Showing with 9 additions and 6 deletions.
  1. +9 −6 xbmc/network/cddb.cpp
View
@@ -415,16 +415,19 @@ void Xcddb::addTitle(const char *buffer)
}
if (found)
{
- strncpy(artist, value, index);
- artist[index] = '\0';
- strncpy(title, value + index + 3, sizeof(title));
- title[0] = '\0';
+ int artist_len = std::min(index, sizeof(artist) - 1);
+ strncpy(artist, value, artist_len);
+ artist[artist_len] = '\0';
+ int title_len = std::min(len - index - 3, sizeof(title)-1);
+ strncpy(title, value + index + 3, title_len);
+ title[title_len] = '\0';
}
else
{
artist[0] = '\0';
- strncpy(title, value, sizeof(title));
- title[0] = '\0';
+ int title_len = std::min(len, sizeof(title)-1);
+ strncpy(title, value, title_len);
+ title[title_len] = '\0';
}
CStdString strArtist=artist;

0 comments on commit f0f66c4

Please sign in to comment.