git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Add overflow check to get_delta_hdr_size

From
Martin Koegler <martin.koegler@chello.at>
Date
Aug 12, 2017, 07:27 UTC
Message-ID
<1502522838-12581-1-git-send-email-martin@mail.zuhause>
From: Martin Koegler <martin.koegler@chello.at>
Signed-off-by: Martin Koegler <martin.koegler@chello.at>
---
Applies on top of my size_t series
I'm not sure, if die or error is better.
 delta.h | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/delta.h b/delta.h
index 2df0f55..18a4983 100644
--- a/delta.h
+++ b/delta.h
@@ -96,6 +96,11 @@ static inline size_t get_delta_hdr_size(const unsigned char **datap,
 		cmd = *data++;
 		size |= (cmd & 0x7f) << i;
 		i += 7;
+		if (bitsizeof(size_t) <= i) {
+			error("too large object size");
+			size = 0;
+			break;
+		}
 	} while (cmd & 0x80 && data < top);
 	*datap = data;
 	return size;
-- 
2.1.4
Next: Junio C Hamano
Message 1 of 3 in “Add overflow check to get_delta_hdr_size”
  1. Add overflow check to get_delta_hdr_sizeMartin Koegler, Aug 12, 2017
  2. Junio C HamanoAug 14, 2017
  3. Junio C HamanoAug 14, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.