mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-12 09:58:36 +00:00
Re-order terms to avoid potential pointer overflow, and remove one
more potential buffer overflow. Submitted by: bde
This commit is contained in:
parent
753da60320
commit
43ec585267
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=23982
@ -174,7 +174,12 @@ tgoto(const char *CM, int destcol, int destline)
|
||||
* to be the successor of tab.
|
||||
*/
|
||||
do {
|
||||
strcat(added, oncol ? (BC ? BC : "\b") : UP);
|
||||
const char *extra;
|
||||
|
||||
extra = oncol ? (BC ? BC : "\b") : UP;
|
||||
if (strlen(added) + strlen(extra) >= 10)
|
||||
return ("OVERFLOW");
|
||||
strcat(added, extra);
|
||||
which++;
|
||||
} while (which == '\n');
|
||||
}
|
||||
@ -215,7 +220,7 @@ tgoto(const char *CM, int destcol, int destline)
|
||||
goto toohard;
|
||||
}
|
||||
}
|
||||
if (dp+strlen(added)+1 > &result[MAXRETURNSIZE])
|
||||
if (strlen(added) >= &result[MAXRETURNSIZE] - dp)
|
||||
return ("OVERFLOW");
|
||||
strcpy(dp, added);
|
||||
return (result);
|
||||
|
Loading…
Reference in New Issue
Block a user