[PATCH] fopencookie: Mangle function pointers stored on the heap [BZ #20222]
Carlos O'Donell
carlos@redhat.com
Fri Jun 10 17:50:00 GMT 2016
On 06/10/2016 11:56 AM, Florian Weimer wrote:
> On 06/10/2016 05:55 PM, Carlos O'Donell wrote:
>
>>> +/* Copy the callbacks from SOURCE to *TARGET, with pointer
>>> + mangling. */
>>> +static void
>>> +set_callbacks (_IO_cookie_io_functions_t *target,
>>> + _IO_cookie_io_functions_t source)
>>> +{
>>> + PTR_MANGLE (source.read);
>>> + PTR_MANGLE (source.write);
>>> + PTR_MANGLE (source.seek);
>>> + PTR_MANGLE (source.close);
>>
>> Isn't this modifying the user's copy of the callbacks
>> passed in during the call to fopencookie?
>
> No, C function arguments are pass-by-value. It's not a
> pointer-to-struct, it's the struct object itself.
Sorry yes, I misread that as pointer-to-struct.
You are absolutely right, these are just struct copies
being passed around so we don't care.
Patch looks good to me then.
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list