Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnQGG-000337-R1 for pgsql-bugs@arkaria.postgresql.org; Tue, 16 Jul 2019 16:25:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hnQGF-0005NO-Jr for pgsql-bugs@arkaria.postgresql.org; Tue, 16 Jul 2019 16:25:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnQGF-0005Mq-BC for pgsql-bugs@lists.postgresql.org; Tue, 16 Jul 2019 16:25:03 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnQGD-0004iv-9Y for pgsql-bugs@lists.postgresql.org; Tue, 16 Jul 2019 16:25:02 +0000 Received: by mail-lj1-x234.google.com with SMTP id p17so20600059ljg.1 for ; Tue, 16 Jul 2019 09:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=IGWRrOiDy7cutHA4TBGrHseXw87aAe71lxpzLsbv+jI=; b=Rrc8xh4YXMaIFcRpHZb6LkT0mUgU9+goydkQIdjafEvFKQoK8OceAxeJj3ivJtyO5M 4OE3OFxnnDWowfJDTaRvrmoRM4PIISawQIRC6WJnGsHDfZPVtoRbPdxxXBzlaxjapiyC jHWh/ER+15HK6hpZBltcSxKB0vtl3YgmgPx/IHU2GtZOSHnGvkm2ZryA9Xv8jhkjrZGs S69pTNNOk+1Jg7hrbDGm7JBiQyhS2SR/RUiQjCxrXcvKJZMa/iBCKXMJd6b3Pq7T/csb fiqnbtv9iy8/v48W6tIZhnfdrMv4YXan/ahaByrMeNOlMia0Irox9uQYIkL7vL2c5B5G ImOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=IGWRrOiDy7cutHA4TBGrHseXw87aAe71lxpzLsbv+jI=; b=M8JgiasfTETKKez5wgjSX7sUONblPe44HGjGZDU3KPc6WB63A3M4F8PA7yHZxkRfWR AoynOzrdC1lPjxGTFjozGMcBfknQ9yXfpONjArOhX4BPNOC04HHwnWN0Y8QgXbVomAwT cATSkJQs9tUFY6FpuNRDXLuY8F8v1DlMCTLMj3FScKlrnyUaUz0gUKYl35eYaMBm/Qff aHmbHb5oJ+Vlkcj3f3hUKEYBKq3FhgCzt7BVg/ntsNLuEmB/aBGq71kcIjIdiC+JIJGU ZUdgJhdqCmrcvj8NYCGb+IkQkDNIAsx6drdwabSbb8t2/yFv7jgBEMrVOPcpQhoZzgjk rbgw== X-Gm-Message-State: APjAAAUA4dt0JGMdaLh5mZ3HCHb4zelLlqkK+1lvh9+v0YtD8V65DK+j gRDFrQpQKzcc8KkOernZx5QsyNs3 X-Google-Smtp-Source: APXvYqxyyeCCJY4GPNgL3NMa93oCt+TDqp1FoEOQymk3JMnv6NI51/FQ6DZ8WCtmJL7yXSAjJzFg0Q== X-Received: by 2002:a2e:9b4a:: with SMTP id o10mr18375913ljj.137.1563294298268; Tue, 16 Jul 2019 09:24:58 -0700 (PDT) Received: from [1.0.0.7] ([178.155.4.224]) by smtp.gmail.com with ESMTPSA id u13sm2908140lfi.4.2019.07.16.09.24.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jul 2019 09:24:57 -0700 (PDT) Subject: Re: BUG #15910: Valgrind-detected error in DecodeTimeOnly To: pgsql-bugs@lists.postgresql.org References: <15910-2eba5106b9aa0c61@postgresql.org> From: Alexander Lakhin Message-ID: <0aaf1cb9-0f85-e786-fb32-b3d68b80d027@gmail.com> Date: Tue, 16 Jul 2019 19:24:56 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <15910-2eba5106b9aa0c61@postgresql.org> Content-Type: multipart/mixed; boundary="------------85EDEB98F6040A61207ECA35" Content-Language: ru-RU List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------85EDEB98F6040A61207ECA35 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit > Bug reference: 15910 > Logged by: Alexander Lakhin > Email address: exclusion@gmail.com > PostgreSQL version: 12beta2 > Operating system: Ubuntu 18.04 > Description: > > When executing the following query: > SELECT time with time zone '04:05:06 m2'; > I get a strange result: > timetz > ------------------- > 04:05:06+02:30:17 > and the valgrind errors: > ==00:00:00:07.177 31724== Conditional jump or move depends on uninitialised > value(s) > ==00:00:00:07.177 31724== at 0x57333D: DetermineTimeZoneOffsetInternal > (datetime.c:1485) > ==00:00:00:07.177 31724== by 0x573DA6: DetermineTimeZoneOffset The attached patch fixes this issue. Best regards, Alexander --------------85EDEB98F6040A61207ECA35 Content-Type: text/x-patch; name="fix-DecodeTimeOnly.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix-DecodeTimeOnly.patch" diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 54ea69f7f1..0a13ec8492 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -2280,6 +2280,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf, GetCurrentDateTime(tmp); else { + /* a date has to be fully specified */ + if ((fmask & DTK_DATE_M) != DTK_DATE_M) + return DTERR_BAD_FORMAT; tmp->tm_year = tm->tm_year; tmp->tm_mon = tm->tm_mon; tmp->tm_mday = tm->tm_mday; @@ -2307,6 +2310,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf, GetCurrentDateTime(tmp); else { + /* a date has to be fully specified */ + if ((fmask & DTK_DATE_M) != DTK_DATE_M) + return DTERR_BAD_FORMAT; tmp->tm_year = tm->tm_year; tmp->tm_mon = tm->tm_mon; tmp->tm_mday = tm->tm_mday; --------------85EDEB98F6040A61207ECA35--