From 9e301afb8826b2c0926779c1439643b7506df953 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Tue, 25 Jun 2024 21:39:50 -0700 Subject: [PATCH] idpriv-droptemp: Handle large user and group ids. * lib/idpriv-droptemp.c (saved_uid): Use uid_t instead of int. (saved_gid): Use gid_t instead of int. (idpriv_temp_drop): Use uid_t and gid_t instead of int. (idpriv_temp_restore): Likewise. --- ChangeLog | 6 ++++++ lib/idpriv-droptemp.c | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index f10e0edb43..05bec51810 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2024-06-25 Collin Funk + idpriv-droptemp: Handle large user and group ids. + * lib/idpriv-droptemp.c (saved_uid): Use uid_t instead of int. + (saved_gid): Use gid_t instead of int. + (idpriv_temp_drop): Use uid_t and gid_t instead of int. + (idpriv_temp_restore): Likewise. + idpriv-drop: Handle large user and group ids. * lib/idpriv-drop.c (idpriv_drop): Use uid_t and gid_t instead of int. diff --git a/lib/idpriv-droptemp.c b/lib/idpriv-droptemp.c index eb882dea6d..15337cdd9e 100644 --- a/lib/idpriv-droptemp.c +++ b/lib/idpriv-droptemp.c @@ -25,18 +25,18 @@ /* The privileged uid and gid that the process had earlier. */ #if HAVE_GETUID -static int saved_uid = -1; +static uid_t saved_uid = -1; #endif #if HAVE_GETGID -static int saved_gid = -1; +static gid_t saved_gid = -1; #endif int idpriv_temp_drop (void) { #if HAVE_GETEUID && HAVE_GETEGID && (HAVE_SETRESUID || HAVE_SETREUID) && (HAVE_SETRESGID || HAVE_SETREGID) - int uid = getuid (); - int gid = getgid (); + uid_t uid = getuid (); + gid_t gid = getgid (); /* Find out about the privileged uid and gid at the first call. */ if (saved_uid == -1) @@ -124,8 +124,8 @@ int idpriv_temp_restore (void) { #if HAVE_GETEUID && HAVE_GETEGID && (HAVE_SETRESUID || HAVE_SETREUID) && (HAVE_SETRESGID || HAVE_SETREGID) - int uid = getuid (); - int gid = getgid (); + uid_t uid = getuid (); + gid_t gid = getgid (); if (saved_uid == -1 || saved_gid == -1) /* Caller error: idpriv_temp_drop was never invoked. */ -- 2.39.5