aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-04-18 22:09:06 +0000
committerErik Andersen <andersen@codepoet.org>2000-04-18 22:09:06 +0000
commit632bb571357c4cef455c00fb06493810284e544d (patch)
tree21e52f13437307a0ca182125f6dc11715e16f8c4
parentc366050a23630f0763159263d62b3f1efa0c46ef (diff)
downloadbusybox-w32-632bb571357c4cef455c00fb06493810284e544d.tar.gz
busybox-w32-632bb571357c4cef455c00fb06493810284e544d.tar.bz2
busybox-w32-632bb571357c4cef455c00fb06493810284e544d.zip
Fix symlink following bug in chmod -R and friends. Allow SYSV style
'chown foo:bar' in addition to 'chown foo.bar', and fix a bug in the busybox globbing routine such that 'find /dir -name [i]' no longer segfaults. -Erik
-rw-r--r--chmod_chown_chgrp.c6
-rw-r--r--utility.c17
2 files changed, 15 insertions, 8 deletions
diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c
index 8dd767054..fb93f3ff8 100644
--- a/chmod_chown_chgrp.c
+++ b/chmod_chown_chgrp.c
@@ -48,7 +48,7 @@ static const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n\n"
48 48
49 "\nOptions:\n\t-R\tchange files and directories recursively\n"; 49 "\nOptions:\n\t-R\tchange files and directories recursively\n";
50static const char chown_usage[] = 50static const char chown_usage[] =
51 "chown [OPTION]... OWNER[.[GROUP] FILE...\n\n" 51 "chown [OPTION]... OWNER[<.|:>[GROUP] FILE...\n\n"
52 "Change the owner and/or group of each FILE to OWNER and/or GROUP.\n" 52 "Change the owner and/or group of each FILE to OWNER and/or GROUP.\n"
53 53
54 "\nOptions:\n\t-R\tchange files and directories recursively\n"; 54 "\nOptions:\n\t-R\tchange files and directories recursively\n";
@@ -140,6 +140,8 @@ int chmod_chown_chgrp_main(int argc, char **argv)
140 goto bad_group; 140 goto bad_group;
141 } else { 141 } else {
142 groupName = strchr(*argv, '.'); 142 groupName = strchr(*argv, '.');
143 if (groupName == NULL)
144 groupName = strchr(*argv, ':');
143 if (groupName) { 145 if (groupName) {
144 *groupName++ = '\0'; 146 *groupName++ = '\0';
145 gid = strtoul(groupName, &p, 10); 147 gid = strtoul(groupName, &p, 10);
@@ -169,7 +171,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
169 fatalError( "%s: too few arguments\n", invocationName); 171 fatalError( "%s: too few arguments\n", invocationName);
170 } 172 }
171 while (argc-- > 1) { 173 while (argc-- > 1) {
172 if (recursiveAction (*(++argv), recursiveFlag, TRUE, FALSE, 174 if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,
173 fileAction, fileAction, NULL) == FALSE) 175 fileAction, fileAction, NULL) == FALSE)
174 exit(FALSE); 176 exit(FALSE);
175 } 177 }
diff --git a/utility.c b/utility.c
index 0045e4d75..773f6a83e 100644
--- a/utility.c
+++ b/utility.c
@@ -1058,6 +1058,7 @@ extern int check_wildcard_match(const char *text, const char *pattern)
1058 const char *retryText; 1058 const char *retryText;
1059 int ch; 1059 int ch;
1060 int found; 1060 int found;
1061 int len;
1061 1062
1062 retryPat = NULL; 1063 retryPat = NULL;
1063 retryText = NULL; 1064 retryText = NULL;
@@ -1084,13 +1085,17 @@ extern int check_wildcard_match(const char *text, const char *pattern)
1084 if (*text == ch) 1085 if (*text == ch)
1085 found = TRUE; 1086 found = TRUE;
1086 } 1087 }
1087 if (found == FALSE) 1088 len=strlen(text);
1088 continue; 1089 if (found == FALSE && len!=0) {
1090 return FALSE;
1091 }
1089 if (found == TRUE) { 1092 if (found == TRUE) {
1090 //printf("Got a match. pattern='%s' text='%s'\n", pattern, text); 1093 if (strlen(pattern)==0 && len==1) {
1091 if (retryPat || retryText) { 1094 return TRUE;
1092 pattern = retryPat; 1095 }
1093 text = ++retryText; 1096 if (len!=0) {
1097 text++;
1098 continue;
1094 } 1099 }
1095 } 1100 }
1096 1101