[BusyBox] Serious bug in udhcpc
Russ Dill
Russ.Dill at asu.edu
Mon Apr 21 18:46:46 UTC 2003
On Sun, 2003-04-20 at 22:31, Michael Sternberg wrote:
> > From: Russ Dill [mailto:Russ.Dill at asu.edu]
> > ...which would come from a possibly
> > incorrect value for time(0)....
>
> Yes, you're right. I just checked my time and received November 1917.. :)
> Fixed this and everything works now.. Time have to be set at least to 1
> Jan 1971 01:00 AM.
>
> Is it the reason for DHCP client to fail ? I mean - if user will find out
> that machine did not received an IP he will hardly go check if time was
> set up correctly...
DESCRIPTION
time returns the time since the Epoch (00:00:00 UTC, January 1,
1970), measured in seconds.
the value that it returns is seconds *since* epoch, and since it returns
a signed long, dates larger than 0x7FFFFFFF (sometime in 2038) don't
make sense. Its a broken system, in no way should the time ever have
been set to that value.
time(0) returns a signed long, so its between -0x80000000, and
0x7FFFFFFF.
If I set timeout to 0x7FFFFFFF, then:
tv.tv_sec = timeout - time(0);
would only produce negative values for time(0) < 0. (or time >
0x7FFFFFFF, depending on what would cause that), thus breaking all
working systems. The solution that *would* fix this would be to use a
unsigned tv.tv_sec, but select doesn't support this.
Basically, I don't want to add complex code to account ofr seriously
broken systems. Maybe add a if (time(0) < 0) printf("fscked time\n"); if
you are concerned about it.
More information about the busybox
mailing list