From: Alejandro Colomar Date: Wed, 1 Jan 2025 14:53:19 +0000 (+0100) Subject: lib/: Use vaprintf() instead of vasprintf(3) X-Git-Tag: 4.18.0-rc1~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d895ee1ac8cf35cbc68c53ae896c8f5d04a43d48;p=thirdparty%2Fshadow.git lib/: Use vaprintf() instead of vasprintf(3) --- diff --git a/lib/selinux.c b/lib/selinux.c index 6eb2894c3..7f279e942 100644 --- a/lib/selinux.c +++ b/lib/selinux.c @@ -13,9 +13,11 @@ #include #include -#include "prototypes.h" +#include "prototypes.h" #include "shadowlog_internal.h" +#include "string/sprintf/aprintf.h" + static bool selinux_checked = false; static bool selinux_enabled; @@ -113,18 +115,15 @@ format_attr(printf, 2, 3) static int selinux_log_cb (int type, const char *fmt, ...) { va_list ap; char *buf; - int r; #ifdef WITH_AUDIT static int selinux_audit_fd = -2; #endif va_start (ap, fmt); - r = vasprintf (&buf, fmt, ap); + buf = vaprintf(fmt, ap); va_end (ap); - - if (r < 0) { + if (buf == NULL) return 0; - } #ifdef WITH_AUDIT if (-2 == selinux_audit_fd) { diff --git a/lib/semanage.c b/lib/semanage.c index 277e20ec4..221a0c43d 100644 --- a/lib/semanage.c +++ b/lib/semanage.c @@ -23,8 +23,8 @@ #include "attr.h" #include "prototypes.h" - #include "shadowlog_internal.h" +#include "string/sprintf/aprintf.h" format_attr(printf, 3, 4) @@ -32,18 +32,14 @@ static void semanage_error_callback (MAYBE_UNUSED void *varg, semanage_handle_t *handle, const char *fmt, ...) { - int ret; char * message = NULL; va_list ap; - va_start (ap, fmt); - ret = vasprintf (&message, fmt, ap); + message = vaprintf(fmt, ap); va_end (ap); - if (ret < 0) { - /* ENOMEM */ + if (message == NULL) return; - } switch (semanage_msg_get_level (handle)) { case SEMANAGE_MSG_ERR: