summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-extended
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2013-01-05 19:35:31 -0800
committerKhem Raj <raj.khem@gmail.com>2013-01-08 09:31:44 -0800
commitd42ea54e6db25e52837bd4edd77a8285daf867e6 (patch)
tree61dacaf4f92be1006e75805f7c0cb1fc2deff4f4 /meta-oe/recipes-extended
parent683ef63fff826500d46128464ab4a9ee7c4851ca (diff)
downloadmeta-openembedded-d42ea54e6db25e52837bd4edd77a8285daf867e6.tar.gz
atftp: Upgrade to latest from git
Add patches to let atftp serve huge ramdisks >500M in size Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe/recipes-extended')
-rw-r--r--meta-oe/recipes-extended/atftp/atftp_git.bb (renamed from meta-oe/recipes-extended/atftp/atftp_0.7.bb)18
-rw-r--r--meta-oe/recipes-extended/atftp/files/atftpd-0.7_circumvent_tftp_size_restrictions.patch158
-rw-r--r--meta-oe/recipes-extended/atftp/files/atftpd-0.7_unprotected_assignments_crash.patch145
3 files changed, 311 insertions, 10 deletions
diff --git a/meta-oe/recipes-extended/atftp/atftp_0.7.bb b/meta-oe/recipes-extended/atftp/atftp_git.bb
index ff1e11dcf..774dd6884 100644
--- a/meta-oe/recipes-extended/atftp/atftp_0.7.bb
+++ b/meta-oe/recipes-extended/atftp/atftp_git.bb
@@ -3,13 +3,16 @@ SECTION = "network"
3HOMEPAGE = "http://packages.debian.org/atftp" 3HOMEPAGE = "http://packages.debian.org/atftp"
4LICENSE = "GPLv2" 4LICENSE = "GPLv2"
5LIC_FILES_CHKSUM = "file://LICENSE;md5=94d55d512a9ba36caa9b7df079bae19f" 5LIC_FILES_CHKSUM = "file://LICENSE;md5=94d55d512a9ba36caa9b7df079bae19f"
6PR = "r4" 6PV = "0.7.1+git${SRCPV}"
7 7
8SRC_URI = "${DEBIAN_MIRROR}/main/a/atftp/atftp_${PV}.dfsg.orig.tar.gz;name=archive \ 8SRCREV = "be3291a18c069ae23a124ffdc56d64a5ff0bbec7"
9 ${DEBIAN_MIRROR}/main/a/atftp/atftp_${PV}.dfsg-11.diff.gz;name=patch \
10 file://atftpd.init"
11 9
12S = "${WORKDIR}/atftp-${PV}.dfsg" 10SRC_URI = "git://atftp.git.sourceforge.net/gitroot/atftp/atftp;protocol=git \
11 file://atftpd-0.7_circumvent_tftp_size_restrictions.patch \
12 file://atftpd-0.7_unprotected_assignments_crash.patch \
13 file://atftpd.init \
14 "
15S = "${WORKDIR}/git"
13 16
14inherit autotools update-rc.d useradd 17inherit autotools update-rc.d useradd
15 18
@@ -35,8 +38,3 @@ PACKAGES =+ "atftpd"
35FILES_${PN} = "${bindir}/*" 38FILES_${PN} = "${bindir}/*"
36 39
37FILES_${PN}d = "${sbindir}/* ${sysconfdir}/init.d/* /srv/tftp" 40FILES_${PN}d = "${sbindir}/* ${sysconfdir}/init.d/* /srv/tftp"
38
39SRC_URI[archive.md5sum] = "aa269044a6f992eca78fee2f6119643c"
40SRC_URI[archive.sha256sum] = "18815f5b67290fac087c6b9da28dfa5e0feb722096f5c5de52e59b46026da559"
41SRC_URI[patch.md5sum] = "1636f199bf32c754a7bf34a5c647d138"
42SRC_URI[patch.sha256sum] = "0df33f6c09c2b2de58a84d7bb757844fc9538cd4d6c8d9c463da5270ebc2e41d"
diff --git a/meta-oe/recipes-extended/atftp/files/atftpd-0.7_circumvent_tftp_size_restrictions.patch b/meta-oe/recipes-extended/atftp/files/atftpd-0.7_circumvent_tftp_size_restrictions.patch
new file mode 100644
index 000000000..9aeb3515b
--- /dev/null
+++ b/meta-oe/recipes-extended/atftp/files/atftpd-0.7_circumvent_tftp_size_restrictions.patch
@@ -0,0 +1,158 @@
1Fate #303031: Circumvent TFTP size restrictions in atftpd
2The size of a single image file that can be transferred with TFTP is limited to
32^(2*8) *BLOCKSIZE (as per RFC 1350 there are only two bytes for the block
4counter). This is problematic for one of our customers who needs to transfer
5100+ MB Windows images using a TFTP client (NT bootloader) which has a
6hardwared BLOCKSIZE setting of 1432).
7
8block rollover
9http://www.compuphase.com/tftp.htm
10
11Index: git/tftp_def.h
12===================================================================
13--- git.orig/tftp_def.h 2012-11-19 16:28:50.221027144 -0800
14+++ git/tftp_def.h 2012-11-20 17:40:54.391206979 -0800
15@@ -32,6 +32,7 @@
16 #define TIMEOUT 5 /* Client timeout */
17 #define S_TIMEOUT 5 /* Server timout. */
18 #define NB_OF_RETRY 5
19+#define MAXBLOCKS 1000000 /* maximum number of blocks in a download */
20
21 /* definition to use tftp_options structure */
22 #define OPT_FILENAME 0
23Index: git/tftp_file.c
24===================================================================
25--- git.orig/tftp_file.c 2012-11-19 16:28:50.221027144 -0800
26+++ git/tftp_file.c 2012-11-19 16:28:51.201027167 -0800
27@@ -622,8 +622,8 @@
28 int state = S_SEND_REQ; /* current state in the state machine */
29 int timeout_state = state; /* what state should we go on when timeout */
30 int result;
31- int block_number = 0;
32- int last_block = -1;
33+ long block_number = 0;
34+ long last_block = -1;
35 int data_size; /* size of data received */
36 int sockfd = data->sockfd; /* just to simplify calls */
37 struct sockaddr_storage sa; /* a copy of data.sa_peer */
38@@ -637,8 +637,8 @@
39 int convert = 0; /* if true, do netascii convertion */
40 char string[MAXLEN];
41
42- int prev_block_number = 0; /* needed to support netascii convertion */
43- int prev_file_pos = 0;
44+ long prev_block_number = 0; /* needed to support netascii convertion */
45+ long prev_file_pos = 0;
46 int temp = 0;
47
48 data->file_size = 0;
49@@ -745,7 +745,7 @@
50 data_size, data->data_buffer);
51 data->file_size += data_size;
52 if (data->trace)
53- fprintf(stderr, "sent DATA <block: %d, size: %d>\n",
54+ fprintf(stderr, "sent DATA <block: %ld, size: %d>\n",
55 block_number + 1, data_size - 4);
56 state = S_WAIT_PACKET;
57 break;
58@@ -785,7 +785,7 @@
59 }
60 block_number = ntohs(tftphdr->th_block);
61 if (data->trace)
62- fprintf(stderr, "received ACK <block: %d>\n",
63+ fprintf(stderr, "received ACK <block: %ld>\n",
64 block_number);
65 if ((last_block != -1) && (block_number > last_block))
66 {
67Index: git/tftp_io.c
68===================================================================
69--- git.orig/tftp_io.c 2012-11-19 16:28:50.221027144 -0800
70+++ git/tftp_io.c 2012-11-19 16:28:51.201027167 -0800
71@@ -350,8 +350,8 @@
72 /*
73 * Read from file and do netascii conversion if needed
74 */
75-int tftp_file_read(FILE *fp, char *data_buffer, int data_buffer_size, int block_number,
76- int convert, int *prev_block_number, int *prev_file_pos, int *temp)
77+int tftp_file_read(FILE *fp, char *data_buffer, int data_buffer_size, long block_number,
78+ int convert, long *prev_block_number, long *prev_file_pos, int *temp)
79 {
80 int i;
81 int c;
82Index: git/tftp_io.h
83===================================================================
84--- git.orig/tftp_io.h 2012-11-19 16:28:50.221027144 -0800
85+++ git/tftp_io.h 2012-11-19 16:28:51.201027167 -0800
86@@ -52,8 +52,8 @@
87 int tftp_get_packet(int sock1, int sock2, int *sock, struct sockaddr_storage *sa,
88 struct sockaddr_storage *from, struct sockaddr_storage *to,
89 int timeout, int *size, char *data);
90-int tftp_file_read(FILE *fp, char *buffer, int buffer_size, int block_number, int convert,
91- int *prev_block_number, int *prev_file_pos, int *temp);
92+int tftp_file_read(FILE *fp, char *buffer, int buffer_size, long block_number, int convert,
93+ long *prev_block_number, long *prev_file_pos, int *temp);
94 int tftp_file_write(FILE *fp, char *data_buffer, int data_buffer_size, int block_number,
95 int data_size, int convert, int *prev_block_number, int *temp);
96 #endif
97Index: git/tftpd_file.c
98===================================================================
99--- git.orig/tftpd_file.c 2012-11-19 16:28:50.225027144 -0800
100+++ git/tftpd_file.c 2012-11-19 16:28:51.201027167 -0800
101@@ -407,8 +407,9 @@
102 int state = S_BEGIN;
103 int timeout_state = state;
104 int result;
105- int block_number = 0;
106- int last_block = -1;
107+ long block_number = 0;
108+ long last_block = -1;
109+ int block_loops = 0;
110 int data_size;
111 struct sockaddr_storage *sa = &data->client_info->client;
112 struct sockaddr_storage from;
113@@ -431,8 +432,8 @@
114 struct client_info *client_old = NULL;
115 struct tftp_opt options[OPT_NUMBER];
116
117- int prev_block_number = 0; /* needed to support netascii convertion */
118- int prev_file_pos = 0;
119+ long prev_block_number = 0; /* needed to support netascii convertion */
120+ long prev_file_pos = 0;
121 int temp = 0;
122
123 /* look for mode option */
124@@ -565,11 +566,12 @@
125 logger(LOG_INFO, "blksize option -> %d", result);
126 }
127
128- /* Verify that the file can be sent in 2^16 block of BLKSIZE octets */
129- if ((file_stat.st_size / (data->data_buffer_size - 4)) > 65535)
130+ /* Verify that the file can be sent in MAXBLOCKS blocks of BLKSIZE octets */
131+ if ((file_stat.st_size / (data->data_buffer_size - 4)) > MAXBLOCKS)
132 {
133 tftp_send_error(sockfd, sa, EUNDEF, data->data_buffer, data->data_buffer_size);
134- logger(LOG_NOTICE, "Requested file to big, increase BLKSIZE");
135+ logger(LOG_NOTICE, "Requested file too big, increase BLKSIZE");
136+ logger(LOG_NOTICE, "Only %d blocks of %d bytes can be served.", MAXBLOCKS, data->data_buffer_size);
137 if (data->trace)
138 logger(LOG_DEBUG, "sent ERROR <code: %d, msg: %s>", EUNDEF,
139 tftp_errmsg[EUNDEF]);
140@@ -880,10 +882,15 @@
141 }
142 /* The ACK is from the current client */
143 number_of_timeout = 0;
144- block_number = ntohs(tftphdr->th_block);
145+ block_number = (block_loops * 65536) + ntohs(tftphdr->th_block);
146 if (data->trace)
147- logger(LOG_DEBUG, "received ACK <block: %d>",
148- block_number);
149+ {
150+ logger(LOG_DEBUG, "received ACK <block: %d>", block_number);
151+ }
152+ if (ntohs(tftphdr->th_block) == 65535)
153+ {
154+ block_loops++;
155+ };
156 if ((last_block != -1) && (block_number > last_block))
157 {
158 state = S_END;
diff --git a/meta-oe/recipes-extended/atftp/files/atftpd-0.7_unprotected_assignments_crash.patch b/meta-oe/recipes-extended/atftp/files/atftpd-0.7_unprotected_assignments_crash.patch
new file mode 100644
index 000000000..6faf5f9d9
--- /dev/null
+++ b/meta-oe/recipes-extended/atftp/files/atftpd-0.7_unprotected_assignments_crash.patch
@@ -0,0 +1,145 @@
1Index: git/tftpd_list.c
2===================================================================
3--- git.orig/tftpd_list.c 2012-10-24 21:48:47.000000000 -0700
4+++ git/tftpd_list.c 2012-10-24 21:52:04.266205076 -0700
5@@ -49,11 +49,11 @@
6 */
7 int tftpd_list_add(struct thread_data *new)
8 {
9- struct thread_data *current = thread_data;
10+ struct thread_data *current;
11 int ret;
12
13 pthread_mutex_lock(&thread_list_mutex);
14-
15+ current = thread_data;
16 number_of_thread++;
17
18 ret = number_of_thread;
19@@ -81,11 +81,13 @@
20 */
21 int tftpd_list_remove(struct thread_data *old)
22 {
23- struct thread_data *current = thread_data;
24+ struct thread_data *current;
25 int ret;
26
27 pthread_mutex_lock(&thread_list_mutex);
28
29+ current = thread_data;
30+
31 number_of_thread--;
32 ret = number_of_thread;
33
34@@ -137,23 +139,26 @@
35 struct thread_data *data,
36 struct client_info *client)
37 {
38- struct thread_data *current = thread_data; /* head of the list */
39- struct tftp_opt *tftp_options = data->tftp_options;
40+ struct thread_data *current; /* head of the list */
41+ struct tftp_opt *tftp_options;
42 struct client_info *tmp;
43 char options[MAXLEN];
44 char string[MAXLEN];
45 char *index;
46 int len;
47
48+ /* lock the whole list before walking it */
49+ pthread_mutex_lock(&thread_list_mutex);
50+
51 *thread = NULL;
52
53+ current = thread_data;
54+ tftp_options = data->tftp_options;
55+
56 opt_request_to_string(tftp_options, options, MAXLEN);
57 index = strstr(options, "multicast");
58 len = (int)index - (int)options;
59
60- /* lock the whole list before walking it */
61- pthread_mutex_lock(&thread_list_mutex);
62-
63 while (current)
64 {
65 if (current != data)
66@@ -214,9 +219,10 @@
67 void tftpd_clientlist_remove(struct thread_data *thread,
68 struct client_info *client)
69 {
70- struct client_info *tmp = thread->client_info;
71+ struct client_info *tmp;
72
73 pthread_mutex_lock(&thread->client_mutex);
74+ tmp = thread->client_info;
75 while ((tmp->next != client) && (tmp->next != NULL))
76 tmp = tmp->next;
77 if (tmp->next == NULL)
78@@ -231,9 +237,11 @@
79 void tftpd_clientlist_free(struct thread_data *thread)
80 {
81 struct client_info *tmp;
82- struct client_info *head = thread->client_info;
83+ struct client_info *head;
84
85 pthread_mutex_lock(&thread->client_mutex);
86+ head = thread->client_info;
87+
88 while (head)
89 {
90 tmp = head;
91@@ -250,9 +258,10 @@
92 struct client_info *client,
93 struct sockaddr_storage *sock)
94 {
95- struct client_info *head = thread->client_info;
96+ struct client_info *head;
97
98 pthread_mutex_lock(&thread->client_mutex);
99+ head = thread->client_info;
100
101 if (client)
102 {
103@@ -334,10 +343,10 @@
104
105 void tftpd_list_kill_threads(void)
106 {
107- struct thread_data *current = thread_data; /* head of list */
108+ struct thread_data *current; /* head of list */
109
110 pthread_mutex_lock(&thread_list_mutex);
111-
112+ current = thread_data;
113
114 while (current != NULL)
115 {
116Index: git/tftpd_mcast.c
117===================================================================
118--- git.orig/tftpd_mcast.c 2012-10-24 21:48:47.000000000 -0700
119+++ git/tftpd_mcast.c 2012-10-24 21:49:11.570201582 -0700
120@@ -51,9 +51,11 @@
121 */
122 int tftpd_mcast_get_tid(char **addr, short *port)
123 {
124- struct tid *current = tid_list;
125+ struct tid *current;
126
127 pthread_mutex_lock(&mcast_tid_list);
128+ current = tid_list;
129+
130 /* walk the list for a free tid */
131 while (current != NULL)
132 {
133@@ -74,9 +76,11 @@
134
135 int tftpd_mcast_free_tid(char *addr, short port)
136 {
137- struct tid *current = tid_list;
138+ struct tid *current;
139
140 pthread_mutex_lock(&mcast_tid_list);
141+ current = tid_list;
142+
143 while (current != NULL)
144 {
145 if ((current->used == 1) && (current->port == port) &&