wget-1.12-CVE-2010-2252.diff 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. diff -Naurp wget-1.12/doc/wget.texi wget-1.12.oden/doc/wget.texi
  2. --- wget-1.12/doc/wget.texi 2010-09-02 12:21:40.000000000 -0400
  3. +++ wget-1.12.oden/doc/wget.texi 2010-09-02 12:22:13.000000000 -0400
  4. @@ -1487,6 +1487,13 @@ This option is useful for some file-down
  5. @code{Content-Disposition} headers to describe what the name of a
  6. downloaded file should be.
  7. +@cindex Trust server names
  8. +@item --trust-server-names
  9. +
  10. +If this is set to on, on a redirect the last component of the
  11. +redirection URL will be used as the local file name. By default it is
  12. +used the last component in the original URL.
  13. +
  14. @cindex authentication
  15. @item --auth-no-challenge
  16. @@ -2799,6 +2806,10 @@ Set the connect timeout---the same as @s
  17. Turn on recognition of the (non-standard) @samp{Content-Disposition}
  18. HTTP header---if set to @samp{on}, the same as @samp{--content-disposition}.
  19. +@item trust_server_names = on/off
  20. +If set to on, use the last component of a redirection URL for the local
  21. +file name.
  22. +
  23. @item continue = on/off
  24. If set to on, force continuation of preexistent partially retrieved
  25. files. See @samp{-c} before setting it.
  26. diff -Naurp wget-1.12/src/http.c wget-1.12.oden/src/http.c
  27. --- wget-1.12/src/http.c 2010-09-02 12:21:40.000000000 -0400
  28. +++ wget-1.12.oden/src/http.c 2010-09-02 12:22:13.000000000 -0400
  29. @@ -2410,8 +2410,9 @@ File %s already there; not retrieving.\n
  30. /* The genuine HTTP loop! This is the part where the retrieval is
  31. retried, and retried, and retried, and... */
  32. uerr_t
  33. -http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
  34. - int *dt, struct url *proxy, struct iri *iri)
  35. +http_loop (struct url *u, struct url *original_url, char **newloc,
  36. + char **local_file, const char *referer, int *dt, struct url *proxy,
  37. + struct iri *iri)
  38. {
  39. int count;
  40. bool got_head = false; /* used for time-stamping and filename detection */
  41. @@ -2457,7 +2458,8 @@ http_loop (struct url *u, char **newloc,
  42. }
  43. else if (!opt.content_disposition)
  44. {
  45. - hstat.local_file = url_file_name (u);
  46. + hstat.local_file =
  47. + url_file_name (opt.trustservernames ? u : original_url);
  48. got_name = true;
  49. }
  50. @@ -2497,7 +2499,7 @@ File %s already there; not retrieving.\n
  51. /* Send preliminary HEAD request if -N is given and we have an existing
  52. * destination file. */
  53. - file_name = url_file_name (u);
  54. + file_name = url_file_name (opt.trustservernames ? u : original_url);
  55. if (opt.timestamping
  56. && !opt.content_disposition
  57. && file_exists_p (file_name))
  58. @@ -2852,9 +2854,9 @@ Remote file exists.\n\n"));
  59. /* Remember that we downloaded the file for later ".orig" code. */
  60. if (*dt & ADDED_HTML_EXTENSION)
  61. - downloaded_file(FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED, hstat.local_file);
  62. + downloaded_file (FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED, hstat.local_file);
  63. else
  64. - downloaded_file(FILE_DOWNLOADED_NORMALLY, hstat.local_file);
  65. + downloaded_file (FILE_DOWNLOADED_NORMALLY, hstat.local_file);
  66. ret = RETROK;
  67. goto exit;
  68. @@ -2885,9 +2887,9 @@ Remote file exists.\n\n"));
  69. /* Remember that we downloaded the file for later ".orig" code. */
  70. if (*dt & ADDED_HTML_EXTENSION)
  71. - downloaded_file(FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED, hstat.local_file);
  72. + downloaded_file (FILE_DOWNLOADED_AND_HTML_EXTENSION_ADDED, hstat.local_file);
  73. else
  74. - downloaded_file(FILE_DOWNLOADED_NORMALLY, hstat.local_file);
  75. + downloaded_file (FILE_DOWNLOADED_NORMALLY, hstat.local_file);
  76. ret = RETROK;
  77. goto exit;
  78. diff -Naurp wget-1.12/src/http.h wget-1.12.oden/src/http.h
  79. --- wget-1.12/src/http.h 2009-09-04 12:31:54.000000000 -0400
  80. +++ wget-1.12.oden/src/http.h 2010-09-02 12:22:13.000000000 -0400
  81. @@ -33,8 +33,8 @@ as that of the covered work. */
  82. struct url;
  83. -uerr_t http_loop (struct url *, char **, char **, const char *, int *,
  84. - struct url *, struct iri *);
  85. +uerr_t http_loop (struct url *, struct url *, char **, char **, const char *,
  86. + int *, struct url *, struct iri *);
  87. void save_cookies (void);
  88. void http_cleanup (void);
  89. time_t http_atotm (const char *);
  90. diff -Naurp wget-1.12/src/init.c wget-1.12.oden/src/init.c
  91. --- wget-1.12/src/init.c 2010-09-02 12:21:40.000000000 -0400
  92. +++ wget-1.12.oden/src/init.c 2010-09-02 12:22:13.000000000 -0400
  93. @@ -244,6 +244,7 @@ static const struct {
  94. { "timeout", NULL, cmd_spec_timeout },
  95. { "timestamping", &opt.timestamping, cmd_boolean },
  96. { "tries", &opt.ntry, cmd_number_inf },
  97. + { "trustservernames", &opt.trustservernames, cmd_boolean },
  98. { "useproxy", &opt.use_proxy, cmd_boolean },
  99. { "user", &opt.user, cmd_string },
  100. { "useragent", NULL, cmd_spec_useragent },
  101. diff -Naurp wget-1.12/src/main.c wget-1.12.oden/src/main.c
  102. --- wget-1.12/src/main.c 2010-09-02 12:21:40.000000000 -0400
  103. +++ wget-1.12.oden/src/main.c 2010-09-02 12:22:13.000000000 -0400
  104. @@ -268,6 +268,7 @@ static struct cmdline_option option_data
  105. { "timeout", 'T', OPT_VALUE, "timeout", -1 },
  106. { "timestamping", 'N', OPT_BOOLEAN, "timestamping", -1 },
  107. { "tries", 't', OPT_VALUE, "tries", -1 },
  108. + { "trust-server-names", 0, OPT_BOOLEAN, "trustservernames", -1 },
  109. { "user", 0, OPT_VALUE, "user", -1 },
  110. { "user-agent", 'U', OPT_VALUE, "useragent", -1 },
  111. { "verbose", 'v', OPT_BOOLEAN, "verbose", -1 },
  112. @@ -679,6 +680,8 @@ Recursive accept/reject:\n"),
  113. N_("\
  114. -I, --include-directories=LIST list of allowed directories.\n"),
  115. N_("\
  116. + --trust-server-names use the name specified by the redirection url last component.\n"),
  117. + N_("\
  118. -X, --exclude-directories=LIST list of excluded directories.\n"),
  119. N_("\
  120. -np, --no-parent don't ascend to the parent directory.\n"),
  121. diff -Naurp wget-1.12/src/options.h wget-1.12.oden/src/options.h
  122. --- wget-1.12/src/options.h 2010-09-02 12:21:40.000000000 -0400
  123. +++ wget-1.12.oden/src/options.h 2010-09-02 12:22:13.000000000 -0400
  124. @@ -243,6 +243,7 @@ struct options
  125. char *encoding_remote;
  126. char *locale;
  127. + bool trustservernames;
  128. #ifdef __VMS
  129. int ftp_stmlf; /* Force Stream_LF format for binary FTP. */
  130. #endif /* def __VMS */
  131. diff -Naurp wget-1.12/src/retr.c wget-1.12.oden/src/retr.c
  132. --- wget-1.12/src/retr.c 2009-09-04 12:31:54.000000000 -0400
  133. +++ wget-1.12.oden/src/retr.c 2010-09-02 12:22:13.000000000 -0400
  134. @@ -689,7 +689,8 @@ retrieve_url (struct url * orig_parsed,
  135. #endif
  136. || (proxy_url && proxy_url->scheme == SCHEME_HTTP))
  137. {
  138. - result = http_loop (u, &mynewloc, &local_file, refurl, dt, proxy_url, iri);
  139. + result = http_loop (u, orig_parsed, &mynewloc, &local_file, refurl, dt,
  140. + proxy_url, iri);
  141. }
  142. else if (u->scheme == SCHEME_FTP)
  143. {