From 1b249101df13bc8cd455a28d5eeb87730fe2c0ae Mon Sep 17 00:00:00 2001 From: Scott Long Date: Sun, 15 Nov 2020 07:50:29 +0000 Subject: [PATCH] Fix the previous revision, it suffered from an incomplete change to the getlocalbase API. Also don't erroneously subtract the lenth from the buffer a second time. --- sbin/nvmecontrol/nvmecontrol.c | 2 +- usr.sbin/mailwrapper/mailwrapper.c | 4 ++-- usr.sbin/pkg/pkg.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sbin/nvmecontrol/nvmecontrol.c b/sbin/nvmecontrol/nvmecontrol.c index bc8e564a84dd..733a475c8721 100644 --- a/sbin/nvmecontrol/nvmecontrol.c +++ b/sbin/nvmecontrol/nvmecontrol.c @@ -187,7 +187,7 @@ main(int argc, char *argv[]) snprintf(locallib, MAXPATHLEN, "/lib/nvmecontrol"); cmd_load_dir(locallib, NULL, NULL); if ((len = getlocalbase(locallib, MAXPATHLEN)) > 0) { - strlcat(locallib, "/lib/nvmecontrol", MAXPATHLEN - len); + strlcat(locallib, "/lib/nvmecontrol", MAXPATHLEN); cmd_load_dir(locallib, NULL, NULL); } diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c index 083949f266df..9c92af02533a 100644 --- a/usr.sbin/mailwrapper/mailwrapper.c +++ b/usr.sbin/mailwrapper/mailwrapper.c @@ -105,10 +105,10 @@ main(int argc, char *argv[], char *envp[]) initarg(&al); addarg(&al, argv[0]); - if ((len = getlocalbase(localmailerconf, MAXPATHLEN)) != 0) + if ((len = getlocalbase(localmailerconf, MAXPATHLEN)) <= 0) err(EX_OSERR, "cannot determine local path"); - strlcat(localmailerconf, "/etc/mail/mailer.conf", MAXPATHLEN - len); + strlcat(localmailerconf, "/etc/mail/mailer.conf", MAXPATHLEN); mailerconf = localmailerconf; if ((config = fopen(localmailerconf, "r")) == NULL) diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 057a4236174d..0130e9da83b6 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -1047,11 +1047,11 @@ main(int argc, char *argv[]) pkgarg = NULL; yes = false; - if ((len = getlocalbase(pkgpath, MAXPATHLEN)) != 0) { + if ((len = getlocalbase(pkgpath, MAXPATHLEN)) <= 0) { fprintf(stderr, "Cannot determine local path\n"); exit(EXIT_FAILURE); } - strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN - len); + strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN); if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) { bootstrap_only = true;