projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
plugin_mmock.c: Added daemon_log()
[collectd.git]
/
src
/
snmp_agent.c
diff --git
a/src/snmp_agent.c
b/src/snmp_agent.c
index
3c042a8
..
d65af1f
100644
(file)
--- a/
src/snmp_agent.c
+++ b/
src/snmp_agent.c
@@
-383,11
+383,20
@@
static int snmp_agent_create_token(char const *input, int t_off, int n,
int ret = 0;
token->key = index_key;
int ret = 0;
token->key = index_key;
- token->str = strndup(input + t_off, n);
+ /* copy at most n bytes from input with offset t_off into token->str */
+ input += t_off;
+ size_t len = strlen(input);
+ if (n < len)
+ len = n;
+
+ token->str = malloc(len + 1);
if (token->str == NULL)
goto free_offset_error;
if (token->str == NULL)
goto free_offset_error;
+ memcpy(token->str, input, len);
+ token->str[len] = '\0';
+
*offset = t_off;
ret = c_avl_insert(tree, (void *)offset, (void *)token);
*offset = t_off;
ret = c_avl_insert(tree, (void *)offset, (void *)token);
@@
-522,7
+531,7
@@
static int snmp_agent_fill_index_list(table_definition_t *td,
/* Parsing input string if necessary */
if (td->index_keys[i].regex) {
/* Parsing input string if necessary */
if (td->index_keys[i].regex) {
- regmatch_t m
= {-1, -1}
;
+ regmatch_t m;
/* Parsing input string */
ret = snmp_agent_parse_index_key(ptr, &td->index_keys[i].regex_info,
/* Parsing input string */
ret = snmp_agent_parse_index_key(ptr, &td->index_keys[i].regex_info,