From 8e8e3c26b87d78b92d96ba91d58ee59d774ebcb5 Mon Sep 17 00:00:00 2001 From: Nickolai Zeldovich Date: Sat, 5 Jan 2013 23:45:59 -0500 Subject: [PATCH] libadmin/vos/vosutils.c: mask out sign-extension Right-shifting a signed int by 24 bits can produce a value outside of 0..0xff due to sign-extension. As a result, in AddressMatch(), the first bPattern!=255 check can never succeed. Fix by masking with 255 before comparison. Change-Id: Idb0b4c176ff120c7cf0e03a935ebfdca51084bbd Reviewed-on: http://gerrit.openafs.org/8884 Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman Tested-by: BuildBot --- src/libadmin/vos/vosutils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libadmin/vos/vosutils.c b/src/libadmin/vos/vosutils.c index 191e5f435c..3fcab99890 100644 --- a/src/libadmin/vos/vosutils.c +++ b/src/libadmin/vos/vosutils.c @@ -568,8 +568,8 @@ AddressMatch(int addrTest, int addrPattern) int bPattern; /* Test the high byte */ - bTest = addrTest >> 24; - bPattern = addrPattern >> 24; + bTest = (addrTest >> 24) & 255; + bPattern = (addrPattern >> 24) & 255; if ((bTest != bPattern) && (bPattern != 255)) { return FALSE; }