Browse Source

Plan 9 from Bell Labs 2010-10-01

David du Colombier 13 years ago
parent
commit
10d4d4309c
3 changed files with 8 additions and 4 deletions
  1. 2 2
      sys/src/boot/pc/bootp.c
  2. 1 1
      sys/src/boot/pc/console.c
  3. 5 1
      sys/src/boot/pc/ether.c

+ 2 - 2
sys/src/boot/pc/bootp.c

@@ -223,7 +223,7 @@ nak(int ctlrno, Netaddr *a, int code, char *msg, int report)
 	buf[1] = Tftp_ERROR;
 	buf[2] = 0;
 	buf[3] = code;
-	strcpy(buf+4, msg);
+	strncpy(buf+4, msg, sizeof buf - 4);
 	n = strlen(msg) + 4 + 1;
 	udpsend(ctlrno, a, buf, n);
 	if(report)
@@ -461,7 +461,7 @@ bootpopen(int ctlrno, char *file, Bootp *rep, int dotftpopen)
 	filename = 0;
 	sysname = 0;
 	if(file && *file){
-		strcpy(name, file);
+		strncpy(name, file, sizeof name);
 		if(filename = strchr(name, '!')){
 			sysname = name;
 			*filename++ = 0;

+ 1 - 1
sys/src/boot/pc/console.c

@@ -190,7 +190,7 @@ getstr(char *prompt, char *buf, int size, char *def, int timeout)
 		break;
 	}
 	if(len == 0 && isdefault)
-		strcpy(buf, def);
+		strncpy(buf, def, size);
 	return 0;
 }
 

+ 5 - 1
sys/src/boot/pc/ether.c

@@ -78,7 +78,11 @@ fakeintrs(Alarm *)
 	alarm(TK2MS(1), fakeintrs, nil);
 }
 
-/* terrible temporary hack for 82575 */
+/*
+ * terrible temporary hack for 82575.
+ * if we do actually get the right interrupts, this quickly floods
+ * the alarm table and we panic, so use with caution.
+ */
 static void
 startfakeintrs(void)
 {