bugThe GNU Hurd - Bugs: bug #11531, w(1) does not support large uptimes

 
 

bug #11531: w(1) does not support large uptimes

Submitted by:  None
Submitted on:  Sat 08 Jan 2005 07:12:53 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: NonePrivacy: Public
Assigned to: NoneOriginator Name: Manuel Menal
Originator Email: -unavailable-Open/Closed: Open
Reproducibility: Every TimeSize (loc): None
Planned Release: NoneEffort: 0.00
Wiki-like text discussion box: 

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 08 Jan 2005 07:12:53 PM UTC, original submission:

Hello,

The Hurd version of uptime(1) (of w(1), actually) doesn't
work with uptimes larger than 2485 days, 12 hours, 19
minutes, 24 secondes (that is, larger than 214748364 which
is 2^31/10). For example, it prints 6.-128 years for
214748365 seconds, as you can see using the attached file
(which works on GNU/Linux as well).

This is due to an integer overflow in
libshouldbeinlibc/timefmt.c:fmt_named_len() at line
130. The first check (num < 10) is not enough to see if we
have a "low number". 214748365 secondes gives a num of 7,
which is less than 10, but will overflow when multiplied
by 10.

The overflow can be avoided by changing the condition.
tv->tv_sec < LONG_MAX sounds reasonable enough, as tv_sec
is a long in most OSes (at least, GNU/Linux, GNU/Hurd,
*BSD and Solaris). But POSIX defines the `tv_sec' field
in `struct timeval' to be a time_t, which can be any
integer or real type. Someone suggested to do something
like :

if (tv->tv_sec < (time_t) pow (2, CHAR_BIT * sizeof (time_t) - 1)
&& ...)

... but that is well, a bit too much (and adds a libm
dependency for libshouldbeinlibc).

Both solutions have been successfully tested on three
different systems. Note that uptime(1) prints a large
approximation of uptimes in those cases, albeit seemingly
correct.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #2343:  uptime.c added by None (5KiB - application/octet-stream - Test case)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Sun 09 Jan 2005 11:53:58 AM UTCmmenalCarbon-Copy-=>Added -unavailable-
Sat 08 Jan 2005 07:12:54 PM UTCNoneAttached File-=>Added uptime.c, #2044

Back to the top


Powered by Savane 3.1-cleanup1