[gnutls-dev] Gnutls4win: Problem with custom push/pull functions,
errno and Visual Studio (Workaround included)
Tim Kosse
tim.kosse at filezilla-project.org
Sat Nov 4 16:30:44 CET 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I encountered some problems while trying to use custom push/pull
functions in a program compiled with Visual Studio.
Just setting errno to EAGAIN and returning -1 caused gnutls to fail with
GNUTLS_E_PUSH_ERROR.
I found out that libgnutls-13.dll is linked against msvcrt.dll, whereas
visual studio programs use a different runtime library (msvcr71.dll for
example). These libraries bring along their own version of errno.
So the errno inside the program is different from the one used in GnuTLS.
A workaround is to load the correct errno from msvcrt.dll:
HMODULE crtdll = LoadLibrary(_T("msvcrt.dll"));
typedef int* (*t_errno)(void);
t_errno pErrno = (t_errno)GetProcAddress(crtdll, "_errno");
*pErrno() = EAGAIN;
FreeLibrary(crtdll);
Would it be possible to add a function like for example void
gnutls_transport_set_errno(int), which does nothing else than setting
errno to the provided value?
Regards,
Tim Kosse
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFTLIk8N9+lcqiUkURAkWdAKDUwpSeZ+z/paTen8N0zq0sCohd8gCfZjcP
coCbXLJEiJL7urayR22GY8E=
=qL5q
-----END PGP SIGNATURE-----
More information about the Gnutls-dev
mailing list