From 8aeecc155d3aef5dae8762ace236dd6365fb636d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Sat, 16 Nov 2002 00:24:41 +0100 Subject: [PATCH] (macro GET): Check sign of parsed numbers. Rev: src/nettle/sexp2dsa.c:1.2 Rev: src/nettle/sexp2rsa.c:1.9 --- sexp2dsa.c | 8 ++++++-- sexp2rsa.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sexp2dsa.c b/sexp2dsa.c index e7731cc6..357b3cf8 100644 --- a/sexp2dsa.c +++ b/sexp2dsa.c @@ -35,8 +35,12 @@ #include <string.h> -#define GET(x, l, v) \ -do { if (!nettle_mpz_set_sexp((x), (l), (v))) return 0; } while(0) +#define GET(x, l, v) \ +do { \ + if (!nettle_mpz_set_sexp((x), (l), (v)) \ + || mpz_sgn(x) <= 0) \ + return 0; \ +} while(0) /* Iterator should point past the algorithm tag, e.g. * diff --git a/sexp2rsa.c b/sexp2rsa.c index 85111408..c5795db3 100644 --- a/sexp2rsa.c +++ b/sexp2rsa.c @@ -35,8 +35,12 @@ #include <string.h> -#define GET(x, l, v) \ -do { if (!nettle_mpz_set_sexp((x), (l), (v))) return 0; } while(0) +#define GET(x, l, v) \ +do { \ + if (!nettle_mpz_set_sexp((x), (l), (v)) \ + || mpz_sgn(x) <= 0) \ + return 0; \ +} while(0) /* Iterator should point past the algorithm tag, e.g. * -- GitLab