NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/54785: bozo_set_defaults() returns 0 on sucess instead of 1



>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@localhost:/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;



Home | Main Index | Thread Index | Old Index