0350142
From 81169c06a76f62ff987ed990ac910c2ae08b3f91 Mon Sep 17 00:00:00 2001
0350142
From: Karl Williamson <khw@cpan.org>
0350142
Date: Tue, 10 Mar 2020 15:19:57 -0600
0350142
Subject: [PATCH] reentr.c: Buffer sizes for asctime_r,ctime_r are small
0350142
MIME-Version: 1.0
0350142
Content-Type: text/plain; charset=UTF-8
0350142
Content-Transfer-Encoding: 8bit
0350142
0350142
The needed sizes of these are stated in the man pages, and are much
0350142
smaller than were being allocated.
0350142
0350142
Signed-off-by: Petr Písař <ppisar@redhat.com>
0350142
---
0350142
 reentr.c        | 4 ++--
0350142
 regen/reentr.pl | 5 ++++-
0350142
 2 files changed, 6 insertions(+), 3 deletions(-)
0350142
0350142
diff --git a/reentr.c b/reentr.c
0350142
index 8ddda7bfc0..8438c8f90f 100644
0350142
--- a/reentr.c
0350142
+++ b/reentr.c
0350142
@@ -52,14 +52,14 @@ Perl_reentrant_size(pTHX) {
0350142
 #  define REENTRANTUSUALSIZE	4096	/* Make something up. */
0350142
 
0350142
 #  ifdef HAS_ASCTIME_R
0350142
-	PL_reentrant_buffer->_asctime_size = REENTRANTSMALLSIZE;
0350142
+	PL_reentrant_buffer->_asctime_size = 26;
0350142
 #  endif /* HAS_ASCTIME_R */
0350142
 
0350142
 #  ifdef HAS_CRYPT_R
0350142
 #  endif /* HAS_CRYPT_R */
0350142
 
0350142
 #  ifdef HAS_CTIME_R
0350142
-	PL_reentrant_buffer->_ctime_size = REENTRANTSMALLSIZE;
0350142
+	PL_reentrant_buffer->_ctime_size = 26;
0350142
 #  endif /* HAS_CTIME_R */
0350142
 
0350142
 #  ifdef HAS_GETGRNAM_R
0350142
diff --git a/regen/reentr.pl b/regen/reentr.pl
0350142
index f5788c7ad9..94721e9dec 100644
0350142
--- a/regen/reentr.pl
0350142
+++ b/regen/reentr.pl
0350142
@@ -495,8 +495,11 @@ for my $func (@seenf) {
0350142
 	char*	_${func}_buffer;
0350142
 	size_t	_${func}_size;
0350142
 EOF
0350142
+            my $size = ($func =~ /^(asctime|ctime)$/)
0350142
+                       ? 26
0350142
+                       : "REENTRANTSMALLSIZE";
0350142
 	    push @size, <
0350142
-	PL_reentrant_buffer->_${func}_size = REENTRANTSMALLSIZE;
0350142
+	PL_reentrant_buffer->_${func}_size = $size;
0350142
 EOF
0350142
 	    pushinitfree $func;
0350142
 	    pushssif $endif;
0350142
-- 
0350142
2.25.4
0350142