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>
Thu, 1 Jun 2017 20:22:24 +0000 (22:22 +0200)
commit9a2a0617e5b042ae5d5b53886e30dc47fe778f7f
tree27eaa48bccf1d34218f51192310210368769a296
parent44191de234b061145a6ed14221927ec0c9c7b7bf
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.]

This backport of 0e83981d61fc435f42d4bb4d774272b69556b7bc.

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