The input string to be tokenized is not modified. Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> --- libsepol/include/sepol/policydb/util.h | 2 +- libsepol/src/util.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libsepol/include/sepol/policydb/util.h b/libsepol/include/sepol/policydb/util.h index db8da213..4ea5a346 100644 --- a/libsepol/include/sepol/policydb/util.h +++ b/libsepol/include/sepol/policydb/util.h @@ -40,7 +40,7 @@ char *sepol_extended_perms_to_string(avtab_extended_perms_t *xperms); * The tokenize function may be used to * replace sscanf */ -extern int tokenize(char *line_buf, char delim, int num_args, ...); +extern int tokenize(const char *line_buf, char delim, int num_args, ...); #ifdef __cplusplus } diff --git a/libsepol/src/util.c b/libsepol/src/util.c index 2f877920..571f6c93 100644 --- a/libsepol/src/util.c +++ b/libsepol/src/util.c @@ -221,9 +221,9 @@ err: */ /* Read a token from a buffer */ -static inline int tokenize_str(char delim, char **str, char **ptr, size_t *len) +static inline int tokenize_str(char delim, char **str, const char **ptr, size_t *len) { - char *tmp_buf = *ptr; + const char *tmp_buf = *ptr; *str = NULL; while (**ptr != '\0') { @@ -273,9 +273,10 @@ static inline int tokenize_str(char delim, char **str, char **ptr, size_t *len) * contain the remaining content of line_buf. If the delimiter is any whitespace * character, then all whitespace will be squashed. */ -int tokenize(char *line_buf, char delim, int num_args, ...) +int tokenize(const char *line_buf, char delim, int num_args, ...) { - char **arg, *buf_p; + char **arg; + const char *buf_p; int rc, items; size_t arg_len = 0; va_list ap; -- 2.43.0