player: fix potential buffer overflow
Previously, sync_track_path could either overflow it's 'temp' buffer by one byte, or (even worse) end up not zero-terminating it. Correct the code by explicitly zero-terminating the result of strncpy, and reducing the lenght-parameter to strncat.
This commit is contained in:
parent
1044584639
commit
8a49fd3c05
@ -11,10 +11,11 @@
|
||||
static const char *sync_track_path(const char *base, const char *name)
|
||||
{
|
||||
static char temp[FILENAME_MAX];
|
||||
strncpy(temp, base, sizeof(temp));
|
||||
strncat(temp, "_", sizeof(temp));
|
||||
strncat(temp, name, sizeof(temp));
|
||||
strncat(temp, ".track", sizeof(temp));
|
||||
strncpy(temp, base, sizeof(temp) - 1);
|
||||
temp[sizeof(temp) - 1] = '\0';
|
||||
strncat(temp, "_", sizeof(temp) - 1);
|
||||
strncat(temp, name, sizeof(temp) - 1);
|
||||
strncat(temp, ".track", sizeof(temp) - 1);
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user