]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
Replace DNSSEC_ENOMEM with KNOT_ENOMEM
authorDaniel Salzman <daniel.salzman@nic.cz>
Tue, 21 Oct 2025 07:48:25 +0000 (09:48 +0200)
committerLibor Peltan <libor.peltan@nic.cz>
Fri, 24 Oct 2025 07:17:08 +0000 (09:17 +0200)
17 files changed:
src/libknot/dnssec/binary.c
src/libknot/dnssec/digest.c
src/libknot/dnssec/error.c
src/libknot/dnssec/error.h
src/libknot/dnssec/key/dnskey.c
src/libknot/dnssec/key/key.c
src/libknot/dnssec/key/privkey.c
src/libknot/dnssec/keystore/keystore.c
src/libknot/dnssec/keystore/pkcs11.c
src/libknot/dnssec/keystore/pkcs8.c
src/libknot/dnssec/nsec/nsec.c
src/libknot/dnssec/p11/p11.c
src/libknot/dnssec/pem.c
src/libknot/dnssec/shared/keyid_gnutls.c
src/libknot/dnssec/sign/der.c
src/libknot/dnssec/tsig.c
src/utils/keymgr/bind_privkey.c

index 17862ccebb7c7ff09c388bdeab5d439482e004cf..c8ba5427d63967b045fcc17833c6a2a04678eb64 100644 (file)
@@ -22,7 +22,7 @@ int dnssec_binary_alloc(dnssec_binary_t *data, size_t size)
 
        uint8_t *new_data = calloc(1, size);
        if (!new_data) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        data->data = new_data;
@@ -51,7 +51,7 @@ int dnssec_binary_dup(const dnssec_binary_t *from, dnssec_binary_t *to)
 
        uint8_t *copy = malloc(from->size);
        if (copy == NULL) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        memmove(copy, from->data, from->size);
@@ -71,7 +71,7 @@ int dnssec_binary_resize(dnssec_binary_t *data, size_t new_size)
 
        uint8_t *new_data = realloc(data->data, new_size);
        if (new_size > 0 && new_data == NULL) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        data->data = new_data;
index 97edf00e511d91122b072c719918fae19e7a77eb..1d6e891bf28f471c1f422df4d49b5a7e479a201f 100644 (file)
@@ -39,7 +39,7 @@ int dnssec_digest_init(dnssec_digest_t algorithm, dnssec_digest_ctx_t **out_ctx)
 
        dnssec_digest_ctx_t *res = malloc(sizeof(*res));
        if (res == NULL) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        res->size = gnutls_hash_get_len(gtalg);
