From 0392a8e620aaa0cc2df9c3b15174ec0b2eaab6c4 Mon Sep 17 00:00:00 2001 From: "Joshua C. Colp" Date: Fri, 1 May 2020 09:29:07 -0300 Subject: [PATCH] res_stir_shaken: Use ast_asprintf for creating file path. Change-Id: Ice5d92ecea2f1101c80487484f48ef98be2f1824 --- res/res_stir_shaken.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/res/res_stir_shaken.c b/res/res_stir_shaken.c index 3f79596201..97fb17710e 100644 --- a/res/res_stir_shaken.c +++ b/res/res_stir_shaken.c @@ -462,9 +462,6 @@ struct ast_stir_shaken_payload *ast_stir_shaken_verify(const char *header, const /* If we don't have an entry in AstDB, CURL from the provided URL */ if (ast_strlen_zero(file_path)) { - - size_t file_path_size; - /* Remove this entry from the database, since we will be * downloading a new file anyways. */ @@ -475,9 +472,9 @@ struct ast_stir_shaken_payload *ast_stir_shaken_verify(const char *header, const /* Set up the default path */ filename = basename(public_key_url); - file_path_size = strlen(ast_config_AST_DATA_DIR) + 3 + strlen(STIR_SHAKEN_DIR_NAME) + strlen(filename) + 1; - file_path = ast_calloc(1, file_path_size); - snprintf(file_path, sizeof(*file_path), "%s/keys/%s/%s", ast_config_AST_DATA_DIR, STIR_SHAKEN_DIR_NAME, filename); + if (ast_asprintf(&file_path, "%s/keys/%s/%s", ast_config_AST_DATA_DIR, STIR_SHAKEN_DIR_NAME, filename) < 0) { + return NULL; + } /* Download to the default path */ if (run_curl(public_key_url, file_path)) { -- 2.47.2