GNU bug report logs - #40217
28.0.50; Add check for valid month to date-days-in-month

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Alex Branham <alex.branham@HIDDEN>; Keywords: patch; Done: Eli Zaretskii <eliz@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 40217-done <at> debbugs.gnu.org:


Received: (at 40217-done) by debbugs.gnu.org; 3 Apr 2020 11:22:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 03 07:22:40 2020
Received: from localhost ([127.0.0.1]:41271 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jKKPI-00064O-14
	for submit <at> debbugs.gnu.org; Fri, 03 Apr 2020 07:22:40 -0400
Received: from eggs.gnu.org ([209.51.188.92]:58100)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1jKKPH-000640-2M
 for 40217-done <at> debbugs.gnu.org; Fri, 03 Apr 2020 07:22:39 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:41823)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1jKKPB-0007El-Hr; Fri, 03 Apr 2020 07:22:33 -0400
Received: from [176.228.60.248] (port=3257 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1jKKPA-0004o5-V5; Fri, 03 Apr 2020 07:22:33 -0400
Date: Fri, 03 Apr 2020 14:22:18 +0300
Message-Id: <83sghkx191.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alex Branham <alex.branham@HIDDEN>
In-Reply-To: <87eethjpa7.fsf@HIDDEN> (message from Alex Branham on Tue, 24
 Mar 2020 19:39:44 -0400)
Subject: Re: bug#40217: 28.0.50;
 Add check for valid month to date-days-in-month
References: <87eethjpa7.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 40217-done
Cc: 40217-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> From: Alex Branham <alex.branham@HIDDEN>
> Date: Tue, 24 Mar 2020 19:39:44 -0400
> 
> Here's a patch that adds a check for whether the month argument is
> valid in the new date-days-in-month function. It currently returns 30
> for a month value of, say, 15.

Thanks, pushed to the master branch (after some minor fixes of the
commit log message).




Notification sent to Alex Branham <alex.branham@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Eli Zaretskii <eliz@HIDDEN>:
You have taken responsibility. Full text available.
Severity set to 'minor' from 'normal' Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Added tag(s) patch. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Mar 2020 23:39:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 24 19:39:52 2020
Received: from localhost ([127.0.0.1]:55746 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jGt9E-00032P-Hp
	for submit <at> debbugs.gnu.org; Tue, 24 Mar 2020 19:39:52 -0400
Received: from lists.gnu.org ([209.51.188.17]:55661)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alex.branham@HIDDEN>) id 1jGt9C-00032H-P8
 for submit <at> debbugs.gnu.org; Tue, 24 Mar 2020 19:39:51 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:53556)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <alex.branham@HIDDEN>) id 1jGt9B-0006DV-Kg
 for bug-gnu-emacs@HIDDEN; Tue, 24 Mar 2020 19:39:50 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <alex.branham@HIDDEN>) id 1jGt99-0004aX-I9
 for bug-gnu-emacs@HIDDEN; Tue, 24 Mar 2020 19:39:49 -0400
Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]:42969)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <alex.branham@HIDDEN>)
 id 1jGt99-0004aG-Cg
 for bug-gnu-emacs@HIDDEN; Tue, 24 Mar 2020 19:39:47 -0400
Received: by mail-qk1-x729.google.com with SMTP id e11so550381qkg.9
 for <bug-gnu-emacs@HIDDEN>; Tue, 24 Mar 2020 16:39:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:subject:date:message-id:user-agent:mime-version;
 bh=a+HKxol4RH5A2JlBGEtTCh+i7Ah9MH9+Gs87/EE0Ox8=;
 b=grvvyAmMBn2KF1tWipI+ce3ad4mATgoETObAcPAumvaMPEWc2FK87AxEsLRV2sv/ou
 6MqjaOzbM5YrQp8KHg89UlmJEW5rAvft2bmj4vxD0Npffp0Cow+hJkNbFf+9d6Ge4Fk0
 4ZPmgjiJmmw2K9ZR0Hd2upbz6bh/j2trkIX2NSDttTmebysLNqOnbt849kvqooC/if7K
 NxC5UojsF/gwN5KBbQeng80ZkOJlDq4v4dtlQD4opjUajEoKAHPvkRMdV3/n84XKx8Zj
 bn222OVXrYM3PB/dfwthhmc+AJq5jBb83BSyy/W/5tVXh7x4TduU4BOzw+ziryIaLVq3
 1PDQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:user-agent
 :mime-version;
 bh=a+HKxol4RH5A2JlBGEtTCh+i7Ah9MH9+Gs87/EE0Ox8=;
 b=S2rwOUQT31J7nnO3pVY9tM5nDV6RDBhZHAxhcua5x7TUQCDPxI7hsw+wCNPXaF5mON
 mkko17tR6dC5gvQ5bdWUhtz8UleXk1VT7ZSmK+XCV1wt4jaHpxBQOzGo+iE47HTLTbMM
 tH9EGUj+zsKr2BzSBYc8lb0z+UGKcRY3xk/7goroTTfPVWgxIhQhLEgpvoq+RLj/6pTe
 eQrEIW9l2fhDcUW/gydQeSLcbzoiNKm7wbG7mLUa50odocz9jvV+WAirDaz5eQISxx77
 bTmSD0Fq6ycusmRneAi9kWDLuudMuL6Bb7cAwJZUP2s/Ksm9nBTU3Ex0HP27vo85aSBp
 o3pA==