index fe8a4d8958f689bf7d1c5d2b0b88f3e2dabdce60..c76a6344b733e042c6fd7fb365ded835c5fabc71 100644 (file)
@@ -16,7 +16,7 @@ typedef struct error_message_t {
 static const error_message_t ERROR_MESSAGES[] = {
        { KNOT_EOK,                     "no error" },
 
-       { DNSSEC_ENOMEM,                "not enough memory" },
+       { KNOT_ENOMEM,          "not enough memory" },
        { DNSSEC_EINVAL,                "invalid argument" },
        { DNSSEC_ENOENT,                "no such file or directory" },
 
index 90a9bbb371667f556d27fdb4104327c6e5ff243e..4ab3ca88ffb9484817d9dc9d6a5def5e17065f6e 100644 (file)
@@ -26,7 +26,7 @@
 enum dnssec_error {
        KNOT_EOK = 0,
 
-       DNSSEC_ENOMEM = -ENOMEM,
+       KNOT_ENOMEM = -ENOMEM,
        DNSSEC_EINVAL = -EINVAL,
        DNSSEC_ENOENT = -ENOENT,
 
index 52d9cf0825198be2ab651e81de69e91b4d88d360..2a7e0dbcd4556a3b583e7547146c2b3aed306cc0 100644 (file)
@@ -65,7 +65,7 @@ int dnskey_rdata_to_crypto_key(const dnssec_binary_t *rdata, gnutls_pubkey_t *ke
        gnutls_pubkey_t key = NULL;
        int result = gnutls_pubkey_init(&key);
        if (result != GNUTLS_E_SUCCESS) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        result = convert_dnskey_to_pubkey(algorithm, &rdata_pubkey, key);
index 46e948b7c9a2ec8d44cb346fff39b057f98b2e99..072129f3a8d186e8527766bbce9e69c4eddb917f 100644 (file)
@@ -48,13 +48,13 @@ int dnssec_key_new(dnssec_key_t **key_ptr)
 
        dnssec_key_t *key = calloc(1, sizeof(*key));
        if (!key) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        int r = dnssec_binary_dup(&DNSKEY_RDATA_TEMPLATE, &key->rdata);
        if (r != KNOT_EOK) {
                free(key);
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        *key_ptr = key;
@@ -179,7 +179,7 @@ int dnssec_key_set_dname(dnssec_key_t *key, const uint8_t *dname)
        if (dname) {
                copy = knot_dname_copy(dname, NULL);
                if (!copy) {
-                       return DNSSEC_ENOMEM;
+                       return KNOT_ENOMEM;
                }
 
                knot_dname_to_lower(copy);
index 71db505fa93763fe2c1bb1fbeea9201d754f4688..a1e10553b3deb46e3e6c785c4be26ac0129ec6fe 100644 (file)
@@ -40,7 +40,7 @@ static int public_from_private(gnutls_privkey_t privkey, gnutls_pubkey_t *pubkey
        gnutls_pubkey_t new_key = NULL;
        int result = gnutls_pubkey_init(&new_key);
        if (result != GNUTLS_E_SUCCESS) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        result = gnutls_pubkey_import_privkey(new_key, privkey, 0, 0);
index 4c64b8f936a1385df40f8d36720c861a3417931a..e19747d063de09e84d958a46d6f1f86a6f16d677 100644 (file)
@@ -27,7 +27,7 @@ int keystore_create(dnssec_keystore_t **store_ptr,
 
        dnssec_keystore_t *store = calloc(1, sizeof(*store));
        if (!store) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        store->functions = functions;
@@ -35,7 +35,7 @@ int keystore_create(dnssec_keystore_t **store_ptr,
        int result = functions->ctx_new(&store->ctx);
        if (result != KNOT_EOK) {
                free(store);
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        *store_ptr = store;
index 52002720d0a5c97614135dd6820f132412c45fec..9a40a11f37acd8be931d6fface11618bb04fa3c2 100644 (file)
@@ -48,13 +48,13 @@ static int key_url(const char *token_uri, const char *key_id, char **url_ptr)
        size_t len = token_len + 4 + (id_len / 2 * 3);
        char *url = malloc(len + 1);
        if (!url) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        size_t prefix = snprintf(url, len, "%s;id=", token_uri);
        if (prefix != token_len + 4) {
                free(url);
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        assert(id_len % 2 == 0);
@@ -87,7 +87,7 @@ static int parse_config(const char *config, char **uri_ptr, char **module_ptr)
        if (!url || !module) {
                free(url);
                free(module);
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        *uri_ptr = url;
@@ -143,7 +143,7 @@ static int pkcs11_ctx_new(void **ctx_ptr)
 
        pkcs11_ctx_t *ctx = calloc(1, sizeof(*ctx));
        if (!ctx) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        *ctx_ptr = ctx;
@@ -205,7 +205,7 @@ static int pkcs11_generate_key(void *_ctx, gnutls_pk_algorithm_t algorithm,
 
        char *id = bin_to_hex(cka_id.data, cka_id.size, false);
        if (id == NULL) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        *id_ptr = id;
@@ -229,7 +229,7 @@ static int import_pem(const dnssec_binary_t *pem,
        if (gnutls_privkey_init(&key) != GNUTLS_E_SUCCESS ||
            gnutls_pubkey_init(&pubkey) != GNUTLS_E_SUCCESS
        ) {
-               r = DNSSEC_ENOMEM;
+               r = KNOT_ENOMEM;
                goto fail;
        }
 
@@ -288,7 +288,7 @@ static int pkcs11_import_key(void *_ctx, const dnssec_binary_t *pem, char **id_p
 
        *id_ptr = bin_to_hex(id.data, id.size, false);
        if (*id_ptr == NULL) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        return KNOT_EOK;
@@ -327,7 +327,7 @@ static int pkcs11_get_private(void *_ctx, const char *id, gnutls_privkey_t *key_
        gnutls_privkey_t key = NULL;
        r = gnutls_privkey_init(&key);
        if (r != GNUTLS_E_SUCCESS) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        r = gnutls_privkey_import_pkcs11_url(key, url);
index 986dd9b094c95688c4bc421e03511b499dc10423..bb7149c2631824b812c2e445a37babeeaf58e79f 100644 (file)
@@ -77,7 +77,7 @@ static int key_open(const char *dir_name, const char *id, int flags,
 
        _cleanup_free_ char *filename = key_path(dir_name, id);
        if (!filename) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        int fd = open(filename, flags, mode);
@@ -176,7 +176,7 @@ static int pem_generate(gnutls_pk_algorithm_t algorithm, unsigned bits,
        _cleanup_x509_privkey_ gnutls_x509_privkey_t key = NULL;
        int r = gnutls_x509_privkey_init(&key);
        if (r != GNUTLS_E_SUCCESS) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        r = gnutls_x509_privkey_generate(key, algorithm, bits, 0);
@@ -217,7 +217,7 @@ static int pkcs8_ctx_new(void **ctx_ptr)
 
        pkcs8_dir_handle_t *ctx = calloc(1, sizeof(*ctx));
        if (!ctx) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        *ctx_ptr = ctx;
@@ -380,7 +380,7 @@ static int pkcs8_remove_key(void *ctx, const char *id)
 
        _cleanup_free_ char *filename = key_path(handle->dir_name, id);
        if (!filename) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        if (unlink(filename) == -1) {
index 5debf382b62883ac68272232126ce00beb621873..b104b42e543ce9651a43a2023ea9ab63ad99b1a2 100644 (file)
@@ -56,7 +56,7 @@ int dnssec_nsec3_params_from_rdata(dnssec_nsec3_params_t *params,
 
        new_params.salt.data = malloc(new_params.salt.size);
        if (new_params.salt.data == NULL) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        binary_read(&wire, &new_params.salt);
index c0571fd38f2ae0cf54dd481a82afc875915d2e60..1de8c35e17ae58d97529a12c951434ed2b5ca44a 100644 (file)
@@ -50,7 +50,7 @@ int p11_load_module(const char *module)
 
        char *copy = strdup(module);
        if (!copy) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        int r = gnutls_pkcs11_add_provider(module, NULL);
index 2c95539cffd89e6df0265f8cf6195005182310fd..3aa565dfe87219f32a476c08093acebeb89adf4b 100644 (file)
@@ -26,7 +26,7 @@ int dnssec_pem_to_x509(const dnssec_binary_t *pem, gnutls_x509_privkey_t *key)
        gnutls_x509_privkey_t _key = NULL;
        int r = gnutls_x509_privkey_init(&_key);
        if (r != GNUTLS_E_SUCCESS) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        int format = GNUTLS_X509_FMT_PEM;
@@ -60,7 +60,7 @@ int dnssec_pem_to_privkey(const dnssec_binary_t *pem, gnutls_privkey_t *key)
        r = gnutls_privkey_init(&key_abs);
        if (r != GNUTLS_E_SUCCESS) {
                gnutls_x509_privkey_deinit(key_x509);
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        int flags = GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE;
@@ -68,7 +68,7 @@ int dnssec_pem_to_privkey(const dnssec_binary_t *pem, gnutls_privkey_t *key)
        if (r != GNUTLS_E_SUCCESS) {
                gnutls_x509_privkey_deinit(key_x509);
                gnutls_privkey_deinit(key_abs);
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        *key = key_abs;
index 42ea122d5f9f589934cf50e5c68ce49e131e406f..a7437f97e4c8324c438ab1ee7bca9a07e31d51ad 100644 (file)
@@ -61,7 +61,7 @@ static int keyid_hex(gnutls_x509_privkey_t key, gnutls_pubkey_t pubkey, char **i
 
        *id = bin_to_hex(bin.data, bin.size, false);
        if (*id == NULL) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        return KNOT_EOK;
index 11ef0647bff3a4b61f990f8f7f7000f3d578a07e..54c1ee095070af2050256effc4857e4f1a383b70 100644 (file)
@@ -203,7 +203,7 @@ int dss_sig_value_encode(const dnssec_binary_t *r, const dnssec_binary_t *s,
 
        dnssec_binary_t _der = { 0 };
        if (dnssec_binary_alloc(&_der, total_size)) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        wire_ctx_t wire = binary_init(&_der);
index af70d91e234509839f70c8df250b06baee9c96b6..32fe15639e4701d62697007b13b191af77c7f576 100644 (file)
@@ -155,7 +155,7 @@ int dnssec_tsig_new(dnssec_tsig_ctx_t **ctx_ptr,
 
        dnssec_tsig_ctx_t *ctx = calloc(1, sizeof(*ctx));
        if (!ctx) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        ctx->algorithm = algorithm_to_gnutls(algorithm);
index 05e1a2d962d491069f7dbef545926799bdbb2dc3..d82f524eca3285f63f7b59d45b29185d47c01ef2 100644 (file)
@@ -246,7 +246,7 @@ static int rsa_params_to_pem(const bind_privkey_t *params, dnssec_binary_t *pem)
        _cleanup_x509_privkey_ gnutls_x509_privkey_t key = NULL;
        int result = gnutls_x509_privkey_init(&key);
        if (result != GNUTLS_E_SUCCESS) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        gnutls_datum_t m = binary_to_datum(&params->modulus);
@@ -301,7 +301,7 @@ static int ecdsa_params_to_pem(dnssec_key_t *dnskey, const bind_privkey_t *param
        _cleanup_x509_privkey_ gnutls_x509_privkey_t key = NULL;
        int result = gnutls_x509_privkey_init(&key);
        if (result != GNUTLS_E_SUCCESS) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        gnutls_ecc_curve_t curve = 0;
@@ -339,7 +339,7 @@ static int eddsa_params_to_pem(dnssec_key_t *dnskey, const bind_privkey_t *param
        _cleanup_x509_privkey_ gnutls_x509_privkey_t key = NULL;
        int result = gnutls_x509_privkey_init(&key);
        if (result != GNUTLS_E_SUCCESS) {
-               return DNSSEC_ENOMEM;
+               return KNOT_ENOMEM;
        }
 
        gnutls_ecc_curve_t curve = 0;