From: Paul Eggert <eggert@cs.ucla.edu>
To: Valery Ushakov <uwe@stderr.spb.ru>
Cc: 30739-done@debbugs.gnu.org
Subject: bug#30739: Invalid timezone (tzalloc failure) treated as out-of-memory
Date: Sun, 11 Mar 2018 00:27:09 -0800 [thread overview]
Message-ID: <1370cc81-6aea-ed58-fcc0-1adc32f4252c@cs.ucla.edu> (raw)
In-Reply-To: <20180307002657.31473-1-dannym@scratchpost.org>
[-- Attachment #1: Type: text/plain, Size: 215 bytes --]
Thanks for reporting the problem. I have installed the attached two patches,
which I think should fix the problem so I'm closing the bug report. Please give
them a try on NetBSD (as I typically don't use NetBSD).
[-- Attachment #2: 0001-Fix-minor-timezone-memory-leak.patch --]
[-- Type: text/x-patch, Size: 1219 bytes --]
From f7c07930b581b1bcfdfb1874b6883233516bdf11 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 16 May 2017 14:19:36 -0700
Subject: [PATCH] Fix minor timezone memory leak
* src/editfns.c (wall_clock_tz): Remove; unused.
---
src/editfns.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/editfns.c b/src/editfns.c
index ecb8e3f083..75eb75a729 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -81,10 +81,8 @@ static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool);
enum { tzeqlen = sizeof "TZ=" - 1 };
-/* Time zones equivalent to current local time, to wall clock time,
- and to UTC, respectively. */
+/* Time zones equivalent to current local time and to UTC, respectively. */
static timezone_t local_tz;
-static timezone_t wall_clock_tz;
static timezone_t const utc_tz = 0;
/* The cached value of Vsystem_name. This is used only to compare it
@@ -269,7 +267,6 @@ init_editfns (bool dumping)
/* Set the time zone rule now, so that the call to putenv is done
before multiple threads are active. */
- wall_clock_tz = xtzalloc (0);
tzlookup (tz ? build_string (tz) : Qwall, true);
pw = getpwuid (getuid ());
--
2.14.3
[-- Attachment #3: 0001-Port-to-NetBSD-tzalloc.patch --]
[-- Type: text/x-patch, Size: 1590 bytes --]
From 46844ad78968cd804d0e5fc98ce49b46b3d8a53d Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 11 Mar 2018 00:18:34 -0800
Subject: [PATCH] Port to NetBSD tzalloc
Problem reported by Valery Ushakov (Bug#30738).
* src/editfns.c (xtzalloc): Remove.
(invalid_time_zone_specification): New function.
(tzlookup): Port to NetBSD, where tzalloc can fail when the TZ
string has an invalid value.
---
src/editfns.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/editfns.c b/src/editfns.c
index 3a34dd0980..debe10572d 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -117,14 +117,10 @@ emacs_mktime_z (timezone_t tz, struct tm *tm)
return t;
}
-/* Allocate a timezone, signaling on failure. */
-static timezone_t
-xtzalloc (char const *name)
+static _Noreturn void
+invalid_time_zone_specification (Lisp_Object zone)
{
- timezone_t tz = tzalloc (name);
- if (!tz)
- memory_full (SIZE_MAX);
- return tz;
+ xsignal2 (Qerror, build_string ("Invalid time zone specification"), zone);
}
/* Free a timezone, except do not free the time zone for local time.
@@ -205,9 +201,15 @@ tzlookup (Lisp_Object zone, bool settz)
}
}
else
- xsignal2 (Qerror, build_string ("Invalid time zone specification"),
- zone);
- new_tz = xtzalloc (zone_string);
+ invalid_time_zone_specification (zone);
+
+ new_tz = tzalloc (zone_string);
+ if (!new_tz)
+ {
+ if (errno == ENOMEM)
+ memory_full (SIZE_MAX);
+ invalid_time_zone_specification (zone);
+ }
}
if (settz)
--
2.14.3
next prev parent reply other threads:[~2018-03-11 8:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-07 0:26 [bug#30739] [PATCH 0/3] Add Ada parsers Danny Milosavljevic
2018-03-07 1:05 ` [bug#30739] [PATCH 1/3] gnu: Add python2-langkit Danny Milosavljevic
2018-03-07 1:05 ` [bug#30739] [PATCH 2/3] gnu: Add python2-quex Danny Milosavljevic
2018-03-12 14:35 ` Ludovic Courtès
2018-03-13 19:58 ` Danny Milosavljevic
2018-03-13 21:09 ` Ludovic Courtès
2018-03-13 21:29 ` Danny Milosavljevic
2018-03-16 11:03 ` Ludovic Courtès
2018-03-07 1:05 ` [bug#30739] [PATCH 3/3] gnu: Add python2-libadalang Danny Milosavljevic
2018-03-12 14:35 ` Ludovic Courtès
2018-03-12 14:33 ` [bug#30739] [PATCH 1/3] gnu: Add python2-langkit Ludovic Courtès
2018-03-13 19:57 ` Danny Milosavljevic
2018-03-11 8:27 ` Paul Eggert [this message]
2018-03-11 8:34 ` [bug#30739] Invalid timezone (tzalloc failure) treated as out-of-memory Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1370cc81-6aea-ed58-fcc0-1adc32f4252c@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=30739-done@debbugs.gnu.org \
--cc=uwe@stderr.spb.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.