mirror of
https://github.com/SELinuxProject/selinux
synced 2025-03-09 19:57:34 +00:00
libsepol: constify tokenized input
The input string to be tokenized is not modified. Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
4d33c6753e
commit
22d3609b13
@ -40,7 +40,7 @@ char *sepol_extended_perms_to_string(avtab_extended_perms_t *xperms);
|
|||||||
* The tokenize function may be used to
|
* The tokenize function may be used to
|
||||||
* replace sscanf
|
* 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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -221,9 +221,9 @@ err:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Read a token from a buffer */
|
/* 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;
|
*str = NULL;
|
||||||
|
|
||||||
while (**ptr != '\0') {
|
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
|
* contain the remaining content of line_buf. If the delimiter is any whitespace
|
||||||
* character, then all whitespace will be squashed.
|
* 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;
|
int rc, items;
|
||||||
size_t arg_len = 0;
|
size_t arg_len = 0;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
Loading…
Reference in New Issue
Block a user