lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri,  9 Apr 2021 18:48:36 +0100
From:   Andriy Tkachuk <andriy.tkachuk@...il.com>
To:     Alexander Viro <viro@...iv.linux.org.uk>
Cc:     Andreas Gruenbacher <agruenba@...hat.com>,
        Andriy Tkachuk <andriy.tkachuk@...gate.com>,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] xattr: simplify logic at xattr_resolve_name()

The negative case check logic with XOR operation between the
two variables with negated values is really hard to comprehend.
Change it to positive case check with == instead of XOR.

Signed-off-by: Andriy Tkachuk <andriy.tkachuk@...gate.com>
---
 fs/xattr.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index b3444e06cd..531562535d 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -66,13 +66,13 @@ xattr_resolve_name(struct inode *inode, const char **name)
 
 		n = strcmp_prefix(*name, xattr_prefix(handler));
 		if (n) {
-			if (!handler->prefix ^ !*n) {
-				if (*n)
-					continue;
-				return ERR_PTR(-EINVAL);
+			if (!handler->prefix == !*n) {
+				*name = n;
+				return handler;
 			}
-			*name = n;
-			return handler;
+			if (*n)
+				continue;
+			return ERR_PTR(-EINVAL);
 		}
 	}
 	return ERR_PTR(-EOPNOTSUPP);
-- 
2.27.0

Powered by blists - more mailing lists