summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a302b46)
raw | patch | inline | side by side (parent: a302b46)
author | John Conroy <john.conroy@interoptechnologies.com> | |
Wed, 13 Jul 2016 21:03:11 +0000 (17:03 -0400) | ||
committer | John Conroy <john.conroy@interoptechnologies.com> | |
Mon, 12 Sep 2016 18:34:26 +0000 (14:34 -0400) |
If strjoin() runs out of buffer space when joining strings, use the
remainder of available space rather than skipping additional strings
Reworked return() to avoid extra strlen() call
remainder of available space rather than skipping additional strings
Reworked return() to avoid extra strlen() call
src/daemon/common.c | patch | blob | history |
diff --git a/src/daemon/common.c b/src/daemon/common.c
index 05b119901ce2bf9a606a4e07c1ed45b7c2d78ce7..d1d8bf15dcfcd85124849b7653b3fcee9be560a3 100644 (file)
--- a/src/daemon/common.c
+++ b/src/daemon/common.c
ptr += sep_len;
avail -= sep_len;
}
+ if (avail == 0)
+ return (-1);
field_len = strlen (fields[i]);
if (avail < field_len)
- return (-1);
+ field_len = avail;
memcpy (ptr, fields[i], field_len);
ptr += field_len;
}
assert (buffer[buffer_size - 1] == 0);
- return ((int) strlen (buffer));
+ return ((int) ((buffer_size - 1) - avail));
}
int escape_string (char *buffer, size_t buffer_size)