[Asterisk-code-review] res_stir_shaken: Use ast_asprintf for creating file path. (asterisk[master])

Joshua Colp asteriskteam at digium.com
Mon May 4 08:08:44 CDT 2020


Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14335 )

Change subject: res_stir_shaken: Use ast_asprintf for creating file path.
......................................................................

res_stir_shaken: Use ast_asprintf for creating file path.

Change-Id: Ice5d92ecea2f1101c80487484f48ef98be2f1824
---
M res/res_stir_shaken.c
1 file changed, 3 insertions(+), 6 deletions(-)

Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Joshua Colp: Approved for Submit



diff --git a/res/res_stir_shaken.c b/res/res_stir_shaken.c
index 3f79596..97fb177 100644
--- a/res/res_stir_shaken.c
+++ b/res/res_stir_shaken.c
@@ -462,9 +462,6 @@
 
 	/* 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 @@
 
 		/* 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)) {

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14335
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ice5d92ecea2f1101c80487484f48ef98be2f1824
Gerrit-Change-Number: 14335
Gerrit-PatchSet: 2
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200504/31992da8/attachment-0001.html>


More information about the asterisk-code-review mailing list