[PHP-DEV] Question about zend_hash.c, UPDATE_DATA macro

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: [PHP-DEV] Question about zend_hash.c, UPDATE_DATA macro

    I think I brought this up here before too.
    I can't remember the outcome - would you mind looking through the archives?

    --Wez.
    > The macro is used to update a hash table element in
    > zend_hash_add_or_update(). But it seems to me that if p->pData already
    > points to a
    > data block that hash size != sizeof (void *), and the macro is called to
    > update the hash element with another block that has
    > size != sizeof (void *), then the data block pointed at by p->pData will
    not
    > be reallocated and the last memcpy() call will overwrite the old
    > data block with the new data. This could possibly lead to memory
    corruption
    > if the new block is bigger than the old block.
    >
    > Could any of the PHP developers comment on this?


    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Wez Furlong Guest

  2. Similar Questions and Discussions

    1. Anyway to run a DB Macro from a CF web front end?
      Good morning, I was wondering if anyone knew of a way i could click a button on a CF web page which would run a query in our ACCESS DB? anyone...
    2. Macro compromise for D70
      I like to do some macro shooting but I really don't want to go out & spend $650 on a special lense, mostly because I wouldn't want to keep...
    3. Feature Question: Generic Macro Capability
      Does indesign have any support for embedded macros along the lines that Word does? 1. Is there any way to insert any non-printing text into a...
    4. Tamron sp 90 1:1 macro
      I like Tokina better as well, but the Tamron is nothing to sneeze at, should be just as sharp. Alex "Eyron" <odd1@rogers.com> wrote in message...
    5. Tamron sp 90 f2/8 macro
      I am looking for opinions on the lense for macro work and portraiture. I have a Fuji S2 Pro. Because of the 1,5 X factor will I effectively get a...
  3. #2

    Default Re: [PHP-DEV] Question about zend_hash.c, UPDATE_DATA macro

    Hello.
    Yes. They are different sizes both != sizeof (void *) and second update is bigger than first,
    then memory block of first update will be reused, but it will not be big enough for second update. Is it a valid scenario?

    vesselin
    > Just to make sure I understand what you're asking, are your
    > first and
    > second updates of data with different sizes?
    >
    > Andi

    -----------------------------------------------------------------
    [url]http://club.ABV.bg[/url] - Êëóá ÀÁÂ - Âèíàãè ON !

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Vesselin Atanasov Guest

  4. #3

    Default Re: [PHP-DEV] Question about zend_hash.c, UPDATE_DATA macro


    This same problem likely exists in ZE1 too? Are you gonna
    fix it there?

    --Jani


    On Wed, 30 Jul 2003, Andi Gutmans wrote:
    >Yes you are right. There indeed seems to be some flaw in the logic. I'll
    >commit a fix in a few minutes.
    >Please test it and let me know if it fixes your problems.
    >
    >Thanks,
    >
    >Andi
    >
    >
    >At 02:50 PM 7/29/2003 +0300, Vesselin Atanasov wrote:
    >>Hello.
    >>In PHP5, file zend_hash.c there is a macro
    >>
    >>#define UPDATE_DATA(ht, p, pData, nDataSize)
    >>\
    >> if (nDataSize == sizeof(void*))
    >>{
    >>\
    >> if (!(p)->pDataPtr)
    >>{
    >>\
    >> pefree((p)->pData, (ht)->persistent);
    >>\
    >> }
    >>\
    >> memcpy(&(p)->pDataPtr, pData, sizeof(void *));
    >>\
    >> (p)->pData = &(p)->pDataPtr;
    >>\
    >> } else
    >>{
    >>\
    >> if ((p)->pDataPtr)
    >>{
    >>\
    >> (p)->pData = (void *) pemalloc(nDataSize,
    >>(ht)->persistent); \
    >> (p)->pDataPtr=NULL;
    >>\
    >> }
    >>\
    >> memcpy((p)->pData, pData, nDataSize);
    >>\
    >> }
    >>
    >>The macro is used to update a hash table element in
    >>zend_hash_add_or_update(). But it seems to me that if p->pData already
    >>points to a
    >>data block that hash size != sizeof (void *), and the macro is called to
    >>update the hash element with another block that has
    >>size != sizeof (void *), then the data block pointed at by p->pData will not
    >>be reallocated and the last memcpy() call will overwrite the old
    >>data block with the new data. This could possibly lead to memory corruption
    >>if the new block is bigger than the old block.
    >>
    >>Could any of the PHP developers comment on this?
    >>
    >>
    >>--
    >>PHP Internals - PHP Runtime Development Mailing List
    >>To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    >
    >
    >
    --
    [url]https://www.paypal.com/xclick/business=sniper@php.net&no_note=1&tax=0&currency_c ode=EUR[/url]



    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Jani Taskinen Guest

  5. #4

    Default Re: [PHP-DEV] Question about zend_hash.c, UPDATE_DATA macro

    Sure, but I want to first make sure that the fix is OK.

    At 01:14 AM 7/31/2003 +0300, Jani Taskinen wrote:
    > This same problem likely exists in ZE1 too? Are you gonna
    > fix it there?
    >
    > --Jani
    >
    >
    >On Wed, 30 Jul 2003, Andi Gutmans wrote:
    >
    > >Yes you are right. There indeed seems to be some flaw in the logic. I'll
    > >commit a fix in a few minutes.
    > >Please test it and let me know if it fixes your problems.
    > >
    > >Thanks,
    > >
    > >Andi
    > >
    > >
    > >At 02:50 PM 7/29/2003 +0300, Vesselin Atanasov wrote:
    > >>Hello.
    > >>In PHP5, file zend_hash.c there is a macro
    > >>
    > >>#define UPDATE_DATA(ht, p, pData, nDataSize)
    > >>\
    > >> if (nDataSize == sizeof(void*))
    > >>{
    > >>\
    > >> if (!(p)->pDataPtr)
    > >>{
    > >>\
    > >> pefree((p)->pData, (ht)->persistent);
    > >>\
    > >> }
    > >>\
    > >> memcpy(&(p)->pDataPtr, pData, sizeof(void *));
    > >>\
    > >> (p)->pData = &(p)->pDataPtr;
    > >>\
    > >> } else
    > >>{
    > >>\
    > >> if ((p)->pDataPtr)
    > >>{
    > >>\
    > >> (p)->pData = (void *) pemalloc(nDataSize,
    > >>(ht)->persistent); \
    > >> (p)->pDataPtr=NULL;
    > >>\
    > >> }
    > >>\
    > >> memcpy((p)->pData, pData, nDataSize);
    > >>\
    > >> }
    > >>
    > >>The macro is used to update a hash table element in
    > >>zend_hash_add_or_update(). But it seems to me that if p->pData already
    > >>points to a
    > >>data block that hash size != sizeof (void *), and the macro is called to
    > >>update the hash element with another block that has
    > >>size != sizeof (void *), then the data block pointed at by p->pData
    > will not
    > >>be reallocated and the last memcpy() call will overwrite the old
    > >>data block with the new data. This could possibly lead to memory corruption
    > >>if the new block is bigger than the old block.
    > >>
    > >>Could any of the PHP developers comment on this?
    > >>
    > >>
    > >>--
    > >>PHP Internals - PHP Runtime Development Mailing List
    > >>To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    > >
    > >
    > >
    >
    >--
    >[url]https://www.paypal.com/xclick/business=sniper@php.net&no_note=1&tax=0&currency_c ode=EUR[/url]
    >

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Andi Gutmans Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139