diff options
| author | Roy Marples <roy@marples.name> | 2007-10-11 13:26:16 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2007-10-11 13:26:16 +0000 |
| commit | b3f5301936ef265fc53a4e02c62edd809b25d3a1 (patch) | |
| tree | 066c369adf40f1bdb6f8e7a29376fd21c919a0a0 /socket.c | |
| parent | cdf73a84ba306f0ede27b7395412b40791408133 (diff) | |
| download | dhcpcd-b3f5301936ef265fc53a4e02c62edd809b25d3a1.tar.xz | |
Reduce stack usage by using malloc more.
Diffstat (limited to 'socket.c')
| -rw-r--r-- | socket.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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"); |
