summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2018-09-04 15:06:40 +0300
committerRobert Mustacchi <rm@joyent.com>2018-09-21 16:30:38 +0000
commit63e2133b60ad42fc1b90a89825378dc1cdc82f85 (patch)
tree2fa746b97d1176031c266cceb075b25d4181706e
parent75383e32bbd38e24115eefe5dee272d42a5c723e (diff)
downloadillumos-joyent-63e2133b60ad42fc1b90a89825378dc1cdc82f85.tar.gz
9788 loader: validate tftp_makereq() after we did reset the read
Reviewed by: Jason King <jason.king@joyent.com> Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk> Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r--usr/src/boot/lib/libstand/tftp.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/usr/src/boot/lib/libstand/tftp.c b/usr/src/boot/lib/libstand/tftp.c
index e235f8a537..ad3e89d448 100644
--- a/usr/src/boot/lib/libstand/tftp.c
+++ b/usr/src/boot/lib/libstand/tftp.c
@@ -487,6 +487,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) {
@@ -498,19 +501,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;
@@ -550,7 +553,7 @@ tftp_read(struct open_file *f, void *addr, size_t size,
if (resid)
*resid = size;
- return (0);
+ return (rc);
}
static int