#ifdef _PATH_BPF
fd = open(_PATH_BPF, O_RDWR | O_CLOEXEC | O_NONBLOCK);
#else
- char device[PATH_MAX];
+ char device[32];
int n = 0;
do {
- snprintf(device, PATH_MAX, "/dev/bpf%d", n++);
+ snprintf(device, sizeof(device), "/dev/bpf%d", n++);
fd = open(device, O_RDWR | O_CLOEXEC | O_NONBLOCK);
} while (fd == -1 && errno == EBUSY);
#endif
struct in_addr net;
struct in_addr dst;
- char leasefile[PATH_MAX];
+ char leasefile[sizeof(LEASEFILE) + IF_NAMESIZE];
time_t start_uptime;
unsigned char *clientid;
uint32_t lowpl;
uint32_t sla;
uint8_t sla_set;
- char leasefile[PATH_MAX];
+ char leasefile[sizeof(LEASEFILE6) + IF_NAMESIZE];
const char *reason;
struct authstate auth;
ifo->options |= DHCPCD_BACKGROUND;
break;
case 'c':
- strlcpy(ifo->script, arg, sizeof(ifo->script));
+ free(ifo->script);
+ ifo->script = strdup(arg);
+ if (ifo->script == NULL)
+ syslog(LOG_ERR, "%s: %m", __func__);
break;
case 'd':
ifo->options |= DHCPCD_DEBUG;
ifo->metric = -1;
ifo->auth.options |= DHCPCD_AUTH_REQUIRE;
TAILQ_INIT(&ifo->auth.tokens);
- strlcpy(ifo->script, SCRIPT, sizeof(ifo->script));
ifo->vendorclassid[0] = dhcp_vendor((char *)ifo->vendorclassid + 1,
sizeof(ifo->vendorclassid) - 1);
free(ifo->config);
}
ipv4_freeroutes(ifo->routes);
+ free(ifo->script);
free(ifo->arping);
free(ifo->blacklist);
free(ifo->fallback);
char **config;
char **environ;
- char script[PATH_MAX];
+ char *script;
char hostname[HOSTNAME_MAX_LEN + 1]; /* We don't store the length */
int fqdn;
int
script_runreason(const struct interface *ifp, const char *reason)
{
- char *const argv[2] = { UNCONST(ifp->options->script), NULL };
+ char *argv[2];
char **env = NULL, **ep;
char *path, *bigenv;
ssize_t e, elen = 0;
const struct fd_list *fd;
struct iovec iov[2];
- if (ifp->options->script == NULL ||
- ifp->options->script[0] == '\0' ||
- strcmp(ifp->options->script, "/dev/null") == 0)
+ if (ifp->options->script &&
+ (ifp->options->script[0] == '\0' ||
+ strcmp(ifp->options->script, "/dev/null") == 0))
return 0;
+ argv[0] = ifp->options->script ? ifp->options->script : UNCONST(SCRIPT);
+ argv[1] = NULL;
syslog(LOG_DEBUG, "%s: executing `%s' %s",
ifp->name, argv[0], reason);