diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2020-10-19 07:26:42 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2020-10-19 07:26:42 +0000 |
commit | ae659caa0aa4a4e0d3e7eb2e910c553b4b76df39 (patch) | |
tree | 33a7487b8b392f3cf8d86eb2d9aed441c7399561 /usr.sbin/pkg | |
parent | 618cdd89645f0a6af3ef85c59fda975888ae83f8 (diff) |
Use asprintf instead of sbuf
Notes
Notes:
svn path=/head/; revision=366828
Diffstat (limited to 'usr.sbin/pkg')
-rw-r--r-- | usr.sbin/pkg/config.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c index e467a3c34357..fc7df8d31dae 100644 --- a/usr.sbin/pkg/config.c +++ b/usr.sbin/pkg/config.c @@ -32,8 +32,8 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/queue.h> -#include <sys/sbuf.h> #include <sys/utsname.h> +#include <sys/sbuf.h> #include <sys/sysctl.h> #include <dirent.h> @@ -168,7 +168,7 @@ pkg_get_myabi(char *dest, size_t sz) static void subst_packagesite(const char *abi) { - struct sbuf *newval; + char *newval; const char *variable_string; const char *oldval; @@ -180,14 +180,14 @@ subst_packagesite(const char *abi) if ((variable_string = strstr(oldval, "${ABI}")) == NULL) return; - newval = sbuf_new_auto(); - sbuf_bcat(newval, oldval, variable_string - oldval); - sbuf_cat(newval, abi); - sbuf_cat(newval, variable_string + strlen("${ABI}")); - sbuf_finish(newval); + asprintf(&newval, "%.*s%s%s", + (int)(variable_string - oldval), oldval, abi, + variable_string + strlen("${ABI}")); + if (newval == NULL) + errx(EXIT_FAILURE, "asprintf"); free(c[PACKAGESITE].value); - c[PACKAGESITE].value = strdup(sbuf_data(newval)); + c[PACKAGESITE].value = newval; } static int |