diff options
| -rw-r--r-- | lib/libtermcap/tgoto.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libtermcap/tgoto.c b/lib/libtermcap/tgoto.c index ca493024f706..4088fa5f7ff3 100644 --- a/lib/libtermcap/tgoto.c +++ b/lib/libtermcap/tgoto.c @@ -174,7 +174,12 @@ casedot: * 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 @@ casedot: goto toohard; } } - if (dp+strlen(added)+1 > &result[MAXRETURNSIZE]) + if (strlen(added) >= &result[MAXRETURNSIZE] - dp) return ("OVERFLOW"); strcpy(dp, added); return (result); |
