diff --git a/atftp-0.7-ack_heuristic.patch b/atftp-0.7-ack_heuristic.patch index abc34b6..7934036 100644 --- a/atftp-0.7-ack_heuristic.patch +++ b/atftp-0.7-ack_heuristic.patch @@ -2,15 +2,15 @@ Index: tftpd_file.c =================================================================== --- tftpd_file.c.orig +++ tftpd_file.c -@@ -402,7 +402,6 @@ int tftpd_send_file(struct thread_data * +@@ -406,7 +406,6 @@ int tftpd_send_file(struct thread_data * int timeout_state = state; int result; long block_number = 0; - long last_requested_block = -1; long last_block = -1; - int block_loops = 0; int data_size; -@@ -430,6 +429,11 @@ int tftpd_send_file(struct thread_data * + struct sockaddr_storage *sa = &data->client_info->client; +@@ -434,6 +433,11 @@ int tftpd_send_file(struct thread_data * long prev_file_pos = 0; int temp = 0; @@ -22,8 +22,8 @@ Index: tftpd_file.c /* look for mode option */ if (strcasecmp(data->tftp_options[OPT_MODE].value, "netascii") == 0) { -@@ -786,8 +790,8 @@ int tftpd_send_file(struct thread_data * - ntohs(client_info->client.sin_port)); +@@ -819,8 +823,8 @@ int tftpd_send_file(struct thread_data * + &client_info->client)); sa = &client_info->client; - /* rewind the last_requested_block counter */ @@ -33,117 +33,111 @@ Index: tftpd_file.c state = S_SEND_OACK; break; -@@ -856,6 +860,7 @@ int tftpd_send_file(struct thread_data * +@@ -895,6 +899,7 @@ int tftpd_send_file(struct thread_data * "source port mismatch, check bypassed"); } } + /* The ACK is from the current client */ number_of_timeout = 0; - block_number = (block_loops * 65536) + ntohs(tftphdr->th_block); -@@ -864,28 +869,88 @@ int tftpd_send_file(struct thread_data * - logger(LOG_DEBUG, "received ACK ", block_number); - } + if (multicast) +@@ -908,24 +913,82 @@ int tftpd_send_file(struct thread_data * + logger(LOG_DEBUG, "received ACK ", + block_number); -- /* if turned on, check whether the block request isn't already fulfilled */ +- /* if turned on, check whether the block request isn't already fulfilled */ - if (tftpd_prevent_sas) { -- /* multicast, block numbers could contain gaps */ -- if (multicast) { -- if (last_requested_block >= block_number) +- /* multicast, block numbers could contain gaps */ +- if (multicast) { +- if (last_requested_block >= block_number) { + /* Now check the ACK number and possibly ignore the request */ + + /* multicast, block numbers could contain gaps */ + if (multicast) { -+ /* if turned on, check whether the block request isn't already fulfilled */ -+ if (tftpd_prevent_sas) { -+ if (prev_sent_block >= block_number) - { - if (data->trace) -- logger(LOG_DEBUG, "received duplicated ACK = %d>", last_requested_block, block_number); -+ logger(LOG_DEBUG, "received duplicated ACK = %d>", prev_sent_block, block_number); - break; - } - else -- last_requested_block = block_number; -- /* unicast, blocks should be requested one after another */ -- } else { -- if (last_requested_block + 1 != block_number && last_requested_block != -1) -+ prev_sent_block = block_number; -+ } -+ /* don't prevent thes SAS */ -+ /* use a heuristic suggested by Vladimir Nadvornik */ -+ else { -+ /* here comes the ACK again */ -+ if (prev_sent_block == block_number) -+ { -+ /* drop if number of ACKs == times of previous block sending */ -+ if (++prev_ack_count == prev_sent_count) { -+ logger(LOG_DEBUG, "ACK count (%d) == previous block transmission count -> dropping ACK", prev_ack_count); -+ break; -+ } -+ /* else resend the block */ -+ logger(LOG_DEBUG, "resending block %d", block_number + 1); -+ } -+ /* received ACK to sent block -> move on to next block */ -+ else if (prev_sent_block < block_number) { -+ prev_sent_block = block_number; -+ prev_sent_count = curr_sent_count; -+ curr_sent_count = 0; -+ prev_ack_count = 1; -+ } -+ /* block with low number -> ignore it completely */ -+ else { -+ logger(LOG_DEBUG, "ignoring ACK %d", block_number); -+ break; -+ } -+ } -+ /* unicast, blocks should be requested one after another */ -+ } else { -+ /* if turned on, check whether the block request isn't already fulfilled */ -+ if (tftpd_prevent_sas) { -+ if (prev_sent_block + 1 != block_number) - { -+ logger(LOG_WARNING, "timeout: retrying..."); - if (data->trace) -- logger(LOG_DEBUG, "received out of order ACK ", last_requested_block + 1, block_number); -+ logger(LOG_DEBUG, "received out of order ACK ", prev_sent_block + 1, block_number); -+ break; -+ } -+ else { -+ prev_sent_block = block_number; -+ } -+ /* don't prevent thes SAS */ -+ /* use a heuristic suggested by Vladimir Nadvornik */ -+ } else { -+ /* here comes the ACK again */ -+ if (prev_sent_block == block_number) -+ { -+ /* drop if number of ACKs == times of previous block sending */ -+ if (++prev_ack_count == prev_sent_count) { -+ logger(LOG_DEBUG, "ACK count (%d) == previous block transmission count -> dropping ACK", prev_ack_count); -+ break; -+ } -+ /* else resend the block */ -+ logger(LOG_DEBUG, "resending block %d", block_number + 1); -+ } -+ /* received ACK to sent block -> move on to next block */ -+ else if (prev_sent_block < block_number) { -+ prev_sent_block = block_number; -+ prev_sent_count = curr_sent_count; -+ curr_sent_count = 0; -+ prev_ack_count = 1; -+ } -+ /* nor previous nor current block number -> ignore it completely */ -+ else { -+ logger(LOG_DEBUG, "ignoring ACK %d", block_number); - break; - } -- else -- last_requested_block = block_number; - } ++ /* if turned on, check whether the block request isn't already fulfilled */ ++ if (tftpd_prevent_sas) { ++ if (prev_sent_block >= block_number) { + if (data->trace) +- logger(LOG_DEBUG, "received duplicated ACK = %d>", last_requested_block, block_number); ++ logger(LOG_DEBUG, "received duplicated ACK = %d>", prev_sent_block, block_number); + break; + } else +- last_requested_block = block_number; +- /* unicast, blocks should be requested one after another */ +- } else { +- if (last_requested_block + 1 != block_number && last_requested_block != -1) { ++ prev_sent_block = block_number; ++ } ++ /* don't prevent thes SAS */ ++ /* use a heuristic suggested by Vladimir Nadvornik */ ++ else { ++ /* here comes the ACK again */ ++ if (prev_sent_block == block_number) { ++ /* drop if number of ACKs == times of previous block sending */ ++ if (++prev_ack_count == prev_sent_count) { ++ logger(LOG_DEBUG, "ACK count (%d) == previous block transmission count -> dropping ACK", prev_ack_count); ++ break; ++ } ++ /* else resend the block */ ++ logger(LOG_DEBUG, "resending block %d", block_number + 1); ++ } ++ /* received ACK to sent block -> move on to next block */ ++ else if (prev_sent_block < block_number) { ++ prev_sent_block = block_number; ++ prev_sent_count = curr_sent_count; ++ curr_sent_count = 0; ++ prev_ack_count = 1; ++ } ++ /* block with low number -> ignore it completely */ ++ else { ++ logger(LOG_DEBUG, "ignoring ACK %d", block_number); ++ break; ++ } ++ } ++ /* unicast, blocks should be requested one after another */ ++ } else { ++ /* if turned on, check whether the block request isn't already fulfilled */ ++ if (tftpd_prevent_sas) { ++ if (prev_sent_block + 1 != block_number) { ++ logger(LOG_WARNING, "timeout: retrying..."); + if (data->trace) +- logger(LOG_DEBUG, "received out of order ACK ", last_requested_block + 1, block_number); ++ logger(LOG_DEBUG, "received out of order ACK ", prev_sent_block + 1, block_number); + break; +- } else +- last_requested_block = block_number; ++ } else { ++ prev_sent_block = block_number; ++ } ++ /* don't prevent thes SAS */ ++ /* use a heuristic suggested by Vladimir Nadvornik */ ++ } else { ++ /* here comes the ACK again */ ++ if (prev_sent_block == block_number) { ++ /* drop if number of ACKs == times of previous block sending */ ++ if (++prev_ack_count == prev_sent_count) { ++ logger(LOG_DEBUG, "ACK count (%d) == previous block transmission count -> dropping ACK", prev_ack_count); ++ break; ++ } ++ /* else resend the block */ ++ logger(LOG_DEBUG, "resending block %d", block_number + 1); ++ } ++ /* received ACK to sent block -> move on to next block */ ++ else if (prev_sent_block < block_number) { ++ prev_sent_block = block_number; ++ prev_sent_count = curr_sent_count; ++ curr_sent_count = 0; ++ prev_ack_count = 1; ++ } ++ /* nor previous nor current block number -> ignore it completely */ ++ else { ++ logger(LOG_DEBUG, "ignoring ACK %d", block_number); ++ break; ++ } + } } -@@ -898,6 +963,8 @@ int tftpd_send_file(struct thread_data * +@@ -934,6 +997,8 @@ int tftpd_send_file(struct thread_data * state = S_END; break; } @@ -152,7 +146,7 @@ Index: tftpd_file.c state = S_SEND_DATA; break; case GET_ERROR: -@@ -989,7 +1056,7 @@ int tftpd_send_file(struct thread_data * +@@ -1028,7 +1093,7 @@ int tftpd_send_file(struct thread_data * state = S_SEND_OACK; fseek(fp, 0, SEEK_SET); /* reset the last block received counter */ diff --git a/atftp-0.7-default_user_man.patch b/atftp-0.7-default_user_man.patch index 3ccb0f1..a8da8f2 100644 --- a/atftp-0.7-default_user_man.patch +++ b/atftp-0.7-default_user_man.patch @@ -12,10 +12,10 @@ Index: atftpd.8 file. Assuming the file is /var/log/atftpd.log, simply run: "touch -/var/log/atftpd.log" and then "chown nobody.nogroup +/var/log/atftpd.log" and then "chown tftp.tftp - /var/log/atftpd.log". When the server is ran in daemon mode, - /dev/stdout or /dev/stderr can be used. - -@@ -105,8 +105,8 @@ specialized usage. + /var/log/atftpd.log". When the server is run in daemon mode, + /dev/stdout or /dev/stderr can be used. Specifying a single dash as + the filename will send logs to stdout (file descriptor 1). +@@ -106,8 +106,8 @@ specialized usage. .TP .B \-\-user @@ -26,7 +26,7 @@ Index: atftpd.8 .TP .B \-\-group -@@ -211,7 +211,7 @@ Show summary of options. +@@ -212,7 +212,7 @@ Show summary of options. This is the root directory used by the TFTP server. All requested files from a TFTP client must reside in this directory. If not specified, the directory defaults to /tftpboot. Since diff --git a/atftp-0.7-server_receive_race.patch b/atftp-0.7-server_receive_race.patch index 4ed5627..5c3ba9e 100644 --- a/atftp-0.7-server_receive_race.patch +++ b/atftp-0.7-server_receive_race.patch @@ -2,16 +2,16 @@ Index: tftpd_file.c =================================================================== --- tftpd_file.c.orig +++ tftpd_file.c -@@ -114,7 +114,7 @@ int tftpd_receive_file(struct thread_dat - struct sockaddr_in *sa = &data->client_info->client; - struct sockaddr_in from; +@@ -115,7 +115,7 @@ int tftpd_receive_file(struct thread_dat + struct sockaddr_storage from; + char addr_str[SOCKADDR_PRINT_ADDR_LEN]; struct tftphdr *tftphdr = (struct tftphdr *)data->data_buffer; - FILE *fp; + FILE *fp = NULL; char filename[MAXLEN]; char string[MAXLEN]; int timeout = data->timeout; -@@ -144,18 +144,6 @@ int tftpd_receive_file(struct thread_dat +@@ -145,18 +145,6 @@ int tftpd_receive_file(struct thread_dat return ERR; } @@ -30,7 +30,7 @@ Index: tftpd_file.c /* tsize option */ if (((result = opt_get_tsize(data->tftp_options)) > -1) && !convert) { -@@ -172,7 +160,6 @@ int tftpd_receive_file(struct thread_dat +@@ -173,7 +161,6 @@ int tftpd_receive_file(struct thread_dat if (data->trace) logger(LOG_DEBUG, "sent ERROR ", EOPTNEG, tftp_errmsg[EOPTNEG]); @@ -38,7 +38,7 @@ Index: tftpd_file.c return ERR; } timeout = result; -@@ -189,7 +176,6 @@ int tftpd_receive_file(struct thread_dat +@@ -190,7 +177,6 @@ int tftpd_receive_file(struct thread_dat if (data->trace) logger(LOG_DEBUG, "sent ERROR ", EOPTNEG, tftp_errmsg[EOPTNEG]); @@ -46,7 +46,7 @@ Index: tftpd_file.c return ERR; } -@@ -199,7 +185,6 @@ int tftpd_receive_file(struct thread_dat +@@ -200,7 +186,6 @@ int tftpd_receive_file(struct thread_dat if (data->data_buffer == NULL) { logger(LOG_ERR, "memory allocation failure"); @@ -54,7 +54,7 @@ Index: tftpd_file.c return ERR; } tftphdr = (struct tftphdr *)data->data_buffer; -@@ -210,7 +195,6 @@ int tftpd_receive_file(struct thread_dat +@@ -211,7 +196,6 @@ int tftpd_receive_file(struct thread_dat if (data->trace) logger(LOG_DEBUG, "sent ERROR ", ENOSPACE, tftp_errmsg[ENOSPACE]); @@ -62,7 +62,7 @@ Index: tftpd_file.c return ERR; } opt_set_blksize(result, data->tftp_options); -@@ -343,6 +327,20 @@ int tftpd_receive_file(struct thread_dat +@@ -346,6 +330,20 @@ int tftpd_receive_file(struct thread_dat } break; case S_DATA_RECEIVED: @@ -81,9 +81,9 @@ Index: tftpd_file.c + } + /* We need to seek to the right place in the file */ - block_number = ntohs(tftphdr->th_block); - if (data->trace) -@@ -370,13 +368,13 @@ int tftpd_receive_file(struct thread_dat + block_number = tftp_rollover_blocknumber( + ntohs(tftphdr->th_block), prev_block_number, 0); +@@ -374,13 +372,13 @@ int tftpd_receive_file(struct thread_dat state = S_SEND_ACK; break; case S_END: diff --git a/atftp-0.7-sorcerers_apprentice.patch b/atftp-0.7-sorcerers_apprentice.patch index 67bf4eb..7cc75a9 100644 --- a/atftp-0.7-sorcerers_apprentice.patch +++ b/atftp-0.7-sorcerers_apprentice.patch @@ -10,7 +10,7 @@ Index: tftp_file.c /* * Find a hole in the file bitmap. -@@ -605,6 +606,7 @@ int tftp_send_file(struct client_data *d +@@ -629,6 +631,7 @@ int tftp_send_file(struct client_data *d int timeout_state = state; /* what state should we go on when timeout */ int result; long block_number = 0; @@ -18,22 +18,20 @@ Index: tftp_file.c long last_block = -1; int data_size; /* size of data received */ int sockfd = data->sockfd; /* just to simplify calls */ -@@ -765,6 +767,20 @@ int tftp_send_file(struct client_data *d - connected = 1; +@@ -791,6 +794,18 @@ int tftp_send_file(struct client_data *d } - block_number = ntohs(tftphdr->th_block); + block_number = tftp_rollover_blocknumber( + ntohs(tftphdr->th_block), prev_block_number, 0); + -+ /* if turned on, check whether the block request isn't already fulfilled */ ++ /* if turned on, check whether the block request isn't already fulfilled */ + if (tftp_prevent_sas) { -+ if (last_requested_block >= block_number) -+ { -+ if (data->trace) -+ fprintf(stderr, "received duplicated ACK = %ld>\n", -+ last_requested_block, block_number); -+ break; -+ } -+ else -+ last_requested_block = block_number; ++ if (last_requested_block >= block_number) { ++ if (data->trace) ++ fprintf(stderr, "received duplicated ACK = %ld>\n", ++ last_requested_block, block_number); ++ break; ++ } else ++ last_requested_block = block_number; + } + if (data->trace) @@ -51,17 +49,17 @@ Index: tftpd_file.c #ifdef HAVE_PCRE extern tftpd_pcre_self_t *pcre_top; -@@ -403,6 +404,7 @@ int tftpd_send_file(struct thread_data * +@@ -407,6 +408,7 @@ int tftpd_send_file(struct thread_data * int timeout_state = state; int result; long block_number = 0; + long last_requested_block = -1; long last_block = -1; - int block_loops = 0; int data_size; -@@ -785,6 +787,10 @@ int tftpd_send_file(struct thread_data * - inet_ntoa(client_info->client.sin_addr), - ntohs(client_info->client.sin_port)); + struct sockaddr_storage *sa = &data->client_info->client; +@@ -818,6 +820,10 @@ int tftpd_send_file(struct thread_data * + sockaddr_get_port( + &client_info->client)); sa = &client_info->client; + + /* rewind the last_requested_block counter */ @@ -70,40 +68,36 @@ Index: tftpd_file.c state = S_SEND_OACK; break; } -@@ -859,6 +865,32 @@ int tftpd_send_file(struct thread_data * - { - logger(LOG_DEBUG, "received ACK ", block_number); - } +@@ -903,6 +909,28 @@ int tftpd_send_file(struct thread_data * + if (data->trace) + logger(LOG_DEBUG, "received ACK ", + block_number); + -+ /* if turned on, check whether the block request isn't already fulfilled */ ++ /* if turned on, check whether the block request isn't already fulfilled */ + if (tftpd_prevent_sas) { -+ /* multicast, block numbers could contain gaps */ -+ if (multicast) { -+ if (last_requested_block >= block_number) -+ { -+ if (data->trace) -+ logger(LOG_DEBUG, "received duplicated ACK = %d>", last_requested_block, block_number); -+ break; -+ } -+ else -+ last_requested_block = block_number; -+ /* unicast, blocks should be requested one after another */ -+ } else { -+ if (last_requested_block + 1 != block_number && last_requested_block != -1) -+ { -+ if (data->trace) -+ logger(LOG_DEBUG, "received out of order ACK ", last_requested_block + 1, block_number); -+ break; -+ } -+ else -+ last_requested_block = block_number; -+ } ++ /* multicast, block numbers could contain gaps */ ++ if (multicast) { ++ if (last_requested_block >= block_number) { ++ if (data->trace) ++ logger(LOG_DEBUG, "received duplicated ACK = %d>", last_requested_block, block_number); ++ break; ++ } else ++ last_requested_block = block_number; ++ /* unicast, blocks should be requested one after another */ ++ } else { ++ if (last_requested_block + 1 != block_number && last_requested_block != -1) { ++ if (data->trace) ++ logger(LOG_DEBUG, "received out of order ACK ", last_requested_block + 1, block_number); ++ break; ++ } else ++ last_requested_block = block_number; ++ } + } + - if (ntohs(tftphdr->th_block) == 65535) + if ((last_block != -1) && (block_number > last_block)) { - block_loops++; -@@ -958,6 +990,8 @@ int tftpd_send_file(struct thread_data * + state = S_END; +@@ -1001,6 +1029,8 @@ int tftpd_send_file(struct thread_data * /* nedd to send an oack to that client */ state = S_SEND_OACK; fseek(fp, 0, SEEK_SET); @@ -116,15 +110,15 @@ Index: tftpd.c =================================================================== --- tftpd.c.orig +++ tftpd.c -@@ -62,6 +62,7 @@ int retry_timeout = S_TIMEOUT; +@@ -65,6 +65,7 @@ int listen_local = 0; int tftpd_daemon = 0; /* By default we are started by inetd */ int tftpd_daemon_no_fork = 0; /* For who want a false daemon mode */ +int tftpd_prevent_sas = 0; /* For who don't want the sorcerer's apprentice syndrome */ - short tftpd_port = 0; /* Port atftpd listen to */ + short tftpd_port = 69; /* Port atftpd listen to */ char tftpd_addr[MAXLEN] = ""; /* IP address atftpd binds to */ -@@ -833,6 +834,7 @@ int tftpd_cmd_line_options(int argc, cha +@@ -922,6 +923,7 @@ int tftpd_cmd_line_options(int argc, cha { "mtftp", 1, NULL, OPT_MTFTP }, { "mtftp-port", 1, NULL, OPT_MTFTP_PORT }, #endif @@ -132,7 +126,7 @@ Index: tftpd.c { "no-source-port-checking", 0, NULL, OPT_PORT_CHECK }, { "mcast-switch-client", 0, NULL, OPT_MCAST_SWITCH }, { "version", 0, NULL, 'V' }, -@@ -896,6 +898,9 @@ int tftpd_cmd_line_options(int argc, cha +@@ -991,6 +993,9 @@ int tftpd_cmd_line_options(int argc, cha case 'N': tftpd_daemon_no_fork = 1; break; @@ -142,8 +136,8 @@ Index: tftpd.c case 'U': tmp = strtok(optarg, "."); if (tmp != NULL) -@@ -1120,6 +1125,7 @@ void tftpd_usage(void) - " --pidfile : write PID to this file\n" +@@ -1223,6 +1228,7 @@ void tftpd_usage(void) + " --listen-local : force listen on local network address\n" " --daemon : run atftpd standalone (no inetd)\n" " --no-fork : run as a daemon, don't fork\n" + " --prevent-sas : prevent Sorcerer's Apprentice Syndrome\n" @@ -154,7 +148,7 @@ Index: tftp.c =================================================================== --- tftp.c.orig +++ tftp.c -@@ -57,6 +57,7 @@ +@@ -58,6 +58,7 @@ /* defined as extern in tftp_file.c and mtftp_file.c, set by the signal handler */ int tftp_cancel = 0; @@ -162,7 +156,7 @@ Index: tftp.c /* local flags */ int interactive = 1; /* if false, we run in batch mode */ -@@ -982,6 +983,7 @@ int tftp_cmd_line_options(int argc, char +@@ -1006,6 +1007,7 @@ int tftp_cmd_line_options(int argc, char #endif { "mtftp", 1, NULL, '1'}, { "no-source-port-checking", 0, NULL, '0'}, @@ -170,7 +164,7 @@ Index: tftp.c { "verbose", 0, NULL, 'v'}, { "trace", 0, NULL, 'd'}, #if DEBUG -@@ -1086,6 +1088,9 @@ int tftp_cmd_line_options(int argc, char +@@ -1115,6 +1117,9 @@ int tftp_cmd_line_options(int argc, char case '0': data.checkport = 0; break; @@ -180,7 +174,7 @@ Index: tftp.c case 'v': snprintf(string, sizeof(string), "verbose on"); make_arg(string, &ac, &av); -@@ -1182,6 +1187,7 @@ void tftp_usage(void) +@@ -1226,6 +1231,7 @@ void tftp_usage(void) " --mtftp <\"name value\"> : set mtftp variable to value\n" #endif " --no-source-port-checking: violate RFC, see man page\n" @@ -192,7 +186,7 @@ Index: atftpd.8 =================================================================== --- atftpd.8.orig +++ atftpd.8 -@@ -180,6 +180,14 @@ implication. Be aware that this option v +@@ -181,6 +181,14 @@ implication. Be aware that this option v option has effect only for non-multicast transfer. .TP @@ -211,7 +205,7 @@ Index: atftp.1 =================================================================== --- atftp.1.orig +++ atftp.1 -@@ -77,6 +77,14 @@ to configure client side port to use. +@@ -88,6 +88,14 @@ to configure client side port to use. See atftpd's man page. .TP diff --git a/atftp-0.7.2.tar.gz b/atftp-0.7.2.tar.gz new file mode 100644 index 0000000..a3105f0 --- /dev/null +++ b/atftp-0.7.2.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ad080674e9f974217b3a703e7356c6c8446dc5e7b2014d0d06e1bfaa11b5041 +size 248038 diff --git a/atftp-0.7.dif b/atftp-0.7.dif deleted file mode 100644 index 6adf72e..0000000 --- a/atftp-0.7.dif +++ /dev/null @@ -1,70 +0,0 @@ -Index: argz.h -=================================================================== ---- argz.h.orig -+++ argz.h -@@ -180,7 +180,7 @@ extern char *argz_next (__const char *__ - #ifdef __USE_EXTERN_INLINES - extern inline char * - __argz_next (__const char *__argz, size_t __argz_len, -- __const char *__entry) __THROW -+ __const char *__entry) - { - if (__entry) - { -@@ -194,7 +194,7 @@ __argz_next (__const char *__argz, size_ - } - extern inline char * - argz_next (__const char *__argz, size_t __argz_len, -- __const char *__entry) __THROW -+ __const char *__entry) - { - return __argz_next (__argz, __argz_len, __entry); - } -Index: tftp.c -=================================================================== ---- tftp.c.orig -+++ tftp.c -@@ -354,7 +354,7 @@ char *command_generator(const char *text - void make_arg(char *string, int *argc, char ***argv) - { - static char *tmp = NULL; -- int argz_len; -+ size_t argz_len; - - /* split the string to an argz vector */ - if (argz_create_sep(string, ' ', &tmp, &argz_len) != 0) -@@ -731,7 +731,7 @@ int get_file(int argc, char **argv) - fsync(data.sockfd); - close(data.sockfd); - -- return OK; -+ return tftp_result; - } - - #ifdef HAVE_MTFTP -Index: tftp_file.c -=================================================================== ---- tftp_file.c.orig -+++ tftp_file.c -@@ -59,9 +59,9 @@ int tftp_find_bitmap_hole(int prev_hole, - unsigned int next_word; - - /* initial stuff */ -- next_hole = prev_hole + 1; -- next_word_no = next_hole / 32; -- next_bit_no = next_hole % 32; -+ next_hole = 0; -+ next_word_no = next_hole / 32; /* effectively 0 */ -+ next_bit_no = next_hole % 32; /* effectively 0 */ - next_word = bitmap[next_word_no]; - - /* Check if there is a remainder of the current word to traverse */ -@@ -136,7 +136,7 @@ int tftp_receive_file(struct client_data - struct hostent *host; - int master_client = 0; - unsigned int file_bitmap[NB_BLOCK]; -- int prev_bitmap_hole = -1; /* the previous hole found in the bitmap */ -+ int prev_bitmap_hole = 0; /* the previous hole found in the bitmap */ - char string[MAXLEN]; - - int prev_block_number = 0; /* needed to support netascii convertion */ diff --git a/atftp-0.7.tar.bz2 b/atftp-0.7.tar.bz2 deleted file mode 100644 index b5261c7..0000000 --- a/atftp-0.7.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:90a3cb7d2bf4ef3d82bdff2d01d95ca1f53607438211c944bb3ee4ae7ac27b6f -size 164599 diff --git a/atftp-0.7_bug-213384_OPT_NUMBER.patch b/atftp-0.7_bug-213384_OPT_NUMBER.patch deleted file mode 100644 index 4e7baa1..0000000 --- a/atftp-0.7_bug-213384_OPT_NUMBER.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- - options.h | 2 +- - tftp_def.c | 2 +- - tftp_def.h | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -Index: options.h -=================================================================== ---- options.h.orig -+++ options.h -@@ -27,7 +27,7 @@ struct tftp_opt { - int enabled; /* enabled for use by server or client */ - }; - --extern struct tftp_opt tftp_default_options[OPT_NUMBER]; -+extern struct tftp_opt tftp_default_options[OPT_NUMBER + 1]; - - int opt_parse_request(char *data, int data_size, struct tftp_opt *options); - int opt_parse_options(char *data, int data_size, struct tftp_opt *options); -Index: tftp_def.c -=================================================================== ---- tftp_def.c.orig -+++ tftp_def.c -@@ -30,7 +30,7 @@ - */ - - // FIXME: is there a way to use TIMEOUT and SEGSIZE here? --struct tftp_opt tftp_default_options[OPT_NUMBER] = { -+struct tftp_opt tftp_default_options[OPT_NUMBER + 1] = { - { "filename", "", 0, 1}, /* file to transfer */ - { "mode", "octet", 0, 1}, /* mode for transfer */ - { "tsize", "0", 0, 1 }, /* RFC1350 options. See RFC2347, */ -Index: tftp_def.h -=================================================================== ---- tftp_def.h.orig -+++ tftp_def.h -@@ -40,7 +40,7 @@ - #define OPT_TIMEOUT 3 - #define OPT_BLKSIZE 4 - #define OPT_MULTICAST 5 --#define OPT_NUMBER 7 -+#define OPT_NUMBER 6 - - #define OPT_SIZE 12 - #define VAL_SIZE MAXLEN diff --git a/atftp-0.7_compiler_warnings.patch b/atftp-0.7_compiler_warnings.patch deleted file mode 100644 index 9b46a65..0000000 --- a/atftp-0.7_compiler_warnings.patch +++ /dev/null @@ -1,109 +0,0 @@ -Index: logger.c -=================================================================== ---- logger.c.orig -+++ logger.c -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - #include "logger.h" - - #define MAXLEN 128 -@@ -102,17 +103,17 @@ void logger(int severity, const char *fm - if (severity <= log_priority) - { - vsnprintf(message, sizeof(message), fmt, args); -- -+ - if (log_fp) - { -- fprintf(log_fp, "%s %s %s[%d.%d]: %s\n", time_buf, hostname, -+ fprintf(log_fp, "%s %s %s[%d.%ld]: %s\n", time_buf, hostname, - log_ident, getpid(), pthread_self(), message); - fflush(log_fp); - } - else if (log_syslog_is_open) - syslog(severity, "%s", message); - else -- fprintf(stderr, "%s %s %s[%d.%d]: %s\n", time_buf, hostname, -+ fprintf(stderr, "%s %s %s[%d.%ld]: %s\n", time_buf, hostname, - log_ident, getpid(), pthread_self(), message); - } - va_end(args); -Index: configure.ac -=================================================================== ---- configure.ac.orig -+++ configure.ac -@@ -66,7 +66,7 @@ AC_PROG_CC - dnl Check for AIX - AC_AIX - --CFLAGS="-g -Wall -D_REENTRANT" -+CFLAGS="${CFLAGS} -g -Wall -D_REENTRANT" - - if test x$debug = xtrue; then - CFLAGS="$CFLAGS -O0 -DDEBUG" -Index: tftpd_list.c -=================================================================== ---- tftpd_list.c.orig -+++ tftpd_list.c -@@ -143,13 +143,13 @@ int tftpd_list_find_multicast_server_and - char options[MAXLEN]; - char string[MAXLEN]; - char *index; -- int len; -+ size_t len; - - *thread = NULL; - - opt_request_to_string(tftp_options, options, MAXLEN); - index = strstr(options, "multicast"); -- len = (int)index - (int)options; -+ len = (size_t)(index - options); - - /* lock the whole list before walking it */ - pthread_mutex_lock(&thread_list_mutex); -@@ -166,7 +166,7 @@ int tftpd_list_find_multicast_server_and - /* must have exact same option string */ - if (strncmp(string, options, len) == 0) - { -- *thread = current; -+ *thread = current; - /* insert the new client at the end. If the client is already - in the list, don't add it again. */ - tmp = current->client_info; -@@ -188,17 +188,17 @@ int tftpd_list_find_multicast_server_and - } - tmp->next = client; - /* unlock mutex and exit */ -- pthread_mutex_unlock(¤t->client_mutex); -+ pthread_mutex_unlock(¤t->client_mutex); - pthread_mutex_unlock(&thread_list_mutex); - return 1; - } - } -- pthread_mutex_unlock(¤t->client_mutex); -+ pthread_mutex_unlock(¤t->client_mutex); - } - current = current->next; - } - pthread_mutex_unlock(&thread_list_mutex); -- -+ - return 0; - } - -Index: tftp_mtftp.c -=================================================================== ---- tftp_mtftp.c.orig -+++ tftp_mtftp.c -@@ -63,7 +63,7 @@ extern int tftp_cancel; - * If mode = 0, count missed packet from block 0. Else, start after first - * received block. - */ --int tftp_mtftp_missed_packet(int file_bitmap[], int last_block, int mode) -+int tftp_mtftp_missed_packet(unsigned int file_bitmap[], int last_block, int mode) - { - int missed_block = 0; - int block_number = 0; diff --git a/atftp-0.7_sol_ip.patch b/atftp-0.7_sol_ip.patch deleted file mode 100644 index 3ba9f13..0000000 --- a/atftp-0.7_sol_ip.patch +++ /dev/null @@ -1,19 +0,0 @@ -Index: tftp_io.c -=================================================================== ---- tftp_io.c.orig -+++ tftp_io.c -@@ -284,12 +284,14 @@ int tftp_get_packet(int sock1, int sock2 - cmsg != NULL && cmsg->cmsg_len >= sizeof(*cmsg); - cmsg = CMSG_NXTHDR(&msg, cmsg)) - { -+#ifdef SOL_IP - if (cmsg->cmsg_level == SOL_IP - && cmsg->cmsg_type == IP_PKTINFO) - { - pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg); - sa_to->sin_addr = pktinfo->ipi_addr; - } -+#endif - break; - } - } diff --git a/atftp-0.7_thread_crash.patch b/atftp-0.7_thread_crash.patch deleted file mode 100644 index 3689a60..0000000 --- a/atftp-0.7_thread_crash.patch +++ /dev/null @@ -1,41 +0,0 @@ -http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=271816 -Index: tftpd.c -=================================================================== ---- tftpd.c.orig -+++ tftpd.c -@@ -157,6 +157,7 @@ int main(int argc, char **argv) - struct servent *serv; - struct passwd *user; - struct group *group; -+ pthread_t tid; - - #ifdef HAVE_MTFTP - pthread_t mtftp_thread; -@@ -466,7 +467,7 @@ int main(int argc, char **argv) - new->client_info->next = NULL; - - /* Start a new server thread. */ -- if (pthread_create(&new->tid, NULL, tftpd_receive_request, -+ if (pthread_create(&tid, NULL, tftpd_receive_request, - (void *)new) != 0) - { - logger(LOG_ERR, "Failed to start new thread"); -@@ -567,7 +568,8 @@ void *tftpd_receive_request(void *arg) - - /* Detach ourself. That way the main thread does not have to - * wait for us with pthread_join. */ -- pthread_detach(pthread_self()); -+ data->tid = pthread_self(); -+ pthread_detach(data->tid); - - /* Read the first packet from stdin. */ - data_size = data->data_buffer_size; -@@ -733,7 +735,7 @@ void *tftpd_receive_request(void *arg) - - /* free the thread structure */ - free(data); -- -+ - logger(LOG_INFO, "Server thread exiting"); - pthread_exit(NULL); - } diff --git a/atftp-CLK_TCK.diff b/atftp-CLK_TCK.diff deleted file mode 100644 index 25018f6..0000000 --- a/atftp-CLK_TCK.diff +++ /dev/null @@ -1,15 +0,0 @@ -Index: stats.c -=================================================================== ---- stats.c.orig -+++ stats.c -@@ -142,6 +142,10 @@ void stats_thread_usage_locked(void) - pthread_mutex_unlock(&s_stats.mutex); - } - -+#ifndef CLK_TCK -+#define CLK_TCK CLOCKS_PER_SEC -+#endif -+ - /* - * Called at the end of the main thread, when no other threads are - * running, to print the final statistics. diff --git a/atftp-drop_privileges_non-daemon.patch b/atftp-drop_privileges_non-daemon.patch index 9b55f81..98c679d 100644 --- a/atftp-drop_privileges_non-daemon.patch +++ b/atftp-drop_privileges_non-daemon.patch @@ -1,8 +1,8 @@ -Index: atftp-0.7/tftpd.c +Index: atftp-0.7.2/tftpd.c =================================================================== ---- atftp-0.7.orig/tftpd.c 2016-12-06 13:41:15.955496990 +0100 -+++ atftp-0.7/tftpd.c 2016-12-06 14:55:23.573139906 +0100 -@@ -95,8 +95,8 @@ int deny_severity = LOG_NOTICE; +--- atftp-0.7.2.orig/tftpd.c ++++ atftp-0.7.2/tftpd.c +@@ -98,8 +98,8 @@ int deny_severity = LOG_NOTICE; #endif /* user ID and group ID when running as a daemon */ @@ -13,9 +13,11 @@ Index: atftp-0.7/tftpd.c /* For special uses, disable source port checking */ int source_port_checking = 1; -@@ -274,33 +274,47 @@ int main(int argc, char **argv) +@@ -296,54 +296,46 @@ int main(int argc, char **argv) + */ dup2(sockfd, 0); close(sockfd); ++ } - /* release priviliedge */ - user = getpwnam(user_name); @@ -27,16 +29,6 @@ Index: atftp-0.7/tftpd.c - user_name, group_name); - exit(1); - } -+ } - -- /* write our pid in the specified file before changing user*/ -- if (pidfile) -- { -- if (tftpd_pid_file(pidfile, 1) != OK) -- exit(1); -- /* to be able to remove it later */ -- chown(pidfile, user->pw_uid, group->gr_gid); -- } + /* release privilege */ + user = getpwnam(user_name); + group = getgrnam(group_name); @@ -48,9 +40,25 @@ Index: atftp-0.7/tftpd.c + exit(1); + } -- setgid(group->gr_gid); -- setuid(user->pw_uid); -+ /* write our pid in the specified file before changing user*/ +- /* write our pid in the specified file before changing user*/ +- if (pidfile) +- { +- if (tftpd_pid_file(pidfile, 1) != OK) +- { +- logger(LOG_ERR, +- "atftpd: can't write our pid file: %s.", +- pidfile); +- exit(1); +- } +- /* to be able to remove it later */ +- if (chown(pidfile, user->pw_uid, group->gr_gid) != OK) { +- logger(LOG_ERR, +- "atftpd: failed to chown our pid file %s to owner %s.%s.", +- pidfile, user_name, group_name); +- exit(1); +- } +- } ++ /* write our pid in the specified file before changing user */ + if (pidfile) + { + if (tftpd_pid_file(pidfile, 1) != OK) @@ -59,21 +67,33 @@ Index: atftp-0.7/tftpd.c + chown(pidfile, user->pw_uid, group->gr_gid); + } +- if (setgid(group->gr_gid) != OK) { +- logger(LOG_ERR, +- "atftpd: failed to setgid to group %d (%s).", +- group->gr_gid, group_name); +- exit(1); +- } +- if (setuid(user->pw_uid) != OK) { +- logger(LOG_ERR, +- "atftpd: failed to setuid to user %d (%s).", +- user->pw_uid, user_name); +- exit(1); +- } +- - /* Reopen log file now that we changed user, and that we've - * open and dup2 the socket. */ - open_logger("atftpd", log_file, logging_level); -+ if(setgid(group->gr_gid)) -+ { -+ logger(LOG_ERR, "atftpd: can't switch group to %s, exiting.", group_name); -+ exit(1); -+ } -+ if (setgroups(0, NULL)) -+ { -+ logger(LOG_ERR, "atftpd: can't clear supplementary group list"); ++ if (setgid(group->gr_gid) != OK) { ++ logger(LOG_ERR, ++ "atftpd: failed to setgid to group %d (%s).", ++ group->gr_gid, group_name); + exit(1); } -+ if(setuid(user->pw_uid)) -+ { ++ if (setgroups(0, NULL)) { ++ logger(LOG_ERR, "atftpd: can't clear supplementary group list"); ++ exit(1); ++ } ++ if(setuid(user->pw_uid)) { + logger(LOG_ERR, "atftpd: can't switch user to %s, exiting.", user_name); + exit(1); + } @@ -82,5 +102,5 @@ Index: atftp-0.7/tftpd.c + * open and dup2 the socket. */ + open_logger("atftpd", log_file, logging_level); + #if defined(SOL_IP) && defined(IP_PKTINFO) /* We need to retieve some information from incomming packets */ - if (setsockopt(0, SOL_IP, IP_PKTINFO, &one, sizeof(one)) != 0) diff --git a/atftp.changes b/atftp.changes index 3dec029..9205614 100644 --- a/atftp.changes +++ b/atftp.changes @@ -1,3 +1,57 @@ +------------------------------------------------------------------- +Fri Apr 26 09:37:19 UTC 2019 - Pedro Monreal Gonzalez + +- Removed old initscript conditionals and atftpd.init file + +------------------------------------------------------------------- +Wed Apr 24 14:57:32 UTC 2019 - Pedro Monreal Gonzalez + +- Update to version 0.7.2 [bsc#1133114, CVE-2019-11365][bsc#1133145, CVE-2019-11366] + * atftpd.c: Fixed a potential DoS bug (introduced by the IPv6 patch) + * Fix Debian Bug deb#613582 and deb#258998 atftpd: does not reply properly when there's more than 1 interface + * Fix Debian Bug deb#622840 atftpd: Forgets port if both --port and --bind-address are used + * Fix Debian Bug deb#606969 atftp exits with no error after a get when disk is full + * Fix Debian Bug deb#575831 atftp: error return value when tftp put file + * Fix missing default port from Ubuntu bug lp#972834 + * Merged patches to improve debugging and warning messages + * Merged patch from Gentoo distribution: + add support for proprietary password extension necessary for + transferring files to linksys routers (atftp client) + * Added patch from Gentoo bug #322601: client fails for filenames containing spaces + * Listening Address configuration fixed + * Added Patch "Blksize option can be smaller than SEGSIZE" + * Fix Debian Bug deb#609813 Apply patch listen on requested port when in daemon mode. + * Fix Debian Bug deb#598474 Fixed use of sendto() over a connected datagram socket on FreeBSD + * Fix Debian Bug deb#580473 Apply IPv6 support patch by Ben Hutchings. + Add AC_GNU_SOURCE to configure.ac to address FTBFS. + * Fix Debian Bug deb#536295 Updated config.sub .guess. + * Fix Debian Bug deb#535604 Make sure we have the --daemon option before starting atftpd + * Fix Debian Bug deb#514521 Crash fix + * Fix Debian Bug deb#484739 Added support for logging to stdout. + * Fix Debian Bug deb#484932 inetd.conf: change udp to udp4 + * Fix Debian Bug deb#436310 Fixed the FTBFS. + * Fix Debian Bug deb#420900 Use CLOCKS_PER_SEC instead of CLK_TCK. Fixed a FTBFS. + * Fix Debian Bug deb#271816 Random segfaults fixed + * Fix Debian Bug deb#291829 Segfault fixed on AMD64. + * Fix Debian Bug deb#290062 Copyright fixed. + * Fix Debian Bug deb#275052 Data corruption bug in multicast mode fixed. + * New Project home: https://sourceforge.net/projects/atftp/ +- Removed patches fixed upstream: + * atftp-0.7.dif + * atftp-CLK_TCK.diff + * atftp-0.7_compiler_warnings.patch + * atftp-0.7_thread_crash.patch + * atftp-0.7_sol_ip.patch + * atftp-0.7_bug-213384_OPT_NUMBER.patch + * atftpd-0.7_unprotected_assignments_crash.patch + * atftpd-0.7_circumvent_tftp_size_restrictions.patch +- Rebased patches: + * atftp-0.7-ack_heuristic.patch + * atftp-0.7-default_user_man.patch + * atftp-0.7-server_receive_race.patch + * atftp-0.7-sorcerers_apprentice.patch + * atftp-drop_privileges_non-daemon.patch + ------------------------------------------------------------------- Thu Nov 23 13:38:03 UTC 2017 - rbrown@suse.com diff --git a/atftp.spec b/atftp.spec index e73de98..8716fc1 100644 --- a/atftp.spec +++ b/atftp.spec @@ -1,7 +1,7 @@ # # spec file for package atftp # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -23,39 +23,29 @@ %endif %define _fwdefdir %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services -%define pkg_version 0.7 Name: atftp -Version: 0.7.0 +Version: 0.7.2 Release: 0 Summary: Advanced TFTP Server and Client -License: GPL-2.0+ +License: GPL-2.0-or-later Group: System/Daemons -Url: ftp://ftp.mamalinux.com/pub/atftp/ -Source: %{name}-%{pkg_version}.tar.bz2 -Source1: atftpd.init +URL: https://sourceforge.net/projects/atftp/ +Source: %{name}-%{version}.tar.gz Source2: atftpd.sysconfig Source3: atftpd.logrotate Source4: atftp.fw Source5: atftpd.service Source6: atftpd.socket -Patch1: atftp-0.7.dif -Patch2: atftp-CLK_TCK.diff -Patch3: atftp-0.7_compiler_warnings.patch -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 # PATCH-FIX-SUSE sorcerer's apprentice syndrom (bnc#727843) -Patch9: atftp-0.7-sorcerers_apprentice.patch +Patch1: atftp-0.7-sorcerers_apprentice.patch # PATCH-FIX-SUSE server receive thread race (bnc#599856) -Patch10: atftp-0.7-server_receive_race.patch +Patch2: atftp-0.7-server_receive_race.patch # PATCH-FIX-SUSE drop one duplicated ACK each round (bnc#774376) -Patch12: atftp-0.7-ack_heuristic.patch -Patch13: atftp-0.7-default_user_man.patch +Patch3: atftp-0.7-ack_heuristic.patch +Patch4: atftp-0.7-default_user_man.patch # PATCH-FIX-SUSE update default directory in man (bnc#507011) -Patch14: atftp-0.7-default_dir_man.patch -Patch15: atftp-drop_privileges_non-daemon.patch +Patch5: atftp-0.7-default_dir_man.patch +Patch6: atftp-drop_privileges_non-daemon.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: pcre-devel @@ -68,12 +58,8 @@ Conflicts: tftp Provides: tftp(client) Provides: tftp(server) BuildRoot: %{_tmppath}/%{name}-%{version}-build -%if 0%{?suse_version} >= 1210 BuildRequires: systemd-rpm-macros %{?systemd_requires} -%else -Requires(pre): %insserv_prereq -%endif %description atftp stands for Advanced Trivial File Transfer Protocol. It is called @@ -85,21 +71,13 @@ multithreaded and will eventually support multicast, allowing faster boot of hundreds of machines simultaneously. %prep -%setup -q -n %{name}-%{pkg_version} +%setup -q -n %{name}-%{version} %patch1 %patch2 %patch3 %patch4 %patch5 -%patch6 -%patch7 -%patch8 -%patch9 -%patch10 -%patch12 -%patch13 -%patch14 -%patch15 -p1 +%patch6 -p1 %build autoreconf -fi @@ -110,14 +88,9 @@ make %{?_smp_mflags} %install make DESTDIR=%{buildroot} install %{?_smp_mflags} # SuSE rc -%if 0%{?suse_version} >= 1210 install -D -m 0644 %{SOURCE5} %{buildroot}/%{_unitdir}/atftpd.service install -D -m 0644 %{SOURCE6} %{buildroot}/%{_unitdir}/atftpd.socket ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcatftpd -%else -install -D -m 0755 %{SOURCE1} %{buildroot}%{_initddir}/atftpd -ln -s -f ../..%{_initddir}/atftpd %{buildroot}%{_sbindir}/rcatftpd -%endif install -D -m 0644 %{SOURCE2} %{buildroot}%{_fillupdir}/sysconfig.atftpd install -D -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} mkdir -p %{buildroot}/%{_fwdefdir} @@ -138,44 +111,28 @@ if [ -f %{_sysconfdir}/sysconfig/atftpd ]; then sed -i -e "s@^\(ATFTPD_OPTIONS=\"--daemon \"\)@#\1@" %{_sysconfdir}/sysconfig/atftpd sed -i -e "s@^\(ATFTPD_DIRECTORY=\"/tftpboot\"\)@#\1@" %{_sysconfdir}/sysconfig/atftpd fi -%if 0%{?suse_version} >= 1210 %service_add_pre atftpd.service atftpd.socket -%endif %preun -%if 0%{?suse_version} >= 1210 %service_del_preun atftpd.service atftpd.socket -%else -%stop_on_removal atftpd -%endif %post -%if 0%{?suse_version} >= 1210 %service_add_post atftpd.service atftpd.socket -%endif %{fillup_only -n atftpd} %postun -%if 0%{?suse_version} >= 1210 %service_del_postun atftpd.service atftpd.socket -%else -%restart_on_update atftpd -%insserv_cleanup -%endif %files %defattr(-,root,root) -%doc BUGS FAQ LICENSE README README.MCAST README.PCRE TODO +%license LICENSE +%doc BUGS FAQ README README.MCAST README.PCRE TODO %{_bindir}/atftp %{_sbindir}/atftpd %{_sbindir}/in.tftpd %{_sbindir}/rcatftpd -%if 0%{?suse_version} >= 1210 %{_unitdir}/atftpd.service %{_unitdir}/atftpd.socket -%else -%{_initddir}/atftpd -%endif %config %{_sysconfdir}/logrotate.d/%{name} %{_fillupdir}/sysconfig.atftpd %{_mandir}/man1/atftp.1.gz diff --git a/atftpd-0.7_circumvent_tftp_size_restrictions.patch b/atftpd-0.7_circumvent_tftp_size_restrictions.patch deleted file mode 100644 index d8614ca..0000000 --- a/atftpd-0.7_circumvent_tftp_size_restrictions.patch +++ /dev/null @@ -1,158 +0,0 @@ -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 -+++ tftp_def.h -@@ -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 -+++ tftp_file.c -@@ -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 -+++ tftp_io.c -@@ -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 -+++ tftp_io.h -@@ -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 -+++ tftpd_file.c -@@ -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-0.7_unprotected_assignments_crash.patch b/atftpd-0.7_unprotected_assignments_crash.patch deleted file mode 100644 index b3e76d2..0000000 --- a/atftpd-0.7_unprotected_assignments_crash.patch +++ /dev/null @@ -1,145 +0,0 @@ -Index: tftpd_list.c -=================================================================== ---- tftpd_list.c.orig -+++ tftpd_list.c -@@ -49,11 +49,11 @@ pthread_mutex_t thread_list_mutex = PTHR - */ - int tftpd_list_add(struct thread_data *new) - { -- struct thread_data *current = thread_data; -+ struct thread_data *current; - int ret; - - pthread_mutex_lock(&thread_list_mutex); -- -+ current = thread_data; - number_of_thread++; - - ret = number_of_thread; -@@ -81,11 +81,13 @@ int tftpd_list_add(struct thread_data *n - */ - int tftpd_list_remove(struct thread_data *old) - { -- struct thread_data *current = thread_data; -+ struct thread_data *current; - int ret; - - pthread_mutex_lock(&thread_list_mutex); - -+ current = thread_data; -+ - number_of_thread--; - ret = number_of_thread; - -@@ -137,23 +139,26 @@ int tftpd_list_find_multicast_server_and - struct thread_data *data, - struct client_info *client) - { -- struct thread_data *current = thread_data; /* head of the list */ -- struct tftp_opt *tftp_options = data->tftp_options; -+ struct thread_data *current; /* head of the list */ -+ struct tftp_opt *tftp_options; - struct client_info *tmp; - char options[MAXLEN]; - char string[MAXLEN]; - char *index; - size_t len; - -+ /* lock the whole list before walking it */ -+ pthread_mutex_lock(&thread_list_mutex); -+ - *thread = NULL; - -+ current = thread_data; -+ tftp_options = data->tftp_options; -+ - opt_request_to_string(tftp_options, options, MAXLEN); - index = strstr(options, "multicast"); - len = (size_t)(index - options); - -- /* lock the whole list before walking it */ -- pthread_mutex_lock(&thread_list_mutex); -- - while (current) - { - if (current != data) -@@ -215,9 +220,10 @@ inline void tftpd_clientlist_ready(struc - void tftpd_clientlist_remove(struct thread_data *thread, - struct client_info *client) - { -- struct client_info *tmp = thread->client_info; -+ struct client_info *tmp; - - pthread_mutex_lock(&thread->client_mutex); -+ tmp = thread->client_info; - while ((tmp->next != client) && (tmp->next != NULL)) - tmp = tmp->next; - if (tmp->next == NULL) -@@ -232,9 +238,11 @@ void tftpd_clientlist_remove(struct thre - void tftpd_clientlist_free(struct thread_data *thread) - { - struct client_info *tmp; -- struct client_info *head = thread->client_info; -+ struct client_info *head; - - pthread_mutex_lock(&thread->client_mutex); -+ head = thread->client_info; -+ - while (head) - { - tmp = head; -@@ -251,9 +259,10 @@ int tftpd_clientlist_done(struct thread_ - struct client_info *client, - struct sockaddr_in *sock) - { -- struct client_info *head = thread->client_info; -+ struct client_info *head; - - pthread_mutex_lock(&thread->client_mutex); -+ head = thread->client_info; - - if (client) - { -@@ -335,10 +344,10 @@ int tftpd_clientlist_next(struct thread_ - - void tftpd_list_kill_threads(void) - { -- struct thread_data *current = thread_data; /* head of list */ -+ struct thread_data *current; /* head of list */ - - pthread_mutex_lock(&thread_list_mutex); -- -+ current = thread_data; - - while (current != NULL) - { -Index: tftpd_mcast.c -=================================================================== ---- tftpd_mcast.c.orig -+++ tftpd_mcast.c -@@ -51,9 +51,11 @@ struct tid *tid_list = NULL; - */ - int tftpd_mcast_get_tid(char **addr, short *port) - { -- struct tid *current = tid_list; -+ struct tid *current; - - pthread_mutex_lock(&mcast_tid_list); -+ current = tid_list; -+ - /* walk the list for a free tid */ - while (current != NULL) - { -@@ -74,9 +76,11 @@ int tftpd_mcast_get_tid(char **addr, sho - - int tftpd_mcast_free_tid(char *addr, short port) - { -- struct tid *current = tid_list; -+ struct tid *current; - - pthread_mutex_lock(&mcast_tid_list); -+ current = tid_list; -+ - while (current != NULL) - { - if ((current->used == 1) && (current->port == port) && diff --git a/atftpd.init b/atftpd.init deleted file mode 100644 index e6f2680..0000000 --- a/atftpd.init +++ /dev/null @@ -1,190 +0,0 @@ -#! /bin/sh -# Copyright (c) 2002,2003 SuSE Linux AG, Nuernberg, Germany. -# All rights reserved. -# -# Author: Anas Nashif -# -# /etc/init.d/atftpd -# and its symbolic link -# /usr/sbin/rcatftpd -# - -### BEGIN INIT INFO -# Provides: atftpd -# Required-Start: $syslog $remote_fs -# Required-Stop: $syslog $remote_fs -# Default-Start: 3 5 -# Default-Stop: 0 1 2 6 -# Short-Description: launch atftpd server -# Description: launch Advanced TFTP Server -### END INIT INFO - -# Shell functions sourced from /etc/rc.status: -# rc_check check and set local and overall rc status -# rc_status check and set local and overall rc status -# rc_status -v ditto but be verbose in local rc status -# rc_status -v -r ditto and clear the local rc status -# rc_failed set local and overall rc status to failed -# rc_failed set local and overall rc status to -# rc_reset clear local rc status (overall remains) -# rc_exit exit appropriate to overall rc status -# rc_active checks whether a service is activated by symlinks -. /etc/rc.status -# First reset status of this service -rc_reset - -# Return values acc. to LSB for all commands but status: -# 0 - success -# 1 - generic or unspecified error -# 2 - invalid or excess argument(s) -# 3 - unimplemented feature (e.g. "reload") -# 4 - insufficient privilege -# 5 - program is not installed -# 6 - program is not configured -# 7 - program is not running -# -# Note that starting an already running service, stopping -# or restarting a not-running service as well as the restart -# with force-reload (in case signalling is not supported) are -# considered a success. - -ATFTP_BIN="/usr/sbin/atftpd" -if [ ! -x $ATFTP_BIN ]; then - echo -n "Advanced Trivial FTP server, $ATFTP_BIN is not installed." - # Tell the user this has skipped - rc_status -s - exit 5 -fi - -ATFTP_LOG_FILE="/var/log/atftpd/atftp.log" -ATFTP_LOG_DIR="$(dirname ${ATFTP_LOG_FILE})" -ATFTP_PID_DIR="/var/run/atftpd" - -# check for sysconfig file -[ -f /etc/sysconfig/atftpd ] && . /etc/sysconfig/atftpd - -# Set default in case of missing sysconfig file -ATFTP_USR=${ATFTPD_USER:="tftp"} -ATFTP_GRP=${ATFTPD_GROUP:="tftp"} -ATFTP_OPTS=${ATFTPD_OPTIONS:=""} -ATFTP_USE_INETD=${ATFTPD_USE_INETD:="no"} -ATFTP_DIR=${ATFTPD_DIRECTORY:="/srv/tftpboot"} -ATFTP_BIND=${ATFTPD_BIND_ADDRESSES:=""} - -# start as daemon with some default opts -ATFTP_DEF_OPTS="--daemon --user $ATFTP_USR --group $ATFTP_GRP --logfile $ATFTP_LOG_FILE" - -# create logfile and PID directory if they don't exist -create_logfile_and_piddir(){ - # /var/run is mounted as tmpfs on openSUSE >= 11.4 - [ ! -d "$ATFTP_PID_DIR" ] && /usr/bin/install -o ${ATFTP_USR} -g ${ATFTP_GRP} -d "$ATFTP_PID_DIR"; - # must exist otherwise atftp will log to syslog - [ ! -f "$ATFTP_PID_DIR" ] && /usr/bin/install -m 0644 -o ${ATFTP_USR} -g ${ATFTP_GRP} /dev/null "$ATFTP_LOG_FILE" -} - -if [ "$ATFTP_USE_INETD" = "yes" ]; then - echo "ATFTP is set to start via inetd" - exit 0; -fi - -case "$1" in - start) - create_logfile_and_piddir - if [ -n "$ATFTP_BIND" ]; then - for IP in $ATFTP_BIND; do - echo -n "Starting Advanced Trivial FTP server on $IP: " - ## Start daemon with startproc(8). If this fails - ## the echo return value is set appropriate. - startproc -p "${ATFTP_PID_DIR}/$IP.pid" -f $ATFTP_BIN --pidfile "${ATFTP_PID_DIR}/$IP.pid" $ATFTP_DEF_OPTS $ATFTP_OPTS $ATFTP_DIR --bind-address $IP - - # Remember status and be verbose - rc_status -v - done - else - echo -n "Starting Advanced Trivial FTP server: " - ## Start daemon with startproc(8). If this fails - ## the echo return value is set appropriate. - startproc $ATFTP_BIN --pidfile "${ATFTP_PID_DIR}/pid" $ATFTP_DEF_OPTS $ATFTP_OPTS $ATFTP_DIR - - # Remember status and be verbose - rc_status -v - fi - ;; - stop) - echo -n "Stopping Advanced Trivial FTP server: " - killproc -TERM $ATFTP_BIN - - # Remember status and be verbose - rc_status -v - ;; - try-restart) - ## Do a restart only if the service was active before. - ## Note: try-restart is not (yet) part of LSB (as of 1.2) - $0 status >/dev/null && $0 restart - - # Remember status and be quiet - rc_status - ;; - restart) - ## Stop the service and regardless of whether it was - ## running or not, start it again. - $0 stop - $0 start - - # Remember status and be quiet - rc_status - ;; - force-reload) - #echo -n "Reloading Advanced Trivial FTP server: " - ## if it supports it: - #/sbin/killproc -HUP $ATFTP_BIN - #touch /var/run/FOO.pid - - # Remember status and be verbose - #rc_status -v - - ## Otherwise: - $0 try-restart - #rc_status - ;; - reload) - echo -n "Reloading Advanced Trivial FTP server: " - ## Like force-reload, but if daemon does not support - ## signaling, do nothing (!) - - # If it supports signaling: - #/sbin/killproc -HUP $ATFTP_BIN - #touch /var/run/FOO.pid - - # Remember status and be verbose - #rc_status -v - - ## Otherwise if it does not support reload: - rc_failed 5 - - # Remember status and be verbose - rc_status -v - ;; - status) - echo -n "Checking for Advanced Trivial FTP server: " - ## Check status with checkproc(8), if process is running - ## checkproc will return with exit status 0. - - # Return value is slightly different for the status command: - # 0 - service running - # 1 - service dead, but /var/run/ pid file exists - # 2 - service dead, but /var/lock/ lock file exists - # 3 - service not running - - # NOTE: checkproc returns LSB compliant status values. - checkproc $ATFTP_BIN - - # Remember status and be verbose - rc_status -v - ;; - *) - echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" - exit 1 - ;; -esac -rc_exit