summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 43f6100)
raw | patch | inline | side by side (parent: 43f6100)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 11 Jun 2007 10:08:57 +0000 (12:08 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 11 Jun 2007 10:08:57 +0000 (12:08 +0200) |
src/hddtemp.c | patch | blob | history | |
src/ntpd.c | patch | blob | history |
diff --git a/src/hddtemp.c b/src/hddtemp.c
index 00814bd23d36208660595d920bd37f48eef525a7..d60481e35663313c34b05abd6c4aedabf82f652d 100644 (file)
--- a/src/hddtemp.c
+++ b/src/hddtemp.c
static hddname_t *first_hddname = NULL;
static char *hddtemp_host = NULL;
-static char *hddtemp_port = NULL;
+static char hddtemp_port[16];
/*
* NAME
host = HDDTEMP_DEF_HOST;
port = hddtemp_port;
- if (port == NULL)
+ if (strlen (port) == 0)
port = HDDTEMP_DEF_PORT;
if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
static int hddtemp_config (const char *key, const char *value)
{
- if (strcasecmp (key, "host") == 0)
+ if (strcasecmp (key, "Host") == 0)
{
if (hddtemp_host != NULL)
free (hddtemp_host);
hddtemp_host = strdup (value);
}
- else if (strcasecmp (key, "port") == 0)
+ else if (strcasecmp (key, "Port") == 0)
{
- if (hddtemp_port != NULL)
- free (hddtemp_port);
- hddtemp_port = strdup (value);
+ int port = (int) (atof (value));
+ if ((port > 0) && (port <= 65535))
+ snprintf (hddtemp_port, sizeof (hddtemp_port),
+ "%i", port);
+ else
+ strncpy (hddtemp_port, value, sizeof (hddtemp_port));
+ hddtemp_port[sizeof (hddtemp_port) - 1] = '\0';
}
else
{
diff --git a/src/ntpd.c b/src/ntpd.c
index 6f8e00e35c1d1acdc93c14f4ec06b9d3f4277652..1c97e69ad721c834c93f41b8e6407a65e6d1f3cb 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
# define NTPD_DEFAULT_PORT "123"
static int sock_descr = -1;
static char *ntpd_host = NULL;
-static char *ntpd_port = NULL;
+static char ntpd_port[16];
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* The following definitions were copied from the NTPd distribution *
static int ntpd_config (const char *key, const char *value)
{
- if (strcasecmp (key, "host") == 0)
+ if (strcasecmp (key, "Host") == 0)
{
if (ntpd_host != NULL)
free (ntpd_host);
if ((ntpd_host = strdup (value)) == NULL)
return (1);
}
- else if (strcasecmp (key, "port") == 0)
+ else if (strcasecmp (key, "Port") == 0)
{
- if (ntpd_port != NULL)
- free (ntpd_port);
- if ((ntpd_port = strdup (value)) == NULL)
- return (1);
+ int port = (int) (atof (value));
+ if ((port > 0) && (port <= 65535))
+ snprintf (ntpd_port, sizeof (ntpd_port),
+ "%i", port);
+ else
+ strncpy (ntpd_port, value, sizeof (ntpd_port));
+ ntpd_port[sizeof (ntpd_port) - 1] = '\0';
}
else
{
host = NTPD_DEFAULT_HOST;
port = ntpd_port;
- if (port == NULL)
+ if (strlen (port) == 0)
port = NTPD_DEFAULT_PORT;
memset (&ai_hints, '\0', sizeof (ai_hints));