Ticket #2077: 0001-Correct-the-logic-from-f14754fbd-for-tor_gmtime_r.patch

File 0001-Correct-the-logic-from-f14754fbd-for-tor_gmtime_r.patch, 1.2 KB (added by special, 9 years ago)

Patch to correct gmtime_null (f1475fbd)

  • src/common/compat.c

    From 3431529abaae0f342113e0dc8efee1740256fd17 Mon Sep 17 00:00:00 2001
    From: John Brooks <special@dereferenced.net>
    Date: Mon, 3 Jan 2011 21:36:09 -0700
    Subject: [PATCH 1/1] Correct the logic from f14754fbd for tor_gmtime_r
    
    ---
     src/common/compat.c |    8 +++++---
     1 files changed, 5 insertions(+), 3 deletions(-)
    
    diff --git a/src/common/compat.c b/src/common/compat.c
    index d607f32..10f9d1a 100644
    a b tor_localtime_r(const time_t *timep, struct tm *result) 
    20812081}
    20822082#endif
    20832083
    2084 #ifndef HAVE_GMTIME_R
     2084#ifdef HAVE_GMTIME_R
    20852085struct tm *
    20862086tor_gmtime_r(const time_t *timep, struct tm *result)
    20872087{
    tor_gmtime_r(const time_t *timep, struct tm *result) 
    20992099  tor_assert(result);
    21002100  tor_mutex_acquire(m);
    21012101  r = gmtime(timep);
    2102   memcpy(result, r, sizeof(struct tm));
     2102  if (r)
     2103    memcpy(result, r, sizeof(struct tm));
    21032104  tor_mutex_release(m);
    21042105  return correct_tm(0, timep, result, r);
    21052106}
    tor_gmtime_r(const time_t *timep, struct tm *result) 
    21102111  struct tm *r;
    21112112  tor_assert(result);
    21122113  r = gmtime(timep);
    2113   memcpy(result, r, sizeof(struct tm));
     2114  if (r)
     2115    memcpy(result, r, sizeof(struct tm));
    21142116  return correct_tm(0, timep, result, r);
    21152117}
    21162118#endif