Skip to content

Commit

Permalink
Make buf_append_bytes() NUL-terminate the buffer storage
Browse files Browse the repository at this point in the history
We rely on being able to use these as strings

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jun 20, 2014
1 parent e33b27b commit 827f74d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion http.c
Expand Up @@ -99,7 +99,7 @@ void buf_append_bytes(struct oc_text_buf *buf, const void *bytes, int len)
if (!buf || buf->error)
return;

new_buf_len = (buf->pos + len + BUF_CHUNK_SIZE - 1) & ~(BUF_CHUNK_SIZE-1);
new_buf_len = (buf->pos + len + BUF_CHUNK_SIZE) & ~(BUF_CHUNK_SIZE-1);
if (new_buf_len > MAX_BUF_LEN) {
buf->error = -E2BIG;
return;
Expand All @@ -114,6 +114,7 @@ void buf_append_bytes(struct oc_text_buf *buf, const void *bytes, int len)
}
memcpy(buf->data + buf->pos, bytes, len);
buf->pos += len;
buf->data[buf->pos] = 0;
}

int buf_error(struct oc_text_buf *buf)
Expand Down

0 comments on commit 827f74d

Please sign in to comment.