Avoid use of non-reentrant functions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
35b3c67ac2
commit
ad006918a5
6
shared.c
6
shared.c
@ -563,7 +563,7 @@ char *expand_macros(const char *txt)
|
|||||||
|
|
||||||
char *get_mimetype_for_filename(const char *filename)
|
char *get_mimetype_for_filename(const char *filename)
|
||||||
{
|
{
|
||||||
char *ext, *mimetype, *token, line[1024];
|
char *ext, *mimetype, *token, line[1024], *saveptr;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
struct string_list_item *mime;
|
struct string_list_item *mime;
|
||||||
|
|
||||||
@ -588,8 +588,8 @@ char *get_mimetype_for_filename(const char *filename)
|
|||||||
while (fgets(line, sizeof(line), file)) {
|
while (fgets(line, sizeof(line), file)) {
|
||||||
if (!line[0] || line[0] == '#')
|
if (!line[0] || line[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
mimetype = strtok(line, " \t\r\n");
|
mimetype = strtok_r(line, " \t\r\n", &saveptr);
|
||||||
while ((token = strtok(NULL, " \t\r\n"))) {
|
while ((token = strtok_r(NULL, " \t\r\n", &saveptr))) {
|
||||||
if (!strcasecmp(ext, token)) {
|
if (!strcasecmp(ext, token)) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return xstrdup(mimetype);
|
return xstrdup(mimetype);
|
||||||
|
Loading…
Reference in New Issue
Block a user