commit 2e98468788fd42850622d78f29e49b92a120914a
parent 31894adad272f50410e8871e8cac16e9475b2c12
Author: dsp <dsp@2f30.org>
Date: Sat, 1 Feb 2014 19:48:57 +0000
check for valid octal input and crude range check on that for validity
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/chmod.c b/chmod.c
@@ -93,6 +93,7 @@ parsemode(const char *str)
octal = strtol(str, &end, 8);
if(*end == '\0') {
+ if( octal < 0 || octal > 07777) eprintf("invalid mode\n");
if(octal & 04000) mode |= S_ISUID;
if(octal & 02000) mode |= S_ISGID;
if(octal & 01000) mode |= S_ISVTX;
@@ -106,6 +107,8 @@ parsemode(const char *str)
if(octal & 00002) mode |= S_IWOTH;
if(octal & 00001) mode |= S_IXOTH;
return;
+ } else {
+ eprintf("not octal\n");
}
for(p = str; *p; p++)
switch(*p) {