瀏覽代碼

lib/digsig: digsig_verify_rsa(): return -EINVAL if modulo length is zero

Currently, if digsig_verify_rsa() detects that the modulo's length is zero,
i.e. mlen == 0, it returns -ENOMEM which doesn't really fit here.

Make digsig_verify_rsa() return -EINVAL upon mlen == 0.

Signed-off-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Nicolai Stange 9 年之前
父節點
當前提交
c5ce7c697c
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      lib/digsig.c

+ 5 - 3
lib/digsig.c

@@ -114,13 +114,15 @@ static int digsig_verify_rsa(struct key *key,
 		datap += remaining;
 		datap += remaining;
 	}
 	}
 
 
-	err = -ENOMEM;
-
 	mblen = mpi_get_nbits(pkey[0]);
 	mblen = mpi_get_nbits(pkey[0]);
 	mlen = DIV_ROUND_UP(mblen, 8);
 	mlen = DIV_ROUND_UP(mblen, 8);
 
 
-	if (mlen == 0)
+	if (mlen == 0) {
+		err = -EINVAL;
 		goto err;
 		goto err;
+	}
+
+	err = -ENOMEM;
 
 
 	out1 = kzalloc(mlen, GFP_KERNEL);
 	out1 = kzalloc(mlen, GFP_KERNEL);
 	if (!out1)
 	if (!out1)