Home GnuPG

sexp: Avoid a fatal error in case of ENOMEM in called functions.

Description

sexp: Avoid a fatal error in case of ENOMEM in called functions.

* src/sexp.c (do_vsexp_sscan): Replace BUG() by a proper error
return.  Replace sprintf by snprintf.
(convert_to_hex): Replace sprintf by snprintf.
(convert_to_string): Ditto.
(_gcry_sexp_sprint): Ditto.

_gcry_mpi_print can actually return ENOMEM because it inetrnally needs
to allocate temporary buffers. Thus BUG was not the right thing to
do. This was detected while investigating bug 3530.

Replacing sprintf by snprintf is not technically required but some
compilers print warnings for the use of sprintf. So let's silence
them.

  • Signed-off-by: Werner Koch <wk@gnupg.org>

Details

Provenance
wernerAuthored on Nov 24 2017, 10:44 AM
Parents
rCf4582f8c429f: api: Add auto expand secmem feature
Branches
Unknown
Tags
Unknown