fix: validate color values in terminal sequences (#2517)

This commit is contained in:
valoq authored and GitHub committed 2026-04-14 00:23:04 +10:00
1 parent 6d50d981ab
commit f0a8b55ff5
1 file changed
+5 -5
+5 -5
View File
@@ -94,26 +94,26 @@ func parseColor(toks []string) (tcell.Color, int, error) {
}
if toks[0] == "5" && len(toks) >= 2 {
n, err := strconv.Atoi(toks[1])
n, err := strconv.ParseUint(toks[1], 10, 8)
if err != nil {
return tcell.ColorDefault, 0, fmt.Errorf("invalid args: %v", toks)
}
return tcell.PaletteColor(n), 2, nil
return tcell.PaletteColor(int(n)), 2, nil
}
if toks[0] == "2" && len(toks) >= 4 {
r, err := strconv.Atoi(toks[1])
r, err := strconv.ParseUint(toks[1], 10, 8)
if err != nil {
return tcell.ColorDefault, 0, fmt.Errorf("invalid args: %v", toks)
}
g, err := strconv.Atoi(toks[2])
g, err := strconv.ParseUint(toks[2], 10, 8)
if err != nil {
return tcell.ColorDefault, 0, fmt.Errorf("invalid args: %v", toks)
}
b, err := strconv.Atoi(toks[3])
b, err := strconv.ParseUint(toks[3], 10, 8)
if err != nil {
return tcell.ColorDefault, 0, fmt.Errorf("invalid args: %v", toks)
}