anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

commit a29bd72ba3ca14ae6a4aeb5a9ea3155d7ab9abca
parent 7e8d8ef77f55e0b34f7058999b1cc7b7d270cff7
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 29 Jul 2026 16:58:22 +0200

never pass a NULL message template to asprintf in the authorization plugins

Diffstat:
Msrc/authorization/anastasis_authorization_plugin_email.c | 20+++++++++++++++++---
Msrc/authorization/anastasis_authorization_plugin_iban.c | 20+++++++++++++++++---
Msrc/authorization/anastasis_authorization_plugin_post.c | 20+++++++++++++++++---
Msrc/authorization/anastasis_authorization_plugin_sms.c | 20+++++++++++++++++---
4 files changed, 68 insertions(+), 12 deletions(-)

diff --git a/src/authorization/anastasis_authorization_plugin_email.c b/src/authorization/anastasis_authorization_plugin_email.c @@ -136,13 +136,25 @@ struct ANASTASIS_AUTHORIZATION_State /** + * Returned by #get_message() when the configured messages file has no entry + * for the requested ID. This is an installation error, but it must not be + * allowed to reach GNUNET_asprintf() as a NULL format string. The text + * deliberately contains no printf conversions, so substituting it for any + * template is safe whatever argument list the caller passes. + */ +#define MISSING_MESSAGE \ + "The provider is misconfigured: a message template is missing." + + +/** * Obtain internationalized message @a msg_id from @a ctx using * language preferences of @a conn. * * @param messages JSON object to lookup message from * @param conn connection to lookup message for * @param msg_id unique message ID - * @return NULL if message was not found + * @return the requested message, or #MISSING_MESSAGE if it was not + * configured; never NULL */ static const char * get_message (const json_t *messages, @@ -170,9 +182,11 @@ get_message (const json_t *messages, spec, NULL, NULL)) { - GNUNET_break (0); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Message `%s' is missing from the configured messages file\n", + msg_id); GNUNET_JSON_parse_free (spec); - return NULL; + return MISSING_MESSAGE; } GNUNET_JSON_parse_free (spec); return ret; diff --git a/src/authorization/anastasis_authorization_plugin_iban.c b/src/authorization/anastasis_authorization_plugin_iban.c @@ -126,13 +126,25 @@ struct ANASTASIS_AUTHORIZATION_State /** + * Returned by #get_message() when the configured messages file has no entry + * for the requested ID. This is an installation error, but it must not be + * allowed to reach GNUNET_asprintf() as a NULL format string. The text + * deliberately contains no printf conversions, so substituting it for any + * template is safe whatever argument list the caller passes. + */ +#define MISSING_MESSAGE \ + "The provider is misconfigured: a message template is missing." + + +/** * Obtain internationalized message @a msg_id from @a ctx using * language preferences of @a conn. * * @param messages JSON object to lookup message from * @param conn connection to lookup message for * @param msg_id unique message ID - * @return NULL if message was not found + * @return the requested message, or #MISSING_MESSAGE if it was not + * configured; never NULL */ static const char * get_message (const json_t *messages, @@ -160,9 +172,11 @@ get_message (const json_t *messages, spec, NULL, NULL)) { - GNUNET_break (0); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Message `%s' is missing from the configured messages file\n", + msg_id); GNUNET_JSON_parse_free (spec); - return NULL; + return MISSING_MESSAGE; } GNUNET_JSON_parse_free (spec); return ret; diff --git a/src/authorization/anastasis_authorization_plugin_post.c b/src/authorization/anastasis_authorization_plugin_post.c @@ -133,13 +133,25 @@ struct ANASTASIS_AUTHORIZATION_State /** + * Returned by #get_message() when the configured messages file has no entry + * for the requested ID. This is an installation error, but it must not be + * allowed to reach GNUNET_asprintf() as a NULL format string. The text + * deliberately contains no printf conversions, so substituting it for any + * template is safe whatever argument list the caller passes. + */ +#define MISSING_MESSAGE \ + "The provider is misconfigured: a message template is missing." + + +/** * Obtain internationalized message @a msg_id from @a ctx using * language preferences of @a conn. * * @param messages JSON object to lookup message from * @param conn connection to lookup message for * @param msg_id unique message ID - * @return NULL if message was not found + * @return the requested message, or #MISSING_MESSAGE if it was not + * configured; never NULL */ static const char * get_message (const json_t *messages, @@ -167,9 +179,11 @@ get_message (const json_t *messages, spec, NULL, NULL)) { - GNUNET_break (0); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Message `%s' is missing from the configured messages file\n", + msg_id); GNUNET_JSON_parse_free (spec); - return NULL; + return MISSING_MESSAGE; } GNUNET_JSON_parse_free (spec); return ret; diff --git a/src/authorization/anastasis_authorization_plugin_sms.c b/src/authorization/anastasis_authorization_plugin_sms.c @@ -135,13 +135,25 @@ struct ANASTASIS_AUTHORIZATION_State /** + * Returned by #get_message() when the configured messages file has no entry + * for the requested ID. This is an installation error, but it must not be + * allowed to reach GNUNET_asprintf() as a NULL format string. The text + * deliberately contains no printf conversions, so substituting it for any + * template is safe whatever argument list the caller passes. + */ +#define MISSING_MESSAGE \ + "The provider is misconfigured: a message template is missing." + + +/** * Obtain internationalized message @a msg_id from @a ctx using * language preferences of @a conn. * * @param messages JSON object to lookup message from * @param conn connection to lookup message for * @param msg_id unique message ID - * @return NULL if message was not found + * @return the requested message, or #MISSING_MESSAGE if it was not + * configured; never NULL */ static const char * get_message (const json_t *messages, @@ -169,9 +181,11 @@ get_message (const json_t *messages, spec, NULL, NULL)) { - GNUNET_break (0); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Message `%s' is missing from the configured messages file\n", + msg_id); GNUNET_JSON_parse_free (spec); - return NULL; + return MISSING_MESSAGE; } GNUNET_JSON_parse_free (spec); return ret;