On Tue, 2014-02-11 at 10:28 +0100, Nikos Mavrogiannopoulos wrote: > On Tue, Feb 11, 2014 at 10:09 AM, David Woodhouse <dwmw2 at infradead.org> wrote: > >> Yes, this is how errno is interpreted in windows: > >> https://gitorious.org/gnutls/gnutls/source/505540944f1dd6a655a691714aed6d54ea7671fa:lib/system.c#L69 > > Um,... if that's all handled in GnuTLS already, why do we even bother > > with overriding the pull/push/errno functions for OpenConnect? Couldn't > > I just strip that bit out? > > The errno you can strip out. The recv et al, only if you compile with > a gnutls version that doesn't have the bug with gnulib replacement > functions (I think that's 3.2.9, or 3.1.19 and later). How does this bug manifest itself? I'm building with Fedora's mingw32-gnutls-3.1.16 package and both DTLS and TLS seem to be working OK at first glance, at least under Wine. > > Btw, do you have reason to believe that Windows' putenv() takes a *copy* > > of the string? The Linux man page for putenv is very clear that it'll > > use the string in place and using an auto variable for it is very wrong. > > Was that an oversight on your part, or do you know something I don't? > > No reason, it looks like a bug. Actually, apart from setenv(foo, NULL) crashing I think your functions are fine. This test case: #include <stdio.h> #include <stdlib.h> int main(void) { char foo[]="FOO=bar"; char *bar; putenv(foo); printf("FOO is: %s\n", getenv("FOO")); foo[5] = 'f'; printf("FOO is: %s\n", getenv("FOO")); putenv("FOO="); printf("FOO is: %s\n", getenv("FOO")); } ... according to POSIX should give: [dwoodhou at i7 win32]$ ./foo FOO is: bar FOO is: bfr FOO is: but under Wine and under Windows 7 it gives what we want: [dwoodhou at i7 win32]$ wine foo.exe FOO is: bar FOO is: bar FOO is: (null) -- dwmw2 -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 5745 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/openconnect-devel/attachments/20140211/11b39c8a/attachment-0001.bin>