Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit PR/25694: Luke Mewburn: Don't abuse unconstify'i...



details:   https://anonhg.NetBSD.org/src/rev/a6930ebcd3ba
branches:  trunk
changeset: 581154:a6930ebcd3ba
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 29 03:55:37 2005 +0000

description:
PR/25694: Luke Mewburn: Don't abuse unconstify'ing a string and writing to
it, because you'll core dump. Also remove extra const that gives pain to
the irix compiler.

diffstat:

 lib/libedit/parse.c |   6 +++---
 lib/libedit/tty.c   |  14 +++++++-------
 2 files changed, 10 insertions(+), 10 deletions(-)

diffs (77 lines):

diff -r 5dd78d3bb88c -r a6930ebcd3ba lib/libedit/parse.c
--- a/lib/libedit/parse.c       Sat May 28 16:37:20 2005 +0000
+++ b/lib/libedit/parse.c       Sun May 29 03:55:37 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.20 2003/12/05 13:37:48 lukem Exp $ */
+/*     $NetBSD: parse.c,v 1.21 2005/05/29 03:55:37 christos Exp $      */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)parse.c    8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: parse.c,v 1.20 2003/12/05 13:37:48 lukem Exp $");
+__RCSID("$NetBSD: parse.c,v 1.21 2005/05/29 03:55:37 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -136,7 +136,7 @@
  *     the appropriate character or -1 if the escape is not valid
  */
 protected int
-parse__escape(const char **const ptr)
+parse__escape(const char ** ptr)
 {
        const char *p;
        int c;
diff -r 5dd78d3bb88c -r a6930ebcd3ba lib/libedit/tty.c
--- a/lib/libedit/tty.c Sat May 28 16:37:20 2005 +0000
+++ b/lib/libedit/tty.c Sun May 29 03:55:37 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.21 2004/08/13 12:10:39 mycroft Exp $ */
+/*     $NetBSD: tty.c,v 1.22 2005/05/29 03:55:37 christos Exp $        */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)tty.c      8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: tty.c,v 1.21 2004/08/13 12:10:39 mycroft Exp $");
+__RCSID("$NetBSD: tty.c,v 1.22 2005/05/29 03:55:37 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -1228,7 +1228,7 @@
                return (0);
        }
        while (argv && (s = *argv++)) {
-               char *p;
+               const char *p;
                switch (*s) {
                case '+':
                case '-':
@@ -1239,10 +1239,10 @@
                        break;
                }
                d = s;
-               if ((p = strchr(s, '=')) != NULL)
-                       *p++ = '\0';
+               p = strchr(s, '=');
                for (m = ttymodes; m->m_name; m++)
-                       if (strcmp(m->m_name, d) == 0 &&
+                       if ((p ? strncmp(m->m_name, d, (size_t)(p - d)) :
+                           strcmp(m->m_name, d)) == 0 &&
                            (p == NULL || m->m_type == MD_CHAR))
                                break;
 
@@ -1253,7 +1253,7 @@
                }
                if (p) {
                        int c = ffs((int)m->m_value);
-                       int v = *p ? parse__escape((const char **const) &p) :
+                       int v = *++p ? parse__escape((const char **) &p) :
                            el->el_tty.t_vdisable;
                        assert(c-- != 0);
                        c = tty__getcharindex(c);



Home | Main Index | Thread Index | Old Index