Hi Daniel,

Well, just because I supposed that the session struct fields have to be 
dynamically allocated.

How can I know which fields of the session struct have to be allocated and 
which one can in fact point to fixed storage?
How can I know for example that the libssh2_session_free() or other 
libssh2_session_xxxx functions will not in fact do a free on the session fields 
that are non NULL pointers? Remember, that I'm new to libssh2.

Knowing that, and if the userauth_host_method and userauth_pblc_method fields 
don't have to be allocated, your right, there is absolutely no need to malloc 
the method_buf.

My primary goal was to make libssh2_userauth_publickey_fromfile and 
libssh2_userauth_hostbased_fromfile work with no need of the publickeyfile 
because I thought it was a convenient feature. No, as I said, my code I more a 
proof of concept than a definitive perfect version.


JLC


-----Message d'origine-----
De : Daniel Stenberg [mailto:dan...@haxx.se] 
Envoyé : vendredi 27 mars 2009 12:47
À : libssh2 development
Objet : Re: RE : For the interested ones : 
libssh2_userauth_publickey_fromfileandlibssh2_userauth_hostbased_fromfile with 
no need of the publickeyfile

On Fri, 27 Mar 2009, Jean-Louis CHARTON wrote:

> The requested diff.

+    method_buf = LIBSSH2_ALLOC(session, 7);  /* ssh-dss. */
+    if (method_buf == NULL) {
+       goto __alloc_error;
+    }

...

+
+    memcpy(method_buf, "ssh-dss", 7);
+    *method         = method_buf;

Why alloc for 7 bytes? Why alloc for 7 *fixed* bytes?

-- 

  / daniel.haxx.se

------------------------------------------------------------------------------
_______________________________________________
libssh2-devel mailing list
libssh2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

------------------------------------------------------------------------------
_______________________________________________
libssh2-devel mailing list
libssh2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

Reply via email to