summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-12-06 04:59:59 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-12-06 04:59:59 +0000
commit2b4826057532ca32d494f8861b3de6b27f954a41 (patch)
tree2c59cdfc09c557bf07ee1a81ba022fdfbc4e6f14 /usr.bin
parent7e60ed72a1b9a51d91e3d137d0c544bef209b2e7 (diff)
Don't access buf[strlen(buf) - 1] for zero-length strings.
OK jaredy@.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/infocmp/infocmp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/infocmp/infocmp.c b/usr.bin/infocmp/infocmp.c
index 12b5bca3628..d4750f8bca3 100644
--- a/usr.bin/infocmp/infocmp.c
+++ b/usr.bin/infocmp/infocmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: infocmp.c,v 1.17 2003/04/08 19:08:58 deraadt Exp $ */
+/* $OpenBSD: infocmp.c,v 1.18 2006/12/06 04:59:58 ray Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -630,7 +630,8 @@ analyze_string(const char *name, const char *cap, TERMTYPE * tp)
(void) strlcat(buf2, ";", sizeof buf2);
} while
((ep = strtok((char *) 0, ";")));
- buf2[strlen(buf2) - 1] = '\0';
+ if (buf2[0] != '\0' && buf2[strlen(buf2) - 1] == ';')
+ buf2[strlen(buf2) - 1] = '\0';
expansion = buf2;
}
@@ -666,7 +667,8 @@ analyze_string(const char *name, const char *cap, TERMTYPE * tp)
} while
((ep = strtok((char *) 0, ";")));
- buf2[strlen(buf2) - 1] = '\0';
+ if (buf2[0] != '\0' && buf2[strlen(buf2) - 1] == ';')
+ buf2[strlen(buf2) - 1] = '\0';
expansion = buf2;
}
/* now check for scroll region reset */