[openssh-commits] [openssh] 02/03: Cast *ID types to unsigned long when printing.

git+noreply at mindrot.org git+noreply at mindrot.org
Sat Jul 6 13:26:51 AEST 2019


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit 4c3e00b1ed7e596610f34590eb5d54ee50d77878
Author: Darren Tucker <dtucker at dtucker.net>
Date:   Sat Jul 6 13:02:34 2019 +1000

    Cast *ID types to unsigned long when printing.
    
    UID and GID types vary by platform so cast to u_long and use %lu when
    printing them to prevent warnings.
---
 openbsd-compat/bsd-setres_id.c | 12 ++++++------
 openbsd-compat/pwcache.c       |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/openbsd-compat/bsd-setres_id.c b/openbsd-compat/bsd-setres_id.c
index 696ae7b2..a8e76bf6 100644
--- a/openbsd-compat/bsd-setres_id.c
+++ b/openbsd-compat/bsd-setres_id.c
@@ -37,20 +37,20 @@ setresgid(gid_t rgid, gid_t egid, gid_t sgid)
 #if defined(HAVE_SETREGID) && !defined(BROKEN_SETREGID)
 	if (setregid(rgid, egid) < 0) {
 		saved_errno = errno;
-		error("setregid %u: %.100s", rgid, strerror(errno));
+		error("setregid %lu: %.100s", (u_long)rgid, strerror(errno));
 		errno = saved_errno;
 		ret = -1;
 	}
 #else
 	if (setegid(egid) < 0) {
 		saved_errno = errno;
-		error("setegid %u: %.100s", (u_int)egid, strerror(errno));
+		error("setegid %lu: %.100s", (u_long)egid, strerror(errno));
 		errno = saved_errno;
 		ret = -1;
 	}
 	if (setgid(rgid) < 0) {
 		saved_errno = errno;
-		error("setgid %u: %.100s", rgid, strerror(errno));
+		error("setgid %ul: %.100s", (u_long)rgid, strerror(errno));
 		errno = saved_errno;
 		ret = -1;
 	}
@@ -72,7 +72,7 @@ setresuid(uid_t ruid, uid_t euid, uid_t suid)
 #if defined(HAVE_SETREUID) && !defined(BROKEN_SETREUID)
 	if (setreuid(ruid, euid) < 0) {
 		saved_errno = errno;
-		error("setreuid %u: %.100s", ruid, strerror(errno));
+		error("setreuid %lu: %.100s", (u_long)ruid, strerror(errno));
 		errno = saved_errno;
 		ret = -1;
 	}
@@ -81,14 +81,14 @@ setresuid(uid_t ruid, uid_t euid, uid_t suid)
 # ifndef SETEUID_BREAKS_SETUID
 	if (seteuid(euid) < 0) {
 		saved_errno = errno;
-		error("seteuid %u: %.100s", euid, strerror(errno));
+		error("seteuid %lu: %.100s", (u_long)euid, strerror(errno));
 		errno = saved_errno;
 		ret = -1;
 	}
 # endif
 	if (setuid(ruid) < 0) {
 		saved_errno = errno;
-		error("setuid %u: %.100s", ruid, strerror(errno));
+		error("setuid %lu: %.100s", (u_long)ruid, strerror(errno));
 		errno = saved_errno;
 		ret = -1;
 	}
diff --git a/openbsd-compat/pwcache.c b/openbsd-compat/pwcache.c
index 5a8b7880..826c2378 100644
--- a/openbsd-compat/pwcache.c
+++ b/openbsd-compat/pwcache.c
@@ -67,7 +67,7 @@ user_from_uid(uid_t uid, int nouser)
 		if ((pw = getpwuid(uid)) == NULL) {
 			if (nouser)
 				return (NULL);
-			(void)snprintf(nbuf, sizeof(nbuf), "%u", uid);
+			(void)snprintf(nbuf, sizeof(nbuf), "%lu", (u_long)uid);
 		}
 		cp->uid = uid;
 		if (cp->name != NULL)
@@ -102,7 +102,7 @@ group_from_gid(gid_t gid, int nogroup)
 		if ((gr = getgrgid(gid)) == NULL) {
 			if (nogroup)
 				return (NULL);
-			(void)snprintf(nbuf, sizeof(nbuf), "%u", gid);
+			(void)snprintf(nbuf, sizeof(nbuf), "%lu", (u_long)gid);
 		}
 		cp->gid = gid;
 		if (cp->name != NULL)

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list