Fix: 'openssl ca' command crashes when used with 'rand_serial' option
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Tue, 16 Oct 2018 21:50:16 +0000 (23:50 +0200)
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Wed, 17 Oct 2018 10:04:17 +0000 (12:04 +0200)
commit135e8062369f3c7a2398ac12e7eea3c3c18b017d
tree307a9c999c67cbabefecbdbed155d302fd081009
parent695bc60fe4abbe2e6ef3039f96bade5315778c98
Fix: 'openssl ca' command crashes when used with 'rand_serial' option

Commit ffb46830e2df introduced the 'rand_serial' option. When it is used,
the 'serialfile' does not get initialized, i.e. it remains a NULL pointer.
This causes a crash when the NULL pointer is passed to the rotate_serial()
call.

This commit fixes the crash and unifies the pointer checking before
calling the rotate_serial() and save_serial() commands.

Fixes #7412

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7417)

(cherry picked from commit aeec793b4bee929cef8ae35ec4b5a783a6e1d7ed)
apps/ca.c