summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/srp
diff options
context:
space:
mode:
authorderaadt <>2014-05-29 21:07:43 +0000
committerderaadt <>2014-05-29 21:07:43 +0000
commit3d662abca6b2a7f5bc9108b036434d61fcdb6e53 (patch)
treed5fe0c330801f3e72c7b588264c6027636db4330 /src/lib/libcrypto/srp
parentd205a2aecb99564cccfbea61c39ebe3b0ddd7fb7 (diff)
downloadopenbsd-3d662abca6b2a7f5bc9108b036434d61fcdb6e53.tar.gz
openbsd-3d662abca6b2a7f5bc9108b036434d61fcdb6e53.tar.bz2
openbsd-3d662abca6b2a7f5bc9108b036434d61fcdb6e53.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/srp')
-rw-r--r--src/lib/libcrypto/srp/srp_lib.c2
-rw-r--r--src/lib/libcrypto/srp/srp_vfy.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libcrypto/srp/srp_lib.c b/src/lib/libcrypto/srp/srp_lib.c
index a3a67eda2e..77e2c2c2f2 100644
--- a/src/lib/libcrypto/srp/srp_lib.c
+++ b/src/lib/libcrypto/srp/srp_lib.c
@@ -121,7 +121,7 @@ BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
121 121
122 longN= BN_num_bytes(N); 122 longN= BN_num_bytes(N);
123 123
124 if ((cAB = malloc(2*longN)) == NULL) 124 if ((cAB = reallocarray(NULL, 2, longN)) == NULL)
125 return NULL; 125 return NULL;
126 126
127 memset(cAB, 0, longN); 127 memset(cAB, 0, longN);
diff --git a/src/lib/libcrypto/srp/srp_vfy.c b/src/lib/libcrypto/srp/srp_vfy.c
index de7dbe5bbd..6ad80ef992 100644
--- a/src/lib/libcrypto/srp/srp_vfy.c
+++ b/src/lib/libcrypto/srp/srp_vfy.c
@@ -573,7 +573,7 @@ char *SRP_create_verifier(const char *user, const char *pass, char **salt,
573 if(!SRP_create_verifier_BN(user, pass, &s, &v, N_bn, g_bn)) goto err; 573 if(!SRP_create_verifier_BN(user, pass, &s, &v, N_bn, g_bn)) goto err;
574 574
575 BN_bn2bin(v,tmp); 575 BN_bn2bin(v,tmp);
576 if (((vf = malloc(BN_num_bytes(v)*2)) == NULL)) 576 if (((vf = reallocarray(NULL, BN_num_bytes(v), 2)) == NULL))
577 goto err; 577 goto err;
578 t_tob64(vf, tmp, BN_num_bytes(v)); 578 t_tob64(vf, tmp, BN_num_bytes(v));
579 579
@@ -582,7 +582,7 @@ char *SRP_create_verifier(const char *user, const char *pass, char **salt,
582 { 582 {
583 char *tmp_salt; 583 char *tmp_salt;
584 584
585 if ((tmp_salt = malloc(SRP_RANDOM_SALT_LEN * 2)) == NULL) 585 if ((tmp_salt = reallocarray(NULL, SRP_RANDOM_SALT_LEN, 2)) == NULL)
586 { 586 {
587 free(vf); 587 free(vf);
588 goto err; 588 goto err;