From 2e98468788fd42850622d78f29e49b92a120914a Mon Sep 17 00:00:00 2001 From: dsp Date: Sat, 1 Feb 2014 19:48:57 +0000 Subject: [PATCH] check for valid octal input and crude range check on that for validity --- chmod.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chmod.c b/chmod.c index d0b7a4e..abedb53 100644 --- 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) {