From: Alberto Leiva Popper Date: Mon, 14 Oct 2024 23:41:31 +0000 (-0600) Subject: cache index: Allow NULL dlerr, mtim, session_id and serial X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32fbeb67795be2cdd93b39f31d8592a240591976;p=thirdparty%2FFORT-validator.git 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. --- 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)))