wget.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. diff -urN wget-1.8.2/src/fnmatch.c wget-1.8.2_save/src/fnmatch.c
  2. --- wget-1.8.2/src/fnmatch.c Sat May 18 05:05:15 2002
  3. +++ wget-1.8.2_save/src/fnmatch.c Fri Oct 4 14:53:40 2002
  4. @@ -198,6 +198,17 @@
  5. return (FNM_NOMATCH);
  6. }
  7. +/* Return non-zero if S has a leading '/' or contains '../' */
  8. +int
  9. +has_invalid_name (const char *s)
  10. +{
  11. + if (*s == '/')
  12. + return 1;
  13. + if (strstr(s, "../") != 0)
  14. + return 1;
  15. + return 0;
  16. +}
  17. +
  18. /* Return non-zero if S contains globbing wildcards (`*', `?', `[' or
  19. `]'). */
  20. int
  21. diff -urN wget-1.8.2/src/ftp.c wget-1.8.2_save/src/ftp.c
  22. --- wget-1.8.2/src/ftp.c Sat May 18 05:05:16 2002
  23. +++ wget-1.8.2_save/src/ftp.c Fri Oct 4 15:07:22 2002
  24. @@ -1551,6 +1551,8 @@
  25. {
  26. struct fileinfo *orig, *start;
  27. uerr_t res;
  28. + struct fileinfo *f;
  29. +
  30. con->cmd |= LEAVE_PENDING;
  31. @@ -1562,8 +1564,7 @@
  32. opt.accepts and opt.rejects. */
  33. if (opt.accepts || opt.rejects)
  34. {
  35. - struct fileinfo *f = orig;
  36. -
  37. + f = orig;
  38. while (f)
  39. {
  40. if (f->type != FT_DIRECTORY && !acceptable (f->name))
  41. @@ -1575,6 +1576,18 @@
  42. f = f->next;
  43. }
  44. }
  45. + /* Remove all files with possible harmful names */
  46. + f = orig;
  47. + while (f)
  48. + {
  49. + if (has_invalid_name(f->name))
  50. + {
  51. + logprintf (LOG_VERBOSE, _("Rejecting `%s'.\n"), f->name);
  52. + f = delelement (f, &start);
  53. + }
  54. + else
  55. + f = f->next;
  56. + }
  57. /* Now weed out the files that do not match our globbing pattern.
  58. If we are dealing with a globbing pattern, that is. */
  59. if (*u->file && (action == GLOBALL || action == GETONE))
  60. --- wget-1.8.2/src/url.c.fpons 2002-09-04 16:16:52.000000000 +0200
  61. +++ wget-1.8.2/src/url.c 2002-09-04 16:32:14.000000000 +0200
  62. @@ -499,14 +499,18 @@
  63. int
  64. url_skip_uname (const char *url)
  65. {
  66. - const char *p;
  67. + const char *p, *pp;
  68. - /* Look for '@' that comes before '/' or '?'. */
  69. - p = (const char *)strpbrk (url, "/?@");
  70. - if (!p || *p != '@')
  71. - return 0;
  72. + /* Look for last '@' that comes before '/' or '?'. */
  73. + pp = url;
  74. + while ((p = (const char *)strpbrk (pp, "/?@")) != NULL) {
  75. + if (*p != '@')
  76. + break;
  77. + /* Found '@' character so go on with possible next '@'. */
  78. + pp = p + 1;
  79. + }
  80. - return p - url + 1;
  81. + return pp != url ? pp - url: 0;
  82. }
  83. static int