aboutsummaryrefslogtreecommitdiff
path: root/ge.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2024-06-09 09:46:04 +0000
committerOmar Polo <op@omarpolo.com>2024-06-09 09:46:04 +0000
commit68d36b207f055fe76be5f57f034df3c5a60206cf (patch)
treea37c7a37bde8aebcf776788e827a7d506f8f8727 /ge.c
parent910fbe8f00e7e864f7efbb0b2b5a4d475f3968b2 (diff)
check and error on strlcpy truncation
Diffstat (limited to 'ge.c')
-rw-r--r--ge.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ge.c b/ge.c
index 2bd3991..e0d7b55 100644
--- a/ge.c
+++ b/ge.c
@@ -112,7 +112,9 @@ load_local_cert(struct vhost *h, const char *hostname, const char *dir)
if (h->key == NULL)
fatal("can't load %s", key);
- strlcpy(h->domain, hostname, sizeof(h->domain));
+ if (strlcpy(h->domain, hostname, sizeof(h->domain))
+ >= sizeof(h->domain))
+ fatalx("hostname too long: %s", hostname);
}
/* wrapper around dirname(3). dn must be PATH_MAX+1 at least. */
@@ -122,7 +124,8 @@ pdirname(const char *path, char *dn)
char p[PATH_MAX+1];
char *t;
- strlcpy(p, path, sizeof(p));
+ if (strlcpy(p, path, sizeof(p)) >= sizeof(p))
+ fatalx("%s: path too long: %s", __func__, path);
t = dirname(p);
memmove(dn, t, strlen(t)+1);
}