diff --git a/common/lib/libc/string/consttime_memequal.c b/common/lib/libc/string/consttime_memequal.c index 45c81ec65adf..a00d7e197b4b 100644 --- a/common/lib/libc/string/consttime_memequal.c +++ b/common/lib/libc/string/consttime_memequal.c @@ -1,4 +1,4 @@ -/* $NetBSD: consttime_memequal.c,v 1.3 2013/08/28 17:47:07 riastradh Exp $ */ +/* $NetBSD: consttime_memequal.c,v 1.4 2013/08/28 19:31:14 riastradh Exp $ */ #if !defined(_KERNEL) && !defined(_STANDALONE) #include "namespace.h" @@ -18,5 +18,15 @@ consttime_memequal(const void *b1, const void *b2, size_t len) while (len --) res |= *c1++ ^ *c2++; + + /* + * If the compiler for your favourite architecture generates a + * conditional branch for `!res', it will be a data-dependent + * branch, in which case this should be replaced by + * + * return (1 - (1 & ((res - 1) >> 8))); + * + * or rewritten in assembly. + */ return !res; }