From 32fbeb67795be2cdd93b39f31d8592a240591976 Mon Sep 17 00:00:00 2001 From: Alberto Leiva Popper Date: Mon, 14 Oct 2024 17:41:31 -0600 Subject: [PATCH] cache index: Allow NULL dlerr, mtim, session_id and serial NULL dlerr can mean "no error", mtim isn't always set, and session_id/serial do not exist in fallback. --- src/cache.c | 4 ++-- src/rrdp.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cache.c b/src/cache.c index 82be6488..bd90e0be 100644 --- a/src/cache.c +++ b/src/cache.c @@ -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))) diff --git a/src/rrdp.c b/src/rrdp.c index c69eb3d7..d98eee30 100644 --- a/src/rrdp.c +++ b/src/rrdp.c @@ -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))) -- 2.47.2