The argv[] used for el_set() EL_BIND, EL_SETTY, etc should be terminated
authornicm <nicm@openbsd.org>
Tue, 20 May 2014 11:59:03 +0000 (11:59 +0000)
committernicm <nicm@openbsd.org>
Tue, 20 May 2014 11:59:03 +0000 (11:59 +0000)
by NULL. Fix from NetBSD via yasuoka@ but changed by me not to walk off
the end of array with >20 arguments.

ok yasuoka

lib/libedit/eln.c

index eb14581..3204807 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: eln.c,v 1.3 2011/11/27 21:46:44 pascal Exp $  */
+/*     $OpenBSD: eln.c,v 1.4 2014/05/20 11:59:03 nicm Exp $    */
 /*     $NetBSD: eln.c,v 1.9 2010/11/04 13:53:12 christos Exp $ */
 
 /*-
@@ -144,15 +144,15 @@ el_set(EditLine *el, int op, ...)
        case EL_SETTC:
        case EL_ECHOTC:
        case EL_SETTY: {
-               const char *argv[20];
+               const char *argv[21];
                int i;
                const wchar_t **wargv;
-               for (i = 1; i < (int)__arraycount(argv); ++i)
+               for (i = 1; i < (int)__arraycount(argv) - 1; ++i)
                        if ((argv[i] = va_arg(ap, char *)) == NULL)
                            break;
-               argv[0] = NULL;
+               argv[0] = argv[i] = NULL;
                wargv = (const wchar_t **)
-                   ct_decode_argv(i, argv, &el->el_lgcyconv);
+                   ct_decode_argv(i + 1, argv, &el->el_lgcyconv);
                if (!wargv) {
                    ret = -1;
                    goto out;