aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Dokuchaev <danfe@FreeBSD.org>2019-03-28 14:37:33 +0000
committerAlexey Dokuchaev <danfe@FreeBSD.org>2019-03-28 14:37:33 +0000
commit68a0d94c1a743c72d018083c63dfb187c42e2d27 (patch)
tree868dc8a844f81124087fabe68444a10e63724aa8
parent4ff9694c2039ac5ef0635adb669eccbbad45eeee (diff)
downloadports-68a0d94c1a743c72d018083c63dfb187c42e2d27.tar.gz
ports-68a0d94c1a743c72d018083c63dfb187c42e2d27.zip
Simplify error handling logic a bit: there is no immediate need to free
resources after initial BN_bin2bn() calls for `p' and `g'; just utilize the original code and call BN_free() after initializing `a' if anything had failed.
Notes
Notes: svn path=/head/; revision=497025
-rw-r--r--net/ss5/files/patch-modules_mod__authen_SS5Supa.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/net/ss5/files/patch-modules_mod__authen_SS5Supa.c b/net/ss5/files/patch-modules_mod__authen_SS5Supa.c
index 812a381dbdbb..c366dbb82fb7 100644
--- a/net/ss5/files/patch-modules_mod__authen_SS5Supa.c
+++ b/net/ss5/files/patch-modules_mod__authen_SS5Supa.c
@@ -8,7 +8,7 @@
int len = 1;
unsigned char * public_key = NULL;
uint32_t len_key = 0;
-@@ -205,41 +206,85 @@ static unsigned char * ss5_secure_dh_compute_key (int
+@@ -205,41 +206,75 @@ static unsigned char * ss5_secure_dh_compute_key (int
else
pid=(UINT)pthread_self();
@@ -16,12 +16,6 @@
- ss->g = BN_bin2bn ((pippo->g), pippo->leng, NULL);
+ p = BN_bin2bn ((pippo->p), pippo->lenp, NULL);
+ g = BN_bin2bn ((pippo->g), pippo->leng, NULL);
-+ if (p == NULL || g == NULL) {
-+ BN_free(g);
-+ BN_free(p);
-+ DH_free(ss);
-+ return NULL;
-+ }
+#if OPENSSL_VERSION_NUMBER >= 0x10100005L
+ DH_set0_pqg(ss, p, NULL, g);
+#else
@@ -29,11 +23,8 @@
+ ss->g = g;
+#endif
a = BN_bin2bn ((pippo->a), pippo->lena, NULL);
-+#if OPENSSL_VERSION_NUMBER >= 0x10100005L
+- if (!a || !ss->p || !ss->g){
+ if (!a || !p || !g) {
-+#else
- if (!a || !ss->p || !ss->g){
-+#endif
if( VERBOSE() ) {
snprintf(logString,256 - 1,"[%u] [VERB] ss5_secure_dh_compute_key - Error when compute a, p, g",pid);
LOGUPDATE()
@@ -96,7 +87,7 @@
ss5_create_dh_response(s, public_key, len_key);
#if 0
printf("B computed: len is %d\n",len_key);
-@@ -256,6 +301,10 @@ static unsigned char * ss5_secure_dh_compute_key (int
+@@ -256,6 +291,10 @@ static unsigned char * ss5_secure_dh_compute_key (int
snprintf(logString,256 - 1,"[%u] [VERB] ss5_secure_dh_compute_key - malloc error",pid);
LOGUPDATE()
}
@@ -107,7 +98,7 @@
return NULL;
}
bzero(session_key, DH_size (ss));
-@@ -266,6 +315,10 @@ static unsigned char * ss5_secure_dh_compute_key (int
+@@ -266,6 +305,10 @@ static unsigned char * ss5_secure_dh_compute_key (int
printf("%02x ", session_key[len]);
printf("\n");
#endif