diff options
author | Omar Polo <op@omarpolo.com> | 2022-10-05 15:10:44 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2022-10-05 15:10:44 +0000 |
commit | 534afd0ddcba7c3d2f8478e89db026010c6190c5 (patch) | |
tree | b2a6601b8a0fe1ba0128c34df1b9df374869ecf4 /ge.c | |
parent | 4ceb570910de41133b2771cff29cbb78f37fea30 (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.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -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); |