fix(strutil): clamp substring lengths before integer conversion (#377)

This commit is contained in:
Yusuf Efe authored and GitHub committed 2026-10-23 18:04:29 +08:00
1 parent c701a35586
commit b40eea78c3
2 files changed
+5 -3

No files matched your search

+3 -3
View File
@@ -316,10 +316,10 @@ func Substring(s string, offset int, length uint) string {
return ""
}
end := offset + int(length)
if end > size {
end = size
if length > uint(size-offset) {
length = uint(size - offset)
}
end := offset + int(length)
return strings.ReplaceAll(string(rs[offset:end]), "\x00", "")
}