]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Use vaprintf() instead of vasprintf(3)
authorAlejandro Colomar <alx@kernel.org>
Wed, 1 Jan 2025 14:53:19 +0000 (15:53 +0100)
committerSerge Hallyn <serge@hallyn.com>
Wed, 4 Jun 2025 04:25:02 +0000 (23:25 -0500)
lib/selinux.c
lib/semanage.c

index 6eb2894c36ba4c476d5f1df7ace7c7454ae1a990..7f279e94246989d37ac99b01c408fecb9180de5e 100644 (file)
 
 #include <selinux/selinux.h>
 #include <selinux/label.h>
-#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) {
index 277e20ec4cdb2cacba13240533778fa16166831c..221a0c43dd091f1bce6aa7bee50ad51b03580232 100644 (file)
@@ -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: