37 Commits

Author SHA1 Message Date
Darshit Shah
a220ead435 * NEWS: Update NEWS for new release 2019-04-05 11:59:19 +02:00
Tim Ruehsen
692d5c5215 Fix a buffer overflow vulnerability
* src/iri.c(do_conversion): Reallocate the output buffer to a larger
  size if it is already full
2019-04-05 11:54:30 +02:00
Darshit Shah
2ae601a719 * NEWS: Update NEWS for new release 2019-04-05 11:54:30 +02:00
Tim Rühsen
0eaa5f1771 * src/openssl.c (ssl_init): Check for X509_V_FLAG_PARTIAL_CHAIN 2019-04-03 14:54:45 +02:00
Darshit Shah
39f17b3555 * gnulib: Pull forward 2019-04-01 20:15:05 +02:00
Tim Rühsen
4c89c85a28 * fuzz/main.c (test_all_from): Fix indentation 2019-03-26 09:42:50 +01:00
Tim Rühsen
5d87635c66 Fix corner case in processing server response
* src/http.c (response_head_terminator): Don't access uninitialized data
* fuzz/wget_read_hunk_fuzzer.c: Sync response_head_terminator()
2019-03-25 16:05:56 +01:00
Tim Rühsen
4046cd2a71 Add new fuzzer wget_read_hunk_fuzzer.c
* fuzz/Makefile.am: Add wget_read_hunk_fuzzer
* fuzz/wget_read_hunk_fuzzer.c: New file
* fuzz/wget_read_hunk_fuzzer.in/*: Fuzz corpora
* src/connect.c: Add connect_cleanup()
* src/connect.h: Add prototype for connect_cleanup()
2019-03-25 14:57:07 +01:00
Tim Rühsen
ae6636a28f * fuzz/wget_netrc_fuzzer.c: Fix fuzzer 2019-03-03 17:05:58 +01:00
Tim Rühsen
acef0fb4c6 * fuzz/wget_ftpls_fuzzer.c: Fix fuzzer 2019-03-03 17:05:44 +01:00
Jeffrey Walton
7c1c8eb3b1 * src/openssl.c (ssl_init): Trust partial cert chain 2019-02-22 12:46:53 +01:00
Tim Rühsen
19661f1d9a * src/ftp-ls.c (ftp_parse_vms_ls): Use snprintf instead of strcpy/strcat 2019-02-20 10:32:47 +01:00
Darshit Shah
e39be32838 * src/html-url.c(get_urls_html_fm): Add message in verbose mode with no-follow attribute 2019-02-19 23:25:05 +01:00
Tim Rühsen
8d8abcffdf Fix fuzz/ tests for OpenBSD
* fuzz/wget_*_fuzzer.c: Take care when calling exit()
2019-02-19 17:18:49 +01:00
Tim Rühsen
93d21e4217 * fuzz/Makefile.am: Remove hard-coded gcc flags 2019-02-19 15:52:58 +01:00
Tim Rühsen
07f9fbd0b3 Fix STDERR closing/restoring in fuzzers
* fuzz/fuzzer.h: Add CLOSE_STDERR and RESTORE_STDERR
* fuzz/wget_*_fuzzer.c: Use CLOSE_STDERR and RESTORE_STDERR
2019-02-19 15:50:34 +01:00
Tim Rühsen
74866d9ea0 * configure.ac: Rearrange AM_ICONV before gl_INIT 2019-02-19 15:49:41 +01:00
Tim Rühsen
1098de2b49 Do not hard-code -ldl in fuzz/Makefile.am
* configure.ac: Search for dlopen and add library to $FUZZ_LIBS
* fuzz/Makefile.am: Link with $FUZZ_LIBS instead of -ldl

This fixes linking on BSD systems.

Reported-by: Nam Nguyen
2019-02-19 15:11:04 +01:00
Tim Rühsen
c7f31d62b2 * doc/wget.texi: Correct --logfile -> --output-file 2019-02-14 10:39:54 +01:00
Darshit Shah
c53552e8cd Update gnulib 2019-02-10 11:51:03 +01:00
Darshit Shah
8b975e83d3 Update copyright statements 2019-02-10 11:50:17 +01:00
Leon Klingele
9e7c1554bd docs: --no-cache also sets the 'Cache-Control: no-cache' header
* doc/wget.texi: Add Cache-Control to docs
* src/wget.h: Add Cache-Control to comment of SEND_NOCACHE

Copyright-paperwork-exempt: Yes
2019-01-23 22:04:01 +01:00
Tim Rühsen
caf30fbe28 * .gitlab-ci.yml: Add minimal build 2019-01-20 19:58:10 +01:00
Tim Rühsen
f1eda916a6 * src/init.c (cleanup): Check HAVE_HSTS
Reported-by: Simon Dales
2019-01-20 19:42:53 +01:00
André Wolski
5dceb6626b NTLM restart authentication (trivial change)
* src/http-ntlm.c (ntlm_input): Continue on NTLMSTATE_LAST,
  error on NTLMSTATE_TYPE3

The code comes from the cURL project. Thanks to Daniel Stenberg
for donating the code.

https://lists.gnu.org/archive/html/bug-wget/2018-12/msg00030.html
2018-12-31 10:24:27 +01:00
Tim Rühsen
fc65b4521a * contrib/spell-checker: Remove trailing whitespace 2018-12-28 19:05:42 +01:00
Tim Rühsen
fdb7fe613c Fix typos detected by codespell (via contrib/spell-checker) 2018-12-28 18:58:15 +01:00
Tim Rühsen
c0427ebf3c * contrib/spell-checker: Add script for spell checking 2018-12-28 18:55:20 +01:00
Tim Rühsen
af16b0f38f * fuzz/Makefile.am: Fix order of libraries for linking 2018-12-27 20:48:36 +01:00
Tim Rühsen
6ba1cb587c * src/wget.h: #undef _Noreturn when building with C++ 2018-12-27 20:47:58 +01:00
Tim Rühsen
5811c2222b * src/gnutls.c (ssl_connect_wget): Fix call to gnutls_set_default_priority() 2018-12-27 20:46:55 +01:00
Tim Rühsen
70cddf3e29 * NEWS: Add release changes for 1.20.1 2018-12-26 20:35:41 +01:00
Tim Rühsen
3cdfb594cf Don't save user/pw with --xattr
Also the Referer info is reduced to scheme+host+port.

* src/ftp.c (getftp): Change params of set_file_metadata()
* src/http.c (gethttp): Change params of set_file_metadata()
* src/xattr.c (set_file_metadata): Remove user/password from origin URL,
  reduce Referer value to scheme/host/port.
* src/xattr.h: Change prototype of set_file_metadata()
2018-12-26 14:38:24 +01:00
Tim Rühsen
c125d24762 Don't use extended attributes (--xattr) by default
* src/init.c (defaults): Set enable_xattr to false by default
* src/main.c (print_help): Reverse option logic of --xattr
* doc/wget.texi: Add description for --xattr

Users may not be aware that the origin URL and Referer are saved
including credentials, and possibly access tokens within
the urls.
2018-12-26 14:06:38 +01:00
Tim Rühsen
7c0a30d724 * .travis.yml: Email to wget-dev instead bug-wget mailing list 2018-12-13 15:22:17 +01:00
Darshit Shah
3becef17cb * NEWS: Prepare for new version 2018-11-30 01:11:19 +01:00
Darshit Shah
8f780fa274 * contrib/make-release: Add a small checklist for pending tasks 2018-11-13 17:44:51 +01:00
292 changed files with 840 additions and 266 deletions

View File

@@ -111,6 +111,32 @@ GnuTLS/Debian:
- tests/*.log
- testenv/*.log
Minimal/Debian:
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$DEBIAN_BUILD
script:
- cp -a /builds/common/gnulib .
- export CFLAGS=$CFLAGS_DEFAULT
- ./bootstrap --skip-po
- ./configure $CONFIGURE_BASE_FLAGS --cache-file ../cache/config.cache
--disable-nls --without-ssl --enable-ipv6 --without-zlib --without-libiconv-prefix
--disable-iri --disable-ntlm --disable-pcre --without-libpsl --without-libuuid
--without-libintl-prefix
- make -j$(nproc)
- make -j$(nproc) check
- make check-valgrind
tags:
- shared
- docker
artifacts:
expire_in: 2 weeks
when: on_failure
paths:
- ./*.log
- fuzz/*.log
- tests/*.log
- testenv/*.log
#Centos7 build:
# image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD
# script:

View File

@@ -10,7 +10,7 @@ notifications:
email:
recipients:
- darnir@gmail.com
- bug-wget@gnu.org
- wget-dev@gnu.org
on_success: change
on_failure: always

View File

@@ -1,6 +1,5 @@
# Makefile for `Wget' utility
# Copyright (C) 1995-1997, 2006-2018 Free Software Foundation,
# Inc.
# Copyright (C) 1995-1997, 2006-2019 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

23
NEWS
View File

@@ -1,10 +1,31 @@
GNU Wget NEWS -- history of user-visible changes.
Copyright (C) 1997-2018 Free Software Foundation, Inc.
Copyright (C) 1997-2019 Free Software Foundation, Inc.
See the end for copying conditions.
Please send GNU Wget bug reports to <bug-wget@gnu.org>.
* Changes in Wget 1.20.3
** Fixed a buffer overflow vulnerability
* Changes in Wget 1.20.2
** NTLM authentication will retry under certain cases
* Changes in Wget 1.20.1
** --xattr is no longer default since it introduces privacy issues.
** --xattr saves the Referer as scheme/host/port, user/pw/path/query/fragment
are no longer saved to prevent privacy issues.
** --xattr saves the Original URL without user/password to prevent
privacy issues.
* Changes in Wget 1.20
** Add new option `--retry-on-host-error` to treat local errors as transient

View File

@@ -161,8 +161,8 @@ Testing and development
that bug, which might be tedious. Tests should only be run through GDB for that purpose.
Copyright (C) 2008, 2010, 2014-2015, 2018 Free Software Foundation,
Inc.
Copyright (C) 2008, 2010, 2014-2015, 2018-2019 Free Software
Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<https://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.

View File

@@ -4,7 +4,7 @@ scriptversion=2018-10-13.05; # UTC
# Bootstrap this package from checked-out sources.
# Copyright (C) 2003-2018 Free Software Foundation, Inc.
# Copyright (C) 2003-2019 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
# bootstrap.conf - Bootstrap configuration.
# Copyright (C) 2007-2012, 2018 Free Software Foundation, Inc.
# Copyright (C) 2007-2012, 2018-2019 Free Software Foundation, Inc.
#
# This file is part of GNU Wget.
#

View File

@@ -2,7 +2,7 @@
# Generate build_info.c.
# Copyright (C) 2009-2011, 2018 Free Software Foundation, Inc.
# Copyright (C) 2009-2011, 2018-2019 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
dnl Template file for GNU Autoconf
dnl Copyright (C) 1995-1997, 2001, 2007-2014, 2018 Free Software
dnl Copyright (C) 1995-1997, 2001, 2007-2014, 2018-2019 Free Software
dnl Foundation, Inc.
dnl This program is free software; you can redistribute it and/or modify
@@ -51,7 +51,7 @@ dnl
AM_INIT_AUTOMAKE([1.9])
dnl
dnl Get cannonical host
dnl Get canonical host
dnl
AC_CANONICAL_HOST
AC_DEFINE_UNQUOTED([OS_TYPE], "$host_os",
@@ -103,6 +103,15 @@ AC_ARG_ENABLE([fuzzing],
#AC_SUBST([FUZZ_LIBS])
AM_CONDITIONAL([FUZZING], [test "$enable_fuzzing" = "yes"])
dnl needed for some fuzzers
OLD_LIBS="$LIBS"
AC_SEARCH_LIBS([dlopen], [dl dld])
if [[ "${ac_cv_search_dlopen#-l}" != "${ac_cv_search_dlopen}" ]]; then
FUZZ_LIBS="${ac_cv_search_dlopen}"
AC_SUBST([FUZZ_LIBS])
fi
LIBS="$OLD_LIBS"
dnl Opie: Support for opie s/key FTP logins
AC_ARG_ENABLE([opie],
[AS_HELP_STRING([--disable-opie], [disable support for opie or s/key FTP login])],
@@ -281,7 +290,8 @@ AC_CHECK_TYPES(sig_atomic_t, [], [], [
#include <signal.h>
])
# gnulib
# gnulib, AM_ICONV should be placed before gl_INIT
AM_ICONV
gl_INIT
dnl
@@ -618,8 +628,6 @@ AC_ARG_ENABLE(iri,
)
AS_IF([test "X$iri" != "Xno"],[
AM_ICONV
if test "X$am_cv_func_iconv" != "Xyes"; then
iri=no
if test "X$force_iri" = "Xyes"; then

View File

@@ -102,7 +102,14 @@ echo ""
build-aux/announce-gen --release-type "$REL_TYPE" --package-name "$APP_LOWER" --previous-version="$PREV_VER" --current-version "$CUR_VER" --gpg-key-id="$GPG_KEY" --url-directory "https://${REL_LOC}/gnu/${APP_LOWER}" --news=NEWS > "$APP_NAME-$APP_VER.announce"
echo ""
echo "Announce email template placed at $APP_NAME-$APP_VER.announce"
echo "Remaining Release Checklist:
1. Send a mail to coordinator@translationproject.org with the subject
\"Requesting Translations for $APP_NAME-$APP_VER.POT\"
2. Announce email template placed at $APP_NAME-$APP_VER.announce.
Send an announce mail to info-gnu@gnu.org
"
echo ""
prev_tag=$(git tag | tail -2 | head -1)
echo ""

9
contrib/spell-checker Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env sh
#
# see https://github.com/codespell-project/codespell
#
# in short:
# - pip install codespell
# - add ~/.local/bin to PATH
codespell $* -L "tim,gonna,cas,tage,lightening,wither" `git ls-files|egrep -v '_fuzzer.in|_fuzzer.repro|\.der$|gnulib|ChangeLog'`

View File

@@ -1,5 +1,5 @@
# Makefile for `wget' utility
# Copyright (C) 1995-1997, 2007-2011, 2015, 2018 Free Software
# Copyright (C) 1995-1997, 2007-2011, 2015, 2018-2019 Free Software
# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify

View File

@@ -5,8 +5,8 @@
@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2000-2002, 2007-2008, 2015, 2018 Free Software
Foundation, Inc.
Copyright @copyright{} 2000-2002, 2007-2008, 2015, 2018-2019 Free
Software Foundation, Inc.
@uref{http://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies

View File

@@ -106,7 +106,7 @@ found unsafe too, the file is not downloaded.
See [1 #section-1.1].
cat > bugus.meta4 << EOF
cat > bogus.meta4 << EOF
<?xml version="1.0" encoding="UTF-8"?>
<metalink xmlns="urn:ietf:params:xml:ns:metalink">
<file name="/dir/A/File1">

View File

@@ -1,6 +1,6 @@
#! /usr/bin/env perl
# Copyright (C) 1999-2001, 2003, 2007, 2009-2011, 2015, 2018 Free
# Copyright (C) 1999-2001, 2003, 2007, 2009-2011, 2015, 2018-2019 Free
# Software Foundation, Inc.
# This file is part of GCC.

View File

@@ -31,8 +31,8 @@ This file documents the GNU Wget utility for downloading network
data.
@c man begin COPYRIGHT
Copyright @copyright{} 1996-2011, 2015, 2018 Free Software Foundation,
Inc.
Copyright @copyright{} 1996-2011, 2015, 2018-2019 Free Software
Foundation, Inc.
@iftex
Permission is granted to make and distribute verbatim copies of
@@ -540,6 +540,14 @@ right NUMBER.
Set preferred location for Metalink resources. This has effect if multiple
resources with same priority are available.
@cindex xattr
@item --xattr
Enable use of file system's extended attributes to save the
original URL and the Referer HTTP header value if used.
Be aware that the URL might contain private information like
access tokens or credentials.
@cindex force html
@item -F
@@ -855,7 +863,7 @@ files. In such a case, wget could simply be invoked with this parameter to get
a much cleaner output on the screen.
This option will also force the progress bar to be printed to @file{stderr} when
used alongside the @samp{--logfile} option.
used alongside the @samp{--output-file} option.
@item -N
@itemx --timestamping
@@ -1394,10 +1402,10 @@ to the inability of server-side scripts to cope with the connections.
@cindex cache
@item --no-cache
Disable server-side cache. In this case, Wget will send the remote
server an appropriate directive (@samp{Pragma: no-cache}) to get the
file from the remote service, rather than returning the cached version.
This is especially useful for retrieving and flushing out-of-date
documents on proxy servers.
server appropriate directives (@samp{Cache-Control: no-cache} and
@samp{Pragma: no-cache}) to get the file from the remote service,
rather than returning the cached version. This is especially useful
for retrieving and flushing out-of-date documents on proxy servers.
Caching is allowed by default.
@@ -1809,7 +1817,7 @@ Set the cipher list string. Typically this string sets the
cipher suites and other SSL/TLS options that the user wish should be used, in a
set order of preference (GnuTLS calls it 'priority string'). This string
will be fed verbatim to the SSL/TLS engine (OpenSSL or GnuTLS) and hence
its format and syntax is dependant on that. Wget will not process or manipulate it
its format and syntax is dependent on that. Wget will not process or manipulate it
in any way. Refer to the OpenSSL or GnuTLS documentation for more information.
@cindex SSL certificate, check
@@ -1997,7 +2005,7 @@ the same time over the HSTS database. Before dumping the updated HSTS entries
on the file, Wget will re-read it and merge the changes.
Using a custom HSTS database and/or modifying an existing one is discouraged.
For more information about the potential security threats arised from such practice,
For more information about the potential security threats arose from such practice,
see section 14 "Security Considerations" of RFC 6797, specially section 14.9
"Creative Manipulation of HSTS Policy Store".
@end table
@@ -4190,7 +4198,7 @@ from the debug log before sending it to the bug address. The
@code{-d} won't go out of its way to collect sensitive information,
but the log @emph{will} contain a fairly complete transcript of Wget's
communication with the server, which may include passwords and pieces
of downloaded data. Since the bug address is publically archived, you
of downloaded data. Since the bug address is publicly archived, you
may assume that all bug reports are visible to the public.
@item
@@ -4439,7 +4447,7 @@ Tomislav Petrović, Mario Mikočević---many bug reports and
suggestions.
@item
François Pinard---many thorough bug reports and discussions.
Françis Pinard---many thorough bug reports and discussions.
@item
Karl Eichwalder---lots of help with internationalization, Makefile

View File

@@ -1,4 +1,4 @@
AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS) -Wno-unused-parameter -Wno-pedantic
AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS)
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir) -I$(top_builddir)/lib -I$(top_srcdir)/lib \
-DSRCDIR=\"$(abs_srcdir)\"
LDADD = ../lib/libgnu.a \
@@ -6,7 +6,7 @@ LDADD = ../lib/libgnu.a \
$(LIBSOCKET) $(LIB_CLOCK_GETTIME) $(LIB_CRYPTO) $(LIB_GETLOGIN) $(LIB_NANOSLEEP) $(LIB_POLL) \
$(LIB_POSIX_SPAWN) $(LIB_PTHREAD_SIGMASK) $(LIB_SELECT) $(LIBICONV) $(LIBINTL) \
$(LIBMULTITHREAD) $(LIBTHREAD) $(SERVENT_LIB) @INTL_MACOSX_LIBS@ \
-ldl
$(FUZZ_LIBS)
WGET_TESTS = \
wget_css_fuzzer$(EXEEXT) \
@@ -16,7 +16,8 @@ WGET_TESTS = \
wget_netrc_fuzzer$(EXEEXT) \
wget_options_fuzzer$(EXEEXT) \
wget_robots_fuzzer$(EXEEXT) \
wget_url_fuzzer$(EXEEXT)
wget_url_fuzzer$(EXEEXT) \
wget_read_hunk_fuzzer$(EXEEXT)
if FUZZING
bin_PROGRAMS = $(WGET_TESTS)
@@ -60,6 +61,9 @@ wget_robots_fuzzer_LDADD = ../src/libunittest.a $(LDADD)
wget_url_fuzzer_SOURCES = wget_url_fuzzer.c $(MAIN)
wget_url_fuzzer_LDADD = ../src/libunittest.a $(LDADD)
wget_read_hunk_fuzzer_SOURCES = wget_read_hunk_fuzzer.c $(MAIN)
wget_read_hunk_fuzzer_LDADD = ../src/libunittest.a $(LDADD)
#EXTRA_DIST = $(wildcard *.options) $(wildcard *.dict) \
# $(wildcard *.in) $(wildcard *.repro)
@@ -74,7 +78,7 @@ clean-local:
oss-fuzz:
if test "$$OUT" != ""; then \
XLIBS="-lpsl -lgnutls -lnettle -lhogweed -lidn2 -lunistring"; \
XLIBS="-lpsl -lgnutls -lhogweed -lnettle -lidn2 -lunistring"; \
for ccfile in wget*_fuzzer.c; do \
fuzzer=$$(basename $$ccfile .c); \
$$CXX $$CXXFLAGS -I$(top_srcdir)/src -I$(top_srcdir) -I$(top_srcdir)/lib \

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2017-2018 Free Software Foundation, Inc.
* Copyright (c) 2017-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
@@ -20,6 +20,16 @@
#include <stddef.h> // size_t
#include <stdint.h> // uint8_t
#define CLOSE_STDERR \
int bak = dup(STDERR_FILENO); \
int fd = open("/dev/null", O_WRONLY); \
dup2(fd, STDERR_FILENO); \
close(fd);
#define RESTORE_STDERR \
dup2(bak, STDERR_FILENO); \
close(bak);
#ifdef __cplusplus
extern "C"
#endif

View File

@@ -1,4 +1,22 @@
/*
* Copyright (c) 2017-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
* GNU Wget is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GNU Wget is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Wget. If not, see <https://www.gnu.org/licenses/>.
* Created 19.10.2017 by Tim Rühsen
*
* Call glob() using data from fuzzer crash file

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2017-2018 Free Software Foundation, Inc.
* Copyright (c) 2017-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
@@ -51,11 +51,12 @@ static int test_all_from(const char *dirname)
char fname[strlen(dirname) + strlen(dp->d_name) + 2];
snprintf(fname, sizeof(fname), "%s/%s", dirname, dp->d_name);
struct file_memory *fmem;
struct file_memory *fmem;
if ((fmem = wget_read_file(fname))) {
printf("testing %ld bytes from '%s'\n", fmem->length, fname);
fflush(stdout);
LLVMFuzzerTestOneInput((uint8_t *)fmem->content, fmem->length);
wget_read_file_free(fmem);
wget_read_file_free(fmem);
}
}
closedir(dirp);

View File

@@ -1,6 +1,6 @@
#!/bin/sh -eu
# Copyright(c) 2017 Free Software Foundation, Inc.
# Copyright (c) 2017, 2019 Free Software Foundation, Inc.
#
# This file is part of GNU Wget.
#

View File

@@ -1,6 +1,6 @@
#!/bin/bash -e
#
# Copyright(c) 2017 Free Software Foundation, Inc.
# Copyright (c) 2017, 2019 Free Software Foundation, Inc.
#
# This file is part of GNU Wget.
#

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2017-2018 Free Software Foundation, Inc.
* Copyright (c) 2017-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
@@ -25,6 +25,8 @@
#include <stdio.h> // fmemopen
#include <string.h> // strncmp
#include <stdlib.h> // free
#include <fcntl.h> // open flags
#include <unistd.h> // close
#include "wget.h"
#undef fopen_wgetrc
@@ -60,15 +62,10 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
void exit_wget(int status)
{
}
#else
void exit(int status)
{
}
#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
FILE *bak;
struct cookie_jar *cookie_jar;
char *set_cookie;
@@ -79,8 +76,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
memcpy(set_cookie, data, size);
set_cookie[size] = 0;
bak = stderr;
stderr = fopen("/dev/null", "w");
CLOSE_STDERR
cookie_jar = cookie_jar_new();
cookie_handle_set_cookie(cookie_jar, "x", 81, "p", set_cookie);
@@ -88,10 +84,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
cookie_handle_set_cookie(cookie_jar, "x", 80, "p/d/", set_cookie);
cookie_jar_delete(cookie_jar);
fclose(stderr);
stderr = bak;
RESTORE_STDERR
free(set_cookie);
free(set_cookie);
return 0;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2017-2018 Free Software Foundation, Inc.
* Copyright (c) 2017-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
@@ -67,16 +67,26 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
#endif
}
static int do_jump;
static jmp_buf jmpbuf;
#ifdef FUZZING
void exit_wget(int status)
{
longjmp(jmpbuf, 1);
}
#else
#elif defined HAVE_DLFCN_H
#include <dlfcn.h> // dlsym
#ifndef RTLD_NEXT
#define RTLD_NEXT RTLD_GLOBAL
#endif
void exit(int status)
{
longjmp(jmpbuf, 1);
if (do_jump) {
longjmp(jmpbuf, 1);
} else {
void (*libc_exit)(int) = (void(*)(int)) dlsym (RTLD_NEXT, "exit");
libc_exit(status);
}
}
#endif
@@ -91,8 +101,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
.document_file = NULL,
};
FILE *bak = stderr;
stderr = fopen("/dev/null", "w");
CLOSE_STDERR
do_jump = 1;
if (setjmp(jmpbuf))
goto done;
@@ -102,8 +113,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
free((void *) ctx.parent_base);
done:
fclose(stderr);
stderr = bak;
do_jump = 0;
RESTORE_STDERR
return 0;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2017-2018 Free Software Foundation, Inc.
* Copyright (c) 2017-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
@@ -59,30 +59,48 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
return NULL;
}
static int do_jump;
static jmp_buf jmpbuf;
#ifdef FUZZING
void exit_wget(int status)
{
longjmp(jmpbuf, 1);
}
#else
#elif defined HAVE_DLFCN_H
#include <dlfcn.h> // dlsym
#ifndef RTLD_NEXT
#define RTLD_NEXT RTLD_GLOBAL
#endif
void exit(int status)
{
if (do_jump) {
longjmp(jmpbuf, 1);
} else {
void (*libc_exit)(int) = (void(*)(int)) dlsym (RTLD_NEXT, "exit");
libc_exit(status);
}
}
#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
FILE *fp, *bak;
#ifdef HAVE_FMEMOPEN
FILE *fp;
struct fileinfo *fi;
if (size > 4096) // same as max_len = ... in .options file
return 0;
bak = stderr;
stderr = fopen("/dev/null", "w");
fp = fmemopen((void *) data, size, "r");
if (!fp) return 0;
CLOSE_STDERR
do_jump = 1;
if (setjmp(jmpbuf))
goto done;
fi = ftp_parse_ls_fp(fp, ST_UNIX);
freefileinfo(fi);
rewind(fp);
@@ -96,12 +114,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
rewind(fp);
fi = ftp_parse_ls_fp(fp, ST_MACOS);
freefileinfo(fi);
done:
freefileinfo(fi);
fclose(fp);
fclose(stderr);
stderr = bak;
do_jump = 0;
RESTORE_STDERR
#endif
return 0;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2017-2018 Free Software Foundation, Inc.
* Copyright (c) 2017-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
@@ -72,23 +72,17 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
void exit_wget(int status)
{
}
#else
void exit(int status)
{
}
#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
struct urlpos *urls;
struct file_memory fm;
FILE *bak;
if (size > 4096) // same as max_len = ... in .options file
return 0;
bak = stderr;
stderr = fopen("/dev/null", "w");
CLOSE_STDERR
fm.content = (char *) data;
fm.length = size;
@@ -97,8 +91,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
urls = get_urls_html_fm("xxx", &fm, "https://x.y", NULL, NULL);
free_urlpos(urls);
fclose(stderr);
stderr = bak;
RESTORE_STDERR
return 0;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2017-2018 Free Software Foundation, Inc.
* Copyright (c) 2017-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
@@ -25,6 +25,8 @@
#include <string.h> // strncmp
#include <stdlib.h> // free
#include <setjmp.h> // longjmp, setjmp
#include <fcntl.h> // open flags
#include <unistd.h> // close
#include "wget.h"
#undef fopen_wgetrc
@@ -56,31 +58,49 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
return NULL;
}
static int do_jump;
static jmp_buf jmpbuf;
#ifdef FUZZING
void exit_wget(int status)
{
longjmp(jmpbuf, 1);
}
#else
#elif defined HAVE_DLFCN_H
#include <dlfcn.h> // dlsym
#ifndef RTLD_NEXT
#define RTLD_NEXT RTLD_GLOBAL
#endif
void exit(int status)
{
if (do_jump) {
longjmp(jmpbuf, 1);
} else {
void (*libc_exit)(int) = (void(*)(int)) dlsym (RTLD_NEXT, "exit");
libc_exit(status);
}
}
#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
FILE *fp, *bak;
#ifdef HAVE_FMEMOPEN
FILE *fp;
struct fileinfo *fi;
const char *user = NULL, *pw = NULL;
const char *user = NULL, *pw = NULL;
if (size > 4096) // same as max_len = ... in .options file
return 0;
bak = stderr;
stderr = fopen("/dev/null", "w");
fp = fmemopen((void *) data, size, "r");
if (!fp) return 0;
CLOSE_STDERR
do_jump = 1;
if (setjmp(jmpbuf))
goto done;
opt.netrc = 1;
user = NULL; // get first entry
@@ -89,12 +109,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
user = "u"; // get entry for user 'u'
search_netrc("x", &user, &pw, 1, fp);
done:
netrc_cleanup();
fclose(fp);
fclose(stderr);
stderr = bak;
do_jump = 0;
RESTORE_STDERR
#endif
return 0;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright(c) 2017-2018 Free Software Foundation, Inc.
* Copyright (c) 2017-2019 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
@@ -60,16 +60,26 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
#endif
}
static int do_jump;
static jmp_buf jmpbuf;
#ifdef FUZZING
void exit_wget(int status)
{
longjmp(jmpbuf, 1);
}
#else
#elif defined HAVE_DLFCN_H
#include <dlfcn.h> // dlsym
#ifndef RTLD_NEXT
#define RTLD_NEXT RTLD_GLOBAL
#endif
void exit(int status)
{
longjmp(jmpbuf, 1);
if (do_jump) {
longjmp(jmpbuf, 1);
} else {
void (*libc_exit)(int) = (void(*)(int)) dlsym (RTLD_NEXT, "exit");
libc_exit(status);
}
}
#endif
@@ -83,8 +93,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
g_data = data;
g_size = size;
FILE *bak = stderr;
stderr = fopen("/dev/null", "w");
CLOSE_STDERR
do_jump = 1;
if (setjmp(jmpbuf))
goto done;
@@ -94,8 +105,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
done:
cleanup();
fclose(stderr);
stderr = bak;
do_jump = 0;
RESTORE_STDERR
return 0;
}

View File

@@ -0,0 +1,204 @@
/*
* Copyright (c) 2019 Free Software Foundation, Inc.
*
* This file is part of GNU Wget.
*
* GNU Wget is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* GNU Wget is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Wget. If not, see <https://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <sys/types.h>
#include <stdint.h> // uint8_t
#include <stdio.h> // fmemopen
#include <string.h> // strncmp
#include <stdlib.h> // free
#include <unistd.h> // close
#include <fcntl.h> // open flags
#include <unistd.h> // close
#include <unistd.h> // close
#include "wget.h"
#include "connect.h"
#undef fopen_wgetrc
#ifdef __cplusplus
extern "C" {
#endif
#include "retr.h"
// declarations for wget internal functions
int main_wget(int argc, const char **argv);
void cleanup(void);
// FILE *fopen_wget(const char *pathname, const char *mode);
// FILE *fopen_wgetrc(const char *pathname, const char *mode);
void exit_wget(int status);
#ifdef __cplusplus
}
#endif
#include "fuzzer.h"
FILE *fopen_wget(const char *pathname, const char *mode)
{
return fopen("/dev/null", mode);
}
FILE *fopen_wgetrc(const char *pathname, const char *mode)
{
return NULL;
}
#ifdef FUZZING
void exit_wget(int status)
{
}
#endif
static const uint8_t *g_data;
static size_t g_size, g_read;
struct my_context {
int peeklen;
char peekbuf[512];
};
static int my_peek (int fd _GL_UNUSED, char *buf, int bufsize, void *arg)
{
if (g_read < g_size) {
struct my_context *ctx = (struct my_context *) arg;
int n = rand() % (g_size - g_read);
if (n > bufsize)
n = bufsize;
if (n > sizeof(ctx->peekbuf))
n = sizeof(ctx->peekbuf);
memcpy(buf, g_data + g_read, n);
memcpy(ctx->peekbuf, g_data + g_read, n);
g_read += n;
ctx->peeklen=n;
return n;
}
return 0;
}
static int my_read (int fd _GL_UNUSED, char *buf, int bufsize, void *arg)
{
struct my_context *ctx = (struct my_context *) arg;
if (ctx->peeklen) {
/* If we have any peek data, simply return that. */
int copysize = MIN (bufsize, ctx->peeklen);
memcpy (buf, ctx->peekbuf, copysize);
ctx->peeklen -= copysize;
if (ctx->peeklen)
memmove (ctx->peekbuf, ctx->peekbuf + copysize, ctx->peeklen);
return copysize;
}
if (g_read < g_size) {
int n = rand() % (g_size - g_read);
if (n > bufsize)
n = bufsize;
memcpy(buf, g_data + g_read, n);
g_read += n;
return n;
}
return 0;
}
static int my_write (int fd _GL_UNUSED, char *buf _GL_UNUSED, int bufsize, void *arg _GL_UNUSED)
{
return bufsize;
}
static int my_poll (int fd _GL_UNUSED, double timeout _GL_UNUSED, int wait_for _GL_UNUSED, void *arg)
{
struct my_context *ctx = (struct my_context *) arg;
return ctx->peeklen || g_read < g_size;
}
static const char *my_errstr (int fd _GL_UNUSED, void *arg _GL_UNUSED)
{
return "Success";
}
static void my_close (int fd _GL_UNUSED, void *arg _GL_UNUSED)
{
}
static struct transport_implementation my_transport =
{
my_read, my_write, my_poll,
my_peek, my_errstr, my_close
};
/* copied from wget's http.c */
static const char *
response_head_terminator (const char *start, const char *peeked, int peeklen)
{
const char *p, *end;
/* If at first peek, verify whether HUNK starts with "HTTP". If
not, this is a HTTP/0.9 request and we must bail out without
reading anything. */
if (start == peeked && 0 != memcmp (start, "HTTP", MIN (peeklen, 4)))
return start;
/* Look for "\n[\r]\n", and return the following position if found.
Start two chars before the current to cover the possibility that
part of the terminator (e.g. "\n\r") arrived in the previous
batch. */
p = peeked - start < 2 ? start : peeked - 2;
end = peeked + peeklen;
/* Check for \n\r\n or \n\n anywhere in [p, end-2). */
for (; p < end - 2; p++)
if (*p == '\n')
{
if (p[1] == '\r' && p[2] == '\n')
return p + 3;
else if (p[1] == '\n')
return p + 2;
}
/* p==end-2: check for \n\n directly preceding END. */
if (peeklen >= 2 && p[0] == '\n' && p[1] == '\n')
return p + 2;
return NULL;
}
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
char *hunk;
if (size > 4096) // same as max_len = ... in .options file
return 0;
// CLOSE_STDERR
g_data = data;
g_size = size;
g_read = 0;
struct my_context *ctx = calloc(1, sizeof(struct my_context));
fd_register_transport(99, &my_transport, ctx);
while ((hunk = fd_read_hunk(99, response_head_terminator, 512, 65536)))
free(hunk);
connect_cleanup();
free(ctx);
// RESTORE_STDERR
return 0;
}

