File: 08-fix-rip-password.diff

package info (click to toggle)
sendip 2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 484 kB
  • sloc: ansic: 3,737; perl: 321; makefile: 55; sh: 13
file content (28 lines) | stat: -rw-r--r-- 991 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
diff --git a/rip.c b/rip.c
index 84783f5..0d0ac6b 100644
--- a/rip.c
+++ b/rip.c
@@ -38,6 +38,7 @@ bool do_opt(char *opt, char *arg, sendip_data *pack) {
 	rip_header *rippack = (rip_header *)pack->data;
 	rip_options *ripopt;
 	char *p, *q;
+	int l;
 	switch(opt[1]) {
 	case 'v': /* version */
 		rippack->version = (u_int8_t)strtoul(arg, (char **)0, 0);
@@ -60,10 +61,12 @@ bool do_opt(char *opt, char *arg, sendip_data *pack) {
 		while(*(q++)!=':') {} /* do nothing */; *(--q)='\0';
 		ripopt->routeTagOrAuthenticationType=htons((p==q)?2:(u_int16_t)strtoul(p, (char **)0,0));
 		p=++q;
-		if(strlen(p) > 16) {
-		  usage_error("Warning: RIP passord cannot be longer than 16 characters.\n");
+		l=strlen(p)+1;
+		if(l > 16) {
+		  usage_error("Warning: RIP password cannot be longer than 16 characters.\n");
+		  l=16;
 		}
-		strncpy((char *)&(ripopt->address),p,16);
+		memcpy((char *)&(ripopt->address), p, l);
 		break;
 	case 'e': /* rip entry */
 		if(RIP_NUM_ENTRIES(pack)==25) {