about summary refs log tree commit diff
path: root/contrib/patches/edirect-xml-bounds-check.patch
blob: 7e369ca659cc061570dd6e34bd6eb072a909dd08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--- a/eutils/xml.go	2026-01-08 20:01:51.000000000 +0000
+++ b/eutils/xml.go	2026-04-03 06:53:30.494928480 +0000
@@ -1791,14 +1791,23 @@
 
 				// at start of end tag
 				idx++
+				if idx >= txtlen {
+					return NOTAG, NONE, "", "", idx
+				}
 				start = idx
 				ch = text[idx]
 				// expect legal first character of element
 				if inFirst[ch] {
 					idx++
+					if idx >= txtlen {
+						return NOTAG, NONE, "", "", idx
+					}
 					ch = text[idx]
 					for inElement[ch] {
 						idx++
+						if idx >= txtlen {
+							return NOTAG, NONE, "", "", idx
+						}
 						ch = text[idx]
 					}
 					str := text[start:idx]
@@ -1806,6 +1815,9 @@
 						// skip past unexpected blanks
 						for inBlank[ch] {
 							idx++
+							if idx >= txtlen {
+								return NOTAG, NONE, "", "", idx
+							}
 							ch = text[idx]
 						}
 						if ch != '>' {