diff options
author | Omar Polo <op@omarpolo.com> | 2024-06-09 09:46:04 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2024-06-09 09:46:04 +0000 |
commit | 68d36b207f055fe76be5f57f034df3c5a60206cf (patch) | |
tree | a37c7a37bde8aebcf776788e827a7d506f8f8727 /ge.c | |
parent | 910fbe8f00e7e864f7efbb0b2b5a4d475f3968b2 (diff) |
check and error on strlcpy truncation
Diffstat (limited to 'ge.c')
-rw-r--r-- | ge.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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); } |