@@ -584,26 +584,6 @@ rnd(void *buffer)
584
584
*
585
585
*********************************************************************/
586
586
587
- #ifdef USE_SSL
588
- static void
589
- PBKDF2_HMAC_SHA_512 (const char * pass , const unsigned char * salt ,
590
- int32_t iterations , uint32_t outputBytes ,
591
- char * hexResult )
592
- {
593
- unsigned int i ;
594
- unsigned char * digest ;
595
-
596
- digest = (unsigned char * )malloc (outputBytes );
597
-
598
- PKCS5_PBKDF2_HMAC (pass , strlen (pass ), salt , strlen (salt ), iterations ,
599
- EVP_sha512 (), outputBytes , digest );
600
- for (i = 0 ; i < outputBytes ; i ++ )
601
- sprintf (hexResult + (i * 2 ), "%02x" , 255 & digest [i ]);
602
-
603
- free (digest );
604
- }
605
- #endif
606
-
607
587
/**
608
588
* Generate a PBKDF2 password hash with the given password and salt.
609
589
*
@@ -672,7 +652,12 @@ pbkdf2_hash(const char* password, int password_len, const char* salt,
672
652
PKCS5_PBKDF2_HMAC (password , password_len , salt , salt_len , 1000 ,
673
653
EVP_sha512 (), digest_len , digest );
674
654
675
- for (i = 0 ; i < digest_len ; i ++ ) {
655
+ /*
656
+ * The -1 here should avoid a buffer overflow as otherwise this will
657
+ * get to be exactly the same size as buffer with no room for the
658
+ * null.
659
+ */
660
+ for (i = 0 ; i < (digest_len - 1 ); i ++ ) {
676
661
sprintf (buffer + salt_len + 4 + (i * 2 ), "%02x" , 255 & digest [i ]);
677
662
}
678
663
0 commit comments