X-Gm-Message-State: ANhLgQ0XVsTMqrto8qZkhzvDTqzQ6eYouB0GB+PYRD1ax4/SM6Q4Ds35
 2gvN7mv7R+tip5LWqCfbmL9G9dFf
X-Google-Smtp-Source: ADFU+vvcZ8HCiYPIeBIP57nOVOtoeSr9mewx/e3Sx94N6PYAf3O4q2g+BVv54qcXgh1AmfI8hyuA3A==
X-Received: by 2002:a37:49cc:: with SMTP id w195mr451970qka.42.1585093186259; 
 Tue, 24 Mar 2020 16:39:46 -0700 (PDT)
Received: from mars (c-73-163-194-78.hsd1.dc.comcast.net. [73.163.194.78])
 by smtp.gmail.com with ESMTPSA id f26sm14223393qkl.119.2020.03.24.16.39.44
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 24 Mar 2020 16:39:45 -0700 (PDT)
From: Alex Branham <alex.branham@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 28.0.50; Add check for valid month to date-days-in-month
Date: Tue, 24 Mar 2020 19:39:44 -0400
Message-ID: <87eethjpa7.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2607:f8b0:4864:20::729
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--=-=-=
Content-Type: text/plain

Hello -

Here's a patch that adds a check for whether the month argument is
valid in the new date-days-in-month function. It currently returns 30
for a month value of, say, 15.

Thanks,
Alex


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Add-check-for-valid-month-to-date-days-in-month.patch

From f9c3040d516314209d64738fd23deafc5eb59faa Mon Sep 17 00:00:00 2001
From: Alex Branham <alex.branham@HIDDEN>
Date: Tue, 24 Mar 2020 19:34:14 -0400
Subject: [PATCH] Add check for valid month to date-days-in-month

* lisp/calendar/time-date.el (date-days-in-month): Add check.
* test/lisp/calendar/time-date-tests.el (test-days-in-month): Add test
for new error.
---
 lisp/calendar/time-date.el            | 2 ++
 test/lisp/calendar/time-date-tests.el | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index e2402de801..9b58a4884b 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -355,6 +355,8 @@ seconds-to-string
 
 (defun date-days-in-month (year month)
   "The number of days in MONTH in YEAR."
+  (unless (<= 1 month 12)
+    (error "Month %s invalid" month))
   (if (= month 2)
       (if (date-leap-year-p year)
           29
diff --git a/test/lisp/calendar/time-date-tests.el b/test/lisp/calendar/time-date-tests.el
index 4c8f18a7a9..9c90300cfe 100644
--- a/test/lisp/calendar/time-date-tests.el
+++ b/test/lisp/calendar/time-date-tests.el
@@ -31,7 +31,8 @@ test-leap-year
 (ert-deftest test-days-in-month ()
   (should (= (date-days-in-month 2004 2) 29))
   (should (= (date-days-in-month 2004 3) 31))
-  (should-not (= (date-days-in-month 1900 3) 28)))
+  (should-not (= (date-days-in-month 1900 3) 28))
+  (should-error (date-days-in-month 2020 15)))
 
 (ert-deftest test-ordinal ()
   (should (equal (date-ordinal-to-time 2008 271)
-- 
2.25.1


--=-=-=--




Acknowledgement sent to Alex Branham <alex.branham@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#40217; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 3 Apr 2020 11:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.