diff --git a/src/gmnlm.c b/src/gmnlm.c

index 23b8e6054c6824ebfe4aba19404d7eeb2c3dab35..c5419243f983c878abff1cfb36633d648f6449f2 100644

--- a/src/gmnlm.c

+++ b/src/gmnlm.c

@@ -159,7 +159,7 @@ size_t n;

n = snprintf(path, sizeof(path), path_fmt, "bookmarks.gmi");

assert(n < sizeof(path));

- strncpy(dname, dirname(path), sizeof(dname));

+ strncpy(dname, dirname(path), sizeof(dname)-1);

if (mkdirs(dname, 0755) != 0) {

snprintf(path, sizeof(path), path_fmt, "bookmarks.gmi");

free(path_fmt);

@@ -200,7 +200,7 @@ size_t n;

n = snprintf(path, sizeof(path), path_fmt, "bookmarks.gmi");

assert(n < sizeof(path));

- strncpy(dname, dirname(path), sizeof(dname));

+ strncpy(dname, dirname(path), sizeof(dname)-1);

if (mkdirs(dname, 0755) != 0) {

snprintf(path, sizeof(path), path_fmt, "bookmarks.gmi");

free(path_fmt);

diff --git a/src/tofu.c b/src/tofu.c

index 16548a1cbcebc8c4cdda4a57a4655a04e7f390a3..b9100c77fd61c71ce561f2194b991eee7130e689 100644

--- a/src/tofu.c

+++ b/src/tofu.c

@@ -164,7 +164,7 @@ n = snprintf(tofu->known_hosts_path, sizeof(tofu->known_hosts_path),

path_fmt, "known_hosts");

assert(n < sizeof(tofu->known_hosts_path));

- strncpy(dname, dirname(tofu->known_hosts_path), sizeof(dname));

+ strncpy(dname, dirname(tofu->known_hosts_path), sizeof(dname)-1);

if (mkdirs(dname, 0755) != 0) {

snprintf(tofu->known_hosts_path, sizeof(tofu->known_hosts_path),

path_fmt, "known_hosts");