]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Make sha256_process() easier for static analyzers
authorJouni Malinen <j@w1.fi>
Sun, 13 Nov 2011 19:36:23 +0000 (21:36 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 13 Nov 2011 19:36:23 +0000 (21:36 +0200)
md->curlen cannot indicate full buffer size here since the buffered
data is processed whenever the full block size of data is available.
Avoid invalid warnings from static analyzers on memcpy() outside the
buffer length by verifying that curlen is smaller than block size.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/crypto/sha256-internal.c

index 01a8007426ecaee92915c0ce5e2bc6fc588f85f1..aeaa0a106d45c9af5ba92b6f60baf4792bf355d6 100644 (file)
@@ -164,7 +164,7 @@ static int sha256_process(struct sha256_state *md, const unsigned char *in,
        unsigned long n;
 #define block_size 64
 
-       if (md->curlen > sizeof(md->buf))
+       if (md->curlen >= sizeof(md->buf))
                return -1;
 
        while (inlen > 0) {