From b6294fd5f484e933fff627a69032a8c5ef0de568 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 1 Aug 2015 05:52:59 -0400 Subject: [PATCH] src/kauth/krb_udp.c: Remove redundant NULL check for array address Resolves this warning with clang: krb_udp.c:302:13: warning: address of array 'tentry.misc_auth_bytes' will always evaluate to 'true' [-Wpointer-bool-conversion] if (tentry.misc_auth_bytes) { ~~ ~~~~~~~^~~~~~~~~~~~~~~ Reviewed-on: http://gerrit.openafs.org/11964 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit 09bf3ebb26a3d8a4bd10571b394a59207a7f6980) Change-Id: I94850d438902c358239142d696fae7206cef55a6 Reviewed-on: http://gerrit.openafs.org/12077 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk Reviewed-by: Mark Vitale Reviewed-by: Stephan Wiesand --- src/kauth/krb_udp.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/kauth/krb_udp.c b/src/kauth/krb_udp.c index d9ecd3c5a..9ef02fb58 100644 --- a/src/kauth/krb_udp.c +++ b/src/kauth/krb_udp.c @@ -277,6 +277,11 @@ UDP_Authenticate(int ksoc, struct sockaddr_in *client, char *name, if (to) { /* if user exists check other stuff */ afs_int32 sto; struct kaentry sentry; + + unsigned char misc_auth_bytes[4]; + afs_uint32 temp; /* unsigned for safety */ + afs_uint32 pwexpires; + save_principal(udpAuthPrincipal, name, inst, 0); tgt = ((strcmp(sname, KA_TGS_NAME) == 0) @@ -302,23 +307,17 @@ UDP_Authenticate(int ksoc, struct sockaddr_in *client, char *name, goto abort; } - if (tentry.misc_auth_bytes) { - unsigned char misc_auth_bytes[4]; - afs_uint32 temp; /* unsigned for safety */ - afs_uint32 pwexpires; - - memcpy(&temp, tentry.misc_auth_bytes, sizeof(afs_uint32)); - temp = ntohl(temp); - unpack_long(temp, misc_auth_bytes); - pwexpires = misc_auth_bytes[0]; - if (pwexpires) { - pwexpires = - ntohl(tentry.change_password_time) + - 24 * 60 * 60 * pwexpires; - if (pwexpires < now) { - code = KERB_ERR_AUTH_EXP; /* was KAPWEXPIRED */ - goto abort; - } + memcpy(&temp, tentry.misc_auth_bytes, sizeof(afs_uint32)); + temp = ntohl(temp); + unpack_long(temp, misc_auth_bytes); + pwexpires = misc_auth_bytes[0]; + if (pwexpires) { + pwexpires = + ntohl(tentry.change_password_time) + + 24 * 60 * 60 * pwexpires; + if (pwexpires < now) { + code = KERB_ERR_AUTH_EXP; /* was KAPWEXPIRED */ + goto abort; } } -- 2.39.5