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:30:44 +0000 (10:30 +0200)
commit0870b2cdaa65a30645bd0cc70f7ad6e30db7a2cf
treea7c5232c249d617d626f2c623987a6be5f9e3b50
parentc7f6ec9e5afc575df260c21ba77cf3a45a8b9b39
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)

(cherry picked from commit 0e83981d61fc435f42d4bb4d774272b69556b7bc)
apps/srp.c