Path: blob/main/ftp/bbftp-client/files/patch-connecttoserver.c
16462 views
--- connecttoserver.c.orig 2013-02-07 10:42:46 UTC1+++ connecttoserver.c2@@ -517,6 +517,7 @@ int connectviapassword()3#ifdef WITH_SSL4RSA *hisrsa ;5int lenrsa ;6+ BIGNUM *n, *e;7#endif8/*9** Get the socket10@@ -629,33 +630,35 @@ int connectviapassword()11/*12** Getting BIGNUM structures to store the key and exponent13*/14- if ( (hisrsa->n = BN_new()) == NULL) {15+ n = BN_new();16+ e = BN_new();17+ if (n == NULL || e == NULL) {18free(readbuffer) ;19close(tmpctrlsock) ;20printmessage(stderr,CASE_ERROR,56,timestamp,"Error reading encrypted message : %s (%s)\n","getting BIGNUM",(char *) ERR_error_string(ERR_get_error(),NULL)) ;21return -1 ;22}23- if ( (hisrsa->e = BN_new()) == NULL) {24- free(readbuffer) ;25- close(tmpctrlsock) ;26- printmessage(stderr,CASE_ERROR,56,timestamp,"Error reading encrypted message : %s (%s)\n","getting BIGNUM",(char *) ERR_error_string(ERR_get_error(),NULL)) ;27- return -1 ;28- }29/*30** Copy the key and exponent received31*/32- if ( BN_mpi2bn(pubkey,lenkey,hisrsa->n) == NULL ) {33+ if ( BN_mpi2bn(pubkey,lenkey,n) == NULL ) {34free(readbuffer) ;35close(tmpctrlsock) ;36printmessage(stderr,CASE_ERROR,56,timestamp,"Error reading encrypted message : %s (%s)\n","copying pubkey",(char *) ERR_error_string(ERR_get_error(),NULL)) ;37return -1 ;38}39- if ( BN_mpi2bn(pubexponent,lenexpo,hisrsa->e) == NULL ) {40+ if ( BN_mpi2bn(pubexponent,lenexpo,e) == NULL ) {41free(readbuffer) ;42close(tmpctrlsock) ;43printmessage(stderr,CASE_ERROR,56,timestamp,"Error reading encrypted message : %s (%s)\n","copying pubexponent",(char *) ERR_error_string(ERR_get_error(),NULL)) ;44return -1 ;45}46+#if OPENSSL_VERSION_NUMBER < 0x10100000L47+ hisrsa->n = n;48+ hisrsa->e = e;49+#else50+ RSA_set0_key(hisrsa, n, e, NULL);51+#endif52lenrsa = RSA_size(hisrsa) ;5354if (strlen(username) > lenrsa - 41 ) {555657