about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2015-10-09 11:01:04 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2015-10-09 11:01:04 +0200
commitad006918a570da32457461a5e59289b611d9a732 (patch)
tree18559683296ddeddd0b3d43256ac05424ae8362a
parentMakefile: fix MAKEFLAGS tests with multiple flags (diff)
downloadcgit-pink-ad006918a570da32457461a5e59289b611d9a732.tar.gz
cgit-pink-ad006918a570da32457461a5e59289b611d9a732.zip
Avoid use of non-reentrant functions
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--shared.c6
1 files changed, 3 insertions, 3 deletions
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);
man.1?h=2063.91&id=915f8bfc474fcd5bffacba2c21bbb99060082549&follow=1'>Update to Linux man-pages 5.12Štěpán Němec 2021-06-21Add manuals for macOS 11.3June McEnroe 2021-05-08Update to OpenBSD 6.9June McEnroe 2021-04-26Update to Linux man-pages 5.11June McEnroe 2021-04-26Update to FreeBSD 13.0June McEnroe 2021-01-27Completely rewrite how manuals are fetched and installedJune McEnroe Also add section 6 manuals from NetBSD and OpenBSD! 2020-12-14Update to man-pages-posix 2017-aJune McEnroe 2020-12-14Update to OpenBSD 6.8June McEnroe 2020-12-14Update to NetBSD 9.1June McEnroe 2020-12-14Update to man-pages 5.09June McEnroe 2020-12-14Update to FreeBSD 12.2June McEnroe 2020-06-08Update to OpenBSD 6.7June McEnroe 2020-05-04Add hack for macOS to search extra man sectionsJune McEnroe 2020-05-04Don't clear MANSECTJune McEnroe