summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 29a10f6)
raw | patch | inline | side by side (parent: 29a10f6)
author | Florian Forster <octo@collectd.org> | |
Sun, 14 Aug 2016 19:36:27 +0000 (21:36 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Sun, 14 Aug 2016 19:36:50 +0000 (21:36 +0200) |
I'm hoping that this fixes a potential integer underrun that may occur
when unconditionally subtracting strlen(dest) from sizeof(dest).
Issue: #1835
when unconditionally subtracting strlen(dest) from sizeof(dest).
Issue: #1835
src/ceph.c | patch | blob | history |
diff --git a/src/ceph.c b/src/ceph.c
index 55cd64c6937c9a10eaf6dfdbed9e59d8e8989f27..5b7923915db798d1c62419c124addf136eecb56a 100644 (file)
--- a/src/ceph.c
+++ b/src/ceph.c
#define BUFFER_ADD(dest, src) do { \
size_t dest_size = sizeof (dest); \
- strncat ((dest), (src), dest_size - strlen (dest)); \
- (dest)[dest_size - 1] = '\0'; \
+ size_t dest_len = strlen (dest); \
+ if (dest_size > dest_len) { \
+ sstrncpy ((dest) + dest_len, (src), dest_size - dest_len); \
+ } \
+ (dest)[dest_size - 1] = 0; \
} while (0)
static int
{
yajl_struct *state = (yajl_struct*) ctx;
char buffer[number_len+1];
- char key[2 * DATA_MAX_NAME_LEN];
+ char key[2 * DATA_MAX_NAME_LEN] = { 0 };
_Bool latency_type = 0;
int status;
- key[0] = '\0';
memcpy(buffer, number_val, number_len);
buffer[sizeof(buffer) - 1] = '\0';