summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1ca0b79)
raw | patch | inline | side by side (parent: 1ca0b79)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 25 Mar 2008 14:58:15 +0000 (15:58 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 26 Mar 2008 08:33:04 +0000 (09:33 +0100) |
This function modifies its first argument which, in these cases, is used
again after the function call. Now, a copy of the string is passed to
parse_identifier().
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
again after the function call. Now, a copy of the string is passed to
parse_identifier().
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/utils_cmd_getval.c | patch | blob | history | |
src/utils_cmd_putval.c | patch | blob | history |
diff --git a/src/utils_cmd_getval.c b/src/utils_cmd_getval.c
index 85028d0f0bedad22ad35ad9c0e28ae931a8b857e..f110196acaf2c81c931f61cda0b01fe6a05660d3 100644 (file)
--- a/src/utils_cmd_getval.c
+++ b/src/utils_cmd_getval.c
gauge_t *values;
size_t values_num;
+ char *identifier_copy;
+
const data_set_t *ds;
int status;
return (-1);
}
- status = parse_identifier (fields[1], &hostname,
+ /* parse_identifier() modifies its first argument,
+ * returning pointers into it */
+ identifier_copy = sstrdup (fields[1]);
+
+ status = parse_identifier (identifier_copy, &hostname,
&plugin, &plugin_instance,
&type, &type_instance);
if (status != 0)
DEBUG ("unixsock plugin: Cannot parse `%s'", fields[1]);
fprintf (fh, "-1 Cannot parse identifier.\n");
fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
DEBUG ("unixsock plugin: plugin_get_ds (%s) == NULL;", type);
fprintf (fh, "-1 Type `%s' is unknown.\n", type);
fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
{
fprintf (fh, "-1 No such value\n");
fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
fprintf (fh, "-1 Error reading value from cache.\n");
fflush (fh);
sfree (values);
+ sfree (identifier_copy);
return (-1);
}
fflush (fh);
sfree (values);
+ sfree (identifier_copy);
return (0);
} /* int handle_getval */
diff --git a/src/utils_cmd_putval.c b/src/utils_cmd_putval.c
index ec0c09ae0cfc662a8be35e537e8298fcfbfbf2d0..98b5043f33d1a94156fa509404a840af76dc69bb 100644 (file)
--- a/src/utils_cmd_putval.c
+++ b/src/utils_cmd_putval.c
int status;
int i;
+ char *identifier_copy;
+
const data_set_t *ds;
value_list_t vl = VALUE_LIST_INIT;
return (-1);
}
- status = parse_identifier (fields[1], &hostname,
+ /* parse_identifier() modifies its first argument,
+ * returning pointers into it */
+ identifier_copy = sstrdup (fields[1]);
+
+ status = parse_identifier (identifier_copy, &hostname,
&plugin, &plugin_instance,
&type, &type_instance);
if (status != 0)
DEBUG ("cmd putval: Cannot parse `%s'", fields[1]);
fprintf (fh, "-1 Cannot parse identifier.\n");
fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
&& (strlen (type_instance) >= sizeof (vl.type_instance))))
{
fprintf (fh, "-1 Identifier too long.\n");
+ fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
strcpy (vl.type_instance, type_instance);
ds = plugin_get_ds (type);
- if (ds == NULL)
+ if (ds == NULL) {
+ sfree (identifier_copy);
return (-1);
+ }
vl.values_len = ds->ds_num;
vl.values = (value_t *) malloc (vl.values_len * sizeof (value_t));
if (vl.values == NULL)
{
fprintf (fh, "-1 malloc failed.\n");
+ fflush (fh);
+ sfree (identifier_copy);
return (-1);
}
fflush (fh);
sfree (vl.values);
+ sfree (identifier_copy);
return (0);
} /* int handle_putval */