summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2021-01-13 10:57:22 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2021-01-13 10:57:22 +0900
commit00d7c1c632019066a4884930d413ccc044d81af5 (patch)
treec530fce85d86e7c2b5b4cd657cc8c35b717d7f05
parent4768baf74be03d8973d004725f796aef329c45bf (diff)
downloadlibgcrypt-00d7c1c632019066a4884930d413ccc044d81af5.tar.gz
sexp: Raise an error when an integer is negative with USG.
* src/sexp.c (do_vsexp_sscan): Return GPG_ERR_INV_ARG if negative. -- GnuPG-bug-id: 4964 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r--src/sexp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/sexp.c b/src/sexp.c
index de28aedc..864916be 100644
--- a/src/sexp.c
+++ b/src/sexp.c
@@ -1483,6 +1483,12 @@ do_vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
}
else
{
+ if (mpifmt == GCRYMPI_FMT_USG && mpi_cmp_ui (m, 0) < 0)
+ {
+ err = GPG_ERR_INV_ARG;
+ goto leave;
+ }
+
err = _gcry_mpi_print (mpifmt, NULL, 0, &nm, m);
if (err)
goto leave;