Changeset 5990
- Timestamp:
- May 15, 2019 2:43:01 AM (5 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/pool.h
r5980 r5990 398 398 399 399 /** 400 * Release the pool back to pool factory and set the pool pointer to zero. 401 * The memory pool content will be wiped out first before released. 402 * 403 * @param ppool Pointer to memory pool. 404 */ 405 PJ_IDECL(void) pj_pool_secure_release( pj_pool_t **ppool ); 406 407 408 /** 400 409 * Get pool object name. 401 410 * -
pjproject/trunk/pjlib/include/pj/pool_i.h
r5534 r5990 101 101 pj_pool_release(pool); 102 102 } 103 104 PJ_IDEF(void) pj_pool_secure_release( pj_pool_t **ppool ) 105 { 106 pj_pool_block *b; 107 pj_pool_t *pool = *ppool; 108 *ppool = NULL; 109 110 if (!pool) 111 return; 112 113 b = pool->block_list.next; 114 while (b != &pool->block_list) { 115 volatile unsigned char *p = b->buf; 116 while (p < b->end) *p++ = 0; 117 b = b->next; 118 } 119 120 pj_pool_release(pool); 121 } -
pjproject/trunk/pjlib/src/pj/ssl_sock_imp_common.c
r5980 r5990 597 597 } 598 598 599 600 static void wipe_buf(pj_str_t *buf) 601 { 602 volatile char *p = buf->ptr; 603 pj_ssize_t len = buf->slen; 604 while (len--) *p++ = 0; 605 buf->slen = 0; 606 } 607 608 static void wipe_cert_buffer(pj_ssl_cert_t *cert) 609 { 610 wipe_buf(&cert->CA_file); 611 wipe_buf(&cert->CA_path); 612 wipe_buf(&cert->cert_file); 613 wipe_buf(&cert->privkey_file); 614 wipe_buf(&cert->privkey_pass); 615 wipe_buf(&cert->CA_buf); 616 wipe_buf(&cert->cert_buf); 617 wipe_buf(&cert->privkey_buf); 618 } 619 599 620 static void ssl_on_destroy(void *arg) 600 621 { … … 614 635 } 615 636 616 pj_pool_safe_release(&ssock->pool); 637 /* Wipe out cert & key buffer, note that they may not be allocated 638 * using SSL socket memory pool. 639 */ 640 if (ssock->cert) { 641 wipe_cert_buffer(ssock->cert); 642 } 643 644 /* Secure release pool, i.e: all memory blocks will be zeroed first */ 645 pj_pool_secure_release(&ssock->pool); 617 646 } 618 647 -
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r5980 r5990 1052 1052 } 1053 1053 1054 /* Early sensitive data cleanup after OpenSSL context setup. However, 1055 * this cannot be done for listener sockets, as the data will still 1056 * be needed by accepted sockets. 1057 */ 1058 if (cert && (!ssock->is_server || ssock->parent)) { 1059 wipe_cert_buffer(cert); 1060 } 1061 1054 1062 /* Create SSL instance */ 1055 1063 ossock->ossl_ctx = ctx;
Note: See TracChangeset
for help on using the changeset viewer.