git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] tree-walk: disallow overflowing modes
@ 2023-01-21  9:36 René Scharfe
  2023-01-22  7:50 ` Jeff King
  2023-01-23  8:33 ` Ævar Arnfjörð Bjarmason
  0 siblings, 2 replies; 9+ messages in thread
From: René Scharfe @ 2023-01-21  9:36 UTC (permalink / raw)
  To: Git List
  Cc: Junio C Hamano, Jeff King, Ævar Arnfjörð Bjarmason

When parsing tree entries, reject mode values that don't fit into an
unsigned int.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 tree-walk.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tree-walk.c b/tree-walk.c
index 74f4d710e8..5e7bc38600 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -17,6 +17,8 @@ static const char *get_mode(const char *str, unsigned int *modep)
 	while ((c = *str++) != ' ') {
 		if (c < '0' || c > '7')
 			return NULL;
+		if ((mode << 3) >> 3 != mode)
+			return NULL;
 		mode = (mode << 3) + (c - '0');
 	}
 	*modep = mode;
--
2.39.1

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

end of thread, other threads:[~2023-01-26 11:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-21  9:36 [PATCH] tree-walk: disallow overflowing modes René Scharfe
2023-01-22  7:50 ` Jeff King
2023-01-22 10:03   ` René Scharfe
2023-01-22 16:36     ` Junio C Hamano
2023-01-22 22:02     ` Jeff King
2023-01-23  8:33 ` Ævar Arnfjörð Bjarmason
2023-01-24 18:53   ` René Scharfe
2023-01-24 20:44     ` Junio C Hamano
2023-01-26 11:36       ` Jeff King

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

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).