From 997441bed2d4832e0ee5f9effc037986b725059c Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 28 Sep 2025 23:05:20 -0700
Subject: [PROPOSED 3/3] Fix two off-by-1 nits

* localtime.c (union local_storage, tzloadbody): Fix two
recently-introduced off-by-one gotchas.  Neither of these caused a bug,
but we might as well do the calculations correctly.
---
 localtime.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/localtime.c b/localtime.c
index c103909a..3937e5dd 100644
--- a/localtime.c
+++ b/localtime.c
@@ -591,7 +591,7 @@ union local_storage {
      However, there is no need for this to be smaller than struct
      file_analysis as that struct is allocated anyway, as the other
      union member.  */
-  char fullname[max(sizeof(struct file_analysis), sizeof tzdirslash + 1024)];
+  char fullname[max(sizeof(struct file_analysis), sizeof TZDIR + 1024)];
 };
 
 /* These tzload flags can be ORed together, and fit into 'char'.  */
@@ -683,7 +683,7 @@ tzloadbody(char const *name, struct state *sp, char tzloadflags,
 
 	if (!OPENAT_TZDIR && !SUPPRESS_TZDIR && name[0] != '/') {
 		char *cp;
-		size_t namesizemax = sizeof lsp->fullname - sizeof tzdirslash;
+		size_t namesizemax = sizeof lsp->fullname - tzdirslashlen;
 		size_t namelen = strnlen (name, namesizemax);
 		if (namesizemax <= namelen)
 		  return ENAMETOOLONG;
-- 
2.48.1

