Fixes #108
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
17 files changed:
syslog(LOG_INFO, "%s", line);
if (to_stderr)
fprintf(stderr, "%s\n", line);
syslog(LOG_INFO, "%s", line);
if (to_stderr)
fprintf(stderr, "%s\n", line);
syslog(LOG_ERR, "%s", line);
if (to_stderr)
fprintf(stderr, "%s\n", line);
syslog(LOG_ERR, "%s", line);
if (to_stderr)
fprintf(stderr, "%s\n", line);
euid = geteuid();
if (seteuid(getuid()) == -1) {
option_error("unable to reset uid before opening %s: %m", fname);
euid = geteuid();
if (seteuid(getuid()) == -1) {
option_error("unable to reset uid before opening %s: %m", fname);
return 0;
}
ufile = fopen(fname, "r");
return 0;
}
ufile = fopen(fname, "r");
fatal("unable to regain privileges: %m");
if (ufile == NULL) {
option_error("unable to open user login data file %s", fname);
fatal("unable to regain privileges: %m");
if (ufile == NULL) {
option_error("unable to open user login data file %s", fname);
return 0;
}
check_access(ufile, fname);
return 0;
}
check_access(ufile, fname);
|| fgets(p, MAXSECRETLEN - 1, ufile) == NULL) {
fclose(ufile);
option_error("unable to read user login data file %s", fname);
|| fgets(p, MAXSECRETLEN - 1, ufile) == NULL) {
fclose(ufile);
option_error("unable to read user login data file %s", fname);
return 0;
}
fclose(ufile);
return 0;
}
fclose(ufile);
if (p != 0 && get_if_hwaddr(ep->value, p) >= 0) {
ep->class = EPD_MAC;
ep->length = 6;
if (p != 0 && get_if_hwaddr(ep->value, p) >= 0) {
ep->class = EPD_MAC;
ep->length = 6;
/* see if our hostname corresponds to a reasonable IP address */
hp = gethostbyname(hostname);
if (hp != NULL) {
/* see if our hostname corresponds to a reasonable IP address */
hp = gethostbyname(hostname);
if (hp != NULL) {
(*old_pppol2tp_ip_updown_hook)(tunnel_id, session_id, up);
}
(*old_pppol2tp_ip_updown_hook)(tunnel_id, session_id, up);
}
+ if (user_name != NULL)
+ free(user_name);
+
if ((vp = (VALUE_PAIR *) malloc (sizeof (VALUE_PAIR)))
!= (VALUE_PAIR *) NULL)
{
if ((vp = (VALUE_PAIR *) malloc (sizeof (VALUE_PAIR)))
!= (VALUE_PAIR *) NULL)
{
- strncpy (vp->name, pda->name, sizeof (vp->name));
+ strlcpy (vp->name, pda->name, NAME_LENGTH);
vp->attribute = attrid;
vp->vendorcode = vendorcode;
vp->next = (VALUE_PAIR *) NULL;
vp->attribute = attrid;
vp->vendorcode = vendorcode;
vp->next = (VALUE_PAIR *) NULL;
*iptr = AUTH_RADIUS_FST;
else {
error("%s: auth_order: unknown keyword: %s", filename, p);
*iptr = AUTH_RADIUS_FST;
else {
error("%s: auth_order: unknown keyword: %s", filename, p);
*iptr = (*iptr) | AUTH_RADIUS_SND;
else {
error("%s: auth_order: unknown or unexpected keyword: %s", filename, p);
*iptr = (*iptr) | AUTH_RADIUS_SND;
else {
error("%s: auth_order: unknown or unexpected keyword: %s", filename, p);
if (option == NULL)
fatal("rc_conf_str: unkown config option requested: %s", optname);
if (option == NULL)
fatal("rc_conf_str: unkown config option requested: %s", optname);
- return (char *)option->val;
+ return (char *)option->val;
}
int rc_conf_int(char *optname)
}
int rc_conf_int(char *optname)
rstate.start_time = time(NULL);
rstate.start_time = time(NULL);
- strncpy(rstate.session_id, rc_mksid(), sizeof(rstate.session_id));
+ strlcpy(rstate.session_id, rc_mksid(), MAXSESSIONID);
rc_avpair_add(&send, PW_ACCT_SESSION_ID,
rstate.session_id, 0, VENDOR_NONE);
rc_avpair_add(&send, PW_ACCT_SESSION_ID,
rstate.session_id, 0, VENDOR_NONE);
int rc_good_ipaddr __P((char *));
const char *rc_ip_hostname __P((UINT4));
UINT4 rc_own_ipaddress __P((void));
int rc_good_ipaddr __P((char *));
const char *rc_ip_hostname __P((UINT4));
UINT4 rc_own_ipaddress __P((void));
+UINT4 rc_own_bind_ipaddress __P((void));
if ((fd = fopen(radrealms_config, "r")) == NULL) {
option_error("cannot open %s", radrealms_config);
if ((fd = fopen(radrealms_config, "r")) == NULL) {
option_error("cannot open %s", radrealms_config);
+ free(auths);
+ free(accts);
info("Reading %s", radrealms_config);
info("Reading %s", radrealms_config);
while ((fgets(buffer, sizeof(buffer), fd) != NULL)) {
line++;
while ((fgets(buffer, sizeof(buffer), fd) != NULL)) {
line++;
fclose(fd);
option_error("%s: invalid line %d: %s", radrealms_config,
line, buffer);
fclose(fd);
option_error("%s: invalid line %d: %s", radrealms_config,
line, buffer);
+ free(auths);
+ free(accts);
return;
}
info("Parsing '%s' entry:", p);
return;
}
info("Parsing '%s' entry:", p);
fclose(fd);
option_error("%s: realm name missing on line %d: %s",
radrealms_config, line, buffer);
fclose(fd);
option_error("%s: realm name missing on line %d: %s",
radrealms_config, line, buffer);
+ free(auths);
+ free(accts);
fclose(fd);
option_error("%s: server address missing on line %d: %s",
radrealms_config, line, buffer);
fclose(fd);
option_error("%s: server address missing on line %d: %s",
radrealms_config, line, buffer);
+ free(auths);
+ free(accts);
return;
}
s->name[s->max] = strdup(p);
return;
}
s->name[s->max] = strdup(p);
fclose(fd);
option_error("%s: server port missing on line %d: %s",
radrealms_config, line, buffer);
fclose(fd);
option_error("%s: server port missing on line %d: %s",
radrealms_config, line, buffer);
+ free(auths);
+ free(accts);
return;
}
s->port[s->max] = atoi(p);
return;
}
s->port[s->max] = atoi(p);
$(CC) $(LDFLAGS) -o pppoe-discovery pppoe-discovery.o debug.o
pppoe-discovery.o: pppoe-discovery.c
$(CC) $(LDFLAGS) -o pppoe-discovery pppoe-discovery.o debug.o
pppoe-discovery.o: pppoe-discovery.c
- $(CC) $(CFLAGS) -c -o pppoe-discovery.o pppoe-discovery.c
+ $(CC) $(CFLAGS) -I../../.. -c -o pppoe-discovery.o pppoe-discovery.c
- $(CC) $(CFLAGS) -c -o debug.o debug.c
+ $(CC) $(CFLAGS) -I../../.. -c -o debug.o debug.c
rp-pppoe.so: plugin.o discovery.o if.o common.o
$(CC) $(LDFLAGS) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
rp-pppoe.so: plugin.o discovery.o if.o common.o
$(CC) $(LDFLAGS) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
/* Fill in hardware address */
if (hwaddr) {
/* Fill in hardware address */
if (hwaddr) {
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {
error("Can't get hardware address for %s: %m", ifname);
close(fd);
if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {
error("Can't get hardware address for %s: %m", ifname);
close(fd);
}
/* Sanity check on MTU */
}
/* Sanity check on MTU */
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) {
error("Can't get MTU for %s: %m", ifname);
} else if (ifr.ifr_mtu < ETH_DATA_LEN) {
if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) {
error("Can't get MTU for %s: %m", ifname);
} else if (ifr.ifr_mtu < ETH_DATA_LEN) {
sa.sll_family = AF_PACKET;
sa.sll_protocol = htons(type);
sa.sll_family = AF_PACKET;
sa.sll_protocol = htons(type);
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
error("Could not get interface index for %s: %m", ifname);
close(fd);
if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
error("Could not get interface index for %s: %m", ifname);
close(fd);
error("Can't get MTU for %s: %m", conn->ifName);
goto errout;
}
error("Can't get MTU for %s: %m", conn->ifName);
goto errout;
}
- strncpy(ifr.ifr_name, conn->ifName, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, conn->ifName, sizeof(ifr.ifr_name));
if (ioctl(s, SIOCGIFMTU, &ifr) < 0) {
error("Can't get MTU for %s: %m", conn->ifName);
close(s);
if (ioctl(s, SIOCGIFMTU, &ifr) < 0) {
error("Can't get MTU for %s: %m", conn->ifName);
close(s);
/* Try getting interface index */
if (r) {
/* Try getting interface index */
if (r) {
- strncpy(ifr.ifr_name, cmd, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, cmd, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
r = 0;
} else {
if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
r = 0;
} else {
/* Close socket */
close(fd);
if (r && doit) {
/* Close socket */
close(fd);
if (r && doit) {
- strncpy(devnam, cmd, sizeof(devnam));
+ strlcpy(devnam, cmd, sizeof(devnam));
if (the_channel != &pppoe_channel) {
the_channel = &pppoe_channel;
if (the_channel != &pppoe_channel) {
the_channel = &pppoe_channel;
sa.sll_family = AF_PACKET;
sa.sll_protocol = htons(type);
sa.sll_family = AF_PACKET;
sa.sll_protocol = htons(type);
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ ifr.ifr_name[IFNAMSIZ - 1] = 0;
if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
fatalSys("ioctl(SIOCFIGINDEX): Could not get interface index");
}
if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
fatalSys("ioctl(SIOCFIGINDEX): Could not get interface index");
}
#include <stdio.h> /* For FILE */
#include <sys/types.h> /* For pid_t */
#include <stdio.h> /* For FILE */
#include <sys/types.h> /* For pid_t */
+#include "pppd/pppd.h" /* For error */
+
/* How do we access raw Ethernet devices? */
#undef USE_LINUX_PACKET
#undef USE_BPF
/* How do we access raw Ethernet devices? */
#undef USE_LINUX_PACKET
#undef USE_BPF
/* parent */
if (close(child_out[0]) == -1) {
/* parent */
if (close(child_out[0]) == -1) {
notice("error closing pipe?!? for child OUT[0]");
return NOT_AUTHENTICATED;
}
notice("error closing pipe?!? for child OUT[0]");
return NOT_AUTHENTICATED;
}
if (!ok) {
slprintf(route_buffer, sizeof(route_buffer),
"Sorry - PPP driver version %d.%d.%d is out of date\n",
if (!ok) {
slprintf(route_buffer, sizeof(route_buffer),
"Sorry - PPP driver version %d.%d.%d is out of date\n",
warn("Couldn't unlock pty slave %s: %m", pty_name);
#endif
if ((sfd = open(pty_name, O_RDWR | O_NOCTTY)) < 0)
warn("Couldn't unlock pty slave %s: %m", pty_name);
#endif
if ((sfd = open(pty_name, O_RDWR | O_NOCTTY)) < 0)
warn("Couldn't open pty slave %s: %m", pty_name);
warn("Couldn't open pty slave %s: %m", pty_name);
}
}
#endif /* TIOCGPTN */
}
}
#endif /* TIOCGPTN */
#define ifr_name ifr__name
#endif
#define ifr_name ifr__name
#endif
- strncpy(req.ifr_name, interface, sizeof(req.ifr_name));
+ strncpy(req.ifr_name, interface, IFNAMSIZ);
+ req.ifr_name[IFNAMSIZ - 1] = 0;
if (ioctl(s, SIOCGPPPSTATS, &req) < 0) {
fprintf(stderr, "%s: ", progname);
if (errno == ENOTTY)
if (ioctl(s, SIOCGPPPSTATS, &req) < 0) {
fprintf(stderr, "%s: ", progname);
if (errno == ENOTTY)
#define ifr_name ifr__name
#endif
#define ifr_name ifr__name
#endif
- strncpy(creq.ifr_name, interface, sizeof(creq.ifr_name));
+ strncpy(creq.ifr_name, interface, IFNAMSIZ);
+ creq.ifr_name[IFNAMSIZ - 1] = 0;
if (ioctl(s, SIOCGPPPCSTATS, &creq) < 0) {
fprintf(stderr, "%s: ", progname);
if (errno == ENOTTY) {
if (ioctl(s, SIOCGPPPCSTATS, &creq) < 0) {
fprintf(stderr, "%s: ", progname);
if (errno == ENOTTY) {
#undef ifr_name
#define ifr_name ifr_ifrn.ifrn_name
#endif
#undef ifr_name
#define ifr_name ifr_ifrn.ifrn_name
#endif
- strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name));
+ strncpy(ifr.ifr_name, interface, IFNAMSIZ);
+ ifr.ifr_name[IFNAMSIZ - 1] = 0;
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
fprintf(stderr, "%s: nonexistent interface '%s' specified\n",
progname, interface);
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
fprintf(stderr, "%s: nonexistent interface '%s' specified\n",
progname, interface);