Browse Source

fix possible null pointer segfault when using log level 7

Apparently it's possible that ps->selected_sfd is not from the ps->sfds
list, in which case the selected_sfd->crypto context will be left
uninitialized.

fixes #489

Change-Id: I844d9ba1d7e97a80b1f26769c1ea1e99cc2320b9
pull/491/head
Richard Fuchs 8 years ago
parent
commit
2fc2b3bab7
2 changed files with 20 additions and 9 deletions
  1. +3
    -0
      daemon/crypto.c
  2. +17
    -9
      daemon/dtls.c

+ 3
- 0
daemon/crypto.c View File

@ -702,6 +702,9 @@ static int null_crypt_rtcp(struct crypto_context *c, struct rtcp_packet *r, str
static void dump_key(struct crypto_context *c) {
char *k, *s;
if (!c->params.crypto_suite)
return;
k = g_base64_encode(c->params.master_key, c->params.crypto_suite->master_key_len);
s = g_base64_encode(c->params.master_salt, c->params.crypto_suite->master_salt_len);


+ 17
- 9
daemon/dtls.c View File

@ -652,21 +652,29 @@ found:
ilog(LOG_INFO, "DTLS-SRTP successfully negotiated");
if (d->active) {
/* we're the client */
crypto_init(&ps->crypto, &client);
if (ps->selected_sfd)
crypto_init(&ps->selected_sfd->crypto, &server);
}
else {
/* we're the server */
crypto_init(&ps->crypto, &server);
if (ps->selected_sfd)
crypto_init(&ps->selected_sfd->crypto, &client);
}
// it's possible that ps->selected_sfd is not from ps->sfds list (?)
for (GList *l = ps->sfds.head; l; l = l->next) {
struct stream_fd *sfd = l->data;
if (d->active) {
/* we're the client */
crypto_init(&ps->crypto, &client);
if (d->active) /* we're the client */
crypto_init(&sfd->crypto, &server);
}
else {
/* we're the server */
crypto_init(&ps->crypto, &server);
else /* we're the server */
crypto_init(&sfd->crypto, &client);
}
}
crypto_dump_keys(&ps->crypto, &ps->selected_sfd->crypto);
if (ps->selected_sfd)
crypto_dump_keys(&ps->crypto, &ps->selected_sfd->crypto);
return 0;


Loading…
Cancel
Save