diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2010-10-15 15:57:10 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-10-18 13:12:04 -0400 |
commit | 27c67307976a60088ca301e07404bdb52740c3af (patch) | |
tree | 698c9331ad91cd71687055f3cf4951dbc5a755b3 /src/util | |
parent | d80a670c94e5a0e21702b8cd8ac5a66fbba81178 (diff) | |
download | sssd-27c67307976a60088ca301e07404bdb52740c3af.tar.gz sssd-27c67307976a60088ca301e07404bdb52740c3af.tar.xz sssd-27c67307976a60088ca301e07404bdb52740c3af.zip |
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.
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/find_uid.c | 8 |
1 files changed, 4 insertions, 4 deletions
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; } |