From c98e97d8fc4d01bb94645a435fe696686e01a020 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Wed, 17 Feb 2016 11:07:18 -0800 Subject: [PATCH] Fix legit stack smash. --- json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json.c b/json.c index d7f8721..a73614b 100644 --- a/json.c +++ b/json.c @@ -16,7 +16,7 @@ void json_init() { int json_buf_append_callback(const char *buffer, size_t size, void *data) { struct buf *buf = data; - if (size > BUF_LEN_MAX - buf->length - 1) { + if (buf->length + size + 1 > BUF_LEN_MAX) { return -1; } memcpy(buf_at(buf, buf->length), buffer, size); @@ -51,7 +51,7 @@ static void json_serialize_mode_s_short(struct packet *packet, struct buf *buf) static void json_serialize_mode_s_long(struct packet *packet, struct buf *buf) { assert(packet->mlat_timestamp < MLAT_MAX); - char hexbuf[14]; + char hexbuf[28]; hex_from_bin(hexbuf, packet->payload, 14); json_t *out = json_pack("{ssss#sIsI}", "backend_id", packet->backend->id,