summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ecp_nistp521.c
diff options
context:
space:
mode:
authorderaadt <>2014-05-29 21:07:43 +0000
committerderaadt <>2014-05-29 21:07:43 +0000
commit642d45ae22413aa8195b105d051ca8896e782c5d (patch)
treed5fe0c330801f3e72c7b588264c6027636db4330 /src/lib/libcrypto/ec/ecp_nistp521.c
parentf60b3b3365842d8869513a7e36981671cd726939 (diff)
downloadopenbsd-642d45ae22413aa8195b105d051ca8896e782c5d.tar.gz
openbsd-642d45ae22413aa8195b105d051ca8896e782c5d.tar.bz2
openbsd-642d45ae22413aa8195b105d051ca8896e782c5d.zip
convert 53 malloc(a*b) to reallocarray(NULL, a, b). that is 53
potential integer overflows easily changed into an allocation return of NULL, with errno nicely set if need be. checks for an allocations returning NULL are commonplace, or if the object is dereferenced (quite normal) will result in a nice fault which can be detected & repaired properly. ok tedu
Diffstat (limited to 'src/lib/libcrypto/ec/ecp_nistp521.c')
-rw-r--r--src/lib/libcrypto/ec/ecp_nistp521.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/libcrypto/ec/ecp_nistp521.c b/src/lib/libcrypto/ec/ecp_nistp521.c
index 6792c5b71d..083e017cdc 100644
--- a/src/lib/libcrypto/ec/ecp_nistp521.c
+++ b/src/lib/libcrypto/ec/ecp_nistp521.c
@@ -1874,8 +1874,11 @@ ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r,
1874 } 1874 }
1875 secrets = calloc(num_points, sizeof(felem_bytearray)); 1875 secrets = calloc(num_points, sizeof(felem_bytearray));
1876 pre_comp = calloc(num_points, 17 * 3 * sizeof(felem)); 1876 pre_comp = calloc(num_points, 17 * 3 * sizeof(felem));
1877 if (mixed) 1877 if (mixed) {
1878 tmp_felems = malloc((num_points * 17 + 1) * sizeof(felem)); 1878 /* XXX should do more int overflow checking */
1879 tmp_felems = reallocarray(NULL,
1880 (num_points * 17 + 1), sizeof(felem));
1881 }
1879 if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_felems == NULL))) { 1882 if ((secrets == NULL) || (pre_comp == NULL) || (mixed && (tmp_felems == NULL))) {
1880 ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_MALLOC_FAILURE); 1883 ECerr(EC_F_EC_GFP_NISTP521_POINTS_MUL, ERR_R_MALLOC_FAILURE);
1881 goto err; 1884 goto err;