diff options
author | Toomas Soome <tsoome@FreeBSD.org> | 2018-09-09 06:30:15 +0000 |
---|---|---|
committer | Toomas Soome <tsoome@FreeBSD.org> | 2018-09-09 06:30:15 +0000 |
commit | 7e63e808d7eb8e945542965a90b0e891199ab598 (patch) | |
tree | 029f19edafe714eb08e726f3efb3f199f7078cc1 /stand | |
parent | 9c78fa0a6169953e27a760c4cddc9cb0d1554936 (diff) | |
download | src-7e63e808d7eb8e945542965a90b0e891199ab598.tar.gz src-7e63e808d7eb8e945542965a90b0e891199ab598.zip |
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
Notes
Notes:
svn path=/head/; revision=338540
Diffstat (limited to 'stand')
-rw-r--r-- | stand/libsa/tftp.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/stand/libsa/tftp.c b/stand/libsa/tftp.c index e66c362f7f51..fbcbd39aefcf 100644 --- a/stand/libsa/tftp.c +++ b/stand/libsa/tftp.c @@ -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 |