sexp: Avoid a fatal error in case of ENOMEM in called functions.
authorWerner Koch <wk@gnupg.org>
Fri, 24 Nov 2017 09:44:24 +0000 (10:44 +0100)
committerWerner Koch <wk@gnupg.org>
Fri, 24 Nov 2017 09:49:51 +0000 (10:49 +0100)
commit2ad912d5b7794fb32192fddab1b559c7b86303a2
treea4a4cb3c48d308b92f392ea19f07afc5be119ec1
parent1f6b2f6099ebcfd785e2d2ae0aeca810394dbbac
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>
src/sexp.c