From: Jason A. Donenfeld Date: Fri, 9 Oct 2015 09:01:04 +0000 (+0200) Subject: Avoid use of non-reentrant functions X-Git-Url: https://gitweb.ps.run/ps-cgit/commitdiff_plain/ad006918a570da32457461a5e59289b611d9a732 Avoid use of non-reentrant functions Signed-off-by: Jason A. Donenfeld --- diff --git a/shared.c b/shared.c index 3d91a76..e216c64 100644 --- a/shared.c +++ b/shared.c @@ -563,7 +563,7 @@ char *expand_macros(const char *txt) char *get_mimetype_for_filename(const char *filename) { - char *ext, *mimetype, *token, line[1024]; + char *ext, *mimetype, *token, line[1024], *saveptr; FILE *file; struct string_list_item *mime; @@ -588,8 +588,8 @@ char *get_mimetype_for_filename(const char *filename) while (fgets(line, sizeof(line), file)) { if (!line[0] || line[0] == '#') continue; - mimetype = strtok(line, " \t\r\n"); - while ((token = strtok(NULL, " \t\r\n"))) { + mimetype = strtok_r(line, " \t\r\n", &saveptr); + while ((token = strtok_r(NULL, " \t\r\n", &saveptr))) { if (!strcasecmp(ext, token)) { fclose(file); return xstrdup(mimetype);