diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-03-02 19:52:20 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-03-02 19:52:20 +0000 |
commit | a4fa68edc043e1cb9b8acf36bdcfec7068c9dd29 (patch) | |
tree | e51dbc8d074969b73c3313ccb9d984cb7cadd12f /usr.sbin | |
parent | aa7e4ba359f00573e755cba0ccc7f39adfc9da40 (diff) |
Simplify .gz handling a bit
Combine strlcpy + strlcat into a single snprintf and remove a few
unnecessary parentheses.
ok deraadt millert
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/httpd/server_file.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c index f86d3bb3b35..0027056db0d 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.71 2022/02/27 20:30:30 bluhm Exp $ */ +/* $OpenBSD: server_file.c,v 1.72 2022/03/02 19:52:19 tb Exp $ */ /* * Copyright (c) 2006 - 2017 Reyk Floeter <reyk@openbsd.org> @@ -253,14 +253,11 @@ server_file_request(struct httpd *env, struct client *clt, char *path, if (r != NULL && strstr(r->kv_value, "gzip") != NULL) { /* append ".gz" to path and check existence */ - if (strlcpy(gzpath, path, sizeof(gzpath)) >= - sizeof(gzpath) || - strlcat(gzpath, ".gz", sizeof(gzpath)) >= - sizeof(gzpath)) + ret = snprintf(gzpath, sizeof(gzpath), "%s.gz", path); + if (ret < 0 || (size_t)ret >= sizeof(gzpath)) goto abort; - - if ((access(gzpath, R_OK) == 0) && - (stat(gzpath, &gzst) == 0)) { + if (access(gzpath, R_OK) == 0 && + stat(gzpath, &gzst) == 0) { path = gzpath; st = &gzst; kv_add(&resp->http_headers, |