summaryrefslogtreecommitdiffstats
path: root/color.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-07-06 22:40:25 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-07-06 22:40:25 +0000
commitd387bfacb27147970cb2c11a26fa340888c66893 (patch)
tree6747e6c98be2b134acfe09905269ce220c86c0fd /color.c
parent332e531e6cb4f81cd6d7282436770768a14926dd (diff)
Fixing a string buffer problem noted by Todd Larason
<jtl@molehill.org>.
Diffstat (limited to 'color.c')
-rw-r--r--color.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/color.c b/color.c
index 8cdb743f..61a4f031 100644
--- a/color.c
+++ b/color.c
@@ -153,7 +153,7 @@ void ci_start_color (void)
#ifdef HAVE_COLOR
#ifdef USE_SLANG_CURSES
-static char * get_color_name (int val)
+static char *get_color_name (char *dest, size_t destlen, int val)
{
static char * missing[3] = {"brown", "lightgray", ""};
int i;
@@ -161,30 +161,33 @@ static char * get_color_name (int val)
switch (val)
{
case COLOR_YELLOW:
- return (missing[0]);
+ strfcpy (dest, missing[0], destlen);
+ return dest;
case COLOR_WHITE:
- return (missing[1]);
+ strfcpy (dest, missing[1], destlen);
+ return dest;
case COLOR_DEFAULT:
- return (missing[2]);
+ strfcpy (dest, missing[2], destlen);
+ return dest;
}
for (i = 0; Colors[i].name; i++)
{
if (Colors[i].value == val)
- return (Colors[i].name);
+ {
+ strfcpy (dest, Colors[i].name, destlen);
+ return dest;
+ }
}
/* Sigh. If we got this far, the color is of the form 'colorN'
* Slang can handle this itself, so just return 'colorN'
*/
- {
- static char color [SHORT_STRING];
- snprintf (color, sizeof (color), "color%d", val);
- return color;
- }
+ snprintf (dest, destlen, "color%d", val);
+ return dest;
}
#endif
@@ -192,6 +195,10 @@ int mutt_alloc_color (int fg, int bg)
{
COLOR_LIST *p = ColorList;
int i;
+
+#if defined (USE_SLANG_CURSES)
+ char fgc[SHORT_STRING], bgc[SHORT_STRING];
+#endif
/* check to see if this color is already allocated to save space */
while (p)
@@ -232,7 +239,7 @@ int mutt_alloc_color (int fg, int bg)
#if defined (USE_SLANG_CURSES)
if (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT)
- SLtt_set_color (i, NULL, get_color_name (fg), get_color_name (bg));
+ SLtt_set_color (i, NULL, get_color_name (fgc, sizeof (fgc), fg), get_color_name (bgc, sizeof (bgc), bg));
else
#elif defined (HAVE_USE_DEFAULT_COLORS)
if (fg == COLOR_DEFAULT)