summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-01-16 06:40:24 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-01-16 06:40:24 +0000
commit315054f4737a39489e0a14f3a92bff61f1592832 (patch)
tree62bf010653374ce09b6beb4dfa0414a91457233b /usr.sbin/httpd
parent79e3d817585ca08a91e30ad14abe43e2ab70295f (diff)
Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
Diffstat (limited to 'usr.sbin/httpd')
-rw-r--r--usr.sbin/httpd/httpd.c8
-rw-r--r--usr.sbin/httpd/httpd.h9
-rw-r--r--usr.sbin/httpd/logger.c5
-rw-r--r--usr.sbin/httpd/parse.y4
-rw-r--r--usr.sbin/httpd/server.c9
-rw-r--r--usr.sbin/httpd/server_fcgi.c4
-rw-r--r--usr.sbin/httpd/server_file.c17
-rw-r--r--usr.sbin/httpd/server_http.c9
8 files changed, 38 insertions, 27 deletions
diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c
index 491c2d4d385..c7d8f9ff16c 100644
--- a/usr.sbin/httpd/httpd.c
+++ b/usr.sbin/httpd/httpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.c,v 1.28 2014/12/11 17:06:55 schwarze Exp $ */
+/* $OpenBSD: httpd.c,v 1.29 2015/01/16 06:40:17 deraadt Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -16,12 +16,14 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/param.h> /* nitems */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/resource.h>
+#include <sys/signal.h>
#include <net/if.h>
#include <netinet/in.h>
@@ -42,6 +44,8 @@
#include "httpd.h"
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
__dead void usage(void);
int parent_configure(struct httpd *);
@@ -678,7 +682,7 @@ socket_rlimit(int maxfd)
if (maxfd == -1)
rl.rlim_cur = rl.rlim_max;
else
- rl.rlim_cur = MAX(rl.rlim_max, (rlim_t)maxfd);
+ rl.rlim_cur = MAXIMUM(rl.rlim_max, (rlim_t)maxfd);
if (setrlimit(RLIMIT_NOFILE, &rl) == -1)
fatal("socket_rlimit: failed to set resource limit");
}
diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h
index 3a8c7cafd9a..a6f470658b7 100644
--- a/usr.sbin/httpd/httpd.h
+++ b/usr.sbin/httpd/httpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.h,v 1.67 2015/01/13 09:21:15 reyk Exp $ */
+/* $OpenBSD: httpd.h,v 1.68 2015/01/16 06:40:17 deraadt Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -23,7 +23,6 @@
#include <sys/tree.h>
-#include <sys/param.h> /* MAXHOSTNAMELEN */
#include <limits.h>
#include <imsg.h>
#include <tls.h>
@@ -361,11 +360,11 @@ TAILQ_HEAD(log_files, log_file) log_files;
struct server_config {
u_int32_t id;
- char name[MAXHOSTNAMELEN];
+ char name[HOST_NAME_MAX+1];
char location[NAME_MAX];
char index[NAME_MAX];
- char root[MAXPATHLEN];
- char socket[MAXPATHLEN];
+ char root[PATH_MAX];
+ char socket[PATH_MAX];
char accesslog[NAME_MAX];
char errorlog[NAME_MAX];
diff --git a/usr.sbin/httpd/logger.c b/usr.sbin/httpd/logger.c
index 672f3b820c1..ee215851f59 100644
--- a/usr.sbin/httpd/logger.c
+++ b/usr.sbin/httpd/logger.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logger.c,v 1.8 2014/12/21 00:54:49 guenther Exp $ */
+/* $OpenBSD: logger.c,v 1.9 2015/01/16 06:40:17 deraadt Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -16,6 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/param.h> /* nitems */
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/queue.h>
@@ -152,7 +153,7 @@ logger_open_fd(struct imsg *imsg)
int
logger_open_priv(struct imsg *imsg)
{
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
char name[NAME_MAX], *p;
u_int32_t id;
size_t len;
diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y
index 5489738749b..f06927095a2 100644
--- a/usr.sbin/httpd/parse.y
+++ b/usr.sbin/httpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.53 2015/01/13 09:21:15 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.54 2015/01/16 06:40:17 deraadt Exp $ */
/*
* Copyright (c) 2007 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -119,7 +119,7 @@ typedef struct {
struct portrange port;
struct {
struct sockaddr_storage ss;
- char name[MAXHOSTNAMELEN];
+ char name[HOST_NAME_MAX+1];
} addr;
} v;
int lineno;
diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c
index f4b6414c9fd..943e60af036 100644
--- a/usr.sbin/httpd/server.c
+++ b/usr.sbin/httpd/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.51 2015/01/13 09:21:15 reyk Exp $ */
+/* $OpenBSD: server.c,v 1.52 2015/01/16 06:40:17 deraadt Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -16,6 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/param.h> /* nitems */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -45,6 +46,8 @@
#include "httpd.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
int server_dispatch_parent(int, struct privsep_proc *,
struct imsg *);
int server_dispatch_logger(int, struct privsep_proc *,
@@ -569,7 +572,7 @@ server_tls_readcb(int fd, short event, void *arg)
}
if (bufev->wm_read.high != 0)
- howmuch = MIN(sizeof(rbuf), bufev->wm_read.high);
+ howmuch = MINIMUM(sizeof(rbuf), bufev->wm_read.high);
ret = tls_read(clt->clt_tls_ctx, rbuf, howmuch, &len);
if (ret == TLS_READ_AGAIN || ret == TLS_WRITE_AGAIN) {
@@ -1025,7 +1028,7 @@ server_sendlog(struct server_config *srv_conf, int cmd, const char *emsg, ...)
void
server_log(struct client *clt, const char *msg)
{
- char ibuf[MAXHOSTNAMELEN], obuf[MAXHOSTNAMELEN];
+ char ibuf[HOST_NAME_MAX+1], obuf[HOST_NAME_MAX+1];
struct server_config *srv_conf = clt->clt_srv_conf;
char *ptr = NULL;
int debug_cmd = -1;
diff --git a/usr.sbin/httpd/server_fcgi.c b/usr.sbin/httpd/server_fcgi.c
index 012e2eaaea8..d4135aa3925 100644
--- a/usr.sbin/httpd/server_fcgi.c
+++ b/usr.sbin/httpd/server_fcgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_fcgi.c,v 1.45 2015/01/13 08:54:01 reyk Exp $ */
+/* $OpenBSD: server_fcgi.c,v 1.46 2015/01/16 06:40:17 deraadt Exp $ */
/*
* Copyright (c) 2014 Florian Obser <florian@openbsd.org>
@@ -97,7 +97,7 @@ server_fcgi(struct httpd *env, struct client *clt)
struct http_descriptor *desc = clt->clt_descreq;
struct fcgi_record_header *h;
struct fcgi_begin_request_body *begin;
- char hbuf[MAXHOSTNAMELEN];
+ char hbuf[HOST_NAME_MAX+1];
size_t scriptlen;
int pathlen;
int fd = -1, ret;
diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c
index e12644dd6f6..447a0ddd701 100644
--- a/usr.sbin/httpd/server_file.c
+++ b/usr.sbin/httpd/server_file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_file.c,v 1.46 2015/01/13 09:21:15 reyk Exp $ */
+/* $OpenBSD: server_file.c,v 1.47 2015/01/16 06:40:17 deraadt Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -43,6 +43,9 @@
#include "httpd.h"
#include "http.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
int server_file_access(struct httpd *, struct client *, char *, size_t);
int server_file_request(struct httpd *, struct client *, char *,
struct stat *);
@@ -150,7 +153,7 @@ server_file(struct httpd *env, struct client *clt)
{
struct http_descriptor *desc = clt->clt_descreq;
struct server_config *srv_conf = clt->clt_srv_conf;
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
const char *stripped, *errstr = NULL;
int ret = 500;
@@ -221,7 +224,7 @@ server_file_request(struct httpd *env, struct client *clt, char *path,
media = media_find(env->sc_mediatypes, path);
ret = server_response_http(clt, 200, media, st->st_size,
- MIN(time(NULL), st->st_mtim.tv_sec));
+ MINIMUM(time(NULL), st->st_mtim.tv_sec));
switch (ret) {
case -1:
goto fail;
@@ -270,7 +273,7 @@ server_file_request(struct httpd *env, struct client *clt, char *path,
int
server_file_index(struct httpd *env, struct client *clt, struct stat *st)
{
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
char tmstr[21];
struct http_descriptor *desc = clt->clt_descreq;
struct server_config *srv_conf = clt->clt_srv_conf;
@@ -299,7 +302,7 @@ server_file_index(struct httpd *env, struct client *clt, struct stat *st)
goto abort;
/* Save last modification time */
- dir_mtime = MIN(time(NULL), st->st_mtim.tv_sec);
+ dir_mtime = MINIMUM(time(NULL), st->st_mtim.tv_sec);
if ((evb = evbuffer_new()) == NULL)
goto abort;
@@ -349,13 +352,13 @@ server_file_index(struct httpd *env, struct client *clt, struct stat *st)
if (evbuffer_add_printf(evb,
"<a href=\"%s\">%s/</a>%*s%s%20s\n",
dp->d_name, dp->d_name,
- MAX(namewidth, 0), " ", tmstr, "-") == -1)
+ MAXIMUM(namewidth, 0), " ", tmstr, "-") == -1)
skip = 1;
} else if (S_ISREG(st->st_mode)) {
if (evbuffer_add_printf(evb,
"<a href=\"%s\">%s</a>%*s%s%20llu\n",
dp->d_name, dp->d_name,
- MAX(namewidth, 0), " ", tmstr, st->st_size) == -1)
+ MAXIMUM(namewidth, 0), " ", tmstr, st->st_size) == -1)
skip = 1;
}
free(dp);
diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c
index 4e1d627e17f..c5dd4ab5650 100644
--- a/usr.sbin/httpd/server_http.c
+++ b/usr.sbin/httpd/server_http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_http.c,v 1.63 2015/01/13 09:21:15 reyk Exp $ */
+/* $OpenBSD: server_http.c,v 1.64 2015/01/16 06:40:17 deraadt Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <stdio.h>
#include <err.h>
#include <pwd.h>
@@ -571,7 +572,7 @@ server_http_time(time_t t, char *tmbuf, size_t len)
const char *
server_http_host(struct sockaddr_storage *ss, char *buf, size_t len)
{
- char hbuf[MAXHOSTNAMELEN];
+ char hbuf[HOST_NAME_MAX+1];
in_port_t port;
if (print_host(ss, buf, len) == NULL)
@@ -768,8 +769,8 @@ server_close_http(struct client *clt)
int
server_response(struct httpd *httpd, struct client *clt)
{
- char path[MAXPATHLEN];
- char hostname[MAXHOSTNAMELEN];
+ char path[PATH_MAX];
+ char hostname[HOST_NAME_MAX+1];
struct http_descriptor *desc = clt->clt_descreq;
struct http_descriptor *resp = clt->clt_descresp;
struct server *srv = clt->clt_srv;