mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH 1/2] Avoid out-of-bounds read for invalid quoted timezone
@ 2020-02-22 22:01 Samuel Holland
  2020-02-22 22:01 ` [musl] [PATCH 2/2] Fix parsing offsets after long timezone names Samuel Holland
  0 siblings, 1 reply; 2+ messages in thread
From: Samuel Holland @ 2020-02-22 22:01 UTC (permalink / raw)
  To: musl; +Cc: Samuel Holland

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-22 22:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-22 22:01 [musl] [PATCH 1/2] Avoid out-of-bounds read for invalid quoted timezone Samuel Holland
2020-02-22 22:01 ` [musl] [PATCH 2/2] Fix parsing offsets after long timezone names Samuel Holland

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).