Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sat, 22 Feb 2020 16:01:12 -0600
From: Samuel Holland <samuel@...lland.org>
To: musl@...ts.openwall.com
Cc: Samuel Holland <samuel@...lland.org>
Subject: [PATCH 1/2] Avoid out-of-bounds read for invalid quoted timezone

Parsing the timezone name must stop when reaching the null terminator.
In that case, there is no '>' to skip.
---

This was found while investigating the bug fixed by patch 2.

# env -i TZ="<" date
Sat Feb 22 22:34:06 ate 2020
# env -i TZ="UTC0" date
Sat Feb 22 21:34:09 UTC 2020

---
 src/time/__tz.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/time/__tz.c b/src/time/__tz.c
index 185642e8..a962960e 100644
--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -86,9 +86,9 @@ static void getname(char *d, const char **p)
 	int i;
 	if (**p == '<') {
 		++*p;
-		for (i=0; (*p)[i]!='>' && i<TZNAME_MAX; i++)
+		for (i=0; (*p)[i] && (*p)[i]!='>' && i<TZNAME_MAX; i++)
 			d[i] = (*p)[i];
-		++*p;
+		if ((*p)[i]) ++*p;
 	} else {
 		for (i=0; ((*p)[i]|32)-'a'<26U && i<TZNAME_MAX; i++)
 			d[i] = (*p)[i];
-- 
2.24.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.