diff options
-rw-r--r-- | config.c | 4 | ||||
-rw-r--r-- | http.h | 4 | ||||
-rw-r--r-- | httpd.c | 8 | ||||
-rw-r--r-- | httpd.conf.5 | 6 | ||||
-rw-r--r-- | httpd.h | 11 | ||||
-rw-r--r-- | logger.c | 5 | ||||
-rw-r--r-- | parse.y | 6 | ||||
-rw-r--r-- | server.c | 11 | ||||
-rw-r--r-- | server_fcgi.c | 4 | ||||
-rw-r--r-- | server_file.c | 19 | ||||
-rw-r--r-- | server_http.c | 11 |
11 files changed, 50 insertions, 39 deletions
@@ -1,7 +1,7 @@ -/* $OpenBSD: config.c,v 1.28 2015/01/06 14:07:48 reyk Exp $ */ +/* $OpenBSD: config.c,v 1.29 2015/01/13 09:21:15 reyk Exp $ */ /* - * Copyright (c) 2011 - 2014 Reyk Floeter <reyk@openbsd.org> + * Copyright (c) 2011 - 2015 Reyk Floeter <reyk@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -1,7 +1,7 @@ -/* $OpenBSD: http.h,v 1.10 2015/01/07 16:57:17 reyk Exp $ */ +/* $OpenBSD: http.h,v 1.11 2015/01/13 09:21:15 reyk Exp $ */ /* - * Copyright (c) 2012 - 2014 Reyk Floeter <reyk@openbsd.org> + * Copyright (c) 2012 - 2015 Reyk Floeter <reyk@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -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/httpd.conf.5 b/httpd.conf.5 index 2f10a73..08efe74 100644 --- a/httpd.conf.5 +++ b/httpd.conf.5 @@ -1,6 +1,6 @@ -.\" $OpenBSD: httpd.conf.5,v 1.43 2015/01/05 11:03:57 reyk Exp $ +.\" $OpenBSD: httpd.conf.5,v 1.44 2015/01/13 09:21:15 reyk Exp $ .\" -.\" Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org> +.\" Copyright (c) 2014, 2015 Reyk Floeter <reyk@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 5 2015 $ +.Dd $Mdocdate: January 13 2015 $ .Dt HTTPD.CONF 5 .Os .Sh NAME @@ -1,7 +1,7 @@ -/* $OpenBSD: httpd.h,v 1.66 2015/01/04 22:23:58 chrisz Exp $ */ +/* $OpenBSD: httpd.h,v 1.68 2015/01/16 06:40:17 deraadt Exp $ */ /* - * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org> + * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@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]; @@ -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; @@ -1,7 +1,7 @@ -/* $OpenBSD: parse.y,v 1.52 2015/01/07 11:04:29 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.54 2015/01/16 06:40:17 deraadt Exp $ */ /* - * Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org> + * Copyright (c) 2007 - 2015 Reyk Floeter <reyk@openbsd.org> * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> * Copyright (c) 2004, 2005 Esben Norby <norby@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; @@ -1,7 +1,7 @@ -/* $OpenBSD: server.c,v 1.50 2015/01/06 14:07:48 reyk Exp $ */ +/* $OpenBSD: server.c,v 1.52 2015/01/16 06:40:17 deraadt Exp $ */ /* - * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org> + * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -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/server_fcgi.c b/server_fcgi.c index 012e2ea..d4135aa 100644 --- a/server_fcgi.c +++ b/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/server_file.c b/server_file.c index d1ccce7..447a0dd 100644 --- a/server_file.c +++ b/server_file.c @@ -1,7 +1,7 @@ -/* $OpenBSD: server_file.c,v 1.45 2015/01/06 17:55:28 stsp Exp $ */ +/* $OpenBSD: server_file.c,v 1.47 2015/01/16 06:40:17 deraadt Exp $ */ /* - * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org> + * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -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/server_http.c b/server_http.c index b0ae73d..c5dd4ab 100644 --- a/server_http.c +++ b/server_http.c @@ -1,7 +1,7 @@ -/* $OpenBSD: server_http.c,v 1.62 2015/01/06 17:48:04 reyk Exp $ */ +/* $OpenBSD: server_http.c,v 1.64 2015/01/16 06:40:17 deraadt Exp $ */ /* - * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org> + * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -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; |