Initail import package wget: A utility for retrieving files using the HTTP or FTP...
[external/wget.git] / packaging / wget-1.12-CVE-2010-2252.patch
1 diff -rupN wget-1.12.orig//doc/wget.texi wget-1.12//doc/wget.texi
2 --- wget-1.12.orig//doc/wget.texi       2009-09-05 05:22:04.000000000 +0800
3 +++ wget-1.12//doc/wget.texi    2010-10-12 23:26:37.554569261 +0800
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  
8 +@cindex Trust server names
9 +@item --trust-server-names
10 +
11 +If this is set to on, on a redirect the last component of the
12 +redirection URL will be used as the local file name.  By default it is
13 +used the last component in the original URL.
14 +
15  @cindex authentication
16  @item --auth-no-challenge
17  
18 @@ -2799,6 +2806,10 @@ Set the connect timeout---the same as @s
19  Turn on recognition of the (non-standard) @samp{Content-Disposition}
20  HTTP header---if set to @samp{on}, the same as @samp{--content-disposition}.
21  
22 +@item trust_server_names = on/off
23 +If set to on, use the last component of a redirection URL for the local
24 +file name.
25 +
26  @item continue = on/off
27  If set to on, force continuation of preexistent partially retrieved
28  files.  See @samp{-c} before setting it.
29 diff -rupN wget-1.12.orig//NEWS wget-1.12//NEWS
30 --- wget-1.12.orig//NEWS        2009-09-22 10:53:35.000000000 +0800
31 +++ wget-1.12//NEWS     2010-10-12 23:24:57.746064253 +0800
32 @@ -5,6 +5,10 @@ Copyright (C) 1997, 1998, 1999, 2000, 20
33  See the end for copying conditions.
34  
35  Please send GNU Wget bug reports to <bug-wget@gnu.org>.
36 +
37 +** By default, on server redirects, use the original URL to get the
38 +   local file name. Close CVE-2010-2252.
39 +
40  \f
41  * Changes in Wget 1.12
42  
43 diff -rupN wget-1.12.orig//src/ChangeLog wget-1.12//src/ChangeLog
44 --- wget-1.12.orig//src/ChangeLog       2009-09-22 23:35:54.000000000 +0800
45 +++ wget-1.12//src/ChangeLog    2010-10-12 23:29:36.266568685 +0800
46 @@ -1,3 +1,20 @@
47 +2010-07-28  Giuseppe Scrivano  <gscrivano@gnu.org>
48 +
49 +       * http.h (http_loop): Add new argument `original_url'
50 +       * http.c (http_loop): Add new argument `original_url'.  Use
51 +       `original_url' to get a filename if `trustservernames' is false.
52 +
53 +       * init.c (commands): Add "trustservernames".
54 +
55 +       * options.h (library): Add variable `trustservernames'.
56 +
57 +       * main.c (option_data): Add trust-server-names.
58 +       (print_help): Describe --trust-server-names.
59 +
60 +       * retr.c (retrieve_url): Pass new argument to `http_loop'.
61 +
62 +       * Patched code merged by Jian-feng Ding <jian-feng.ding@intel.com>
63 +
64  2009-09-22  Micah Cowan  <micah@cowan.name>
65  
66         * openssl.c (ssl_check_certificate): Avoid reusing the same buffer
67 diff -rupN wget-1.12.orig//src/http.c wget-1.12//src/http.c
68 --- wget-1.12.orig//src/http.c  2009-09-22 11:02:18.000000000 +0800
69 +++ wget-1.12//src/http.c       2010-10-12 23:36:45.882569196 +0800
70 @@ -2410,8 +2410,9 @@ File %s already there; not retrieving.\n
71  /* The genuine HTTP loop!  This is the part where the retrieval is
72     retried, and retried, and retried, and...  */
73  uerr_t
74 -http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
75 -           int *dt, struct url *proxy, struct iri *iri)
76 +http_loop (struct url *u, struct url *original_url, char **newloc,
77 +           char **local_file, const char *referer, int *dt, struct url *proxy,
78 +           struct iri *iri)
79  {
80    int count;
81    bool got_head = false;         /* used for time-stamping and filename detection */
82 @@ -2457,7 +2458,8 @@ http_loop (struct url *u, char **newloc,
83      }
84    else if (!opt.content_disposition)
85      {
86 -      hstat.local_file = url_file_name (u);
87 +      hstat.local_file =
88 +        url_file_name (opt.trustservernames ? u : original_url);
89        got_name = true;
90      }
91  
92 @@ -2497,7 +2499,7 @@ File %s already there; not retrieving.\n
93  
94    /* Send preliminary HEAD request if -N is given and we have an existing
95     * destination file. */
96 -  file_name = url_file_name (u);
97 +  file_name = url_file_name (opt.trustservernames ? u : original_url);
98    if (opt.timestamping
99        && !opt.content_disposition
100        && file_exists_p (file_name))
101 diff -rupN wget-1.12.orig//src/http.h wget-1.12//src/http.h
102 --- wget-1.12.orig//src/http.h  2009-09-05 00:31:54.000000000 +0800
103 +++ wget-1.12//src/http.h       2010-10-12 23:38:06.098870920 +0800
104 @@ -33,8 +33,8 @@ as that of the covered work.  */
105  
106  struct url;
107  
108 -uerr_t http_loop (struct url *, char **, char **, const char *, int *,
109 -                 struct url *, struct iri *);
110 +uerr_t http_loop (struct url *, struct url *, char **, char **, const char *,
111 +                  int *, struct url *, struct iri *);
112  void save_cookies (void);
113  void http_cleanup (void);
114  time_t http_atotm (const char *);
115 diff -rupN wget-1.12.orig//src/init.c wget-1.12//src/init.c
116 --- wget-1.12.orig//src/init.c  2009-09-22 11:02:41.000000000 +0800
117 +++ wget-1.12//src/init.c       2010-10-12 23:38:43.781575846 +0800
118 @@ -243,6 +243,7 @@ static const struct {
119    { "timeout",          NULL,                   cmd_spec_timeout },
120    { "timestamping",     &opt.timestamping,      cmd_boolean },
121    { "tries",            &opt.ntry,              cmd_number_inf },
122 +  { "trustservernames", &opt.trustservernames,  cmd_boolean },
123    { "useproxy",         &opt.use_proxy,         cmd_boolean },
124    { "user",             &opt.user,              cmd_string },
125    { "useragent",        NULL,                   cmd_spec_useragent },
126 diff -rupN wget-1.12.orig//src/main.c wget-1.12//src/main.c
127 --- wget-1.12.orig//src/main.c  2009-09-22 11:03:11.000000000 +0800
128 +++ wget-1.12//src/main.c       2010-10-12 23:40:56.793873677 +0800
129 @@ -266,6 +266,7 @@ static struct cmdline_option option_data
130      { "timeout", 'T', OPT_VALUE, "timeout", -1 },
131      { "timestamping", 'N', OPT_BOOLEAN, "timestamping", -1 },
132      { "tries", 't', OPT_VALUE, "tries", -1 },
133 +    { "trust-server-names", 0, OPT_BOOLEAN, "trustservernames", -1 },
134      { "user", 0, OPT_VALUE, "user", -1 },
135      { "user-agent", 'U', OPT_VALUE, "useragent", -1 },
136      { "verbose", 'v', OPT_BOOLEAN, "verbose", -1 },
137 @@ -677,6 +678,8 @@ Recursive accept/reject:\n"),
138      N_("\
139    -X,  --exclude-directories=LIST  list of excluded directories.\n"),
140      N_("\
141 +  --trust-server-names  use the name specified by the redirection url last component.\n"),
142 +    N_("\
143    -np, --no-parent                 don't ascend to the parent directory.\n"),
144      "\n",
145  
146 diff -rupN wget-1.12.orig//src/options.h wget-1.12//src/options.h
147 --- wget-1.12.orig//src/options.h       2009-09-22 11:03:47.000000000 +0800
148 +++ wget-1.12//src/options.h    2010-10-12 23:41:12.098201815 +0800
149 @@ -242,6 +242,7 @@ struct options
150    char *encoding_remote;
151    char *locale;
152  
153 +  bool trustservernames;
154  #ifdef __VMS
155    int ftp_stmlf;                /* Force Stream_LF format for binary FTP. */
156  #endif /* def __VMS */
157 diff -rupN wget-1.12.orig//src/retr.c wget-1.12//src/retr.c
158 --- wget-1.12.orig//src/retr.c  2009-09-05 00:31:54.000000000 +0800
159 +++ wget-1.12//src/retr.c       2010-10-12 23:42:03.433569219 +0800
160 @@ -689,7 +689,8 @@ retrieve_url (struct url * orig_parsed,
161  #endif
162        || (proxy_url && proxy_url->scheme == SCHEME_HTTP))
163      {
164 -      result = http_loop (u, &mynewloc, &local_file, refurl, dt, proxy_url, iri);
165 +      result = http_loop (u, orig_parsed, &mynewloc, &local_file, refurl, dt,
166 +                          proxy_url, iri);
167      }
168    else if (u->scheme == SCHEME_FTP)
169      {