Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit Make sure that argv is NULL terminated since fun...



details:   https://anonhg.NetBSD.org/src/rev/51d095beffee
branches:  trunk
changeset: 820408:51d095beffee
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jan 09 02:54:18 2017 +0000

description:
Make sure that argv is NULL terminated since functions like tty_stty rely
on it to be so (Gerry Swinslow)

diffstat:

 lib/libedit/chartype.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r f285dbeca0f4 -r 51d095beffee lib/libedit/chartype.c
--- a/lib/libedit/chartype.c    Mon Jan 09 00:31:30 2017 +0000
+++ b/lib/libedit/chartype.c    Mon Jan 09 02:54:18 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chartype.c,v 1.30 2016/05/09 21:46:56 christos Exp $   */
+/*     $NetBSD: chartype.c,v 1.31 2017/01/09 02:54:18 christos Exp $   */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.30 2016/05/09 21:46:56 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.31 2017/01/09 02:54:18 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <ctype.h>
@@ -156,7 +156,7 @@
                if (ct_conv_wbuff_resize(conv, bufspace + CT_BUFSIZ) == -1)
                        return NULL;
 
-       wargv = el_malloc((size_t)argc * sizeof(*wargv));
+       wargv = el_malloc((size_t)(argc + 1) * sizeof(*wargv));
 
        for (i = 0, p = conv->wbuff; i < argc; ++i) {
                if (!argv[i]) {   /* don't pass null pointers to mbstowcs */
@@ -174,6 +174,7 @@
                bufspace -= (size_t)bytes;
                p += bytes;
        }
+       wargv[i] = NULL;
 
        return wargv;
 }



Home | Main Index | Thread Index | Old Index