Change-Id: I08303e9f4a00a214a678b1db0a46bde1d4cb8213
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4072
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Sharath George
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
Summary: Advanced Trivial File Transfer Protocol (ATFTP) - TFTP server |
| 2 | 2 |
Name: atftp |
| 3 | 3 |
Version: 0.7.1 |
| 4 |
-Release: 7%{?dist}
|
|
| 4 |
+Release: 8%{?dist}
|
|
| 5 | 5 |
URL: http://sourceforge.net/projects/atftp |
| 6 | 6 |
License: GPLv2+ and GPLv3+ and LGPLv2+ |
| 7 | 7 |
Group: System Environment/Daemons |
| ... | ... |
@@ -10,6 +10,7 @@ Distribution: Photon |
| 10 | 10 |
Source0: http://sourceforge.net/projects/atftp/files/latest/download/%{name}-%{version}.tar.gz
|
| 11 | 11 |
|
| 12 | 12 |
%define sha1 atftp=fc9e9f821dfd2f257b4a5c32b948ed60b4e31fd1 |
| 13 |
+Patch0: atftpd_circumvent_tftp_size_restrictions.patch |
|
| 13 | 14 |
|
| 14 | 15 |
BuildRequires: systemd |
| 15 | 16 |
Requires: systemd |
| ... | ... |
@@ -38,6 +39,7 @@ files using the TFTP protocol. |
| 38 | 38 |
|
| 39 | 39 |
%prep |
| 40 | 40 |
%setup |
| 41 |
+%patch0 -p1 |
|
| 41 | 42 |
sed -i "s/-g -Wall -D_REENTRANT/-g -Wall -D_REENTRANT -std=gnu89/" configure.ac |
| 42 | 43 |
|
| 43 | 44 |
%build |
| ... | ... |
@@ -125,6 +127,8 @@ fi |
| 125 | 125 |
|
| 126 | 126 |
|
| 127 | 127 |
%changelog |
| 128 |
+* Wed Oct 18 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 0.7.1-8 |
|
| 129 |
+- apply patch for large file support |
|
| 128 | 130 |
* Thu May 26 2016 Divya Thaluru <dthaluru@vmware.com> 0.7.1-7 |
| 129 | 131 |
- Fixed logic to restart the active services after upgrade |
| 130 | 132 |
* Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 0.7.1-6 |
| 131 | 133 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,163 @@ |
| 0 |
+Fate #303031: Circumvent TFTP size restrictions in atftpd |
|
| 1 |
+The size of a single image file that can be transferred with TFTP is limited to |
|
| 2 |
+2^(2*8) *BLOCKSIZE (as per RFC 1350 there are only two bytes for the block |
|
| 3 |
+counter). This is problematic for one of our customers who needs to transfer |
|
| 4 |
+100+ MB Windows images using a TFTP client (NT bootloader) which has a |
|
| 5 |
+hardwared BLOCKSIZE setting of 1432). |
|
| 6 |
+ |
|
| 7 |
+block rollover |
|
| 8 |
+http://www.compuphase.com/tftp.htm |
|
| 9 |
+ |
|
| 10 |
+Patch originally from OpenSUSE: |
|
| 11 |
+https://build.opensuse.org/package/view_file/openSUSE:Leap:42.2/atftp/atftpd-0.7_circumvent_tftp_size_restrictions.patch?expand=1 |
|
| 12 |
+ |
|
| 13 |
+Modified to apply for atftp-0.7.1 used in PhotonOS |
|
| 14 |
+ |
|
| 15 |
+diff --git a/tftp_def.h b/tftp_def.h.new |
|
| 16 |
+index e4b338d..6849d6f 100644 |
|
| 17 |
+--- a/tftp_def.h |
|
| 18 |
+@@ -32,6 +32,7 @@ |
|
| 19 |
+ #define TIMEOUT 5 /* Client timeout */ |
|
| 20 |
+ #define S_TIMEOUT 5 /* Server timout. */ |
|
| 21 |
+ #define NB_OF_RETRY 5 |
|
| 22 |
++#define MAXBLOCKS 1000000 /* maximum number of blocks in a download */ |
|
| 23 |
+ |
|
| 24 |
+ /* definition to use tftp_options structure */ |
|
| 25 |
+ #define OPT_FILENAME 0 |
|
| 26 |
+diff --git a/tftp_file.c b/tftp_file.c.new |
|
| 27 |
+index 27ae4d0..baab66c 100644 |
|
| 28 |
+--- a/tftp_file.c |
|
| 29 |
+@@ -622,8 +622,8 @@ int tftp_send_file(struct client_data *data) |
|
| 30 |
+ int state = S_SEND_REQ; /* current state in the state machine */ |
|
| 31 |
+ int timeout_state = state; /* what state should we go on when timeout */ |
|
| 32 |
+ int result; |
|
| 33 |
+- int block_number = 0; |
|
| 34 |
+- int last_block = -1; |
|
| 35 |
++ long block_number = 0; |
|
| 36 |
++ long last_block = -1; |
|
| 37 |
+ int data_size; /* size of data received */ |
|
| 38 |
+ int sockfd = data->sockfd; /* just to simplify calls */ |
|
| 39 |
+ struct sockaddr_storage sa; /* a copy of data.sa_peer */ |
|
| 40 |
+@@ -637,8 +637,8 @@ int tftp_send_file(struct client_data *data) |
|
| 41 |
+ int convert = 0; /* if true, do netascii convertion */ |
|
| 42 |
+ char string[MAXLEN]; |
|
| 43 |
+ |
|
| 44 |
+- int prev_block_number = 0; /* needed to support netascii convertion */ |
|
| 45 |
+- int prev_file_pos = 0; |
|
| 46 |
++ long prev_block_number = 0; /* needed to support netascii convertion */ |
|
| 47 |
++ long prev_file_pos = 0; |
|
| 48 |
+ int temp = 0; |
|
| 49 |
+ |
|
| 50 |
+ data->file_size = 0; |
|
| 51 |
+@@ -745,7 +745,7 @@ int tftp_send_file(struct client_data *data) |
|
| 52 |
+ data_size, data->data_buffer); |
|
| 53 |
+ data->file_size += data_size; |
|
| 54 |
+ if (data->trace) |
|
| 55 |
+- fprintf(stderr, "sent DATA <block: %d, size: %d>\n", |
|
| 56 |
++ fprintf(stderr, "sent DATA <block: %ld, size: %d>\n", |
|
| 57 |
+ block_number + 1, data_size - 4); |
|
| 58 |
+ state = S_WAIT_PACKET; |
|
| 59 |
+ break; |
|
| 60 |
+@@ -785,7 +785,7 @@ int tftp_send_file(struct client_data *data) |
|
| 61 |
+ } |
|
| 62 |
+ block_number = ntohs(tftphdr->th_block); |
|
| 63 |
+ if (data->trace) |
|
| 64 |
+- fprintf(stderr, "received ACK <block: %d>\n", |
|
| 65 |
++ fprintf(stderr, "received ACK <block: %ld>\n", |
|
| 66 |
+ block_number); |
|
| 67 |
+ if ((last_block != -1) && (block_number > last_block)) |
|
| 68 |
+ {
|
|
| 69 |
+diff --git a/tftp_io.c b/tftp_io.c.new |
|
| 70 |
+index 605a9c2..b559d5a 100644 |
|
| 71 |
+--- a/tftp_io.c |
|
| 72 |
+@@ -350,8 +350,8 @@ int tftp_get_packet(int sock1, int sock2, int *sock, struct sockaddr_storage *sa |
|
| 73 |
+ /* |
|
| 74 |
+ * Read from file and do netascii conversion if needed |
|
| 75 |
+ */ |
|
| 76 |
+-int tftp_file_read(FILE *fp, char *data_buffer, int data_buffer_size, int block_number, |
|
| 77 |
+- int convert, int *prev_block_number, int *prev_file_pos, int *temp) |
|
| 78 |
++int tftp_file_read(FILE *fp, char *data_buffer, int data_buffer_size, long block_number, |
|
| 79 |
++ int convert, long *prev_block_number, long *prev_file_pos, int *temp) |
|
| 80 |
+ {
|
|
| 81 |
+ int i; |
|
| 82 |
+ int c; |
|
| 83 |
+diff --git a/tftp_io.h b/tftp_io.h.new |
|
| 84 |
+index da8c369..7840744 100644 |
|
| 85 |
+--- a/tftp_io.h |
|
| 86 |
+@@ -52,8 +52,8 @@ int tftp_send_data(int socket, struct sockaddr_storage *s_inn, short block_numbe |
|
| 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 |
|
| 97 |
+diff --git a/tftpd_file.c b/tftpd_file.c.new |
|
| 98 |
+index da1d6c9..3b37f94 100644 |
|
| 99 |
+--- a/tftpd_file.c |
|
| 100 |
+@@ -407,8 +407,9 @@ int tftpd_send_file(struct thread_data *data) |
|
| 101 |
+ int state = S_BEGIN; |
|
| 102 |
+ int timeout_state = state; |
|
| 103 |
+ int result; |
|
| 104 |
+- int block_number = 0; |
|
| 105 |
+- int last_block = -1; |
|
| 106 |
++ long block_number = 0; |
|
| 107 |
++ long last_block = -1; |
|
| 108 |
++ int block_loops = 0; |
|
| 109 |
+ int data_size; |
|
| 110 |
+ struct sockaddr_storage *sa = &data->client_info->client; |
|
| 111 |
+ struct sockaddr_storage from; |
|
| 112 |
+@@ -431,8 +432,8 @@ int tftpd_send_file(struct thread_data *data) |
|
| 113 |
+ struct client_info *client_old = NULL; |
|
| 114 |
+ struct tftp_opt options[OPT_NUMBER]; |
|
| 115 |
+ |
|
| 116 |
+- int prev_block_number = 0; /* needed to support netascii convertion */ |
|
| 117 |
+- int prev_file_pos = 0; |
|
| 118 |
++ long prev_block_number = 0; /* needed to support netascii convertion */ |
|
| 119 |
++ long prev_file_pos = 0; |
|
| 120 |
+ int temp = 0; |
|
| 121 |
+ |
|
| 122 |
+ /* look for mode option */ |
|
| 123 |
+@@ -565,11 +566,12 @@ int tftpd_send_file(struct thread_data *data) |
|
| 124 |
+ logger(LOG_INFO, "blksize option -> %d", result); |
|
| 125 |
+ } |
|
| 126 |
+ |
|
| 127 |
+- /* Verify that the file can be sent in 2^16 block of BLKSIZE octets */ |
|
| 128 |
+- if ((file_stat.st_size / (data->data_buffer_size - 4)) > 65535) |
|
| 129 |
++ /* Verify that the file can be sent in MAXBLOCKS blocks of BLKSIZE octets */ |
|
| 130 |
++ if ((file_stat.st_size / (data->data_buffer_size - 4)) > MAXBLOCKS) |
|
| 131 |
+ {
|
|
| 132 |
+ tftp_send_error(sockfd, sa, EUNDEF, data->data_buffer, data->data_buffer_size); |
|
| 133 |
+- logger(LOG_NOTICE, "Requested file to big, increase BLKSIZE"); |
|
| 134 |
++ logger(LOG_NOTICE, "Requested file too big, increase BLKSIZE"); |
|
| 135 |
++ logger(LOG_NOTICE, "Only %d blocks of %d bytes can be served.", MAXBLOCKS, data->data_buffer_size); |
|
| 136 |
+ if (data->trace) |
|
| 137 |
+ logger(LOG_DEBUG, "sent ERROR <code: %d, msg: %s>", EUNDEF, |
|
| 138 |
+ tftp_errmsg[EUNDEF]); |
|
| 139 |
+@@ -880,10 +882,15 @@ int tftpd_send_file(struct thread_data *data) |
|
| 140 |
+ } |
|
| 141 |
+ /* The ACK is from the current client */ |
|
| 142 |
+ number_of_timeout = 0; |
|
| 143 |
+- block_number = ntohs(tftphdr->th_block); |
|
| 144 |
++ block_number = (block_loops * 65536) + ntohs(tftphdr->th_block); |
|
| 145 |
+ if (data->trace) |
|
| 146 |
+- logger(LOG_DEBUG, "received ACK <block: %d>", |
|
| 147 |
+- block_number); |
|
| 148 |
++ {
|
|
| 149 |
++ logger(LOG_DEBUG, "received ACK <block: %d>", block_number); |
|
| 150 |
++ } |
|
| 151 |
++ if (ntohs(tftphdr->th_block) == 65535) |
|
| 152 |
++ {
|
|
| 153 |
++ block_loops++; |
|
| 154 |
++ }; |
|
| 155 |
+ if ((last_block != -1) && (block_number > last_block)) |
|
| 156 |
+ {
|
|
| 157 |
+ state = S_END; |