extra checking on memory allocation sizes to prevent a class of overflow attacks

This commit is contained in:
Josh Coalson
2007-09-11 04:49:56 +00:00
parent 0221d87c89
commit 0f008d2e9e
26 changed files with 234 additions and 115 deletions

View File

@@ -400,8 +400,13 @@ void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec)
if(title) {
if (!is_http_source(filename)) {
static const char *errtitle = "Invalid FLAC File: ";
*title = g_malloc(strlen(errtitle) + 1 + strlen(filename) + 1 + 1);
sprintf(*title, "%s\"%s\"", errtitle, filename);
if(strlen(errtitle) + 1 + strlen(filename) + 1 + 1 < strlen(filename)) { /* overflow check */
*title = NULL;
}
else {
*title = g_malloc(strlen(errtitle) + 1 + strlen(filename) + 1 + 1);
sprintf(*title, "%s\"%s\"", errtitle, filename);
}
} else {
*title = NULL;
}