mirror of
https://git.sr.ht/~sircmpwn/gmni
synced 2024-11-23 00:42:15 +01:00
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>
This commit is contained in:
parent
8970adc23e
commit
8a83030e5a
@ -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);
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user