* slerr.c (SLang_doerror): Fix possible off-by-one error.

* sltermin.c (_SLtt_tigetent): Likewise.
This commit is contained in:
Pavel Roskin 2003-09-11 21:38:03 +00:00
parent 58d1d9fe2b
commit 3e0fee42ad
3 changed files with 13 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2003-09-11 Andrew V. Samoilov <sav@bcs.zp.ua>
* slerr.c (SLang_doerror): Fix possible off-by-one error.
* sltermin.c (_SLtt_tigetent): Likewise.
2002-11-28 Pavel Roskin <proski@gnu.org>
* sldisply.c: Fix for the previous patch. Only swap colors if

View File

@ -78,24 +78,25 @@ void SLang_doerror (char *error)
else
{
char *sle = "S-Lang Error: ";
unsigned int len;
char *fmt;
unsigned int len = 0;
char *fmt = "%s%s%s";
str = get_error_string ();
fmt = "%s%s%s";
if ((error == NULL) || (*error == 0))
error = "";
else if (SLang_Error == SL_UNKNOWN_ERROR)
/* Do not display an unknown error message if error is non-NULL */
str = "";
else
else {
fmt = "%s%s: %s";
len = 2; /* ": " */
}
len = strlen (sle) + strlen (str) + strlen(error) + 1;
len += strlen (sle) + strlen (str) + strlen(error) + 1 /* trailing 0 */;
err = err_buf;
if (len >= sizeof (err_buf))
if (len > sizeof (err_buf))
{
if (NULL == (malloced_err_buf = SLmalloc (len)))
err = NULL;

View File

@ -283,7 +283,7 @@ SLterminfo_Type *_SLtt_tigetent (char *term)
if (*tidir == 0)
break; /* last one */
if (sizeof (file) > strlen (tidir) + 2 + strlen (term))
if (sizeof (file) >= strlen (tidir) + 4 + strlen (term))
{
sprintf (file, "%s/%c/%s", tidir, *term, term);
if (NULL != (fp = open_terminfo (file, ti)))