const OCTET_STRING_t *os = sptr;
uint8_t *buf, *end;
char *result, *r;
+ json_t *json;
- result = pmalloc(2 * os->size + 1);
+ result = pmalloc(2 * os->size);
buf = os->buf;
end = buf + os->size;
*r++ = H2C[(*buf >> 4) & 0x0F];
*r++ = H2C[(*buf ) & 0x0F];
}
- *r = '\0';
- return json_string(result);
+ json = json_stringn(result, 2 * os->size);
+
+ free(result);
+ return json;
}
json_t *
#include "types/address.h"
static json_t *
-prefix2json(char *prefix, uint8_t length)
+prefix2json(char const *prefix, uint8_t length)
{
json_t *root;
prefix = pref2json(src);
if (prefix == NULL)
goto fail;
- if (json_array_append(addresses, prefix))
+ if (json_array_append_new(addresses, prefix))
goto fail;
maxlen = asn_DEF_INTEGER.op->json_encoder(&asn_DEF_INTEGER, src->maxLength);
if (root == NULL)
return NULL;
- if (json_object_set_new(root, "digitalSignature", json_boolean(ku->data[0] & 0x80u)) < 0)
+ if (json_object_set_new(root, "digitalSignature", json_boolean(data[0] & 0x80u)) < 0)
goto fail;
- if (json_object_set_new(root, "contentCommitment", json_boolean(ku->data[0] & 0x40u)) < 0)
+ if (json_object_set_new(root, "contentCommitment", json_boolean(data[0] & 0x40u)) < 0)
goto fail;
- if (json_object_set_new(root, "keyEncipherment", json_boolean(ku->data[0] & 0x20u)) < 0)
+ if (json_object_set_new(root, "keyEncipherment", json_boolean(data[0] & 0x20u)) < 0)
goto fail;
- if (json_object_set_new(root, "dataEncipherment", json_boolean(ku->data[0] & 0x10u)) < 0)
+ if (json_object_set_new(root, "dataEncipherment", json_boolean(data[0] & 0x10u)) < 0)
goto fail;
- if (json_object_set_new(root, "keyAgreement", json_boolean(ku->data[0] & 0x08u)) < 0)
+ if (json_object_set_new(root, "keyAgreement", json_boolean(data[0] & 0x08u)) < 0)
goto fail;
- if (json_object_set_new(root, "keyCertSign", json_boolean(ku->data[0] & 0x04u)) < 0)
+ if (json_object_set_new(root, "keyCertSign", json_boolean(data[0] & 0x04u)) < 0)
goto fail;
- if (json_object_set_new(root, "cRLSign", json_boolean(ku->data[0] & 0x02u)) < 0)
+ if (json_object_set_new(root, "cRLSign", json_boolean(data[0] & 0x02u)) < 0)
goto fail;
- if (json_object_set_new(root, "encipherOnly", json_boolean(ku->data[0] & 0x01u)) < 0)
+ if (json_object_set_new(root, "encipherOnly", json_boolean(data[0] & 0x01u)) < 0)
goto fail;
- if (json_object_set_new(root, "decipherOnly", json_boolean(ku->data[1] & 0x80u)) < 0)
+ if (json_object_set_new(root, "decipherOnly", json_boolean(data[1] & 0x80u)) < 0)
goto fail;
return root;
{
json_t *root;
BIO *bio;
+ char *name;
int i;
+ int ret;
if (sk_X509_EXTENSION_num(exts) <= 0)
return json_null();
BIO_free_all(bio);
goto fail;
}
+ name = bio2str(bio);
/* Create node, add to parent */
- node = json_object();
- if (node == NULL) {
- BIO_free_all(bio);
- goto fail;
- }
- if (json_object_set_new(root, bio2str(bio), node) < 0)
+ ret = json_object_set_new(root, name, node = json_object());
+ free(name);
+ if (ret < 0)
goto fail;
/* Child 1: Critical */