summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2021-04-13 18:02:31 -0700
committerKevin McCarthy <kevin@8t8.us>2021-04-15 17:58:56 -0700
commit0684a051821283fc0af5f9b836b37a02720948a2 (patch)
tree39ab73625e26c1a2e3422d1c7d187658310338c0
parent2d6832011debd96324037eee1ccbdfba1903b197 (diff)
Add a check to make sure pair doesn't overflow.
It's not clear if COLOR_PAIRS can be larger than SHRT_MAX + 1, so make sure with a check.
-rw-r--r--color.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/color.c b/color.c
index 1dec01b2..93a01e8a 100644
--- a/color.c
+++ b/color.c
@@ -370,6 +370,12 @@ static int _mutt_alloc_color (int fg, int bg, int type)
* to COLOR_PAIRS-1 pairs. */
if (UserColors >= (COLOR_PAIRS - 1))
return (0);
+
+ /* Check for pair overflow too. We are currently using init_pair(), which
+ * only accepts size short. */
+ if ((pair > SHRT_MAX) || (pair < 0))
+ return (0);
+
UserColors++;
p = (COLOR_LIST *) safe_calloc (1, sizeof (COLOR_LIST));