utils.c: NULL terminate ast_base64decode_string.

With the addition of STIR/SHAKEN, the function ast_base64decode_string
was added for convenience since there is a lot of converting done during
the STIR/SHAKEN process. This function returned the decoded string for
you, but did not NULL terminate it, causing some issues (specifically
with MALLOC_DEBUG). Now, the returned string is NULL terminated, and the
documentation has been updated to reflect this.

Change-Id: Icdd7d05b323b0c47ff6ed43492937a03641bdcf5
This commit is contained in:
Ben Ford
2020-08-04 14:36:22 -05:00
committed by Joshua Colp
parent a15e64aaf5
commit 9ed6387c14
2 changed files with 3 additions and 2 deletions

View File

@@ -331,12 +331,13 @@ char *ast_base64decode_string(const char *src)
}
decoded_len = (encoded_len / 4 * 3) - padding;
decoded_string = ast_calloc(1, decoded_len);
decoded_string = ast_malloc(decoded_len + 1);
if (!decoded_string) {
return NULL;
}
ast_base64decode(decoded_string, src, decoded_len);
decoded_string[decoded_len] = '\0';
return (char *)decoded_string;
}