Fix srp app missing NULL termination with password callback
authorDiego Santa Cruz <Diego.SantaCruz@spinetix.com>
Tue, 16 May 2017 14:05:19 +0000 (16:05 +0200)
committerAndy Polyakov <appro@openssl.org>
Mon, 22 May 2017 08:29:16 +0000 (10:29 +0200)
commit0e83981d61fc435f42d4bb4d774272b69556b7bc
treeb19a5ece895e8aa0e330036387e53f365383a7ac
parent48b5352212d8c68f7fd071ca9f38822b7e954c5a
Fix srp app missing NULL termination with password callback

The password_callback() function does not necessarily NULL terminate
the password buffer, the caller must use the returned length but the
srp app uses this function as if it was doing NULL termination.

This made the -passin and -passout options of "openssl srp"
fail inexpicably and randomly or even crash.

Fixed by enlarging the buffer by one, so that the maximum password length
remains unchanged, and adding NULL termination upon return.

[Rearrange code for coding style compliance in process.]

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3475)
apps/srp.c