NetBSD Problem Report #54785

From www@netbsd.org  Wed Dec 18 22:01:37 2019
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-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 8BE097A153
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 18 Dec 2019 22:01:37 +0000 (UTC)
Message-Id: <20191218220136.811467A1C8@mollari.NetBSD.org>
Date: Wed, 18 Dec 2019 22:01:36 +0000 (UTC)
From: edgar@pettijohn-web.com
Reply-To: edgar@pettijohn-web.com
To: gnats-bugs@NetBSD.org
Subject: bozo_set_defaults() returns 0 on sucess instead of 1
X-Send-Pr-Version: www-1.0

>Number:         54785
>Category:       lib
>Synopsis:       bozo_set_defaults() returns 0 on sucess instead of 1
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 18 22:05:00 +0000 2019
>Originator:     Edgar Pettijohn
>Release:        9.0_RC1 12/18/2019
>Organization:
>Environment:
9.0_RC1 NetBSD 9.0_RC1 (GENERIC) #0: Wed Nov 27 16:14:52 UTC 2019  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
libbozohttpd.3 claims bozo_set_defaults will return 1 on success and 0 on failure. This is incorrect.
>How-To-Repeat:
#include <bozohttpd.h>

#include <err.h>
#include <stdio.h>

int
main(int argc, char *argv[])
{
	bozohttpd_t httpd;
	bozoprefs_t prefs;
	bozo_httpreq_t *request;

        /* this will fail but shouldn't */
	if (!bozo_set_defaults(&httpd, &prefs))
		err(1, "bozo_set_defaults");

	if (!bozo_set_pref(&httpd, &prefs, "bind address", "127.0.0.1"))
		err(1, "set_pref: bind address");

	if (!bozo_set_pref(&httpd, &prefs, "port number", "5000"))
		err(1, "set_pref: port number");

	if (!bozo_set_pref(&httpd, &prefs, "background", "1"))
		err(1, "set_pref: background");

	bozo_setup(&httpd, &prefs, NULL, "/var/www");


	do {
		if ((request = bozo_read_request(&httpd)) != NULL) {
			bozo_process_request(request);
			bozo_clean_request(request);
		}
	} while (httpd.background);

	return 0;
}
>Fix:
Either change the code or the manual. Personally think it would be better to change the code so the return value is in line with others.

Index: bozohttpd.c
===================================================================
RCS file: /cvsroot/src/libexec/httpd/bozohttpd.c,v
retrieving revision 1.86.4.4
diff -u -r1.86.4.4 bozohttpd.c
--- bozohttpd.c	12 Jun 2019 10:32:00 -0000	1.86.4.4
+++ bozohttpd.c	18 Dec 2019 21:50:43 -0000
@@ -2465,19 +2465,19 @@
 	(void) memset(prefs, 0x0, sizeof(*prefs));

 	/* set up default values */
-	if (!bozo_set_pref(httpd, prefs, "server software", SERVER_SOFTWARE))
+	if (bozo_set_pref(httpd, prefs, "server software", SERVER_SOFTWARE))
 		rv = 1;
-	if (!bozo_set_pref(httpd, prefs, "index.html", INDEX_HTML))
+	if (bozo_set_pref(httpd, prefs, "index.html", INDEX_HTML))
 		rv = 1;
-	if (!bozo_set_pref(httpd, prefs, "public_html", PUBLIC_HTML))
+	if (bozo_set_pref(httpd, prefs, "public_html", PUBLIC_HTML))
 		rv = 1;
-	if (!bozo_set_pref(httpd, prefs, "ssl timeout", SSL_TIMEOUT))
+	if (bozo_set_pref(httpd, prefs, "ssl timeout", SSL_TIMEOUT))
 		rv = 1;
-	if (!bozo_set_pref(httpd, prefs, "initial timeout", INITIAL_TIMEOUT))
+	if (bozo_set_pref(httpd, prefs, "initial timeout", INITIAL_TIMEOUT))
 		rv = 1;
-	if (!bozo_set_pref(httpd, prefs, "header timeout", HEADER_WAIT_TIME))
+	if (bozo_set_pref(httpd, prefs, "header timeout", HEADER_WAIT_TIME))
 		rv = 1;
-	if (!bozo_set_pref(httpd, prefs, "request timeout", TOTAL_MAX_REQ_TIME))
+	if (bozo_set_pref(httpd, prefs, "request timeout", TOTAL_MAX_REQ_TIME))
 		rv = 1;

 	return rv;

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.45 2018/12/21 14:23:33 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.