summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-08-09 12:49:56 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-08-09 12:49:56 +0200
commit576fce82f4275975e03ab6a114a1f5b86cdf8b9c (patch)
treecf378332fa8a64bb0b5afbf7596c09ca5530c270 /src
parentcaf4a91464e0aec32a9f62a14a45b25829b03a70 (diff)
-coverity
Diffstat (limited to 'src')
-rw-r--r--src/identity/plugin_rest_identity.c26
-rw-r--r--src/rest/plugin_rest_config.c13
-rw-r--r--src/util/crypto_hkdf.c6
3 files changed, 33 insertions, 12 deletions
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index dba1d478d..d7cd0e826 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -322,7 +322,9 @@ do_error (void *cls)
handle->response_code = MHD_HTTP_OK;
response = json_dumps (json_error, 0);
resp = GNUNET_REST_create_response (response);
- MHD_add_response_header (resp, "Content-Type", "application/json");
+ GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
+ "Content-Type",
+ "application/json"));
handle->proc (handle->proc_cls, resp, handle->response_code);
json_decref (json_error);
GNUNET_free (response);
@@ -412,7 +414,9 @@ ego_get_for_subsystem (void *cls,
result_str = json_dumps (json_root, 0);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
resp = GNUNET_REST_create_response (result_str);
- MHD_add_response_header (resp, "Content-Type", "application/json");
+ GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
+ "Content-Type",
+ "application/json"));
json_decref (json_root);
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
GNUNET_free (result_str);
@@ -514,7 +518,9 @@ ego_get_all (struct GNUNET_REST_RequestHandle *con_handle,
result_str = json_dumps (json_root, 0);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
resp = GNUNET_REST_create_response (result_str);
- MHD_add_response_header (resp, "Content-Type", "application/json");
+ GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
+ "Content-Type",
+ "application/json"));
json_decref (json_root);
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
GNUNET_free (result_str);
@@ -561,7 +567,9 @@ ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
resp = GNUNET_REST_create_response (result_str);
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
- MHD_add_response_header (resp, "Content-Type", "application/json");
+ GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
+ "Content-Type",
+ "application/json"));
json_decref (json_ego);
GNUNET_free (result_str);
GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
@@ -1195,7 +1203,9 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle,
// For now, independent of path return all options
resp = GNUNET_REST_create_response (NULL);
- MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
+ GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
+ "Access-Control-Allow-Methods",
+ allow_methods));
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
return;
@@ -1216,6 +1226,12 @@ list_ego (void *cls,
state = ID_REST_STATE_POST_INIT;
return;
}
+ if (NULL == ego)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Called with NULL ego\n");
+ return;
+ }
if (ID_REST_STATE_INIT == state)
{
ego_entry = GNUNET_new (struct EgoEntry);
diff --git a/src/rest/plugin_rest_config.c b/src/rest/plugin_rest_config.c
index 8269a4662..b0f18754c 100644
--- a/src/rest/plugin_rest_config.c
+++ b/src/rest/plugin_rest_config.c
@@ -91,7 +91,6 @@ static struct RequestHandle *requests_head;
static struct RequestHandle *requests_tail;
-
/**
* Cleanup request handle.
*
@@ -199,7 +198,9 @@ get_cont (struct GNUNET_REST_RequestHandle *con_handle,
}
response = json_dumps (result, 0);
resp = GNUNET_REST_create_response (response);
- MHD_add_response_header (resp, "Content-Type", "application/json");
+ GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
+ "Content-Type",
+ "application/json"));
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
cleanup_handle (handle);
GNUNET_free (response);
@@ -353,9 +354,9 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle,
struct RequestHandle *handle = cls;
resp = GNUNET_REST_create_response (NULL);
- MHD_add_response_header (resp,
- "Access-Control-Allow-Methods",
- MHD_HTTP_METHOD_GET);
+ GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
+ "Access-Control-Allow-Methods",
+ MHD_HTTP_METHOD_GET));
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
cleanup_handle (handle);
}
@@ -425,7 +426,7 @@ libgnunet_plugin_rest_config_init (void *cls)
api->cls = &plugin;
api->name = GNUNET_REST_API_NS_CONFIG;
api->process_request = &rest_config_process_request;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("CONFIG REST API initialized\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("CONFIG REST API initialized\n"));
return api;
}
diff --git a/src/util/crypto_hkdf.c b/src/util/crypto_hkdf.c
index 86a814b12..7270b87b6 100644
--- a/src/util/crypto_hkdf.c
+++ b/src/util/crypto_hkdf.c
@@ -77,7 +77,11 @@ static const void *
doHMAC (gcry_md_hd_t mac, const void *key, size_t key_len, const void *buf,
size_t buf_len)
{
- gcry_md_setkey (mac, key, key_len);
+ if (GPG_ERR_NO_ERROR != gcry_md_setkey (mac, key, key_len))
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
gcry_md_write (mac, buf, buf_len);
return (const void *) gcry_md_read (mac, 0);