diff options
| author | Thomas Haller <thaller@redhat.com> | 2023-08-18 16:33:21 +0200 |
|---|---|---|
| committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-09-01 22:37:01 +0200 |
| commit | b1620740d372a73d4a9ee95e4b893b3f7cd90828 (patch) | |
| tree | e99b7dc92e1383d65ba96ae851dd362c09d347e1 | |
| parent | 0d14d7fa54492da0c43a9ce0be47d691167a5f55 (diff) | |
json: use strtok_r() instead of strtok()
commit 4646d656466b1f05bd765bbfb4d6d7bf1529bdbd upstream.
strtok_r() is probably(?) everywhere available where we care.
Use it. It is thread-safe, and libnftables shouldn't make
assumptions about what other threads of the process are doing.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
| -rw-r--r-- | src/json.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -87,8 +87,9 @@ static json_t *set_dtype_json(const struct expr *key) { char *namedup = xstrdup(key->dtype->name), *tok; json_t *root = NULL; + char *tok_safe; - tok = strtok(namedup, " ."); + tok = strtok_r(namedup, " .", &tok_safe); while (tok) { json_t *jtok = json_string(tok); if (!root) @@ -97,7 +98,7 @@ static json_t *set_dtype_json(const struct expr *key) root = nft_json_pack("[o, o]", root, jtok); else json_array_append_new(root, jtok); - tok = strtok(NULL, " ."); + tok = strtok_r(NULL, " .", &tok_safe); } xfree(namedup); return root; |
