]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
cache index: Allow NULL dlerr, mtim, session_id and serial
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Mon, 14 Oct 2024 23:41:31 +0000 (17:41 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Tue, 15 Oct 2024 00:07:34 +0000 (18:07 -0600)
NULL dlerr can mean "no error", mtim isn't always set,
and session_id/serial do not exist in fallback.

src/cache.c
src/rrdp.c

index 82be64886818e2d3ff8e42fe8a6db17dd27cb6eb..bd90e0bef6a0bdb3e74427049bb24111fbc79f4d 100644 (file)
@@ -394,9 +394,9 @@ node2json(struct cache_node *node)
                goto fail;
        if (json_add_str(json, "path", node->map.path))
                goto fail;
-       if (json_add_int(json, "dlerr", node->dlerr)) // XXX relevant?
+       if (node->dlerr && json_add_int(json, "dlerr", node->dlerr)) // XXX relevant?
                goto fail;
-       if (json_add_ts(json, "mtim", node->mtim))
+       if (node->mtim && json_add_ts(json, "mtim", node->mtim))
                goto fail;
        if (node->rrdp)
                if (json_object_add(json, "rrdp", rrdp_state2json(node->rrdp)))
index c69eb3d717262cbd120ada0ed3d2ef182c35b823..d98eee3093748d3941747cb26e9eb12cbcecf1e7 100644 (file)
@@ -1380,9 +1380,11 @@ rrdp_state2json(struct rrdp_state *state)
        if (json == NULL)
                enomem_panic();
 
-       if (json_add_str(json, TAGNAME_SESSION, state->session.session_id))
+       if (state->session.session_id &&
+           json_add_str(json, TAGNAME_SESSION, state->session.session_id))
                goto fail;
-       if (json_add_str(json, TAGNAME_SERIAL, state->session.serial.str))
+       if (state->session.serial.str &&
+           json_add_str(json, TAGNAME_SERIAL, state->session.serial.str))
                goto fail;
        if (state->files)
                if (json_object_add(json, "files", files2json(state)))