termptyesc: ensure colors are valid

This commit is contained in:
Boris Faure 2017-05-15 21:56:54 +02:00
parent c3767594d1
commit 2b47545fac
1 changed files with 8 additions and 0 deletions

View File

@ -552,6 +552,8 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
// then get next arg - should be color index 0-255
arg = _csi_arg_get(&b);
if (!b) ERR("Failed xterm 256 color fg esc val");
else if (arg < 0 || arg > 255)
ERR("Invalid fg color %d", arg);
else
{
ty->termstate.att.fg256 = 1;
@ -586,6 +588,8 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
// then get next arg - should be color index 0-255
arg = _csi_arg_get(&b);
if (!b) ERR("Failed xterm 256 color bg esc val");
else if (arg < 0 || arg > 255)
ERR("Invalid bg color %d", arg);
else
{
ty->termstate.att.bg256 = 1;
@ -620,6 +624,8 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
// then get next arg - should be color index 0-255
arg = _csi_arg_get(&b);
if (!b) ERR("Failed xterm 256 color fg esc val");
else if (arg < 0 || arg > 255)
ERR("Invalid fg color %d", arg);
else
{
ty->termstate.att.fg256 = 1;
@ -654,6 +660,8 @@ _handle_esc_csi_color_set(Termpty *ty, Eina_Unicode **ptr)
// then get next arg - should be color index 0-255
arg = _csi_arg_get(&b);
if (!b) ERR("Failed xterm 256 color bg esc val");
else if (arg < 0 || arg > 255)
ERR("Invalid bg color %d", arg);
else
{
ty->termstate.att.bg256 = 1;