From: Aurelien Aptel Date: Wed, 9 Mar 2016 12:43:09 +0000 (+0100) Subject: s3/winbindd: use == -1 instead of < 0 for error checking uid_t X-Git-Tag: tdb-1.3.10~578 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f13d07e459261ba0881ee725e94edd988c57479f;p=thirdparty%2Fsamba.git s3/winbindd: use == -1 instead of < 0 for error checking uid_t The sign of the uid_t type is left unspecified by POSIX. It's defined as an unsigned 32b int on Linux, therefore the < 0 check is always false. For unsigned version of uid_t, "uid == -1" will implicitely cast -1 to unsigned making it a valid test for both signed and unsigned version of uid_t. This commit makes the cast to (uid_t) explicit anyway. Signed-off-by: Aurelien Aptel Reviewed-by: Jeremy Allison Reviewed-by: Michael Adam Autobuild-User(master): Michael Adam Autobuild-Date(master): Fri Jul 1 05:22:36 CEST 2016 on sn-devel-144 --- diff --git a/source3/winbindd/winbindd_cred_cache.c b/source3/winbindd/winbindd_cred_cache.c index e113f998a3b..20b4d55fb80 100644 --- a/source3/winbindd/winbindd_cred_cache.c +++ b/source3/winbindd/winbindd_cred_cache.c @@ -503,7 +503,7 @@ NTSTATUS add_ccache_to_list(const char *princ_name, NTSTATUS ntret; if ((username == NULL && princ_name == NULL) || - ccname == NULL || uid < 0) { + ccname == NULL || uid == (uid_t)-1) { return NT_STATUS_INVALID_PARAMETER; } diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c index 2cfd88ae6db..8ec4fe4a6a1 100644 --- a/source3/winbindd/winbindd_pam.c +++ b/source3/winbindd/winbindd_pam.c @@ -555,7 +555,7 @@ uid_t get_uid_from_request(struct winbindd_request *request) uid = request->data.auth.uid; - if (uid < 0) { + if (uid == (uid_t)-1) { DEBUG(1,("invalid uid: '%u'\n", (unsigned int)uid)); return -1; } @@ -2311,7 +2311,7 @@ enum winbindd_result winbindd_dual_pam_logoff(struct winbindd_domain *domain, #ifdef HAVE_KRB5 - if (state->request->data.logoff.uid < 0) { + if (state->request->data.logoff.uid == (uid_t)-1) { DEBUG(0,("winbindd_pam_logoff: invalid uid\n")); goto process_result; }