diff options
Diffstat (limited to 'sys/lib')
-rw-r--r-- | sys/lib/libsa/tftp.c | 5 | ||||
-rw-r--r-- | sys/lib/libsa/tftp.h | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/sys/lib/libsa/tftp.c b/sys/lib/libsa/tftp.c index 9cbce92b217..dd570551724 100644 --- a/sys/lib/libsa/tftp.c +++ b/sys/lib/libsa/tftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftp.c,v 1.2 2004/04/02 04:39:51 deraadt Exp $ */ +/* $OpenBSD: tftp.c,v 1.3 2009/03/02 00:00:56 krw Exp $ */ /* $NetBSD: tftp.c,v 1.15 2003/08/18 15:45:29 dsl Exp $ */ /* @@ -239,6 +239,7 @@ tftp_terminate(struct tftp_handle *h) char *wtail; bzero(&wbuf, sizeof(wbuf)); + wtail = (char *) &wbuf.t.th_data; if (h->islastblock) { wbuf.t.th_opcode = htons((u_short) ACK); @@ -246,8 +247,8 @@ tftp_terminate(struct tftp_handle *h) } else { wbuf.t.th_opcode = htons((u_short) ERROR); wbuf.t.th_code = htons((u_short) ENOSPACE); /* ??? */ + wtail++; /* ERROR data is a string, thus needs NUL. */ } - wtail = (char *) &wbuf.t.th_data; (void) sendudp(h->iodesc, &wbuf.t, wtail - (char *) &wbuf.t); } diff --git a/sys/lib/libsa/tftp.h b/sys/lib/libsa/tftp.h index a041a859a20..3cfc4ddba85 100644 --- a/sys/lib/libsa/tftp.h +++ b/sys/lib/libsa/tftp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tftp.h,v 1.2 2004/04/02 04:39:51 deraadt Exp $ */ +/* $OpenBSD: tftp.h,v 1.3 2009/03/02 00:00:56 krw Exp $ */ /* $NetBSD: tftp.h,v 1.3 2003/08/07 16:32:30 agc Exp $ */ /* @@ -81,6 +81,7 @@ struct tftphdr { char tu_stuff[1]; /* request packet stuff */ } th_u; char th_data[1]; /* data or error string */ + /* [1] because space needed for NUL. */ }; #define th_block th_u.tu_block |