From: Karel Zak Date: Mon, 8 Jan 2024 09:32:54 +0000 (+0100) Subject: libmount: don't assume errno after failed asprintf() X-Git-Tag: v2.40-rc1~50^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a002df07ac15c370381cb44f06afeaa333685780;p=thirdparty%2Futil-linux.git libmount: don't assume errno after failed asprintf() Reported-by: Thomas Weißschuh Signed-off-by: Karel Zak --- diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c index 0e08c9eb57..ef53b6d69d 100644 --- a/libmount/src/monitor.c +++ b/libmount/src/monitor.c @@ -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; } diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c index 67baa8ead4..6a2c77b39c 100644 --- a/libmount/src/tab_update.c +++ b/libmount/src/tab_update.c @@ -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); diff --git a/libmount/src/utils.c b/libmount/src/utils.c index f301f3f567..a2f8ea0337 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -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).