Changeset 77784a878a8f3a8c86917b1d903f38484914aaff

Show
Ignore:
Timestamp:
02/01/10 17:45:06 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1265046306 +0000
git-parent:

[d94c4d2a0febabfc7d914c1ff5ffc305f137b378]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1265046306 +0000
Message:

complete busted, this fixes the null point deref, refs #248

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/stratcon_jlog_streamer.c

    rd94c4d2 r77784a8  
    477477  noit_connection_ctx_t *nctx = closure; 
    478478  int rv; 
     479  const char *error = "jlog streamer SSL upgrade failed.\n"; 
    479480 
    480481  rv = eventer_SSL_connect(e, &mask); 
     
    487488    if((sslctx = eventer_get_eventer_ssl_ctx(e)) != NULL) { 
    488489      const char *cn, *end; 
     490      void *vcn; 
    489491      cn = eventer_ssl_get_peer_subject(sslctx); 
    490492      if(cn && (cn = strstr(cn, "CN=")) != NULL) { 
     
    496498        nctx->remote_cn[end-cn] = '\0'; 
    497499      } 
     500      if(nctx->config && 
     501         noit_hash_retrieve(nctx->config, "cn", 2, &vcn)) { 
     502        const char *cn_expected = vcn; 
     503        if(!nctx->remote_cn || 
     504           strcmp(nctx->remote_cn, cn_expected)) { 
     505          error = "jlog connect CN mismatch\n"; 
     506          goto error; 
     507        } 
     508      } 
    498509    } 
    499510    return e->callback(e, mask, e->closure, now); 
     
    501512  if(errno == EAGAIN) return mask | EVENTER_EXCEPTION; 
    502513 
    503   noitL(noit_error, "jlog streamer SSL upgrade failed.\n"); 
     514 error: 
     515  noitL(noit_error, error); 
    504516  eventer_remove_fd(e->fd); 
    505517  nctx->e = NULL; 
     
    799811  pthread_mutex_lock(&noits_lock); 
    800812  ctx = malloc(sizeof(*ctx) * noits.size); 
    801   while(noit_hash_next(&noits, &iter, (const char **)key_id, &klen, 
     813  while(noit_hash_next(&noits, &iter, (const char **)&key_id, &klen, 
    802814                       &vconn)) { 
    803815    ctx[n] = (noit_connection_ctx_t *)vconn; 
     
    835847  pthread_mutex_lock(&noits_lock); 
    836848  ctxs = malloc(sizeof(*ctxs) * noits.size); 
    837   while(noit_hash_next(&noits, &iter, (const char **)key_id, &klen, 
     849  while(noit_hash_next(&noits, &iter, (const char **)&key_id, &klen, 
    838850                       &vconn)) { 
    839851    ctxs[n] = (noit_connection_ctx_t *)vconn; 
     
    10421054  pthread_mutex_lock(&noits_lock); 
    10431055  ctx = malloc(sizeof(*ctx) * noits.size); 
    1044   while(noit_hash_next(&noits, &iter, (const char **)key_id, &klen, 
     1056  while(noit_hash_next(&noits, &iter, (const char **)&key_id, &klen, 
    10451057                       &vconn)) { 
    10461058    if(!strcmp(((noit_connection_ctx_t *)vconn)->remote_str, remote_str)) {