Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libterminfo make use we don't touch memory past the end ...



details:   https://anonhg.NetBSD.org/src/rev/8fac937ac949
branches:  trunk
changeset: 771173:8fac937ac949
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Nov 13 15:24:04 2011 +0000

description:
make use we don't touch memory past the end of the buffer. Pointed out
by tnozaki.

diffstat:

 lib/libterminfo/termcap.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r 20554bee27c5 -r 8fac937ac949 lib/libterminfo/termcap.c
--- a/lib/libterminfo/termcap.c Sun Nov 13 14:39:42 2011 +0000
+++ b/lib/libterminfo/termcap.c Sun Nov 13 15:24:04 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: termcap.c,v 1.16 2011/10/03 12:31:51 roy Exp $ */
+/* $NetBSD: termcap.c,v 1.17 2011/11/13 15:24:04 christos Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: termcap.c,v 1.16 2011/10/03 12:31:51 roy Exp $");
+__RCSID("$NetBSD: termcap.c,v 1.17 2011/11/13 15:24:04 christos Exp $");
 
 #include <assert.h>
 #include <ctype.h>
@@ -79,7 +79,7 @@
        uint32_t ind;
        size_t i;
        TERMUSERDEF *ud;
-       const char id[] = { id2[0], id2[1], '\0' };
+       const char id[] = { id2[0], id2[0] ? id2[1] : '\0', '\0' };
 
        if (cur_term == NULL)
                return 0;
@@ -104,7 +104,7 @@
        size_t i;
        TERMUSERDEF *ud;
        const TENTRY *te;
-       const char id[] = { id2[0], id2[1], '\0' };
+       const char id[] = { id2[0], id2[0] ? id2[1] : '\0', '\0' };
 
        if (cur_term == NULL)
                return -1;
@@ -136,7 +136,7 @@
        size_t i;
        TERMUSERDEF *ud;
        const char *str;
-       const char id[] = { id2[0], id2[1], '\0' };
+       const char id[] = { id2[0], id2[0] ? id2[1] : '\0', '\0' };
 
        if (cur_term == NULL)
                return NULL;



Home | Main Index | Thread Index | Old Index