Blame SOURCES/netkit-telnet-0.17-covscan.patch

fbcb50
--- a/telnet/commands.c.old
fbcb50
+++ b/telnet/commands.c
fbcb50
@@ -2181,12 +2181,13 @@ cmdrc(char *m1, char *m2)
fbcb50
     int gotmachine = 0;
fbcb50
     int l1 = strlen(m1);
fbcb50
     int l2 = strlen(m2);
fbcb50
-    char m1save[MAXHOSTNAMELEN];
fbcb50
+    char m1save[MAXHOSTNAMELEN+1];
fbcb50
 
fbcb50
     if (skiprc)
fbcb50
 	return;
fbcb50
 
fbcb50
     strncpy(m1save, m1, sizeof(m1save));
fbcb50
+    m1save[MAXHOSTNAMELEN] = 0;
fbcb50
     m1 = m1save;
fbcb50
 
fbcb50
     if (rcname[0] == 0) {
fbcb50
@@ -2218,11 +2218,11 @@ cmdrc(char *m1, char *m2)
fbcb50
 	    if (isspace(line[0]))
fbcb50
 		continue;
fbcb50
 	    if (strncasecmp(line, m1, l1) == 0)
fbcb50
-		strncpy(line, &line[l1], sizeof(line) - l1);
fbcb50
+		memmove(line, &line[l1], sizeof(line) - l1);
fbcb50
 	    else if (strncasecmp(line, m2, l2) == 0)
fbcb50
-		strncpy(line, &line[l2], sizeof(line) - l2);
fbcb50
+		memmove(line, &line[l2], sizeof(line) - l2);
fbcb50
 	    else if (strncasecmp(line, "DEFAULT", 7) == 0)
fbcb50
-		strncpy(line, &line[7], sizeof(line) - 7);
fbcb50
+		memmove(line, &line[7], sizeof(line) - 7);
fbcb50
 	    else
fbcb50
 		continue;
fbcb50
 	    if (line[0] != ' ' && line[0] != '\t' && line[0] != '\n')
fbcb50
@@ -2345,6 +2345,7 @@ tn(int argc, char *argv[])
fbcb50
 	}
fbcb50
     usage:
fbcb50
 	printf("usage: %s [-l user] [-a] host-name [port]\r\n", cmd);
fbcb50
+    free(user);
fbcb50
 	return 0;
fbcb50
     }
fbcb50
     if (hostp == 0)
fbcb50
--- a/telnetd/utility.c
fbcb50
+++ b/telnetd/utility.c
fbcb50
@@ -68,8 +68,10 @@ output_data(const char *format, ...)
fbcb50
 	char *buf;
fbcb50
 
fbcb50
 	va_start(args, format);
fbcb50
-	if ((len = vasprintf(&buf, format, args)) == -1)
fbcb50
+	if ((len = vasprintf(&buf, format, args)) == -1) {
fbcb50
+		va_end(args);
fbcb50
 		return -1;
fbcb50
+	}
fbcb50
 	output_datalen(buf, len);
fbcb50
 	va_end(args);
fbcb50
 	free(buf);