NetBSD Problem Report #56367
From www@netbsd.org Tue Aug 17 19:54:34 2021
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 06BCA1A921F
for <gnats-bugs@gnats.NetBSD.org>; Tue, 17 Aug 2021 19:54:34 +0000 (UTC)
Message-Id: <20210817195432.1D3F01A9239@mollari.NetBSD.org>
Date: Tue, 17 Aug 2021 19:54:32 +0000 (UTC)
From: cshmakk@protonmail.com
Reply-To: cshmakk@protonmail.com
To: gnats-bugs@NetBSD.org
Subject: bozohttpd.c 80-wide
X-Send-Pr-Version: www-1.0
>Number: 56367
>Category: bin
>Synopsis: bozohttpd.c 80-wide
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: mrg
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Aug 17 19:55:01 +0000 2021
>Closed-Date: Tue Aug 24 05:40:57 +0000 2021
>Last-Modified: Tue Aug 24 05:50:01 +0000 2021
>Originator: parrott
>Release: HEAD as of a few days ago, unless i'm mistaken
>Organization:
individual
>Environment:
9.2, HEAD src
>Description:
mostly just 80-wide
+ i think there's an unnecessary USE_ARG
+ i took a stab at an if block
>How-To-Repeat:
>Fix:
Index: bozohttpd.c
===================================================================
RCS file: /cvsroot/src/libexec/httpd/bozohttpd.c,v
retrieving revision 1.132
diff -u -p -r1.132 bozohttpd.c
--- bozohttpd.c 5 May 2021 07:41:48 -0000 1.132
+++ bozohttpd.c 17 Aug 2021 19:47:47 -0000
@@ -148,8 +148,8 @@
#include "bozohttpd.h"
#ifndef SSL_TIMEOUT
-#define SSL_TIMEOUT "30" /* wait for 30 seconds for ssl handshake */
-#endif
+#define SSL_TIMEOUT "30" /* wait for 30 seconds for ssl */
+#endif /* handshake */
#ifndef INITIAL_TIMEOUT
#define INITIAL_TIMEOUT "30" /* wait for 30 seconds initially */
#endif
@@ -291,7 +291,6 @@ parse_request(bozohttpd_t *httpd, char *
ssize_t len;
char *val;
- USE_ARG(httpd);
debug((httpd, DEBUG_EXPLODING, "parse in: %s", in));
*method = *file = *query = *proto = NULL;
@@ -670,23 +669,19 @@ bozo_read_request(bozohttpd_t *httpd)
* Override the bound port from the request value, so it works even
* if passed through a proxy that doesn't rewrite the port.
*/
- if (httpd->bindport) {
+ if (httpd->bindport)
if (strcmp(httpd->bindport, BOZO_HTTP_PORT) != 0)
port = httpd->bindport;
else
port = NULL;
- } else {
- if (getsockname(0, (struct sockaddr *)(void *)&ss, &slen) < 0)
- port = NULL;
- else {
- if (getnameinfo((struct sockaddr *)(void *)&ss, slen,
- NULL, 0, bufport, sizeof bufport,
- NI_NUMERICSERV) == 0)
- port = bufport;
- else
- port = NULL;
- }
- }
+ else if (getsockname(0, (struct sockaddr *)(void *)&ss, &slen) < 0)
+ port = NULL;
+ else if (getnameinfo((struct sockaddr *)(void *)&ss, slen, NULL, 0,
+ bufport, sizeof bufport, NI_NUMERICSERV) == 0)
+ port = bufport;
+ else
+ port = NULL;
+
if (port != NULL)
request->hr_serverport = bozostrdup(httpd, request, port);
@@ -713,11 +708,13 @@ bozo_read_request(bozohttpd_t *httpd)
return NULL;
alarm(httpd->initial_timeout);
- while ((str = bozodgetln(httpd, STDIN_FILENO, &len, bozo_read)) != NULL) {
+ while ((str = bozodgetln(httpd, STDIN_FILENO, &len, bozo_read)) != NULL)
+ {
alarm(0);
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
- bozo_http_error(httpd, 500, NULL, "clock_gettime failed");
+ bozo_http_error(httpd, 500, NULL,
+ "clock_gettime failed");
goto cleanup;
}
/*
@@ -744,7 +741,8 @@ bozo_read_request(bozohttpd_t *httpd)
if (line == 1) {
if (len < 1) {
- bozo_http_error(httpd, 404, NULL, "null method");
+ bozo_http_error(httpd, 404, NULL,
+ "null method");
goto cleanup;
}
bozowarn(httpd,
@@ -754,11 +752,13 @@ bozo_read_request(bozohttpd_t *httpd)
port ? port : "<stdin>");
/* we allocate return space in file and query only */
- parse_request(httpd, str, &method, &file, &query, &proto);
+ parse_request(httpd, str, &method, &file, &query,
+ &proto);
request->hr_file_free = request->hr_file = file;
request->hr_query = query;
if (method == NULL) {
- bozo_http_error(httpd, 404, NULL, "null method");
+ bozo_http_error(httpd, 404, NULL,
+ "null method");
goto cleanup;
}
if (file == NULL) {
@@ -770,7 +770,6 @@ bozo_read_request(bozohttpd_t *httpd)
* note that we parse the proto first, so that we
* can more properly parse the method and the url.
*/
-
if (process_proto(request, proto) ||
process_method(request, method)) {
goto cleanup;
@@ -794,7 +793,8 @@ bozo_read_request(bozohttpd_t *httpd)
"bozostrnsep: str `%s' val `%s'",
str ? str : "<null>", val ? val : "<null>"));
if (val == NULL || len == -1) {
- bozo_http_error(httpd, 404, request, "no header");
+ bozo_http_error(httpd, 404, request,
+ "no header");
goto cleanup;
}
if (str == NULL) {
@@ -817,7 +817,8 @@ bozo_read_request(bozohttpd_t *httpd)
if (strcasecmp(hdr->h_header, "content-type") == 0)
request->hr_content_type = hdr->h_value;
- else if (strcasecmp(hdr->h_header, "content-length") == 0)
+ else if (strcasecmp(hdr->h_header, "content-length") ==
+ 0)
request->hr_content_length = hdr->h_value;
else if (strcasecmp(hdr->h_header, "host") == 0) {
if (request->hr_host) {
@@ -897,8 +898,9 @@ next_header:
if (*dash != '\0') {
request->hr_last_byte_pos =
strtoll(dash, NULL, 10);
- if (request->hr_last_byte_pos < 0)
- request->hr_last_byte_pos = -1;
+ if (request->hr_last_byte_pos <
+ 0)
+ request->hr_last_byte_pos = -1;
}
}
}
@@ -1129,7 +1131,8 @@ handle_redirect(bozo_httpreq_t *request,
hostname = "";
portbuf[0] = '\0';
} else {
- const char *defport = httpd->sslinfo ? BOZO_HTTPS_PORT : BOZO_HTTP_PORT;
+ const char *defport = httpd->sslinfo ? BOZO_HTTPS_PORT :
+ BOZO_HTTP_PORT;
if (request->hr_serverport &&
strcmp(request->hr_serverport, defport) != 0)
@@ -1162,7 +1165,8 @@ handle_redirect(bozo_httpreq_t *request,
bozo_printf(httpd, "\r\n");
if (request->hr_method == HTTP_HEAD)
goto head;
- bozo_printf(httpd, "<html><head><title>Document Moved</title></head>\n");
+ bozo_printf(httpd,
+ "<html><head><title>Document Moved</title></head>\n");
bozo_printf(httpd, "<body><h1>Document Moved</h1>\n");
bozo_printf(httpd, "This document had moved <a href=\"%s\">here</a>\n",
finalurl);
@@ -1417,9 +1421,11 @@ check_virtual(bozo_httpreq_t *request)
d->d_name));
if (strcmp(d->d_name, request->hr_host) == 0) {
/* found it, punch it */
- debug((httpd, DEBUG_OBESE, "found it punch it"));
+ debug((httpd, DEBUG_OBESE, "found it "
+ "punch it"));
request->hr_virthostname =
- bozostrdup(httpd, request, d->d_name);
+ bozostrdup(httpd, request,
+ d->d_name);
bozoasprintf(httpd, &s, "%s/%s",
httpd->virtbase,
request->hr_virthostname);
@@ -1537,8 +1543,10 @@ check_bzredirect(bozo_httpreq_t *request
/* now we have the link pointer, redirect to the real place */
if (!absolute && redirpath[0] != '/') {
- if ((size_t)snprintf(finalredir = redir, sizeof(redir), "%s%s/%s",
- (strlen(dir) > 0 ? "/" : ""), dir, redirpath) >= sizeof(redir)) {
+ if ((size_t)snprintf(finalredir = redir, sizeof(redir),
+ "%s%s/%s",
+ (strlen(dir) > 0 ? "/" : ""), dir, redirpath) >=
+ sizeof(redir)) {
bozo_http_error(httpd, 404, request,
"redirect path too long");
return -1;
@@ -1950,7 +1958,8 @@ bozo_process_request(bozo_httpreq_t *req
/* make sure we're not trying to access special files */
int
-bozo_check_special_files(bozo_httpreq_t *request, const char *name, bool doerror)
+bozo_check_special_files(bozo_httpreq_t *request, const char *name,
+ bool doerror)
{
bozohttpd_t *httpd = request->hr_httpd;
size_t i;
>Release-Note:
>Audit-Trail:
From: JP <cshmakk@protonmail.com>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/56367: bozohttpd.c 80-wide
Date: Tue, 17 Aug 2021 21:40:57 +0000
pretty sure the if blcok is a bust
Sent with ProtonMail Secure Email.
=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me=
ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90
On Tuesday, August 17th, 2021 at 7:55 PM, <gnats-admin@netbsd.org> wrote:
> Thank you very much for your problem report.
>
> It has the internal identification `bin/56367'.
>
> The individual assigned to look at your
>
> report is: bin-bug-people.
>
> > Category: bin
> >
> > Responsible: bin-bug-people
> >
> > Synopsis: bozohttpd.c 80-wide
> >
> > Arrival-Date: Tue Aug 17 19:55:01 +0000 2021
Responsible-Changed-From-To: bin-bug-people->mrg
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Wed, 18 Aug 2021 05:43:06 +0000
Responsible-Changed-Why:
Over to author
State-Changed-From-To: open->closed
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Tue, 24 Aug 2021 05:40:57 +0000
State-Changed-Why:
i applied a change to the bindport stuff, inspired by your change,
but should keep the same semantics with fewer conditionals.
i'm not going to reformat for 80 columns in a partial change, so
that part is not applied.
thanks.
From: "matthew green" <mrg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/56367 CVS commit: src/libexec/httpd
Date: Tue, 24 Aug 2021 05:39:39 +0000
Module Name: src
Committed By: mrg
Date: Tue Aug 24 05:39:39 UTC 2021
Modified Files:
src/libexec/httpd: bozohttpd.c
Log Message:
rework the bindport setting, inspired by part of the patch
from PR#56367 (thanks JP.)
To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/libexec/httpd/bozohttpd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.