Ignore invalid base64 messages

When base64 encoding is enabled, ignore any messages that fail base64
decoding.

Previously signed-unsigned integer conversion would cause the return
value of b64_pton() on error (a negative integer) to be converted to a
large value. The attempt to allocate this value would force xmppipe to
exit.
pull/1/head
Michael Santos 7 years ago
parent 85917f8ec4
commit f51377428f

@ -966,7 +966,12 @@ handle_message(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
/* Does not need to be NULL terminated, buf is passed with length */
size_t len = strlen(message) * 3 / 4;
char *buf = xmppipe_calloc(len, 1);
size_t n = b64_pton(message, (u_char *)buf, len);
int n = b64_pton(message, (u_char *)buf, len);
if (n <= 0 || n > len) {
/* Not a base64 message */
free(buf);
return 1;
}
emessage = xmppipe_nfmt(buf,n);
free(buf);
}

Loading…
Cancel
Save