Bug #3178389 has picked up on a silly error
in the handling of TZ offsets.

The <time.h> header (on Linux at least) defines two
ways of representing the offset between the local
time, and UTC:

    extern long int timezone;     /* Seconds west of UTC.  */

and

    struct tm
    {
        long int tm_gmtoff;           /* Seconds east of UTC.  */
    }

Note that they are counting in different directions!

Unfortunately, our code (in snmplib/snmp-tc.c:date_n_time())
treats them as equivalent, and hence gets the wrong answer
when using the tm_gmtoff form.

The fix (attached) is clearly trivial, and I'd like to include this
in 5.5.1   (although it's not strictly a show-stopper).

Thoughts?

Dave
--- snmplib/snmp-tc.c.orig	2011-02-22 08:59:00.282202000 +0000
+++ snmplib/snmp-tc.c		2011-03-09 10:39:20.400066000 +0000
@@ -165,9 +165,9 @@
      */
     {
 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
-    const int tzoffset = tm_p->tm_gmtoff;
+    const int tzoffset = -tm_p->tm_gmtoff;   /* Seconds east of UTC */
 #else
-    const int tzoffset = timezone;
+    const int tzoffset = timezone;           /* Seconds west of UTC */
 #endif
     if (tzoffset > 0)
         string[8] = '-';
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to