replaced strlen with strnlen
This commit is contained in:
parent
a9988c794a
commit
af45bcfa19
|
@ -37,6 +37,7 @@ static LinkTable *single_LinkTable_new(const char *url)
|
|||
char *ptr = strrchr(url, '/');
|
||||
int dir_len = ptr - url;
|
||||
char *dir_name = CALLOC(dir_len + 1, sizeof(char));
|
||||
|
||||
free(dir_name);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -295,7 +295,8 @@ XML_parser_general(void *data, const char *elem, const char **attr)
|
|||
}
|
||||
}
|
||||
|
||||
if (!linkname_set && strlen(title) > 0 && strlen(suffix) > 0) {
|
||||
if (!linkname_set && strnlen(title, MAX_PATH_LEN) > 0 &&
|
||||
strnlen(suffix, MAX_PATH_LEN) > 0) {
|
||||
snprintf(link->linkname, MAX_FILENAME_LEN, "%02d - %s.%s",
|
||||
track, title, suffix);
|
||||
linkname_set = 1;
|
||||
|
|
|
@ -150,7 +150,7 @@ void FREE(void *ptr)
|
|||
|
||||
char *str_to_hex(char *s)
|
||||
{
|
||||
char *hex = CALLOC(strlen(s) * 2 + 1, sizeof(char));
|
||||
char *hex = CALLOC(strnlen(s, MAX_PATH_LEN) * 2 + 1, sizeof(char));
|
||||
for (char *c = s, *h = hex; *c; c++, h += 2) {
|
||||
sprintf(h, "%x", *c);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue