diff options
| author | lukem <lukem@NetBSD.org> | 1998-01-21 11:12:34 +0000 |
|---|---|---|
| committer | lukem <lukem@NetBSD.org> | 1998-01-21 11:12:34 +0000 |
| commit | 63177b84aec0bbae6862dabf20aa0d61d23fdbab (patch) | |
| tree | 52ba238ea07850172a74cf71aba580734b489e54 /lib/libedit/parse.c | |
| parent | e3f5fb922fee69245b544321fabe9f3d80606365 (diff) | |
in el_parse(), use a temporary buffer to store the program name when
comparing, preventing trashing of argv[0]. remove note in man page
warning of former behaviour.
Diffstat (limited to 'lib/libedit/parse.c')
| -rw-r--r-- | lib/libedit/parse.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/libedit/parse.c b/lib/libedit/parse.c index a1769ef2e2c..83f81c725ee 100644 --- a/lib/libedit/parse.c +++ b/lib/libedit/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.6 1997/07/06 18:25:31 christos Exp $ */ +/* $NetBSD: parse.c,v 1.7 1998/01/21 11:12:35 lukem Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: parse.c,v 1.6 1997/07/06 18:25:31 christos Exp $"); +__RCSID("$NetBSD: parse.c,v 1.7 1998/01/21 11:12:35 lukem Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -110,8 +110,19 @@ el_parse(el, argc, argv) return -1; ptr = strchr(argv[0], ':'); if (ptr != NULL) { - *ptr++ = '\0'; - if (! el_match(el->el_prog, argv[0])) + char *tprog; + int l; + + l = ptr - argv[0] - 1; + tprog = (char *)malloc(l + 1); + if (tprog == NULL) + return 0; + strncpy(tprog, argv[0], l); + tprog[l] = '\0'; + ptr++; + l = el_match(el->el_prog, tprog); + free(tprog); + if (!l) return 0; } else |
