aboutsummaryrefslogtreecommitdiff
path: root/ge.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2022-10-05 15:10:44 +0000
committerOmar Polo <op@omarpolo.com>2022-10-05 15:10:44 +0000
commit534afd0ddcba7c3d2f8478e89db026010c6190c5 (patch)
treeb2a6601b8a0fe1ba0128c34df1b9df374869ecf4 /ge.c
parent4ceb570910de41133b2771cff29cbb78f37fea30 (diff)
make the various strings in the config fixed-length
will help in future restructuring to have fixed-size objects.
Diffstat (limited to 'ge.c')
-rw-r--r--ge.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/ge.c b/ge.c
index 91b6646..1ed3f58 100644
--- a/ge.c
+++ b/ge.c
@@ -53,9 +53,9 @@ load_local_cert(struct vhost *h, const char *hostname, const char *dir)
if (access(cert, R_OK) == -1 || access(key, R_OK) == -1)
gen_certificate(hostname, cert, key);
- h->cert = cert;
- h->key = key;
- h->domain = hostname;
+ strlcpy(h->cert, cert, sizeof(h->cert));
+ strlcpy(h->key, key, sizeof(h->key));
+ strlcpy(h->domain, hostname, sizeof(h->domain));
}
/* wrapper around dirname(3). dn must be PATH_MAX+1 at least. */
@@ -256,16 +256,21 @@ main(int argc, char **argv)
load_local_cert(host, hostname, certs_dir);
- host->domain = "*";
+ strlcpy(host->domain, "*", sizeof(host->domain));
loc->auto_index = 1;
- loc->match = "*";
+ strlcpy(loc->match, "*", sizeof(loc->match));
if (*argv == NULL) {
if (getcwd(path, sizeof(path)) == NULL)
fatal("getcwd");
- loc->dir = path;
- } else
- loc->dir = absolutify_path(*argv);
+ strlcpy(loc->dir, path, sizeof(loc->dir));
+ } else {
+ char *tmp;
+
+ tmp = absolutify_path(*argv);
+ strlcpy(loc->dir, tmp, sizeof(loc->dir));
+ free(tmp);
+ }
if ((loc->dirfd = open(loc->dir, O_RDONLY|O_DIRECTORY)) == -1)
fatal("can't open %s", loc->dir);