diff --git a/src/ceph.c b/src/ceph.c
index 55cd64c6937c9a10eaf6dfdbed9e59d8e8989f27..ad0688ccb22245a6131e135c3f09dddca5a93a74 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';
{
latency_type = 1;
+ /* depth >= 2 => (stack[-1] != NULL && stack[-2] != NULL) */
+ assert ((state->depth < 2)
+ || ((state->stack[state->depth - 1] != NULL)
+ && (state->stack[state->depth - 2] != NULL)));
+
/* Super-special case for filestore.journal_wr_bytes.avgcount: For
* some reason, Ceph schema encodes this as a count/sum pair while all
* other "Bytes" data (excluding used/capacity bytes for OSD space) uses
struct timeval end_tv;
struct cconn io_array[g_num_daemons];
+ if (g_num_daemons < 1)
+ {
+ ERROR ("ceph plugin: No daemons configured. See the \"Daemon\" config option.");
+ return ENOENT;
+ }
+
DEBUG("ceph plugin: entering cconn_main_loop(request_type = %d)", request_type);
/* create cconn array */
/******* lifecycle *******/
static int ceph_init(void)
{
- int ret;
-
#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_DAC_OVERRIDE)
if (check_capability (CAP_DAC_OVERRIDE) != 0)
{
ceph_daemons_print();
- ret = cconn_main_loop(ASOK_REQ_VERSION);
+ if (g_num_daemons < 1)
+ {
+ ERROR ("ceph plugin: No daemons configured. See the \"Daemon\" config option.");
+ return ENOENT;
+ }
- return (ret) ? ret : 0;
+ return cconn_main_loop(ASOK_REQ_VERSION);
}
static int ceph_shutdown(void)