summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2015-04-24 10:42:19 -0500
committerNicolas Williams <nico@cryptonector.com>2015-04-24 10:42:19 -0500
commit5d40f3a7c0d8e2343af98590b8ae95f54d581be0 (patch)
treef526f166252e80be6a71173914394281bd03e4c2
parent5e0e7a7ebd285baa659bd78408cba445c9ecb19d (diff)
--raw-input wrongly adds NULs (fix #761)
-rw-r--r--util.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/util.c b/util.c
index 19b2b051..f5e61ffc 100644
--- a/util.c
+++ b/util.c
@@ -263,7 +263,10 @@ static int jq_util_input_read_more(jq_util_input_state state) {
const char *p = memchr(state->buf, '\n', sizeof(state->buf));
if (p == NULL && state->parser != NULL) {
- /* There should be no NULs in JSON texts */
+ /*
+ * There should be no NULs in JSON texts (but JSON text
+ * sequences are another story).
+ */
state->buf_valid_len = strlen(state->buf);
} else if (p == NULL && feof(state->current_input)) {
size_t i;
@@ -284,7 +287,7 @@ static int jq_util_input_read_more(jq_util_input_state state) {
}
state->buf_valid_len = p - state->buf + 1;
} else if (p == NULL) {
- state->buf_valid_len = sizeof(state->buf);
+ state->buf_valid_len = sizeof(state->buf) - 1;
} else {
state->buf_valid_len = (p - state->buf) + 1;
}