Browse Source

Plan 9 from Bell Labs 2012-01-04

David du Colombier 12 years ago
parent
commit
8d7684d775
2 changed files with 6 additions and 2 deletions
  1. 1 1
      sys/src/boot/pc/bootp.c
  2. 5 1
      sys/src/cmd/ip/tftpd.c

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

@@ -407,7 +407,7 @@ tftpread(int ctlrno, Netaddr *a, Tftp *tftp, int dlen)
 		udpsend(ctlrno, a, buf, sizeof(buf));
 
 		len = udprecv(ctlrno, a, tftp, dlen);
-		if(len <= sizeof(tftp->header)){
+		if(len < sizeof(tftp->header)){
 			if(debug)
 				print("tftpread: too short %d <= %d\n",
 					len, sizeof(tftp->header));

+ 5 - 1
sys/src/cmd/ip/tftpd.c

@@ -609,7 +609,11 @@ recvfile(int fd, char *name, char *mode)
 				name);
 			goto error;
 		}
-		if(n <= Hdrsize) {
+		/*
+		 * NB: not `<='; just a header is legal and happens when
+		 * file being read is a multiple of segment-size bytes long.
+		 */
+		if(n < Hdrsize) {
 			syslog(dbg, flog,
 				"tftpd: short read from network, reading %s",
 				name);