Changeset 400


Ignore:
Timestamp:
2007-05-29T12:03:54+02:00 (7 years ago)
Author:
moo
Message:

fix invalid read of free'ed data for hide-and-seek trick. possible fix version string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r399 r400  
    8888static zend_bool xc_initized = 0; 
    8989static zend_compile_file_t *origin_compile_file; 
     90static zend_llist_element  *xc_llist_zend_extension; 
    9091 
    9192static zend_bool xc_test = 0; 
     
    26222623} 
    26232624 
     2625static zend_llist_element *xc_llist_get_element_by_zend_extension(zend_llist *l, const char *extension_name) 
     2626{ 
     2627    zend_llist_element *element; 
     2628 
     2629    for (element = zend_extensions.head; element; element = element->next) { 
     2630        zend_extension *extension = (zend_extension *) element->data; 
     2631 
     2632        if (!strcmp(extension->name, extension_name)) { 
     2633            return element; 
     2634        } 
     2635    } 
     2636    return NULL; 
     2637} 
     2638 
     2639static void xc_llist_prepend(zend_llist *l, zend_llist_element *element) 
     2640{ 
     2641    element->next = l->head; 
     2642    element->prev = NULL; 
     2643    if (l->head) { 
     2644        l->head->prev = element; 
     2645    } 
     2646    else { 
     2647        l->tail = element; 
     2648    } 
     2649    l->head = element; 
     2650    ++l->count; 
     2651} 
     2652 
     2653static void xc_llist_unlink(zend_llist *l, zend_llist_element *element) 
     2654{ 
     2655    if ((element)->prev) { 
     2656        (element)->prev->next = (element)->next; 
     2657    } 
     2658    else { 
     2659        (l)->head = (element)->next; 
     2660    } 
     2661 
     2662    if ((element)->next) { 
     2663        (element)->next->prev = (element)->prev; 
     2664    } 
     2665    else { 
     2666        (l)->tail = (element)->prev; 
     2667    } 
     2668 
     2669    --l->count; 
     2670} 
     2671 
    26242672static int xc_zend_extension_startup(zend_extension *extension) 
    26252673{ 
     
    28682916/* }}} */ 
    28692917static startup_func_t xc_last_ext_startup; 
    2870 static zend_llist_element *xc_llist_element; 
    28712918static int xc_zend_startup_last(zend_extension *extension) /* {{{ */ 
    28722919{ 
     
    28782925        } 
    28792926    } 
    2880     xc_zend_extension_register(&zend_extension_entry, 0); 
     2927    assert(xc_llist_zend_extension); 
     2928    xc_llist_prepend(&zend_extensions, xc_llist_zend_extension); 
    28812929    if (!xc_module_gotup) { 
    28822930        return zend_startup_module(&xcache_module_entry); 
     
    28882936{ 
    28892937    xc_zend_extension_gotup = 1; 
    2890     xc_llist_element = NULL; 
    28912938    if (zend_llist_count(&zend_extensions) > 1) { 
    28922939        zend_llist_position lpos; 
    28932940        zend_extension *ext; 
    28942941 
    2895         ext = zend_get_extension(XCACHE_NAME); 
    2896         xc_zend_remove_extension(ext); 
     2942        xc_llist_zend_extension = xc_llist_get_element_by_zend_extension(&zend_extensions, XCACHE_NAME); 
     2943        xc_llist_unlink(&zend_extensions, xc_llist_zend_extension); 
    28972944 
    28982945        ext = (zend_extension *) zend_llist_get_last_ex(&zend_extensions, &lpos); 
    2899         assert(ext); 
     2946        assert(ext && ext != xc_llist_zend_extension); 
    29002947        xc_last_ext_startup = ext->startup; 
    29012948        ext->startup = xc_zend_startup_last; 
Note: See TracChangeset for help on using the changeset viewer.