gnutls-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnutls-dev] Gnutls4win: Problem with custom push/pull functions, errno


From: Tim Kosse
Subject: [gnutls-dev] Gnutls4win: Problem with custom push/pull functions, errno and Visual Studio (Workaround included)
Date: Sat, 04 Nov 2006 16:30:44 +0100
User-agent: Thunderbird 1.5.0.7 (Windows/20060909)

-----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-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]