From 27c67307976a60088ca301e07404bdb52740c3af Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 15 Oct 2010 15:57:10 +0200 Subject: Use unsigned long for conversion to id_t We used strtol() on a number of places to convert into uid_t or gid_t from a string representation such as LDAP attribute, but on some platforms, unsigned long might be necessary to store big id_t values. This patch converts to using strtoul() instead. --- src/util/find_uid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/util') diff --git a/src/util/find_uid.c b/src/util/find_uid.c index 02d668636..0937c6648 100644 --- a/src/util/find_uid.c +++ b/src/util/find_uid.c @@ -63,7 +63,7 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) char *p; char *e; char *endptr; - long num=0; + unsigned long num=0; errno_t error; ret = snprintf(path, PATHLEN, "/proc/%d/status", pid); @@ -132,9 +132,9 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) *e = '\0'; } errno = 0; - num = strtol(p, &endptr, 10); + num = strtoul(p, &endptr, 10); error = errno; - if (error == ERANGE) { + if (error != 0) { DEBUG(1, ("strtol failed [%s].\n", strerror(error))); return error; } @@ -143,7 +143,7 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) return EINVAL; } - if (num < 0 || num >= INT_MAX) { + if (num >= UINT32_MAX) { DEBUG(1, ("uid out of range.\n")); return ERANGE; } -- cgit