mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
extra checking on memory allocation sizes to prevent a class of overflow attacks
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user