cgmnlm

Unnamed repository; edit this file 'description' to name the repository.
git clone git://code.clttr.info/cgmnlm.git
Log | Files | Refs | README | LICENSE

commit 8a83030e5a390c2151c485b3c091ba28ddebcab7
parent 8970adc23e0a1bcf29d211f353dbd5ebd68cfe66
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 20 Nov 2020 08:15:25 -0800

Fix more strncpy bugs in gmnlm and tofu

>From gcc 9.3.0:

error: '__builtin_strncpy' specified bound 4097 equals destination size
[-Werror=stringop-truncation]

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/gmnlm.c | 4++--
Msrc/tofu.c | 2+-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gmnlm.c b/src/gmnlm.c @@ -159,7 +159,7 @@ save_bookmark(struct browser *browser) 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 @@ open_bookmarks(struct browser *browser) 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 @@ -164,7 +164,7 @@ gemini_tofu_init(struct gemini_tofu *tofu, 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");