[PATCH] fopencookie: Mangle function pointers stored on the heap [BZ #20222]

Florian Weimer fweimer@redhat.com
Fri Jun 10 15:57:00 GMT 2016


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.

Thanks,
Florian



More information about the Libc-alpha mailing list