Fix NULL deref in oc_tls_audit_log()
@@ -564,10 +564,14 @@ oc_tls_audit_log(const char *aeid, const char *message, uint8_t category,
uint8_t priority, oc_tls_peer_t *peer)
{
char buff[IPADDR_BUFF_SIZE];
+ if (peer) {
SNPRINTFipaddr(buff, IPADDR_BUFF_SIZE, peer->endpoint);
+ } else {
+ buff[0] = '\0';
+ }
char *aux[] = { buff };
- oc_audit_log(peer->endpoint.device, aeid, message, category, priority,
- (const char **)aux, 1);
+ oc_audit_log((peer) ? peer->endpoint.device : 0, aeid, message, category,
+ priority, (const char **)aux, 1);
}
static int
