From 242ba52465194fbd66b995d4db729e867561e408 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sat, 26 Aug 2023 14:59:13 +0200 Subject: [PATCH] lib/subordinateio.c: get_owner_id(): Use snprintf_() instead of its pattern Signed-off-by: Alejandro Colomar --- lib/subordinateio.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/subordinateio.c b/lib/subordinateio.c index bf02328e7..2fdbdea3b 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -807,7 +807,6 @@ static bool get_owner_id(const char *owner, enum subid_type id_type, char *id) { struct passwd *pw; struct group *gr; - int ret = 0; switch (id_type) { case ID_TYPE_UID: @@ -815,20 +814,16 @@ static bool get_owner_id(const char *owner, enum subid_type id_type, char *id) if (pw == NULL) { return false; } - ret = snprintf(id, ID_SIZE, "%u", pw->pw_uid); - if (ret < 0 || ret >= ID_SIZE) { + if (snprintf_(id, ID_SIZE, "%u", pw->pw_uid) == -1) return false; - } break; case ID_TYPE_GID: gr = getgrnam(owner); if (gr == NULL) { return false; } - ret = snprintf(id, ID_SIZE, "%u", gr->gr_gid); - if (ret < 0 || ret >= ID_SIZE) { + if (snprintf_(id, ID_SIZE, "%u", gr->gr_gid) == -1) return false; - } break; default: return false;