summaryrefslogtreecommitdiff
path: root/lib/libtermlib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-16 16:53:42 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-12-16 16:53:42 +0000
commit26c0143d817536c8335c7ec2dc28925082f46f39 (patch)
tree79005fe7449c00ae0931f3a823eb891aed850a4d /lib/libtermlib
parent8d54f79259f72e013f6322888574af4bfec42139 (diff)
strncat botches
Diffstat (limited to 'lib/libtermlib')
-rw-r--r--lib/libtermlib/fillcap.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/libtermlib/fillcap.c b/lib/libtermlib/fillcap.c
index f868d4e5b40..5f364a5d006 100644
--- a/lib/libtermlib/fillcap.c
+++ b/lib/libtermlib/fillcap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fillcap.c,v 1.2 1996/08/27 03:32:32 tholo Exp $ */
+/* $OpenBSD: fillcap.c,v 1.3 1996/12/16 16:53:41 deraadt Exp $ */
/*
* Copyright (c) 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
@@ -31,7 +31,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: fillcap.c,v 1.2 1996/08/27 03:32:32 tholo Exp $";
+static char rcsid[] = "$OpenBSD: fillcap.c,v 1.3 1996/12/16 16:53:41 deraadt Exp $";
#endif
#include <stdio.h>
@@ -84,18 +84,17 @@ _ti_fillcap(term)
}
else if (carriage_return != NULL && carriage_return_delay <= 0) {
if (linefeed_if_not_lf != NULL) {
- strncpy(buf, carriage_return, sizeof(buf) >> 1);
- buf[sizeof(buf) >> 1] = '\0';
- strncat(buf, linefeed_if_not_lf, sizeof(buf) - 1);
+ strncpy(buf, carriage_return, (sizeof(buf) >> 1) -1);
+ buf[(sizeof(buf) >> 1) -1] = '\0';
+ strncat(buf, linefeed_if_not_lf, sizeof(buf) - strlen(buf));
}
else if (new_line_delay > 0)
sprintf(buf, "%s\n$<%d>", carriage_return, new_line_delay);
else {
strncpy(buf, carriage_return, sizeof(buf) >> 1);
- buf[sizeof(buf) >> 1] = '\0';
- strncat(buf, "\n", sizeof(buf) - 1);
+ buf[(sizeof(buf) >> 1) - 1] = '\0';
+ strncat(buf, "\n", sizeof(buf) - strlen(buf));
}
- buf[sizeof(buf) - 1] = '\0';
newline = strdup(buf);
}
if (return_does_clr_eol || no_correctly_working_cr) {