diff options
author | Jason A. Donenfeld | 2015-10-09 11:01:04 +0200 |
---|---|---|
committer | Jason A. Donenfeld | 2015-10-09 11:01:04 +0200 |
commit | ad006918a570da32457461a5e59289b611d9a732 (patch) | |
tree | 18559683296ddeddd0b3d43256ac05424ae8362a /shared.c | |
parent | 35b3c67ac285f0c488b0d3042a1bbc44ef4f1f67 (diff) | |
download | cgit-ad006918a570da32457461a5e59289b611d9a732.tar.gz cgit-ad006918a570da32457461a5e59289b611d9a732.tar.bz2 cgit-ad006918a570da32457461a5e59289b611d9a732.zip |
Avoid use of non-reentrant functions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -563,7 +563,7 @@ char *expand_macros(const char *txt) | |||
563 | 563 | ||
564 | char *get_mimetype_for_filename(const char *filename) | 564 | char *get_mimetype_for_filename(const char *filename) |
565 | { | 565 | { |
566 | char *ext, *mimetype, *token, line[1024]; | 566 | char *ext, *mimetype, *token, line[1024], *saveptr; |
567 | FILE *file; | 567 | FILE *file; |
568 | struct string_list_item *mime; | 568 | struct string_list_item *mime; |
569 | 569 | ||
@@ -588,8 +588,8 @@ char *get_mimetype_for_filename(const char *filename) | |||
588 | while (fgets(line, sizeof(line), file)) { | 588 | while (fgets(line, sizeof(line), file)) { |
589 | if (!line[0] || line[0] == '#') | 589 | if (!line[0] || line[0] == '#') |
590 | continue; | 590 | continue; |
591 | mimetype = strtok(line, " \t\r\n"); | 591 | mimetype = strtok_r(line, " \t\r\n", &saveptr); |
592 | while ((token = strtok(NULL, " \t\r\n"))) { | 592 | while ((token = strtok_r(NULL, " \t\r\n", &saveptr))) { |
593 | if (!strcasecmp(ext, token)) { | 593 | if (!strcasecmp(ext, token)) { |
594 | fclose(file); | 594 | fclose(file); |
595 | return xstrdup(mimetype); | 595 | return xstrdup(mimetype); |