]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: don't assume errno after failed asprintf()
authorKarel Zak <kzak@redhat.com>
Mon, 8 Jan 2024 09:32:54 +0000 (10:32 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 8 Jan 2024 09:32:54 +0000 (10:32 +0100)
Reported-by: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/monitor.c
libmount/src/tab_update.c
libmount/src/utils.c

index 0e08c9eb57abe22e06bb1d1186573a163a9764e7..ef53b6d69d462b4b05509ebee86ac9d19a00c285 100644 (file)
@@ -229,7 +229,7 @@ static int userspace_add_watch(struct monitor_entry *me, int *final, int *fd)
         * libmount uses utab.event file to monitor and control utab updates
         */
        if (asprintf(&filename, "%s.event", me->path) <= 0) {
-               rc = -errno;
+               rc = -ENOMEM;
                goto done;
        }
 
index 67baa8ead4a335f29f6abd9818fbb221ef708426..6a2c77b39c592b266d81c778c380193a7aa12c92 100644 (file)
@@ -1013,7 +1013,7 @@ int mnt_update_emit_event(struct libmnt_update *upd)
                return -EINVAL;
 
        if (asprintf(&filename, "%s.event", upd->filename) <= 0)
-               return -errno;
+               return -ENOMEM;
 
        fd = open(filename, O_WRONLY|O_CREAT|O_CLOEXEC,
                            S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH);
index f301f3f5677a9f2525129c98ba3537eed5186980..a2f8ea0337c929672c158ac60dd8a5bebe74d449 100644 (file)
@@ -1032,7 +1032,7 @@ int mnt_open_uniq_filename(const char *filename, char **name)
 
        rc = asprintf(&n, "%s.XXXXXX", filename);
        if (rc <= 0)
-               return -errno;
+               return -ENOMEM;
 
        /* This is for very old glibc and for compatibility with Posix, which says
         * nothing about mkstemp() mode. All sane glibc use secure mode (0600).