commit 341172f844b6d17e4b40ad7fb0da332b760895cc
parent 19a05b0768a51d217d492663e46417a1be8a0f55
Author: Joris Vink <joris@coders.se>
Date: Tue, 16 Jul 2013 09:56:36 +0200
Do not 0 out everything we allocate, and instead fix the behaviour of the code in the appropriate places.
Diffstat:
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/modules/example/src/example.c b/modules/example/src/example.c
@@ -137,7 +137,9 @@ test_base64(u_int8_t *src, u_int32_t slen, struct kore_buf *res)
if (!kore_base64_decode(in, &out, &len)) {
kore_buf_appendf(res, "decoding failed\n");
} else {
- kore_buf_appendf(res, "decoded: '%s'\n", out);
+ kore_buf_appendf(res, "decoded: ");
+ kore_buf_append(res, out, len);
+ kore_buf_appendf(res, "\n");
kore_mem_free(out);
}
diff --git a/src/http.c b/src/http.c
@@ -316,8 +316,8 @@ http_header_recv(struct netbuf *nb)
kore_debug("http_header_recv(%p)", nb);
- ch = nb->buf[nb->len - 1];
- nb->buf[nb->len - 1] = '\0';
+ ch = nb->buf[nb->offset];
+ nb->buf[nb->offset] = '\0';
if (nb->len < 4)
return (KORE_RESULT_OK);
@@ -326,7 +326,8 @@ http_header_recv(struct netbuf *nb)
if (strncmp(((char *)end_headers - 2), "\r\n\r\n", 4))
return (KORE_RESULT_OK);
- nb->buf[nb->len - 1] = ch;
+ nb->buf[nb->offset] = ch;
+ nb->buf[nb->len - 1] = '\0';
nb->flags |= NETBUF_FORCE_REMOVE;
end_headers += 2;
diff --git a/src/mem.c b/src/mem.c
@@ -61,7 +61,6 @@ kore_malloc(size_t len)
TAILQ_INSERT_TAIL(&memused, mem, list);
meminuse += len;
- memset(addr, '\0', len);
return (addr);
}