diff --git a/atftp.changes b/atftp.changes index b74e657..3c4a6cb 100644 --- a/atftp.changes +++ b/atftp.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Sep 12 16:27:04 CEST 2008 - mrueckert@suse.de + +- add atftpd-0.7_circumvent_tftp_size_restrictions.patch: + allow block counts higher than 65536 (Fate#303031) +- replace network with remote_fs in the init script dependencies + ------------------------------------------------------------------- Fri Aug 22 15:14:00 CEST 2008 - ro@suse.de diff --git a/atftp.spec b/atftp.spec index d4eb8f4..29e1023 100644 --- a/atftp.spec +++ b/atftp.spec @@ -21,7 +21,7 @@ Name: atftp %define pkg_version 0.7 Version: 0.7.0 -Release: 125 +Release: 132 License: GPL v2 or later Group: System/Daemons BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -39,6 +39,7 @@ Patch4: atftp-0.7_thread_crash.patch Patch5: atftp-0.7_sol_ip.patch Patch6: atftp-0.7_bug-213384_OPT_NUMBER.patch Patch7: atftpd-0.7_unprotected_assignments_crash.patch +Patch8: atftpd-0.7_circumvent_tftp_size_restrictions.patch # Summary: Advanced TFTP Server and Client @@ -67,6 +68,7 @@ Authors: %patch5 %patch6 %patch7 +%patch8 %build autoreconf -fi @@ -109,6 +111,10 @@ autoreconf -fi %dir %attr(-,nobody,nogroup) /var/run/atftpd/ %changelog +* Fri Sep 12 2008 mrueckert@suse.de +- add atftpd-0.7_circumvent_tftp_size_restrictions.patch: + allow block counts higher than 65536 (Fate#303031) +- replace network with remote_fs in the init script dependencies * Fri Aug 22 2008 ro@suse.de - change fillup_and_insserv to fillup_only (not active by default) * Thu Apr 03 2008 mrueckert@suse.de diff --git a/atftpd-0.7_circumvent_tftp_size_restrictions.patch b/atftpd-0.7_circumvent_tftp_size_restrictions.patch new file mode 100644 index 0000000..1ab16fc --- /dev/null +++ b/atftpd-0.7_circumvent_tftp_size_restrictions.patch @@ -0,0 +1,158 @@ +Fate #303031: Circumvent TFTP size restrictions in atftpd +The size of a single image file that can be transferred with TFTP is limited to +2^(2*8) *BLOCKSIZE (as per RFC 1350 there are only two bytes for the block +counter). This is problematic for one of our customers who needs to transfer +100+ MB Windows images using a TFTP client (NT bootloader) which has a +hardwared BLOCKSIZE setting of 1432). + +block rollover +http://www.compuphase.com/tftp.htm + +Index: tftp_def.h +=================================================================== +--- tftp_def.h.orig 2008-09-12 16:30:56.092292872 +0200 ++++ tftp_def.h 2008-09-12 16:30:56.160294265 +0200 +@@ -32,6 +32,7 @@ + #define TIMEOUT 5 /* Client timeout */ + #define S_TIMEOUT 5 /* Server timout. */ + #define NB_OF_RETRY 5 ++#define MAXBLOCKS 500000 /* maximum number of blocks in a download */ + + /* definition to use tftp_options structure */ + #define OPT_FILENAME 0 +Index: tftp_file.c +=================================================================== +--- tftp_file.c.orig 2008-09-12 16:30:55.907808154 +0200 ++++ tftp_file.c 2008-09-12 16:31:46.663791666 +0200 +@@ -604,8 +604,8 @@ int tftp_send_file(struct client_data *d + int state = S_SEND_REQ; /* current state in the state machine */ + int timeout_state = state; /* what state should we go on when timeout */ + int result; +- int block_number = 0; +- int last_block = -1; ++ long block_number = 0; ++ long last_block = -1; + int data_size; /* size of data received */ + int sockfd = data->sockfd; /* just to simplify calls */ + struct sockaddr_in sa; /* a copy of data.sa_peer */ +@@ -618,8 +618,8 @@ int tftp_send_file(struct client_data *d + int convert = 0; /* if true, do netascii convertion */ + char string[MAXLEN]; + +- int prev_block_number = 0; /* needed to support netascii convertion */ +- int prev_file_pos = 0; ++ long prev_block_number = 0; /* needed to support netascii convertion */ ++ long prev_file_pos = 0; + int temp = 0; + + data->file_size = 0; +@@ -726,7 +726,7 @@ int tftp_send_file(struct client_data *d + data_size, data->data_buffer); + data->file_size += data_size; + if (data->trace) +- fprintf(stderr, "sent DATA \n", ++ fprintf(stderr, "sent DATA \n", + block_number + 1, data_size - 4); + state = S_WAIT_PACKET; + break; +@@ -766,7 +766,7 @@ int tftp_send_file(struct client_data *d + } + block_number = ntohs(tftphdr->th_block); + if (data->trace) +- fprintf(stderr, "received ACK \n", ++ fprintf(stderr, "received ACK \n", + block_number); + if ((last_block != -1) && (block_number > last_block)) + { +Index: tftp_io.c +=================================================================== +--- tftp_io.c.orig 2008-09-12 16:30:56.048295391 +0200 ++++ tftp_io.c 2008-09-12 16:30:56.200292051 +0200 +@@ -334,8 +334,8 @@ int tftp_get_packet(int sock1, int sock2 + /* + * Read from file and do netascii conversion if needed + */ +-int tftp_file_read(FILE *fp, char *data_buffer, int data_buffer_size, int block_number, +- int convert, int *prev_block_number, int *prev_file_pos, int *temp) ++int tftp_file_read(FILE *fp, char *data_buffer, int data_buffer_size, long block_number, ++ int convert, long *prev_block_number, long *prev_file_pos, int *temp) + { + int i; + int c; +Index: tftp_io.h +=================================================================== +--- tftp_io.h.orig 2004-03-06 21:41:41.000000000 +0100 ++++ tftp_io.h 2008-09-12 16:30:56.240291211 +0200 +@@ -52,8 +52,8 @@ int tftp_send_data(int socket, struct so + int tftp_get_packet(int sock1, int sock2, int *sock, struct sockaddr_in *sa, + struct sockaddr_in *from, struct sockaddr_in *to, + int timeout, int *size, char *data); +-int tftp_file_read(FILE *fp, char *buffer, int buffer_size, int block_number, int convert, +- int *prev_block_number, int *prev_file_pos, int *temp); ++int tftp_file_read(FILE *fp, char *buffer, int buffer_size, long block_number, int convert, ++ long *prev_block_number, long *prev_file_pos, int *temp); + int tftp_file_write(FILE *fp, char *data_buffer, int data_buffer_size, int block_number, + int data_size, int convert, int *prev_block_number, int *temp); + #endif +Index: tftpd_file.c +=================================================================== +--- tftpd_file.c.orig 2004-03-06 21:41:41.000000000 +0100 ++++ tftpd_file.c 2008-09-12 16:30:56.268005211 +0200 +@@ -402,8 +402,9 @@ int tftpd_send_file(struct thread_data * + int state = S_BEGIN; + int timeout_state = state; + int result; +- int block_number = 0; +- int last_block = -1; ++ long block_number = 0; ++ long last_block = -1; ++ int block_loops = 0; + int data_size; + struct sockaddr_in *sa = &data->client_info->client; + struct sockaddr_in from; +@@ -425,8 +426,8 @@ int tftpd_send_file(struct thread_data * + struct client_info *client_old = NULL; + struct tftp_opt options[OPT_NUMBER]; + +- int prev_block_number = 0; /* needed to support netascii convertion */ +- int prev_file_pos = 0; ++ long prev_block_number = 0; /* needed to support netascii convertion */ ++ long prev_file_pos = 0; + int temp = 0; + + /* look for mode option */ +@@ -559,11 +560,12 @@ int tftpd_send_file(struct thread_data * + logger(LOG_INFO, "blksize option -> %d", result); + } + +- /* Verify that the file can be sent in 2^16 block of BLKSIZE octets */ +- if ((file_stat.st_size / (data->data_buffer_size - 4)) > 65535) ++ /* Verify that the file can be sent in MAXBLOCKS blocks of BLKSIZE octets */ ++ if ((file_stat.st_size / (data->data_buffer_size - 4)) > MAXBLOCKS) + { + tftp_send_error(sockfd, sa, EUNDEF, data->data_buffer, data->data_buffer_size); +- logger(LOG_NOTICE, "Requested file to big, increase BLKSIZE"); ++ logger(LOG_NOTICE, "Requested file too big, increase BLKSIZE"); ++ logger(LOG_NOTICE, "Only %d blocks of %d bytes can be served.", MAXBLOCKS, data->data_buffer_size); + if (data->trace) + logger(LOG_DEBUG, "sent ERROR ", EUNDEF, + tftp_errmsg[EUNDEF]); +@@ -852,10 +854,15 @@ int tftpd_send_file(struct thread_data * + } + /* The ACK is from the current client */ + number_of_timeout = 0; +- block_number = ntohs(tftphdr->th_block); ++ block_number = (block_loops * 65536) + ntohs(tftphdr->th_block); + if (data->trace) +- logger(LOG_DEBUG, "received ACK ", +- block_number); ++ { ++ logger(LOG_DEBUG, "received ACK ", block_number); ++ } ++ if (ntohs(tftphdr->th_block) == 65535) ++ { ++ block_loops++; ++ }; + if ((last_block != -1) && (block_number > last_block)) + { + state = S_END; diff --git a/atftpd.init.d b/atftpd.init.d index 6a3c8ff..27f381c 100644 --- a/atftpd.init.d +++ b/atftpd.init.d @@ -11,8 +11,8 @@ ### BEGIN INIT INFO # Provides: atftpd -# Required-Start: $network $syslog -# Required-Stop: $network $syslog +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Description: launch atftpd server