patch-tftp_file_c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. $Id: update-patches 24 2008-08-31 14:56:13Z wbx $
  2. --- atftp-0.7.orig/tftp_file.c 2004-02-13 04:16:09.000000000 +0100
  3. +++ atftp-0.7/tftp_file.c 2008-10-09 11:58:48.000000000 +0200
  4. @@ -123,6 +123,7 @@ int tftp_receive_file(struct client_data
  5. struct tftphdr *tftphdr = (struct tftphdr *)data->data_buffer;
  6. FILE *fp = NULL; /* the local file pointer */
  7. int number_of_timeout = 0;
  8. + int num_retry = atoi(data->tftp_options[OPT_RETRY].value);
  9. int convert = 0; /* if true, do netascii convertion */
  10. int oacks = 0; /* count OACK for improved error checking */
  11. @@ -141,7 +142,7 @@ int tftp_receive_file(struct client_data
  12. int prev_block_number = 0; /* needed to support netascii convertion */
  13. int temp = 0;
  14. -
  15. +
  16. data->file_size = 0;
  17. tftp_cancel = 0;
  18. from.sin_addr.s_addr = 0;
  19. @@ -288,7 +289,7 @@ int tftp_receive_file(struct client_data
  20. case GET_TIMEOUT:
  21. number_of_timeout++;
  22. fprintf(stderr, "timeout: retrying...\n");
  23. - if (number_of_timeout > NB_OF_RETRY)
  24. + if ((num_retry > 0) && (number_of_timeout > num_retry))
  25. state = S_ABORT;
  26. else
  27. state = timeout_state;
  28. @@ -325,7 +326,7 @@ int tftp_receive_file(struct client_data
  29. number_of_timeout++;
  30. fprintf(stderr, "tftp: packet discard <%s:%d>.\n",
  31. inet_ntoa(from.sin_addr), ntohs(from.sin_port));
  32. - if (number_of_timeout > NB_OF_RETRY)
  33. + if ((num_retry > 0) && (number_of_timeout > num_retry))
  34. state = S_ABORT;
  35. break;
  36. case ERR:
  37. @@ -614,6 +615,7 @@ int tftp_send_file(struct client_data *d
  38. struct tftphdr *tftphdr = (struct tftphdr *)data->data_buffer;
  39. FILE *fp; /* the local file pointer */
  40. int number_of_timeout = 0;
  41. + int num_retry = atoi(data->tftp_options[OPT_RETRY].value);
  42. struct stat file_stat;
  43. int convert = 0; /* if true, do netascii convertion */
  44. char string[MAXLEN];
  45. @@ -751,7 +753,7 @@ int tftp_send_file(struct client_data *d
  46. case GET_TIMEOUT:
  47. number_of_timeout++;
  48. fprintf(stderr, "timeout: retrying...\n");
  49. - if (number_of_timeout > NB_OF_RETRY)
  50. + if ((num_retry > 0) && (number_of_timeout > num_retry))
  51. state = S_ABORT;
  52. else
  53. state = timeout_state;
  54. @@ -797,7 +799,7 @@ int tftp_send_file(struct client_data *d
  55. number_of_timeout++;
  56. fprintf(stderr, "tftp: packet discard <%s:%d>.\n",
  57. inet_ntoa(from.sin_addr), ntohs(from.sin_port));
  58. - if (number_of_timeout > NB_OF_RETRY)
  59. + if ((num_retry > 0) && (number_of_timeout > num_retry))
  60. state = S_ABORT;
  61. break;
  62. case ERR: