chiark / gitweb /
Fix bizarre `if (!consttime_memeq(X, Y, N)!=0)' idioms.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 19 Sep 2019 20:01:22 +0000 (20:01 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 21 Sep 2019 09:57:12 +0000 (10:57 +0100)
Clang thinks the `!' is in the wrong place.  I think the `!=0' isn't
doing any work, so I've deleted it.

This stems from 5ad34db2ccbb "memcmp: Introduce and use
consttime_memeq",

  -    if (memcmp(m->nR,st->remoteN,NONCELEN)!=0) {
  +    if (!consttime_memeq(m->nR,st->remoteN,NONCELEN)!=0) {

at which time the !=0 was already redundant and became more confusing.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Acked-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
site.c
transform-cbcmac.c

diff --git a/site.c b/site.c
index c702c7885095b009ca5bea65d259f9d778964823..4ec56dfa5076da4a8a59eea7d7a7ffde74e7e87b 100644 (file)
--- a/site.c
+++ b/site.c
@@ -767,7 +767,7 @@ static bool_t check_msg(struct site *st, uint32_t type, struct msg *m,
        return False;
     }
     if (type==LABEL_MSG2) return True;
-    if (!consttime_memeq(m->nR,st->remoteN,NONCELEN)!=0) {
+    if (!consttime_memeq(m->nR,st->remoteN,NONCELEN)) {
        *error="wrong remotely-generated nonce";
        return False;
     }
index 5e59e212c71857a922459df8e55878299401be40..ad9e901ac332094d9dc0e116493b7855d10ecee7 100644 (file)
@@ -231,7 +231,7 @@ static transform_apply_return transform_reverse(void *sst,
        serpentbe_encrypt(&ti->mackey,macplain,macacc);
     }
     serpentbe_encrypt(&ti->mackey,macacc,macacc);
-    if (!consttime_memeq(macexpected,macacc,16)!=0) {
+    if (!consttime_memeq(macexpected,macacc,16)) {
        *errmsg="invalid MAC";
        return transform_apply_err;
     }