diff options
author | Nicolas Williams <nico@cryptonector.com> | 2015-04-24 10:42:19 -0500 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2015-04-24 10:42:19 -0500 |
commit | 5d40f3a7c0d8e2343af98590b8ae95f54d581be0 (patch) | |
tree | f526f166252e80be6a71173914394281bd03e4c2 | |
parent | 5e0e7a7ebd285baa659bd78408cba445c9ecb19d (diff) |
--raw-input wrongly adds NULs (fix #761)
-rw-r--r-- | util.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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; } |