summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2016-02-16 08:20:58 +0100
committerNiels Möller <nisse@lysator.liu.se>2016-02-16 08:20:58 +0100
commitdd83950b0614ca4aec73da843bfb175c8278be9c (patch)
treeb57f16458467266c829299c79983c9320fe5bbde /tools
parent84c96c59fc63921c03a3e50a7859499792bb0c18 (diff)
downloadnettle-dd83950b0614ca4aec73da843bfb175c8278be9c.tar.gz
Fix sexp-conv assertion failure, reported by Hanno Böck.
Diffstat (limited to 'tools')
-rw-r--r--tools/input.c81
1 files changed, 40 insertions, 41 deletions
diff --git a/tools/input.c b/tools/input.c
index b8085a4e..18a9dff5 100644
--- a/tools/input.c
+++ b/tools/input.c
@@ -286,57 +286,56 @@ sexp_get_string_length(struct sexp_input *input, enum sexp_mode mode,
}
}
- switch(input->c)
- {
- case ':':
- /* Verbatim */
- for (; length; length--)
- {
- sexp_next_char(input);
- sexp_push_char(input, string);
- }
-
- break;
+ if (input->c == ':')
+ /* Verbatim */
+ for (; length; length--)
+ {
+ sexp_next_char(input);
+ sexp_push_char(input, string);
+ }
- case '"':
- if (mode != SEXP_ADVANCED)
- die("Encountered quoted string in canonical mode.\n");
+ else if (mode != SEXP_ADVANCED)
+ die("Encountered advanced string in canonical mode.\n");
- for (; length; length--)
- if (sexp_get_quoted_char(input))
- sexp_push_char(input, string);
- else
- die("Unexpected end of string.\n");
+ else
+ switch(input->c)
+ {
+ case '"':
+ for (; length; length--)
+ if (sexp_get_quoted_char(input))
+ sexp_push_char(input, string);
+ else
+ die("Unexpected end of string.\n");
- if (sexp_get_quoted_char(input))
- die("Quoted string longer than expected.\n");
+ if (sexp_get_quoted_char(input))
+ die("Quoted string longer than expected.\n");
- break;
+ break;
- case '#':
- sexp_input_start_coding(input, &nettle_base16, '#');
- goto decode;
+ case '#':
+ sexp_input_start_coding(input, &nettle_base16, '#');
+ goto decode;
- case '|':
- sexp_input_start_coding(input, &nettle_base64, '|');
+ case '|':
+ sexp_input_start_coding(input, &nettle_base64, '|');
- decode:
- for (; length; length--)
- {
- sexp_next_char(input);
- sexp_push_char(input, string);
- }
- sexp_get_char(input);
- if (input->ctype != SEXP_END_CHAR)
- die("Coded string too long.\n");
+ decode:
+ for (; length; length--)
+ {
+ sexp_next_char(input);
+ sexp_push_char(input, string);
+ }
+ sexp_get_char(input);
+ if (input->ctype != SEXP_END_CHAR)
+ die("Coded string too long.\n");
- sexp_input_end_coding(input);
+ sexp_input_end_coding(input);
- break;
+ break;
- default:
- die("Invalid string.\n");
- }
+ default:
+ die("Invalid string.\n");
+ }
/* Skip the ending character. */
sexp_get_char(input);