瀏覽代碼

crypto: drbg - fix failure of generating multiple of 2**16 bytes

The function drbg_generate_long slices the request into 2**16 byte
or smaller chunks. However, the loop, however invokes the random number
generation function with zero bytes when the request size is a multiple
of 2**16 bytes. The fix prevents zero bytes requests.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Stephan Mueller 11 年之前
父節點
當前提交
ce5481d01f
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      crypto/drbg.c

+ 1 - 1
crypto/drbg.c

@@ -1500,7 +1500,7 @@ static int drbg_generate_long(struct drbg_state *drbg,
 		if (0 >= tmplen)
 			return tmplen;
 		len += tmplen;
-	} while (slice > 0);
+	} while (slice > 0 && (len < buflen));
 	return len;
 }