1
0

patch-tftp_c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. $Id: update-patches 24 2008-08-31 14:56:13Z wbx $
  2. --- atftp-0.7.orig/tftp.c 2004-03-16 00:55:56.000000000 +0100
  3. +++ atftp-0.7/tftp.c 2008-10-09 11:58:48.000000000 +0200
  4. @@ -409,7 +409,7 @@ int process_cmd(int argc, char **argv)
  5. int set_peer(int argc, char **argv)
  6. {
  7. struct hostent *host; /* for host name lookup */
  8. - struct servent *sp; /* server entry for tftp service */
  9. + int port = htons(69);
  10. /* sanity check */
  11. if ((argc < 2) || (argc > 3))
  12. @@ -418,13 +418,6 @@ int set_peer(int argc, char **argv)
  13. return ERR;
  14. }
  15. - /* get the server entry */
  16. - sp = getservbyname("tftp", "udp");
  17. - if (sp == 0) {
  18. - fprintf(stderr, "tftp: udp/tftp, unknown service.\n");
  19. - return ERR;
  20. - }
  21. -
  22. /* look up the host */
  23. host = gethostbyname(argv[1]);
  24. /* if valid, update s_inn structure */
  25. @@ -437,7 +430,7 @@ int set_peer(int argc, char **argv)
  26. Strncpy(data.hostname, host->h_name,
  27. sizeof(data.hostname));
  28. data.hostname[sizeof(data.hostname)-1] = 0;
  29. - data.sa_peer.sin_port = sp->s_port;
  30. + data.sa_peer.sin_port = port;
  31. }
  32. else
  33. {
  34. @@ -448,17 +441,17 @@ int set_peer(int argc, char **argv)
  35. /* get the server port */
  36. if (argc == 3)
  37. {
  38. - sp->s_port = htons(atoi(argv[2]));
  39. - if (sp->s_port < 0)
  40. + port = htons(atoi(argv[2]));
  41. + if (port < 0)
  42. {
  43. fprintf(stderr, "%s: bad port number.\n", argv[2]);
  44. data.connected = 0;
  45. return ERR;
  46. }
  47. - data.sa_peer.sin_port = sp->s_port;
  48. + data.sa_peer.sin_port = port;
  49. }
  50. /* copy port number to data structure */
  51. - data.port = ntohs(sp->s_port);
  52. + data.port = ntohs(port);
  53. data.connected = 1;
  54. return OK;
  55. @@ -974,6 +967,7 @@ int tftp_cmd_line_options(int argc, char
  56. { "tftp-timeout", 1, NULL, 'T'},
  57. { "mode", 1, NULL, 'M'},
  58. { "option", 1, NULL, 'O'},
  59. + { "retry", 1, NULL, 'R'},
  60. #if 1
  61. { "timeout", 1, NULL, 't'},
  62. { "blksize", 1, NULL, 'b'},
  63. @@ -993,11 +987,16 @@ int tftp_cmd_line_options(int argc, char
  64. };
  65. /* Support old argument until 0.8 */
  66. - while ((c = getopt_long(argc, argv, /*"gpl:r:Vh"*/ "gpl:r:Vht:b:sm",
  67. + while ((c = getopt_long(argc, argv, /*"gpl:r:Vh"*/ "gpl:r:Vht:b:smR:",
  68. options, &option_index)) != EOF)
  69. {
  70. switch (c)
  71. {
  72. + case 'R':
  73. + snprintf(string, sizeof(string), "option retry %s", optarg);
  74. + make_arg(string, &ac, &av);
  75. + process_cmd(ac, av);
  76. + break;
  77. case 'g':
  78. interactive = 0;
  79. if ((action == PUT) || (action == MGET))