On Sat, Oct 3, 2009 at 23:48, James Housley <[email protected]> wrote:
>
> On Oct 2, 2009, at 1:55 PM, Daniel Stenberg wrote:
>
>> Hello!
>>
>> On IRC just a while ago it struck us that when using the
>> libssh2_scp_recv() function, it is necessary that the app is built with the
>> same large-file support enabled/disabled as the libssh2 itself was - as
>> various systems provide different 'struct stat' layouts depending on that.
>>
>> In this case, the app didn't have it and the lib had it and that caused
>> the lib to overwrite memory... :-(
>>
>> I guess this is a proof that libssh2_scp_recv() has an API not good
>> enough.
>
>
> Wouldn't it be possible to make a function for runtime, compile time would
> be even be better, that would allow programs linking with libssh2, ie cURL,
> to see the size of the 'struct stat' as a way of seeing if it was build with
> large files.  Or possible set a flag in the installed .h files stating if it
> was compiled with or without large files?

That sounds hairy.. I would ditch the function (obsolete it) and make
a new one which doesn't use a system struct (or any 3party struct
outside our control) as part of its API. It's that bad.
A library API should not do such things. I remember having trouble for
years with a library because someone had used something (one should
think) simple as 'struct mtget' as part of the API for a function. The
itch only went away when the API was replaced.

-Tor
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to