View File

@@ -0,0 +1,3 @@
HTTP
'

View File

@@ -0,0 +1,2 @@
HTTP
<EFBFBD>

View File

@@ -0,0 +1,5 @@
HTTPHH~:þ±
QHTTPHH~:þ±
QTT)÷)÷ÿ

View File

@@ -0,0 +1,3 @@
H
<EFBFBD>

View File

@@ -0,0 +1 @@
HTTP<EFBFBD><EFBFBD>)<29>M<EFBFBD><4D>

View File

@@ -0,0 +1 @@
HTTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29><><EFBFBD><EFBFBD><EFBFBD>HTTP<54><50>

View File

@@ -0,0 +1 @@
H!T'<27>

View File

@@ -0,0 +1 @@
HTT~~~

View File

@@ -0,0 +1,3 @@
HTTPH
<EFBFBD>
~

View File

@@ -0,0 +1,2 @@
HTTH
:

View File

@@ -0,0 +1 @@
'!<21><>!

View File

@@ -0,0 +1 @@
HTTPHHH

View File

@@ -0,0 +1 @@
HIHHT

View File

@@ -0,0 +1,4 @@
HTP

View File

@@ -0,0 +1,3 @@
HTTP<EFBFBD>
<EFBFBD>

Some files were not shown because too many files have changed in this diff Show More