diff options
author | Werner Koch <wk@gnupg.org> | 2003-10-08 08:36:06 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2003-10-08 08:36:06 +0000 |
commit | ecdc47fd753bed8fb3f8f3c29a481d1d5fbb82b6 (patch) | |
tree | b17f4dc9dee07dcdd5b4a7bfb7c71fbb3ed31969 /src/sexp.c | |
parent | 9dc784bccb9baeee721bea02a6097de1572ed44f (diff) | |
download | libgcrypt-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.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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 |