Code

curl_json plugin: avoid accessing off the end of the avl_tree_s
[collectd.git] / src / curl_json.c
index deee460bb3327e6291d6536190ac68e7a7d87cb0..009f718d4d81ea22d5437d35f3ac9d94d1079428 100644 (file)
@@ -48,10 +48,10 @@ struct cj_key_s;
 typedef struct cj_key_s cj_key_t;
 struct cj_key_s /* {{{ */
 {
+  unsigned long magic;
   char *path;
   char *type;
   char *instance;
-  unsigned long magic;
 };
 /* }}} */
 
@@ -500,6 +500,7 @@ static int cj_config_add_key (cj_t *db, /* {{{ */
         len = ptr-name;
         if (len == 0)
           break;
+        len = COUCH_MIN(len, sizeof (ent)-1);
         sstrncpy (ent, name, len+1);
 
         if (c_avl_get (tree, ent, (void *) &value) != 0)