summaryrefslogtreecommitdiffstats
path: root/src/json.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-08-18 16:33:21 +0200
committerFlorian Westphal <fw@strlen.de>2023-08-18 16:50:21 +0200
commit4646d656466b1f05bd765bbfb4d6d7bf1529bdbd (patch)
treed58cbf9b1a64deff447457699889cb2245e704b5 /src/json.c
parentf3411cbf4608df4c83bb7d830ea118d923affb2e (diff)
json: use strtok_r() instead of strtok()
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>
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/json.c b/src/json.c
index a119dfc4..366c0edf 100644
--- a/src/json.c
+++ b/src/json.c
@@ -69,8 +69,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)
@@ -79,7 +80,7 @@ static json_t *set_dtype_json(const struct expr *key)
root = 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;