X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Fcommon_logging.c;h=5b355b2e1d570ee3c8a23382c0762075657e7b41;hb=72c8645af31896829b674b575c5375706f362a30;hp=000c33880538973d76af0c75ea9c2216c66c00af;hpb=c9f2bc5f76b5de8057cd5bdc7fc5321e3ae16abe;p=oweals%2Fgnunet.git diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 000c33880..5b355b2e1 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -886,11 +886,14 @@ mylog (enum GNUNET_ErrorType kind, const char *comp, const char *message, memset (date, 0, DATE_STR_SIZE); { char buf[size]; + long long offset; #ifdef WINDOWS LARGE_INTEGER pc; time_t timetmp; + offset = GNUNET_TIME_get_offset (); time (&timetmp); + timetmp += offset / 1000; tmptr = localtime (&timetmp); pc.QuadPart = 0; QueryPerformanceCounter (&pc); @@ -909,6 +912,30 @@ mylog (enum GNUNET_ErrorType kind, const char *comp, const char *message, struct timeval timeofday; gettimeofday (&timeofday, NULL); + offset = GNUNET_TIME_get_offset (); + if (offset > 0) + { + timeofday.tv_sec += offset / 1000LL; + timeofday.tv_usec += (offset % 1000LL) * 1000LL; + if (timeofday.tv_usec > 1000000LL) + { + timeofday.tv_usec -= 1000000LL; + timeofday.tv_sec++; + } + } + else + { + timeofday.tv_sec += offset / 1000LL; + if (timeofday.tv_usec > - (offset % 1000LL) * 1000LL) + { + timeofday.tv_usec += (offset % 1000LL) * 1000LL; + } + else + { + timeofday.tv_usec += 1000000LL + (offset % 1000LL) * 1000LL; + timeofday.tv_sec--; + } + } tmptr = localtime (&timeofday.tv_sec); if (NULL == tmptr) { @@ -1179,7 +1206,8 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen) off = 0; if (un->sun_path[0] == '\0') off++; - snprintf (buf, sizeof (buf), "%s%.*s", (off == 1) ? "@" : "", + memset (buf, 0, sizeof (buf)); + snprintf (buf, sizeof (buf) - 1, "%s%.*s", (off == 1) ? "@" : "", (int) (addrlen - sizeof (sa_family_t) - 1 - off), &un->sun_path[off]); return buf;