Fix potential buffer overflow.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27568 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2010-07-26 00:06:06 +00:00
parent a3e6a865df
commit f69e995bda

View file

@ -1211,13 +1211,13 @@ void set_file(const char* filename, char* setting, const int maxlen)
else
extlen = strlen(extptr);
len = strlen(fptr) - extlen;
len = strlen(fptr) - extlen + 1;
/* error if filename isn't in ROCKBOX_DIR */
if (strncasecmp(ROCKBOX_DIR, filename, ROCKBOX_DIR_LEN) || (len > maxlen))
return;
strlcpy(setting, fptr, len+1);
strlcpy(setting, fptr, len);
settings_save();
}