2 changed files with 54 additions and 61 deletions
@ -1,89 +1,82 @@
|
||||
diff -urN wget-1.8.2/src/fnmatch.c wget-1.8.2_save/src/fnmatch.c
|
||||
--- wget-1.8.2/src/fnmatch.c Sat May 18 05:05:15 2002
|
||||
+++ wget-1.8.2_save/src/fnmatch.c Fri Oct 4 14:53:40 2002
|
||||
@@ -198,6 +198,17 @@
|
||||
return (FNM_NOMATCH);
|
||||
}
|
||||
--- src/fnmatch.c.orig 2002/05/18 03:05:15 1.2.2.1
|
||||
+++ src/fnmatch.c 2003/01/11 19:53:31 1.2.2.2
|
||||
@@ -35,6 +35,11 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include "wget.h"
|
||||
+#ifdef HAVE_STRING_H
|
||||
+# include <string.h>
|
||||
+#else
|
||||
+# include <strings.h>
|
||||
+#endif /* HAVE_STRING_H */
|
||||
#include "fnmatch.h"
|
||||
|
||||
/* Match STRING against the filename pattern PATTERN, returning zero
|
||||
@@ -196,6 +201,19 @@
|
||||
return (0);
|
||||
|
||||
return (FNM_NOMATCH);
|
||||
+}
|
||||
+
|
||||
+/* Return non-zero if S has a leading '/' or contains '../' */
|
||||
+int
|
||||
+has_invalid_name (const char *s)
|
||||
+has_insecure_name_p (const char *s)
|
||||
+{
|
||||
+ if (*s == '/')
|
||||
+ return 1;
|
||||
+ if (strstr(s, "../") != 0)
|
||||
+ return 1;
|
||||
+ return 0;
|
||||
+}
|
||||
+ if (*s == '/')
|
||||
+ return 1;
|
||||
+
|
||||
+ if (strstr(s, "../") != 0)
|
||||
+ return 1;
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
/* Return non-zero if S contains globbing wildcards (`*', `?', `[' or
|
||||
`]'). */
|
||||
int
|
||||
diff -urN wget-1.8.2/src/ftp.c wget-1.8.2_save/src/ftp.c
|
||||
--- wget-1.8.2/src/ftp.c Sat May 18 05:05:16 2002
|
||||
+++ wget-1.8.2_save/src/ftp.c Fri Oct 4 15:07:22 2002
|
||||
@@ -1551,6 +1551,8 @@
|
||||
--- src/ftp.c.orig 2002/05/18 03:05:16 1.52.2.1
|
||||
+++ src/ftp.c 2003/01/11 19:53:31 1.52.2.2
|
||||
@@ -1549,7 +1549,7 @@
|
||||
static uerr_t
|
||||
ftp_retrieve_glob (struct url *u, ccon *con, int action)
|
||||
{
|
||||
struct fileinfo *orig, *start;
|
||||
- struct fileinfo *orig, *start;
|
||||
+ struct fileinfo *f, *orig, *start;
|
||||
uerr_t res;
|
||||
+ struct fileinfo *f;
|
||||
+
|
||||
|
||||
con->cmd |= LEAVE_PENDING;
|
||||
|
||||
@@ -1562,8 +1564,7 @@
|
||||
@@ -1562,8 +1562,7 @@
|
||||
opt.accepts and opt.rejects. */
|
||||
if (opt.accepts || opt.rejects)
|
||||
{
|
||||
- struct fileinfo *f = orig;
|
||||
-
|
||||
+ f = orig;
|
||||
+ f = orig;
|
||||
while (f)
|
||||
{
|
||||
if (f->type != FT_DIRECTORY && !acceptable (f->name))
|
||||
@@ -1575,6 +1576,18 @@
|
||||
@@ -1575,13 +1574,25 @@
|
||||
f = f->next;
|
||||
}
|
||||
}
|
||||
+ /* Remove all files with possible harmful names */
|
||||
+ f = orig;
|
||||
+ while (f)
|
||||
+ {
|
||||
+ if (has_invalid_name(f->name))
|
||||
+ {
|
||||
+ {
|
||||
+ if (has_insecure_name_p(f->name))
|
||||
+ {
|
||||
+ logprintf (LOG_VERBOSE, _("Rejecting `%s'.\n"), f->name);
|
||||
+ f = delelement (f, &start);
|
||||
+ }
|
||||
+ else
|
||||
+ f = f->next;
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ f = f->next;
|
||||
+ }
|
||||
/* Now weed out the files that do not match our globbing pattern.
|
||||
If we are dealing with a globbing pattern, that is. */
|
||||
if (*u->file && (action == GLOBALL || action == GETONE))
|
||||
--- wget-1.8.2/src/url.c.fpons 2002-09-04 16:16:52.000000000 +0200
|
||||
+++ wget-1.8.2/src/url.c 2002-09-04 16:32:14.000000000 +0200
|
||||
@@ -499,14 +499,18 @@
|
||||
int
|
||||
url_skip_uname (const char *url)
|
||||
{
|
||||
- const char *p;
|
||||
+ const char *p, *pp;
|
||||
|
||||
- /* Look for '@' that comes before '/' or '?'. */
|
||||
- p = (const char *)strpbrk (url, "/?@");
|
||||
- if (!p || *p != '@')
|
||||
- return 0;
|
||||
+ /* Look for last '@' that comes before '/' or '?'. */
|
||||
+ pp = url;
|
||||
+ while ((p = (const char *)strpbrk (pp, "/?@")) != NULL) {
|
||||
+ if (*p != '@')
|
||||
+ break;
|
||||
+ /* Found '@' character so go on with possible next '@'. */
|
||||
+ pp = p + 1;
|
||||
+ }
|
||||
|
||||
- return p - url + 1;
|
||||
+ return pp != url ? pp - url: 0;
|
||||
}
|
||||
{
|
||||
int matchres = 0;
|
||||
- struct fileinfo *f = start;
|
||||
|
||||
static int
|
||||
+ f = start;
|
||||
while (f)
|
||||
{
|
||||
matchres = fnmatch (u->file, f->name, 0);
|
||||
|
||||
Loading…
Reference in new issue