Skip to content

Commit

Permalink
Merge pull request dogecoin#36 from ryanofsky/pr/end-str
Browse files Browse the repository at this point in the history
Reject unterminated strings
  • Loading branch information
jgarzik committed Feb 10, 2017
2 parents a31231b + 4fd5444 commit 7099135
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ TEST_FILES = \
$(TEST_DATA_DIR)/fail40.json \
$(TEST_DATA_DIR)/fail41.json \
$(TEST_DATA_DIR)/fail42.json \
$(TEST_DATA_DIR)/fail44.json \
$(TEST_DATA_DIR)/fail3.json \
$(TEST_DATA_DIR)/fail4.json \
$(TEST_DATA_DIR)/fail5.json \
Expand Down
4 changes: 2 additions & 2 deletions lib/univalue_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ enum jtokentype getJsonToken(string& tokenVal, unsigned int& consumed,
string valStr;
JSONUTF8StringFilter writer(valStr);

while (raw < end) {
if ((unsigned char)*raw < 0x20)
while (true) {
if (raw >= end || (unsigned char)*raw < 0x20)
return JTOK_ERR;

else if (*raw == '\\') {
Expand Down
1 change: 1 addition & 0 deletions test/fail44.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"This file ends without a newline or close-quote.
1 change: 1 addition & 0 deletions test/unitester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ static const char *filenames[] = {
"fail40.json", // invalid unicode: broken UTF-8
"fail41.json", // invalid unicode: unfinished UTF-8
"fail42.json", // valid json with garbage following a nul byte
"fail44.json", // unterminated string
"fail3.json",
"fail4.json", // extra comma
"fail5.json",
Expand Down

0 comments on commit 7099135

Please sign in to comment.