summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-daemons/tftp-hpa
diff options
context:
space:
mode:
authorRoy.Li <rongqing.li@windriver.com>2013-08-28 17:22:58 +0800
committerJoe MacDonald <joe@deserted.net>2013-09-05 08:52:10 -0400
commit3d8520a0b4115a7b4200892447fa94296d9256af (patch)
tree26f5233bc18ffffbef1e6d5f23793c68fc0bdff0 /meta-networking/recipes-daemons/tftp-hpa
parent9f3cea60ed06730e6d26e5dae32ddf0312aee423 (diff)
downloadmeta-openembedded-3d8520a0b4115a7b4200892447fa94296d9256af.tar.gz
tftp-hpa: add error check for disk filled up
Add error check when the write-buffer is finally flushed to the file, the caller can detect if the disk filled up (or had an i/o error) and return a NOSAPCE nak to the other side. Signed-off-by: Roy.Li <rongqing.li@windriver.com> Signed-off-by: Joe MacDonald <joe@deserted.net>
Diffstat (limited to 'meta-networking/recipes-daemons/tftp-hpa')
-rw-r--r--meta-networking/recipes-daemons/tftp-hpa/files/add-error-check-for-disk-filled-up.patch81
-rw-r--r--meta-networking/recipes-daemons/tftp-hpa/tftp-hpa_5.2.bb4
2 files changed, 84 insertions, 1 deletions
diff --git a/meta-networking/recipes-daemons/tftp-hpa/files/add-error-check-for-disk-filled-up.patch b/meta-networking/recipes-daemons/tftp-hpa/files/add-error-check-for-disk-filled-up.patch
new file mode 100644
index 000000000..d01c20d38
--- /dev/null
+++ b/meta-networking/recipes-daemons/tftp-hpa/files/add-error-check-for-disk-filled-up.patch
@@ -0,0 +1,81 @@
1From bd5773947af5ca80ca546ad5625818fc912bdd60 Mon Sep 17 00:00:00 2001
2From: "Roy.Li" <rongqing.li@windriver.com>
3Date: Thu, 22 Aug 2013 08:56:09 +0800
4Subject: [PATCH] tftp-hpa: add error check for disk filled up
5
6Upstream-status: Pending [Sent to http://www.syslinux.org/archives/2013-August/020765.html]
7
8Add error check when the write-buffer is finally flushed to the file,
9the caller can detect if the disk filled up (or had an i/o error) and
10return a NOSAPCE nak to the other side.
11
12Signed-off-by: Ming Liu <ming.liu@windriver.com>
13Signed-off-by: Roy.Li <rongqing.li@windriver.com>
14---
15 common/tftpsubs.c | 8 +++++---
16 tftpd/tftpd.c | 12 ++++++++++--
17 2 files changed, 15 insertions(+), 5 deletions(-)
18
19diff --git a/common/tftpsubs.c b/common/tftpsubs.c
20index 8c999f6..b4d4ffe 100644
21--- a/common/tftpsubs.c
22+++ b/common/tftpsubs.c
23@@ -206,20 +206,22 @@ int write_behind(FILE * file, int convert)
24
25 p = buf;
26 ct = count;
27+ count = 0;
28 while (ct--) { /* loop over the buffer */
29 c = *p++; /* pick up a character */
30 if (prevchar == '\r') { /* if prev char was cr */
31 if (c == '\n') /* if have cr,lf then just */
32- fseek(file, -1, 1); /* smash lf on top of the cr */
33+ count = count - 1;
34 else if (c == '\0') /* if have cr,nul then */
35 goto skipit; /* just skip over the putc */
36 /* else just fall through and allow it */
37 }
38- putc(c, file);
39+ buf[count] = c;
40+ count ++;
41 skipit:
42 prevchar = c;
43 }
44- return count;
45+ return write(fileno(file), buf, count);
46 }
47
48 /* When an error has occurred, it is possible that the two sides
49diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
50index 1873e70..c2adbda 100644
51--- a/tftpd/tftpd.c
52+++ b/tftpd/tftpd.c
53@@ -1681,7 +1681,11 @@ static void tftp_recvfile(const struct formats *pf, struct tftphdr *oap, int oac
54 syslog(LOG_WARNING, "tftpd: write(ack): %m");
55 goto abort;
56 }
57- write_behind(file, pf->f_convert);
58+ if(write_behind(file, pf->f_convert) < 0) {
59+ nak(ENOSPACE, NULL);
60+ (void)fclose(file);
61+ goto abort;
62+ }
63 for (;;) {
64 n = recv_time(peer, dp, PKTSIZE, 0, &r_timeout);
65 if (n < 0) { /* really? */
66@@ -1712,7 +1716,11 @@ static void tftp_recvfile(const struct formats *pf, struct tftphdr *oap, int oac
67 goto abort;
68 }
69 } while (size == segsize);
70- write_behind(file, pf->f_convert);
71+ if(write_behind(file, pf->f_convert) < 0) {
72+ nak(ENOSPACE, NULL);
73+ (void)fclose(file);
74+ goto abort;
75+ }
76 (void)fclose(file); /* close data file */
77
78 ap->th_opcode = htons((u_short) ACK); /* send the "final" ack */
79--
801.7.10.4
81
diff --git a/meta-networking/recipes-daemons/tftp-hpa/tftp-hpa_5.2.bb b/meta-networking/recipes-daemons/tftp-hpa/tftp-hpa_5.2.bb
index cb5b234be..9cb25f071 100644
--- a/meta-networking/recipes-daemons/tftp-hpa/tftp-hpa_5.2.bb
+++ b/meta-networking/recipes-daemons/tftp-hpa/tftp-hpa_5.2.bb
@@ -23,7 +23,9 @@ SRC_URI = "http://kernel.org/pub/software/network/tftp/tftp-hpa/tftp-hpa-${PV}.t
23 file://tftp-hpa-0.49-stats.patch \ 23 file://tftp-hpa-0.49-stats.patch \
24 file://tftp-hpa-5.2-pktinfo.patch \ 24 file://tftp-hpa-5.2-pktinfo.patch \
25 file://default \ 25 file://default \
26 file://init" 26 file://init \
27 file://add-error-check-for-disk-filled-up.patch \
28"
27 29
28SRC_URI[md5sum] = "46c9bd20bbffa62f79c958c7b99aac21" 30SRC_URI[md5sum] = "46c9bd20bbffa62f79c958c7b99aac21"
29SRC_URI[sha256sum] = "0a9f88d4c1c02687b4853b02ab5dd8779d4de4ffdb9b2e5c9332841304d1a269" 31SRC_URI[sha256sum] = "0a9f88d4c1c02687b4853b02ab5dd8779d4de4ffdb9b2e5c9332841304d1a269"