}
l = *p++;
- if (o == DHO_OPTIONSOVERLOADED) {
+ if (o == DHO_OPTSOVERLOADED) {
/* Ensure we only get this option once by setting
* the last bit as well as the value.
* This is valid because only the first two bits
ifp->name, state->leasefile);
dhcp = calloc(1, sizeof(*dhcp));
if (dhcp == NULL) {
- close(fd);
+ if (state->leasefile[0] != '\0')
+ close(fd);
return NULL;
}
bytes = read(fd, dhcp, sizeof(*dhcp));
- close(fd);
+ if (state->leasefile[0] != '\0')
+ close(fd);
if (bytes < 0) {
free(dhcp);
return NULL;
e = 0;
ifo = ifp->options;
- get_option_uint8(ifp->ctx, &overl, dhcp, DHO_OPTIONSOVERLOADED);
+ if (get_option_uint8(ifp->ctx, &overl, dhcp, DHO_OPTSOVERLOADED) == -1)
+ overl = 0;
if (env == NULL) {
if (dhcp->yiaddr || dhcp->ciaddr)
arp_free(astate);
eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
dhcpcd_startinterface(ifp);
+ return;
}
/* RFC 2131 3.1.5, Client-server interaction
eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
eloop_timeout_add_sec(ifp->ctx->eloop,
DHCP_RAND_MAX, dhcp_discover, ifp);
+ return;
}
/* Bound address */
arp_free(astate);
dhcp_expire1(ifp);
}
+ return;
}
}
DHO_VENDOR = 43,
DHO_IPADDRESS = 50,
DHO_LEASETIME = 51,
- DHO_OPTIONSOVERLOADED = 52,
+ DHO_OPTSOVERLOADED = 52,
DHO_MESSAGETYPE = 53,
DHO_SERVERID = 54,
DHO_PARAMETERREQUESTLIST = 55,
} else {
logger(ifp->ctx, LOG_DEBUG, "%s: reading lease `%s'",
ifp->name, state->leasefile);
- fd = open(state->leasefile, O_RDONLY);
+ if (stat(state->leasefile, &st) == -1)
+ fd = -1;
+ else
+ fd = open(state->leasefile, O_RDONLY);
}
if (fd == -1)
return -1;
state->new_len = 0;
- if ((state->new = malloc(BUFSIZ)) == NULL)
+ if ((state->new = malloc(BUFSIZ)) == NULL) {
+ if (state->leasefile[0] != '\0')
+ close(fd);
return -1;
+ }
retval = -1;
/* DHCPv6 messages have no real maximum size.
* As we could be reading from stdin, we loop like so. */
state->new = newnew;
state->new_len = newlen;
}
- close(fd);
+ if (state->leasefile[0] != '\0')
+ close(fd);
if (retval == -1)
goto ex;
- if (ifp->ctx->options & DHCPCD_DUMPLEASE)
+ if (ifp->ctx->options & DHCPCD_DUMPLEASE ||
+ state->leasefile[0] == '\0')
return 0;
/* If not validating IA's and if they have expired,
}
retval = -1;
- if (stat(state->leasefile, &st) == -1)
- goto ex;
clock_gettime(CLOCK_MONOTONIC, &acquired);
if ((now = time(NULL)) == -1)
goto ex;
free(state->new);
state->new = NULL;
state->new_len = 0;
- if (!(ifp->ctx->options & DHCPCD_DUMPLEASE))
+ if (!(ifp->ctx->options & DHCPCD_DUMPLEASE) &&
+ state->leasefile[0] != '\0')
unlink(state->leasefile);
return retval;
}