check for valid octal input and crude range check on that for validity
This commit is contained in:
parent
31894adad2
commit
2e98468788
3
chmod.c
3
chmod.c
|
@ -93,6 +93,7 @@ parsemode(const char *str)
|
||||||
|
|
||||||
octal = strtol(str, &end, 8);
|
octal = strtol(str, &end, 8);
|
||||||
if(*end == '\0') {
|
if(*end == '\0') {
|
||||||
|
if( octal < 0 || octal > 07777) eprintf("invalid mode\n");
|
||||||
if(octal & 04000) mode |= S_ISUID;
|
if(octal & 04000) mode |= S_ISUID;
|
||||||
if(octal & 02000) mode |= S_ISGID;
|
if(octal & 02000) mode |= S_ISGID;
|
||||||
if(octal & 01000) mode |= S_ISVTX;
|
if(octal & 01000) mode |= S_ISVTX;
|
||||||
|
@ -106,6 +107,8 @@ parsemode(const char *str)
|
||||||
if(octal & 00002) mode |= S_IWOTH;
|
if(octal & 00002) mode |= S_IWOTH;
|
||||||
if(octal & 00001) mode |= S_IXOTH;
|
if(octal & 00001) mode |= S_IXOTH;
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
eprintf("not octal\n");
|
||||||
}
|
}
|
||||||
for(p = str; *p; p++)
|
for(p = str; *p; p++)
|
||||||
switch(*p) {
|
switch(*p) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user