summaryrefslogtreecommitdiff
path: root/lib/libcurses/tinfo/captoinfo.c
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-10-15 23:33:49 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-10-15 23:33:49 +0000
commitaf15a7c0ea97a90742c6bc9d032f3a2bbfec42eb (patch)
tree7a7038b3428224a301879537bf4f96eb533ec4a0 /lib/libcurses/tinfo/captoinfo.c
parentd4c4388328c30237df595738e8df868547688ff6 (diff)
fix out of bounds access. found by david@ running with malloc guards and
randomization. ok millert@
Diffstat (limited to 'lib/libcurses/tinfo/captoinfo.c')
-rw-r--r--lib/libcurses/tinfo/captoinfo.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libcurses/tinfo/captoinfo.c b/lib/libcurses/tinfo/captoinfo.c
index 4b9323e8a7f..8e5df76f523 100644
--- a/lib/libcurses/tinfo/captoinfo.c
+++ b/lib/libcurses/tinfo/captoinfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: captoinfo.c,v 1.11 2003/03/18 16:55:54 millert Exp $ */
+/* $OpenBSD: captoinfo.c,v 1.12 2003/10/15 23:33:48 tedu Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -653,11 +653,11 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize
/* we may have to move some trailing mandatory padding up front */
padding = str + strlen(str) - 1;
- if (*padding == '>' && *--padding == '/') {
+ if (padding > str && *padding == '>' && *--padding == '/') {
--padding;
while (isdigit(CharOf(*padding)) || *padding == '.' || *padding == '*')
padding--;
- if (*padding == '<' && *--padding == '$')
+ if (padding > str && *padding == '<' && *--padding == '$')
trimmed = padding;
padding += 2;