summaryrefslogtreecommitdiff
path: root/src/sexp.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2003-10-08 08:36:06 +0000
committerWerner Koch <wk@gnupg.org>2003-10-08 08:36:06 +0000
commitecdc47fd753bed8fb3f8f3c29a481d1d5fbb82b6 (patch)
treeb17f4dc9dee07dcdd5b4a7bfb7c71fbb3ed31969 /src/sexp.c
parent9dc784bccb9baeee721bea02a6097de1572ed44f (diff)
downloadlibgcrypt-ecdc47fd753bed8fb3f8f3c29a481d1d5fbb82b6.tar.gz
* sexp.c (sexp_sscan): Check that parenthesis are matching.
* tsexp.c (check_sscan): New.
Diffstat (limited to 'src/sexp.c')
-rw-r--r--src/sexp.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/sexp.c b/src/sexp.c
index 5de4c8c5..f4a7e0b2 100644
--- a/src/sexp.c
+++ b/src/sexp.c
@@ -857,6 +857,7 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ\
size_t dummy_erroff;
struct make_space_ctx c;
int arg_counter = 0;
+ int level = 0;
if (! erroff)
erroff = &dummy_erroff;
@@ -874,8 +875,9 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ\
} \
while (0)
- /* FIXME: replace all the returns by a jump to the leave label
- * and invent better error codes. Make sure that everything is cleaned up*/
+ /* FIXME: replace all the returns by a jump to the leave label and
+ * invent better error codes. FIXME: Make sure that everything is
+ * cleaned up. */
#define MAKE_SPACE(n) do { make_space ( &c, (n) ); } while (0)
#define STORE_LEN(p,n) do { \
DATALEN ashort = (n); \
@@ -1109,6 +1111,7 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ\
}
MAKE_SPACE (0);
*c.pos++ = ST_OPEN;
+ level++;
}
else if( *p == ')' ) { /* walk up */
if( disphint ) {
@@ -1118,6 +1121,7 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ\
}
MAKE_SPACE (0);
*c.pos++ = ST_CLOSE;
+ level--;
}
else if( *p == '\"' ) {
quoted = p;
@@ -1182,6 +1186,9 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ\
MAKE_SPACE (0);
*c.pos++ = ST_STOP;
+ if (level)
+ return gcry_error (GPG_ERR_SEXP_UNMATCHED_PAREN);
+
*retsexp = normalize ( c.sexp );
return gcry_error (GPG_ERR_NO_ERROR);
#undef MAKE_SPACE