aboutsummaryrefslogtreecommitdiffstats
path: root/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'interface.c')
-rw-r--r--interface.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/interface.c b/interface.c
index 0b0d5791..86332300 100644
--- a/interface.c
+++ b/interface.c
@@ -74,7 +74,7 @@ struct interface_pair_s {
#ifdef linux
#define have_interface_init
-static char *netdevfmt;
+static const char *netdevfmt;
void interface_init(void)
/* figure out which /proc/net/dev format to use */
@@ -173,13 +173,13 @@ static int get_ifinfo(const char *ifname, ifinfo_t *ifinfo)
result = FALSE;
else
{
- char *sp = strchr(ifname, '/');
+ char *tmp = xstrdup(ifname);
+ char *sp = strchr(tmp, '/');
/* hide slash and trailing info from ifname */
if (sp)
*sp = '\0';
result = _get_ifinfoGT_(socket_fd, stats_file, ifname, ifinfo);
- if (sp)
- *sp = '/';
+ free(tmp);
}
if (socket_fd >= 0)
SockClose(socket_fd);
@@ -579,6 +579,7 @@ void interface_parse(char *buf, struct hostdata *hp)
/* parse 'interface' specification */
{
char *cp1, *cp2;
+ char mask1[] = "255.255.255.255";
hp->interface = xstrdup(buf);
@@ -593,7 +594,7 @@ void interface_parse(char *buf, struct hostdata *hp)
/* find and isolate just the netmask */
if (!(cp2 = strchr(cp1, '/')))
- cp2 = "255.255.255.255";
+ cp2 = mask1;
else
*cp2++ = '\000';