Wireshark-bugs: [Wireshark-bugs] [Bug 7676] tshark -q -z io, stat, 1 causes core dump for files

Date: Sat, 22 Jun 2013 16:42:47 +0000

changed bug 7676

What Removed Added
Attachment #11044 Flags   review_for_checkin?

Comment # 14 on bug 7676 from
Created attachment 11044 [details]
All calculations involving time_t are forced to be done in 64bit

All calculations involving time_t are forced to be done in 64bit. All constants
that are combined with 64bit variables are appended with "ULL" so that that all
of the terms are 64bits. NANOSECS_PER_SEC has been redefined as 1000000000ULL. 

All time_t variables are explicitly type casted to guint64 because depending on
the OS, time_t can be either be 32 or 64-bits.  With equations that include
both 64 and 32bit variables the 32bit portion of the equation is performed in
32bits and the result is then cast to 64bits before being combined with the
64bit term shown:    

 Before:  relative_time = (guint64)((pinfo->fd->rel_ts.secs*1000000) + 
                          ((pinfo->fd->rel_ts.nsecs+500)/1000));

 After:   relative_time = ((guint64)pinfo->fd->rel_ts.secs * 1000000ULL) + 
                          ((guint64)((pinfo->fd->rel_ts.nsecs+500)/1000)); 

"relative _time" is a guint64 variable.  "rel_ts.secs" is a time_t so it is
casted as guint64 and multiplied by a 64bit constant. "rel_ts.secs" is always
32bits so all the math is done in 32 bit then the result is cast to guint64
before being added to the first 64bit term.    

Another example;

 Before:   val = (guint64)((new_time->secs*1000000) + (new_time->nsecs/1000));

 After:    val = ((guint64)new_time->secs*1000000ULL) +
(guint64)(new_time->nsecs/1000);


You are receiving this mail because:
  • You are watching all bug changes.