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:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  None Privacy:  Public
Assigned to:  None Originator Name:  Manuel Menal
Originator Email:  -email is unavailable- Open/Closed:  Open
Reproducibility:  Every Time Size (loc):  None
Planned Release:  None Effort:  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 Files:
   
   
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 add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

 

 

Follow 2 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2005-01-09 mmenal Carbon-Copy- => Added bug-hurd@gnu.org
2005-01-08 None Attached File- => Added uptime.c, #2044

Back to the top


Powered by Savane 3.5