Changeset 5285


Ignore:
Timestamp:
May 10, 2016 6:32:30 AM (8 years ago)
Author:
riza
Message:

Misc (re #1882): Fixed buffer size not sufficient when setting cipher list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c

    r5238 r5285  
    838838static pj_status_t set_cipher_list(pj_ssl_sock_t *ssock) 
    839839{ 
    840     char buf[1024]; 
     840    pj_pool_t *tmp_pool = NULL; 
     841    char *buf = NULL; 
     842    enum { BUF_SIZE = 8192 }; 
    841843    pj_str_t cipher_list; 
    842844    STACK_OF(SSL_CIPHER) *sk_cipher; 
     
    852854        return PJ_SUCCESS; 
    853855    } 
     856 
     857    /* Create temporary pool. */ 
     858    tmp_pool = pj_pool_create(ssock->pool->factory, "ciphpool", BUF_SIZE,  
     859                              BUF_SIZE/2 , NULL); 
     860    if (!tmp_pool) 
     861        return PJ_ENOMEM; 
     862 
     863    buf = (char *)pj_pool_zalloc(tmp_pool, BUF_SIZE); 
    854864 
    855865    pj_strset(&cipher_list, buf, 0); 
     
    873883                /* Check buffer size */ 
    874884                if (cipher_list.slen + pj_ansi_strlen(c_name) + 2 > 
    875                     sizeof(buf)) 
     885                    BUF_SIZE) 
    876886                { 
    877887                    pj_assert(!"Insufficient temporary buffer for cipher"); 
     
    896906    ret = SSL_set_cipher_list(ssock->ossl_ssl, buf); 
    897907    if (ret < 1) { 
     908        pj_pool_release(tmp_pool); 
    898909        return GET_SSL_STATUS(ssock); 
    899910    } 
    900911 
     912    pj_pool_release(tmp_pool); 
    901913    return PJ_SUCCESS; 
    902914} 
Note: See TracChangeset for help on using the changeset viewer.