field = *buffer_ret;
field_size = 0;
+ if (buffer_size <= 0)
+ return (-1);
+
/* This is ensured by `handle_request'. */
assert (buffer[buffer_size - 1] == ' ');
status = buffer_get_field (&buffer, &buffer_size, &file);
if (status != 0)
{
- RRDD_LOG (LOG_INFO, "handle_request_flush: Cannot get file name.");
- return (-1);
+ strncpy (result, "-1 Usage: flush <filename>\n", sizeof (result));
}
-
- status = flush_file (file);
- if (status == 0)
- snprintf (result, sizeof (result), "0 Successfully flushed %s.\n", file);
- else if (status == ENOENT)
- snprintf (result, sizeof (result), "-1 No such file: %s.\n", file);
- else if (status < 0)
- strncpy (result, "-1 Internal error.\n", sizeof (result));
else
- snprintf (result, sizeof (result), "-1 Failed with status %i.\n", status);
+ {
+ status = flush_file (file);
+ if (status == 0)
+ snprintf (result, sizeof (result), "0 Successfully flushed %s.\n", file);
+ else if (status == ENOENT)
+ snprintf (result, sizeof (result), "-1 No such file: %s.\n", file);
+ else if (status < 0)
+ strncpy (result, "-1 Internal error.\n", sizeof (result));
+ else
+ snprintf (result, sizeof (result), "-1 Failed with status %i.\n", status);
+ }
result[sizeof (result) - 1] = 0;
status = write (fd, result, strlen (result));