From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Sunshine Subject: Re: [PATCH 2/2] parse_date_basic(): let the system handle DST conversion Date: Wed, 15 Apr 2015 13:23:51 -0400 Message-ID: References: <20150415072223.GA1389@flurp.local> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: Linus Torvalds , Git Mailing List To: Junio C Hamano X-From: git-owner@vger.kernel.org Wed Apr 15 19:23:58 2015 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YiR2b-00039C-U8 for gcvg-git-2@plane.gmane.org; Wed, 15 Apr 2015 19:23:58 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756216AbbDORXz (ORCPT ); Wed, 15 Apr 2015 13:23:55 -0400 Received: from mail-lb0-f169.google.com ([209.85.217.169]:35545 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756188AbbDORXx (ORCPT ); Wed, 15 Apr 2015 13:23:53 -0400 Received: by lbbuc2 with SMTP id uc2so39466623lbb.2 for ; Wed, 15 Apr 2015 10:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=Cj/27zFuy15ql3tfiXgUuPqwQbtbILo73lwIQPWPVI4=; b=OhVZQYmsjS6FWRUvm4j+UWKnYlig/CvcV8laUmFFnLSBj3KtOx06vctLhRjHdngI1O Ydiuc9zWee7O6TTotg2WEMY1uP7ByTIGiqYjr6Wg6S5a9Z1xKd/XxZ5nRulKQmzPYvVy 3K55BnhDUPrS7R81asNMVnzX8hpGszMvqwoYh2YJoRbuAsSOMlhWqThWL9T1I9y/S+6Q dFeENNQmk3k71p+Y990IP/CD2PyxiR5mpxQOwIj5zrbeJgH4d22VUnJaQgWwOT3LjrOU YX6N2PxONFGjhVLwgYbPxivaBOrkzluJYk7eQ5+CJeG4gAcA1cwwczz4u1kA1ZMRwmLO LTjA== X-Received: by 10.112.57.197 with SMTP id k5mr25485979lbq.102.1429118631341; Wed, 15 Apr 2015 10:23:51 -0700 (PDT) Received: by 10.114.25.193 with HTTP; Wed, 15 Apr 2015 10:23:51 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: itAS5M6rRwSEjORWMgZic579rlo Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Wed, Apr 15, 2015 at 12:24 PM, Junio C Hamano wrote: > The function parses the input to compute the broken-down time in > "struct tm", and the GMT timezone offset. If the timezone offset > does not exist in the input, the broken-down time is turned into the > number of seconds since epoch both in the current timezone and in > GMT and the offset is computed as their difference. > > However, we forgot to make sure tm.tm_isdst is set to -1 (i.e. let > the system figure out if DST is in effect in the current timezone > when turning the broken-down time to the number of seconds since > epoch); it is done so at the beginning of the function, but a call > to match_digit() in the function can lead to a call to gmtime_r() to > clobber the field. Thanks for composing the commit message and turning this into a proper patch. > Reported-by: Linus Torvalds > Diagnosed-by: Eric Sunshine > Signed-off-by: Junio C Hamano For what it's worth: Reviewed-by: Eric Sunshine > --- > date.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/date.c b/date.c > index 01fd73f..8ad6cef 100644 > --- a/date.c > +++ b/date.c > @@ -700,7 +700,11 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset) > return -1; > > if (*offset == -1) { > - time_t temp_time = mktime(&tm); > + time_t temp_time; > + > + /* gmtime_r() in match_digit() may have clobbered it */ > + tm.tm_isdst = -1; > + temp_time = mktime(&tm); > if ((time_t)*timestamp > temp_time) { > *offset = ((time_t)*timestamp - temp_time) / 60; > } else { > -- > 2.4.0-rc2-165-g862640d