Skip to content

Commit 6ea3d04

Browse files
authored
patch wget to prevent debug output from printing binary request bodies (#10486)
wget using openssl for tls (which we compile with), with --debug turned on prints the body of ocsp requests (if --ocsp is specified; it's off by default) to stderr even though it's the body is binary. This change patches wget with the proposed fix for upstream issue.
1 parent 698a967 commit 6ea3d04

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
From 3359e3e182a24722d601dfa5e4652143817ef24f Mon Sep 17 00:00:00 2001
2+
From: "Tobias Brick (he/him)" <tobiasb@microsoft.com>
3+
Date: Mon, 16 Sep 2024 15:34:19 +0000
4+
Subject: [PATCH] set debug_skip_body for OCSP requests in openssl tls provider
5+
6+
---
7+
include/wget/wget.h | 1 +
8+
libwget/http_highlevel.c | 6 ++++++
9+
libwget/ssl_openssl.c | 1 +
10+
3 files changed, 8 insertions(+)
11+
12+
diff --git a/include/wget/wget.h b/include/wget/wget.h
13+
index 62ec38364..2dfe56968 100644
14+
--- a/include/wget/wget.h
15+
+++ b/include/wget/wget.h
16+
@@ -250,6 +250,7 @@ WGET_BEGIN_DECLS
17+
#define WGET_HTTP_BODY_SAVEAS 2018
18+
#define WGET_HTTP_USER_DATA 2019
19+
#define WGET_HTTP_RESPONSE_IGNORELENGTH 2020
20+
+#define WGET_HTTP_DEBUG_SKIP_BODY 2021
21+
22+
// definition of error conditions
23+
typedef enum {
24+
diff --git a/libwget/http_highlevel.c b/libwget/http_highlevel.c
25+
index 14c5bea72..3971f8ed0 100644
26+
--- a/libwget/http_highlevel.c
27+
+++ b/libwget/http_highlevel.c
28+
@@ -83,6 +83,7 @@ wget_http_response *wget_http_get(int first_key, ...)
29+
size_t bodylen = 0;
30+
const void *body = NULL;
31+
void *header_user_data = NULL, *body_user_data = NULL;
32+
+ bool debug_skip_body = 0;
33+
34+
struct {
35+
bool
36+
@@ -157,6 +158,9 @@ wget_http_response *wget_http_get(int first_key, ...)
37+
body = va_arg(args, const void *);
38+
bodylen = va_arg(args, size_t);
39+
break;
40+
+ case WGET_HTTP_DEBUG_SKIP_BODY:
41+
+ debug_skip_body = 1;
42+
+ break;
43+
default:
44+
error_printf(_("Unknown option %d\n"), key);
45+
va_end(args);
46+
@@ -239,6 +243,8 @@ wget_http_response *wget_http_get(int first_key, ...)
47+
if (body && bodylen)
48+
wget_http_request_set_body(req, NULL, wget_memdup(body, bodylen), bodylen);
49+
50+
+ req->debug_skip_body = debug_skip_body;
51+
+
52+
rc = wget_http_send_request(conn, req);
53+
54+
if (rc == 0) {
55+
diff --git a/libwget/ssl_openssl.c b/libwget/ssl_openssl.c
56+
index 6cac6ecb0..7a52792d8 100644
57+
--- a/libwget/ssl_openssl.c
58+
+++ b/libwget/ssl_openssl.c
59+
@@ -762,6 +762,7 @@ static OCSP_REQUEST *send_ocsp_request(const char *uri,
60+
WGET_HTTP_HEADER_ADD, "Content-Type", "application/ocsp-request",
61+
WGET_HTTP_MAX_REDIRECTIONS, 5,
62+
WGET_HTTP_BODY, ocspreq_bytes, ocspreq_bytes_len,
63+
+ WGET_HTTP_DEBUG_SKIP_BODY,
64+
0);
65+
66+
OPENSSL_free(ocspreq_bytes);

SPECS/wget/wget.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Summary: An advanced file and recursive website downloader
44
Name: wget
55
Version: 2.1.0
6-
Release: 3%{?dist}
6+
Release: 4%{?dist}
77
License: GPL-3.0-or-later AND LGPL-3.0-or-later AND GFDL-1.3-or-later
88
URL: https://gitlab.com/gnuwget/wget2
99
Group: System Environment/NetworkingPrograms
@@ -29,6 +29,8 @@ Patch0005: 0005-Accept-progress-dot-.-for-backwards-compatibility.patch
2929
Patch0006: 0006-Disable-TCP-Fast-Open-by-default.patch
3030
# https://github.com/rockdaboot/wget2/issues/342
3131
Patch0007: fix-ssl-read-and-write-error-check.patch
32+
# https://github.com/rockdaboot/wget2/issues/344
33+
Patch0008: set-debug_skip_body-for-OCSP-requests-in-openssl-tls-provider.patch
3234

3335
BuildRequires: autoconf
3436
BuildRequires: automake
@@ -155,6 +157,9 @@ echo ".so man1/%{name}.1" > %{buildroot}%{_mandir}/man1/wget.1
155157
%{_mandir}/man3/libwget*.3*
156158

157159
%changelog
160+
* Wed Sep 18 2024 Tobias Brick <tobiasb@microsoft.com> - 2.1.0-4
161+
- Add patch to prevent debug output from printing binary request bodies.
162+
158163
* Fri Sep 13 2024 Tobias Brick <tobiasb@microsoft.com> - 2.1.0-3
159164
- Add patch to fix SSL read and write error check.
160165

0 commit comments

Comments
 (0)