[Fix] Possible buffer overflows with strncpy.
This commit is contained in:
parent
edd3f9cd54
commit
7e0963ad35
@ -387,8 +387,10 @@ static void data_name(void) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
if(xml_isNode(node, "name"))
|
if(xml_isNode(node, "name")) {
|
||||||
strncpy(dataname, xml_get(node), DATA_NAME_LEN);
|
strncpy(dataname, xml_get(node), DATA_NAME_LEN);
|
||||||
|
dataname[DATA_NAME_LEN-1] = '\0';
|
||||||
|
}
|
||||||
} while((node = node->next));
|
} while((node = node->next));
|
||||||
|
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
@ -37,8 +37,10 @@ int lfile_dirMakeExist(char* path) {
|
|||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
if(strcmp(path, ".")==0)
|
if(strcmp(path, ".")==0) {
|
||||||
strncpy(file, lfile_basePath(), PATH_MAX);
|
strncpy(file, lfile_basePath(), PATH_MAX);
|
||||||
|
file[PATH_MAX-1] = '\0';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
snprintf(file, PATH_MAX, "%s%s", lfile_basePath(), path);
|
snprintf(file, PATH_MAX, "%s%s", lfile_basePath(), path);
|
||||||
stat(file, &buf);
|
stat(file, &buf);
|
||||||
|
@ -250,6 +250,7 @@ static int music_loadOGG(const char* filename) {
|
|||||||
|
|
||||||
// Set the new name.
|
// Set the new name.
|
||||||
strncpy(music_vorbis.name, filename, 64);
|
strncpy(music_vorbis.name, filename, 64);
|
||||||
|
music_vorbis.name[64-1] = '\0';
|
||||||
|
|
||||||
// Load the new ogg.
|
// Load the new ogg.
|
||||||
pack_open(&music_vorbis.file, DATA, filename);
|
pack_open(&music_vorbis.file, DATA, filename);
|
||||||
@ -285,7 +286,7 @@ static int music_find(void) {
|
|||||||
// Remove the prefix and suffix.
|
// Remove the prefix and suffix.
|
||||||
len = strlen(files[i]) - strlen(MUSIC_SUFFIX MUSIC_PREFIX);
|
len = strlen(files[i]) - strlen(MUSIC_SUFFIX MUSIC_PREFIX);
|
||||||
strncpy(tmp, files[i] + strlen(MUSIC_PREFIX), len);
|
strncpy(tmp, files[i] + strlen(MUSIC_PREFIX), len);
|
||||||
tmp[len] = '\0';
|
tmp[MIN(len, 64-1)] = '\0';
|
||||||
|
|
||||||
music_selection[nmusic_selection-1] = strdup(tmp);
|
music_selection[nmusic_selection-1] = strdup(tmp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user