~ubuntu-branches/ubuntu/precise/wget/precise-proposed

« back to all changes in this revision

Viewing changes to debian/patches/CVE-2010-2252

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-10-19 00:00:09 UTC
  • mfrom: (2.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20111019000009-8p33w3wz4b1rdri0
Tags: 1.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add wget-udeb to ship wget.gnu as alternative to busybox wget
    implementation.
  - Depend on libssl-dev 0.9.8k-7ubuntu4 (LP: #503339)
* Dropped changes, superseded in Debian:
  - Keep build dependencies in main:
    + debian/control: remove info2man build-dep
    + debian/patches/series: disable wget-infopod_generated_manpage
  - Mark wget Multi-Arch: foreign, so packages that aren't of the same arch
    can depend on it.
* Pass --with-ssl=openssl; we don't want to use gnutls, there's no udeb for
  it.
* Add a second build pass for the udeb, so we can build without libidn.

Show diffs side-by-side

added added

removed removed

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