]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
func_aes: fix misuse of strlen on binary data 38/2438/1
authorGianluca Merlo <gianluca.merlo@gmail.com>
Sat, 19 Mar 2016 01:32:51 +0000 (02:32 +0100)
committerGianluca Merlo <gianluca.merlo@gmail.com>
Sat, 19 Mar 2016 12:20:48 +0000 (07:20 -0500)
The encryption code for AES_ENCRYPT evaluates the length of the data to
be encoded in base64 using strlen. The data is binary, thus the length
of it can be underestimated at the first NULL character.
Reuse the write pointer offset to evaluate it, instead.

ASTERISK-25857 #close

Change-Id: If686b5d570473eb926693c73461177b35b13b186

funcs/func_aes.c

index 2e1959cd8fb02dc5a7d5b641495c2e73187958f4..1d281a7e8dea1151cd2eb5471a0f3c75ab31aa4f 100644 (file)
@@ -146,7 +146,7 @@ static int aes_helper(struct ast_channel *chan, const char *cmd, char *data,
        }
 
        if (encrypt) {                            /* if encrypting encode result to base64 */
-               ast_base64encode(buf, (unsigned char *) tmp, strlen(tmp), len);
+               ast_base64encode(buf, (unsigned char *) tmp, tmpP - tmp, len);
        } else {
                memcpy(buf, tmp, len);
        }