summaryrefslogtreecommitdiff
path: root/sys/lib
diff options
context:
space:
mode:
authordrochner <drochner@NetBSD.org>1999-07-12 12:34:57 +0000
committerdrochner <drochner@NetBSD.org>1999-07-12 12:34:57 +0000
commit756fbc1ee844fb703fb24d096d3df789a87f6ded (patch)
treecfdccc36c39995ced272746dfe38da0ec5550ba2 /sys/lib
parent735b3248577335a3a66840fcebe6cc4c88d3e9f9 (diff)
fix damage in error handling crept in in 1.4
Diffstat (limited to 'sys/lib')
-rw-r--r--sys/lib/libsa/tftp.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/sys/lib/libsa/tftp.c b/sys/lib/libsa/tftp.c
index bc5f2c12d5f..3353aa2d899 100644
--- a/sys/lib/libsa/tftp.c
+++ b/sys/lib/libsa/tftp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tftp.c,v 1.6 1999/03/31 01:50:26 cgd Exp $ */
+/* $NetBSD: tftp.c,v 1.7 1999/07/12 12:34:57 drochner Exp $ */
/*
* Copyright (c) 1996
@@ -116,20 +116,19 @@ recvtftp(d, pkt, len, tleft)
register size_t len;
time_t tleft;
{
+ ssize_t n;
struct tftphdr *t;
errno = 0;
- len = readudp(d, pkt, len, tleft);
+ n = readudp(d, pkt, len, tleft);
- if (len < 4)
+ if (n < 4)
return (-1);
t = (struct tftphdr *) pkt;
switch (ntohs(t->th_opcode)) {
- case DATA: {
- int got;
-
+ case DATA:
if (htons(t->th_block) != d->xid) {
/*
* Expected block?
@@ -144,9 +143,7 @@ recvtftp(d, pkt, len, tleft)
uh = (struct udphdr *) pkt - 1;
d->destport = uh->uh_sport;
} /* else check uh_sport has not changed??? */
- got = len - (t->th_data - (char *) t);
- return got;
- }
+ return (n - (t->th_data - (char *)t));
case ERROR:
if ((unsigned) ntohs(t->th_code) >= 8) {
printf("illegal tftp error %d\n", ntohs(t->th_code));