[PATCH] on lease/pid-file for udhcpd/c
Denis Vlasenko
vda.linux at googlemail.com
Sun Jul 1 16:41:21 UTC 2007
On Sunday 01 July 2007 16:54, Denis Vlasenko wrote:
> On Friday 29 June 2007 21:22, Mats Erik Andersson wrote:
> > Hello all,
> >
> > I was getting annoyed at the reluctance of udhcpd to
> > volontarily update its lease file when a new lease has
> > been granted. The attached patch introduces a configuration
> > entry for Busybox 1.6.0 to write a new copy of the lease
> > file immediately when it has sent DHCPACK.
>
> I will apply this part. Thanks!
BTW, udhcp code needs more love, that's for sure.
Semi-random example:
static int read_ip(const char *line, void *arg)
{
len_and_sockaddr *lsa;
int retval = 0;
lsa = host_and_af2sockaddr(line, 0, AF_INET);
if (lsa) {
*(struct in_addr*)arg = lsa->sin.sin_addr;
free(lsa);
retval = 1;
}
return retval;
}
struct in_addr is:
struct in_addr {
unsigned long int s_addr;
}
thus read_ip uses arg as a ptr to long. But here:
uint32_t *ip;
ip = xmalloc(sizeof(uint32_t));
read_ip(ip_string, ip);
WTF?? What about e.g. AMD64 where longs take 64 bits??
Yet another sad story: "is server_config.start in network or host byte order?".
Different parts of applet have different ideas about it...
More? Unsafe htons macro use and no overflow check:
case OPTION_U16:
*result_u16 = htons(strtoul(val, &endptr, 0));
retval = (endptr[0] == '\0');
break;
More? time() use for timeouts -> unsafe versus time being reset by admin.
--
vda
More information about the busybox
mailing list