diff options
author | Reyk Floeter <reyk@esdenera.com> | 2015-01-18 15:07:18 +0100 |
---|---|---|
committer | Reyk Floeter <reyk@esdenera.com> | 2015-01-18 15:07:18 +0100 |
commit | 56cddace6a66b505f8e47b7117290ab1214aa84a (patch) | |
tree | 4ac8affa66b5811f8791c3c371dc05c8d3c8cbc9 /server_file.c | |
parent | faa9e65a23cdb2e3971b36d7a22fb9d04dabb52c (diff) | |
download | httpd-56cddace6a66b505f8e47b7117290ab1214aa84a.tar.gz httpd-56cddace6a66b505f8e47b7117290ab1214aa84a.zip |
sync with -current:
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 'server_file.c')
-rw-r--r-- | server_file.c | 19 |
1 files changed, 11 insertions, 8 deletions
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); |