diff options
Diffstat (limited to 'meta-networking/recipes-daemons/atftp/files/atftpd-0.7_circumvent_tftp_size_restrictions.patch')
-rw-r--r-- | meta-networking/recipes-daemons/atftp/files/atftpd-0.7_circumvent_tftp_size_restrictions.patch | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/meta-networking/recipes-daemons/atftp/files/atftpd-0.7_circumvent_tftp_size_restrictions.patch b/meta-networking/recipes-daemons/atftp/files/atftpd-0.7_circumvent_tftp_size_restrictions.patch new file mode 100644 index 000000000..280b570b2 --- /dev/null +++ b/meta-networking/recipes-daemons/atftp/files/atftpd-0.7_circumvent_tftp_size_restrictions.patch | |||
@@ -0,0 +1,163 @@ | |||
1 | Fate #303031: Circumvent TFTP size restrictions in atftpd | ||
2 | The size of a single image file that can be transferred with TFTP is limited to | ||
3 | 2^(2*8) *BLOCKSIZE (as per RFC 1350 there are only two bytes for the block | ||
4 | counter). This is problematic for one of our customers who needs to transfer | ||
5 | 100+ MB Windows images using a TFTP client (NT bootloader) which has a | ||
6 | hardwared BLOCKSIZE setting of 1432). | ||
7 | |||
8 | block rollover | ||
9 | http://www.compuphase.com/tftp.htm | ||
10 | |||
11 | Patch originally from OpenSUSE: | ||
12 | https://build.opensuse.org/package/show?package=atftp&project=openSUSE%3A12.2 | ||
13 | |||
14 | Upstream-Status: Pending | ||
15 | |||
16 | Index: git/tftp_def.h | ||
17 | =================================================================== | ||
18 | --- git.orig/tftp_def.h 2012-11-19 16:28:50.221027144 -0800 | ||
19 | +++ git/tftp_def.h 2012-11-20 17:40:54.391206979 -0800 | ||
20 | @@ -32,6 +32,7 @@ | ||
21 | #define TIMEOUT 5 /* Client timeout */ | ||
22 | #define S_TIMEOUT 5 /* Server timout. */ | ||
23 | #define NB_OF_RETRY 5 | ||
24 | +#define MAXBLOCKS 1000000 /* maximum number of blocks in a download */ | ||
25 | |||
26 | /* definition to use tftp_options structure */ | ||
27 | #define OPT_FILENAME 0 | ||
28 | Index: git/tftp_file.c | ||
29 | =================================================================== | ||
30 | --- git.orig/tftp_file.c 2012-11-19 16:28:50.221027144 -0800 | ||
31 | +++ git/tftp_file.c 2012-11-19 16:28:51.201027167 -0800 | ||
32 | @@ -622,8 +622,8 @@ | ||
33 | int state = S_SEND_REQ; /* current state in the state machine */ | ||
34 | int timeout_state = state; /* what state should we go on when timeout */ | ||
35 | int result; | ||
36 | - int block_number = 0; | ||
37 | - int last_block = -1; | ||
38 | + long block_number = 0; | ||
39 | + long last_block = -1; | ||
40 | int data_size; /* size of data received */ | ||
41 | int sockfd = data->sockfd; /* just to simplify calls */ | ||
42 | struct sockaddr_storage sa; /* a copy of data.sa_peer */ | ||
43 | @@ -637,8 +637,8 @@ | ||
44 | int convert = 0; /* if true, do netascii convertion */ | ||
45 | char string[MAXLEN]; | ||
46 | |||
47 | - int prev_block_number = 0; /* needed to support netascii convertion */ | ||
48 | - int prev_file_pos = 0; | ||
49 | + long prev_block_number = 0; /* needed to support netascii convertion */ | ||
50 | + long prev_file_pos = 0; | ||
51 | int temp = 0; | ||
52 | |||
53 | data->file_size = 0; | ||
54 | @@ -745,7 +745,7 @@ | ||
55 | data_size, data->data_buffer); | ||
56 | data->file_size += data_size; | ||
57 | if (data->trace) | ||
58 | - fprintf(stderr, "sent DATA <block: %d, size: %d>\n", | ||
59 | + fprintf(stderr, "sent DATA <block: %ld, size: %d>\n", | ||
60 | block_number + 1, data_size - 4); | ||
61 | state = S_WAIT_PACKET; | ||
62 | break; | ||
63 | @@ -785,7 +785,7 @@ | ||
64 | } | ||
65 | block_number = ntohs(tftphdr->th_block); | ||
66 | if (data->trace) | ||
67 | - fprintf(stderr, "received ACK <block: %d>\n", | ||
68 | + fprintf(stderr, "received ACK <block: %ld>\n", | ||
69 | block_number); | ||
70 | if ((last_block != -1) && (block_number > last_block)) | ||
71 | { | ||
72 | Index: git/tftp_io.c | ||
73 | =================================================================== | ||
74 | --- git.orig/tftp_io.c 2012-11-19 16:28:50.221027144 -0800 | ||
75 | +++ git/tftp_io.c 2012-11-19 16:28:51.201027167 -0800 | ||
76 | @@ -350,8 +350,8 @@ | ||
77 | /* | ||
78 | * Read from file and do netascii conversion if needed | ||
79 | */ | ||
80 | -int tftp_file_read(FILE *fp, char *data_buffer, int data_buffer_size, int block_number, | ||
81 | - int convert, int *prev_block_number, int *prev_file_pos, int *temp) | ||
82 | +int tftp_file_read(FILE *fp, char *data_buffer, int data_buffer_size, long block_number, | ||
83 | + int convert, long *prev_block_number, long *prev_file_pos, int *temp) | ||
84 | { | ||
85 | int i; | ||
86 | int c; | ||
87 | Index: git/tftp_io.h | ||
88 | =================================================================== | ||
89 | --- git.orig/tftp_io.h 2012-11-19 16:28:50.221027144 -0800 | ||
90 | +++ git/tftp_io.h 2012-11-19 16:28:51.201027167 -0800 | ||
91 | @@ -52,8 +52,8 @@ | ||
92 | int tftp_get_packet(int sock1, int sock2, int *sock, struct sockaddr_storage *sa, | ||
93 | struct sockaddr_storage *from, struct sockaddr_storage *to, | ||
94 | int timeout, int *size, char *data); | ||
95 | -int tftp_file_read(FILE *fp, char *buffer, int buffer_size, int block_number, int convert, | ||
96 | - int *prev_block_number, int *prev_file_pos, int *temp); | ||
97 | +int tftp_file_read(FILE *fp, char *buffer, int buffer_size, long block_number, int convert, | ||
98 | + long *prev_block_number, long *prev_file_pos, int *temp); | ||
99 | int tftp_file_write(FILE *fp, char *data_buffer, int data_buffer_size, int block_number, | ||
100 | int data_size, int convert, int *prev_block_number, int *temp); | ||
101 | #endif | ||
102 | Index: git/tftpd_file.c | ||
103 | =================================================================== | ||
104 | --- git.orig/tftpd_file.c 2012-11-19 16:28:50.225027144 -0800 | ||
105 | +++ git/tftpd_file.c 2012-11-19 16:28:51.201027167 -0800 | ||
106 | @@ -407,8 +407,9 @@ | ||
107 | int state = S_BEGIN; | ||
108 | int timeout_state = state; | ||
109 | int result; | ||
110 | - int block_number = 0; | ||
111 | - int last_block = -1; | ||
112 | + long block_number = 0; | ||
113 | + long last_block = -1; | ||
114 | + int block_loops = 0; | ||
115 | int data_size; | ||
116 | struct sockaddr_storage *sa = &data->client_info->client; | ||
117 | struct sockaddr_storage from; | ||
118 | @@ -431,8 +432,8 @@ | ||
119 | struct client_info *client_old = NULL; | ||
120 | struct tftp_opt options[OPT_NUMBER]; | ||
121 | |||
122 | - int prev_block_number = 0; /* needed to support netascii convertion */ | ||
123 | - int prev_file_pos = 0; | ||
124 | + long prev_block_number = 0; /* needed to support netascii convertion */ | ||
125 | + long prev_file_pos = 0; | ||
126 | int temp = 0; | ||
127 | |||
128 | /* look for mode option */ | ||
129 | @@ -565,11 +566,12 @@ | ||
130 | logger(LOG_INFO, "blksize option -> %d", result); | ||
131 | } | ||
132 | |||
133 | - /* Verify that the file can be sent in 2^16 block of BLKSIZE octets */ | ||
134 | - if ((file_stat.st_size / (data->data_buffer_size - 4)) > 65535) | ||
135 | + /* Verify that the file can be sent in MAXBLOCKS blocks of BLKSIZE octets */ | ||
136 | + if ((file_stat.st_size / (data->data_buffer_size - 4)) > MAXBLOCKS) | ||
137 | { | ||
138 | tftp_send_error(sockfd, sa, EUNDEF, data->data_buffer, data->data_buffer_size); | ||
139 | - logger(LOG_NOTICE, "Requested file to big, increase BLKSIZE"); | ||
140 | + logger(LOG_NOTICE, "Requested file too big, increase BLKSIZE"); | ||
141 | + logger(LOG_NOTICE, "Only %d blocks of %d bytes can be served.", MAXBLOCKS, data->data_buffer_size); | ||
142 | if (data->trace) | ||
143 | logger(LOG_DEBUG, "sent ERROR <code: %d, msg: %s>", EUNDEF, | ||
144 | tftp_errmsg[EUNDEF]); | ||
145 | @@ -880,10 +882,15 @@ | ||
146 | } | ||
147 | /* The ACK is from the current client */ | ||
148 | number_of_timeout = 0; | ||
149 | - block_number = ntohs(tftphdr->th_block); | ||
150 | + block_number = (block_loops * 65536) + ntohs(tftphdr->th_block); | ||
151 | if (data->trace) | ||
152 | - logger(LOG_DEBUG, "received ACK <block: %d>", | ||
153 | - block_number); | ||
154 | + { | ||
155 | + logger(LOG_DEBUG, "received ACK <block: %d>", block_number); | ||
156 | + } | ||
157 | + if (ntohs(tftphdr->th_block) == 65535) | ||
158 | + { | ||
159 | + block_loops++; | ||
160 | + }; | ||
161 | if ((last_block != -1) && (block_number > last_block)) | ||
162 | { | ||
163 | state = S_END; | ||