summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-11 13:26:16 +0000
committerRoy Marples <roy@marples.name>2007-10-11 13:26:16 +0000
commitb3f5301936ef265fc53a4e02c62edd809b25d3a1 (patch)
tree066c369adf40f1bdb6f8e7a29376fd21c919a0a0 /socket.c
parentcdf73a84ba306f0ede27b7395412b40791408133 (diff)
downloaddhcpcd-b3f5301936ef265fc53a4e02c62edd809b25d3a1.tar.xz
Reduce stack usage by using malloc more.
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/socket.c b/socket.c
index 832c0ab8..bb939929 100644
--- a/socket.c
+++ b/socket.c
@@ -39,6 +39,7 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -69,7 +70,6 @@ static uint16_t checksum (unsigned char *addr, uint16_t len)
nleft -= 2;
}
-
if (nleft == 1) {
uint8_t a = 0;
memcpy (&a, p.i, 1);
@@ -234,16 +234,18 @@ int open_socket (interface_t *iface, bool arp)
{
int n = 0;
int fd = -1;
- char device[PATH_MAX];
+ char *device;
int flags;
struct ifreq ifr;
int buf = 0;
struct bpf_program p;
+ device = xmalloc (sizeof (char *) * PATH_MAX);
do {
snprintf (device, PATH_MAX, "/dev/bpf%d", n++);
fd = open (device, O_RDWR);
} while (fd == -1 && errno == EBUSY);
+ free (device);
if (fd == -1) {
logger (LOG_ERR, "unable to open a BPF device");