2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-03 15:55:40 +00:00

Use sudo_strsplit() instead of doing the equivalent manually.

This commit is contained in:
Todd C. Miller
2016-08-26 11:07:19 -06:00
parent c50b835255
commit 7918f7e7eb

View File

@@ -833,7 +833,6 @@ store_str(const char *val, struct sudo_defs_types *def)
static bool static bool
store_list(const char *str, struct sudo_defs_types *def, int op) store_list(const char *str, struct sudo_defs_types *def, int op)
{ {
const char *start, *end;
debug_decl(store_list, SUDOERS_DEBUG_DEFAULTS) debug_decl(store_list, SUDOERS_DEBUG_DEFAULTS)
/* Remove all old members. */ /* Remove all old members. */
@@ -842,20 +841,15 @@ store_list(const char *str, struct sudo_defs_types *def, int op)
/* Split str into multiple space-separated words and act on each one. */ /* Split str into multiple space-separated words and act on each one. */
if (str != NULL) { if (str != NULL) {
end = str; const char *cp, *ep;
do { const char *end = str + strlen(str);
/* Remove leading blanks, if nothing but blanks we are done. */ const enum list_ops lop = op == '-' ? delete : add;
for (start = end; isblank((unsigned char)*start); start++)
;
if (*start == '\0')
break;
/* Find end position and perform operation. */ for (cp = sudo_strsplit(str, end, " \t", &ep); cp != NULL;
for (end = start; *end && !isblank((unsigned char)*end); end++) cp = sudo_strsplit(NULL, end, " \t", &ep)) {
; if (!list_op(cp, ep - cp, def, lop))
if (!list_op(start, end - start, def, op == '-' ? delete : add))
debug_return_bool(false); debug_return_bool(false);
} while (*end++ != '\0'); }
} }
debug_return_bool(true); debug_return_bool(true);
} }