Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Sep 2018 06:30:15 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r338540 - head/stand/libsa
Message-ID:  <201809090630.w896UFcL088119@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Sun Sep  9 06:30:15 2018
New Revision: 338540
URL: https://svnweb.freebsd.org/changeset/base/338540

Log:
  libsa: validate tftp_makereq() after we did reset the read
  
  The name check referred in the comment is not the only possible error source,
  we need to validate the result.
  
  Reviewed by:	allanjude
  Approved by:	re (kib)
  Differential Revision:	https://reviews.freebsd.org/D17081

Modified:
  head/stand/libsa/tftp.c

Modified: head/stand/libsa/tftp.c
==============================================================================
--- head/stand/libsa/tftp.c	Sat Sep  8 23:39:26 2018	(r338539)
+++ head/stand/libsa/tftp.c	Sun Sep  9 06:30:15 2018	(r338540)
@@ -490,6 +490,9 @@ tftp_read(struct open_file *f, void *addr, size_t size
     size_t *resid /* out */)
 {
 	struct tftp_handle *tftpfile;
+	int rc;
+
+	rc = 0;
 	tftpfile = (struct tftp_handle *) f->f_fsdata;
 
 	while (size > 0) {
@@ -501,19 +504,19 @@ tftp_read(struct open_file *f, void *addr, size_t size
 
 		if (tftpfile->currblock > needblock) {	/* seek backwards */
 			tftp_senderr(tftpfile, 0, "No error: read aborted");
-			tftp_makereq(tftpfile);	/* no error check, it worked
-						 * for open */
+			rc = tftp_makereq(tftpfile);
+			if (rc != 0)
+				break;
 		}
 
 		while (tftpfile->currblock < needblock) {
-			int res;
 
-			res = tftp_getnextblock(tftpfile);
-			if (res) {	/* no answer */
+			rc = tftp_getnextblock(tftpfile);
+			if (rc) {	/* no answer */
 #ifdef TFTP_DEBUG
 				printf("tftp: read error\n");
 #endif
-				return (res);
+				return (rc);
 			}
 			if (tftpfile->islastblock)
 				break;
@@ -553,7 +556,7 @@ tftp_read(struct open_file *f, void *addr, size_t size
 
 	if (resid)
 		*resid = size;
-	return (0);
+	return (rc);
 }
 
 static int 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201809090630.w896UFcL088119>