about summary refs log tree commit diff stats
path: root/bonus
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-01-11 19:42:30 +0100
committerbptato <nincsnevem662@gmail.com>2024-01-11 19:44:03 +0100
commit9f26d1b8215cf039b38735d785753dda035103b7 (patch)
tree9f1333094c59fdd07226e6083ddbf9a487cbc085 /bonus
parentb7570a38b70059fbb9a3fb3d32df153ad5f9706f (diff)
downloadchawan-9f26d1b8215cf039b38735d785753dda035103b7.tar.gz
cha-http-libfetch: fix incorrect usage of strncat
strncat does not work like that :P
Luckily, BSD has strlcat which does.

(While we're at it, remove the unused PDIE macro.)
Diffstat (limited to 'bonus')
-rw-r--r--bonus/libfetch/cha-http-libfetch.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/bonus/libfetch/cha-http-libfetch.c b/bonus/libfetch/cha-http-libfetch.c
index 38b73c30..4b824ced 100644
--- a/bonus/libfetch/cha-http-libfetch.c
+++ b/bonus/libfetch/cha-http-libfetch.c
@@ -32,14 +32,6 @@
 		exit(1); \
 	} while (0)
 
-#define PDIE(x) \
-	do { \
-		puts("Content-Type: text/plain\r\n"); \
-		puts(x); \
-		puts(strerror(errno)); \
-		exit(1); \
-	} while (0)
-
 #define DIE(x) \
 	do { \
 		puts("Content-Type: text/plain\r\n\r\n" x); \
@@ -91,15 +83,12 @@ int main(int argc, char **argv)
 		iport = 443;
 	docbuf[0] = '\0';
 	path = getenv("MAPPED_URI_PATH");
-	if (path && *path)
-		strncat(docbuf, path, sizeof(docbuf) - 1);
-	else
-		strcat(docbuf, "/");
+	strlcat(docbuf, path && *path ? path : "/", sizeof(docbuf));
 	has_file_ext = hasext(docbuf);
 	query = getenv("MAPPED_URI_QUERY");
 	if (query && *query) {
-		strncat(docbuf, "?", sizeof(docbuf) - 1);
-		strncat(docbuf, query, sizeof(docbuf) - 1);
+		strlcat(docbuf, "?", sizeof(docbuf));
+		strlcat(docbuf, query, sizeof(docbuf));
 	}
 	u = fetchMakeURL(scheme, host, iport, docbuf, username, password);
 	if (!u)