shithub: tcp80

Download patch

ref: aeb4998e34612722386ac2ae28b59af6be951fcf
parent: 400aaf27b76368801aeef438dbd28be3851b566e
author: grobe0ba <[email protected]>
date: Sun Jan 29 09:20:16 EST 2023

use strecpy

--- a/tcp80.c
+++ b/tcp80.c
@@ -247,7 +247,7 @@
 nstrcpy(char *d, char *s, int n)
 {
 	d[n - 1] = 0;
-	return strncpy(d, s, n - 1);
+	return strecpy(d, d + n, s);
 }
 
 char hex[] = "0123456789ABCDEF";
@@ -575,8 +575,7 @@
 
 			h = findhdr(nil, "Host");
 			p = strchr(location, '?');
-			s = fullurl(nil, urlenc(tmp, buf, sizeof(tmp)), "/",
-				    p ? p + 1 : nil);
+			s = fullurl(nil, urlenc(tmp, buf, sizeof(tmp)), "/", p ? p + 1 : nil);
 			if(!nobody)
 				n = snprint(buf, sizeof(buf),
 					    "<html><head><title>%s</title></head>\n"
@@ -848,7 +847,7 @@
 		}
 	}
 	if(remote[0] == 0)
-		strcpy(remote, "-");
+		strecpy(remote, remote + sizeof remote, "-");
 	if(parsequery() < 0){
 		getresponse(statbuf, 32, 400);
 		respond(statbuf);