summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7111df0)
raw | patch | inline | side by side (parent: 7111df0)
author | Florian Forster <octo@huhu.verplant.org> | |
Sat, 8 Nov 2008 15:02:30 +0000 (16:02 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Sat, 8 Nov 2008 15:02:30 +0000 (16:02 +0100) |
src/mysql.c | patch | blob | history |
diff --git a/src/mysql.c b/src/mysql.c
index 08df3fa81d4c3045b592335a6ab9e0e663214048..323154f842b9be82d6b49342e81cd7346d4375bd 100644 (file)
--- a/src/mysql.c
+++ b/src/mysql.c
static char *pass;
static char *db = NULL;
static char *socket = NULL;
-static int port = 0;
+static int port = 0;
static MYSQL *getconnection (void)
{
else if (strcasecmp (key, "socket") == 0)
return ((socket = strdup (value)) == NULL ? 1 : 0);
else if (strcasecmp (key, "port") == 0)
- return ((port = atoi (value)) == NULL ? 1 : 0);
+ {
+ char *endptr = NULL;
+ int temp;
+
+ errno = 0;
+ temp = strtol (value, $endptr, 0);
+ if ((errno != 0) || (value == endptr))
+ {
+ ERROR ("mysql plugin: Invalid \"Port\" argument: %s",
+ value);
+ port = 0;
+ return (1);
+ }
+ else if ((temp < 0) || (temp >= 65535))
+ {
+ ERROR ("mysql plugin: Port number out of range: %i",
+ temp);
+ port = 0;
+ return (1);
+ }
+
+ port = temp;
+ }
else
return (-1);
-}
+} /* int config */
static void counter_submit (const char *type, const char *type_instance,
counter_t value)