summaryrefslogtreecommitdiff
path: root/shell/match.c
diff options
context:
space:
mode:
authorDenis Vlasenko2009-04-26 11:25:19 +0000
committerDenis Vlasenko2009-04-26 11:25:19 +0000
commit5b7589eb27e748a3d281c0341219cf7435e8b4f1 (patch)
treeb9565d8d331207ed37a3b9c0f654b500839d8ef6 /shell/match.c
parent80e57eb7d525803bb776e8294483141756b2b2ef (diff)
downloadbusybox-5b7589eb27e748a3d281c0341219cf7435e8b4f1.zip
busybox-5b7589eb27e748a3d281c0341219cf7435e8b4f1.tar.gz
hush: fix SEGV in % expansion
function old new delta expand_variables 2203 2217 +14
Diffstat (limited to 'shell/match.c')
-rw-r--r--shell/match.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/shell/match.c b/shell/match.c
index 47038d6..a7101ef 100644
--- a/shell/match.c
+++ b/shell/match.c
@@ -11,8 +11,6 @@
* Kenneth Almquist.
*
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
- *
- * Original BSD copyright notice is retained at the end of this file.
*/
#ifdef STANDALONE
# include <stdbool.h>
@@ -28,7 +26,7 @@
#define pmatch(a, b) !fnmatch((a), (b), 0)
-char *scanleft(char *string, char *pattern, bool zero)
+char *scanleft(char *string, char *pattern, bool match_at_left)
{
char c;
char *loc = string;
@@ -38,7 +36,7 @@ char *scanleft(char *string, char *pattern, bool zero)
const char *s;
c = *loc;
- if (zero) {
+ if (match_at_left) {
*loc = '\0';
s = string;
} else
@@ -55,7 +53,7 @@ char *scanleft(char *string, char *pattern, bool zero)
return NULL;
}
-char *scanright(char *string, char *pattern, bool zero)
+char *scanright(char *string, char *pattern, bool match_at_left)
{
char c;
char *loc = string + strlen(string);
@@ -65,7 +63,7 @@ char *scanright(char *string, char *pattern, bool zero)
const char *s;
c = *loc;
- if (zero) {
+ if (match_at_left) {
*loc = '\0';
s = string;
} else
@@ -88,7 +86,7 @@ int main(int argc, char *argv[])
char *string;
char *op;
char *pattern;
- bool zero;
+ bool match_at_left;
char *loc;
int i;
@@ -117,15 +115,15 @@ int main(int argc, char *argv[])
continue;
}
op = string + off;
- scan = pick_scan(op[0], op[1], &zero);
+ scan = pick_scan(op[0], op[1], &match_at_left);
pattern = op + 1;
if (op[0] == op[1])
op[1] = '\0', ++pattern;
op[0] = '\0';
- loc = scan(string, pattern, zero);
+ loc = scan(string, pattern, match_at_left);
- if (zero) {
+ if (match_at_left) {
printf("'%s'\n", loc);
} else {
*loc = '\0';