[CRYPTO] scatterwalk: Handle zero nbytes in scatterwalk_map_and_copy
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 13 Dec 2007 16:44:11 +0000 (00:44 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 10 Jan 2008 21:16:54 +0000 (08:16 +1100)
It's better to return silently than crash and burn when someone feeds us
a zero length.  In particular the null digest algorithm when used as part
of authenc will do that to us.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/scatterwalk.c

index 297e19d13c4e6c34dd52688158266a1b502be518..9aeeb52004a5399d0a9b7a3484044b5de1e3083c 100644 (file)
@@ -105,6 +105,9 @@ void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
        struct scatter_walk walk;
        unsigned int offset = 0;
 
+       if (!nbytes)
+               return;
+
        for (;;) {
                scatterwalk_start(&walk, sg);