From 5657214ac24a62e96b366097ffbfba39ebcd3380 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 5 Dec 2020 03:51:20 -0600 Subject: Small cleanup. --- lib/lib.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'lib/lib.c') diff --git a/lib/lib.c b/lib/lib.c index ebf85ce0..413d0f73 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -971,18 +971,12 @@ mode_t string_to_mode(char *modestr, mode_t mode) } // Repeated "hows" are allowed; something like "a=r+w+s" is valid. - if (!*str) goto barf; - while (*str) { - if (!strchr(hows, *str)) goto barf; - if (!(dohow = *(str++))) goto barf; - - while (*str && (s = strchr(whats, *str))) { - dowhat |= 1<<(s-whats); - str++; - } + do { + if (!(dohow = *str) || !strchr(hows, *str)) goto barf; + while (*++str && (s = strchr(whats, *str))) dowhat |= 1<<(s-whats); // Convert X to x for directory or if already executable somewhere - if ((dowhat&32) && (S_ISDIR(mode) || (mode&0111))) dowhat |= 1; + if ((dowhat&32) && (S_ISDIR(mode) || (mode&0111))) dowhat |= 1; // Copy mode from another category? if (!dowhat && *str && (s = strchr(whys, *str))) { @@ -1004,7 +998,7 @@ mode_t string_to_mode(char *modestr, mode_t mode) // Figure out new value at this location if (i == 3) { // suid and sticky - if (!j) bit = dowhat&16; // o+s = t + if (!j) bit = dowhat&16; // o+s = t but a+s doesn't set t, hence t else if ((dowhat&8) && (dowho&(8|(1<