OpenConnect v6.0 strerror_s can't found in msvcrt.dll in WindowsXPSP3

David Woodhouse dwmw2 at
Wed Jul 30 01:02:19 PDT 2014

On Wed, 2014-07-30 at 12:38 +0800, jacky.he wrote:
> Hi,
> I compile openconnect v6.0 in Fedora 20 with MingW32, and run it successfully in Windows 7,
> but the same program run error in Window XP SP3.

I filed a bug at

> error message is:
> The procedure entry point strerror_s could not be located in the dynamic link library msvcrt.dll
> seems msvcrt.dll in Windows XP don't support secure version strerror function, how can I resolv this isuss.
> thanks.

Hm. We don't use strerror_s in OpenConnect. Looking through the Fedora
DLLs that we used, I see that p11-kit seems to be the culprit.

I've rebuilt it with the following hack; please could you try the
version I've placed at (with
sha1sum 2ebf022ec7cda72d1cea849a3540b070f86c65a4).

--- p11-kit-0.20.2/common/compat.c~	2013-10-14 13:45:10.000000000 +0100
+++ p11-kit-0.20.2/common/compat.c	2014-07-30 08:49:26.032006202 +0100
@@ -833,7 +833,8 @@ strerror_r (int errnum,
             size_t buflen)
 #ifdef OS_WIN32
-	return strerror_s (buf, buflen, errnum);
+	/* Use strcpy_s because it always NUL-terminates, unlike strncpy */
+	strcpy_s(buf, buflen, strerror(errnum));
 	#error no strerror_r implementation

It looks like on Windows, strerror() returns a non-constant string. Thus
my hack isn't thread-safe. Perhaps we could *try* finding strerror_s via
LoadLibrary/GetProcAddress, and fall back to the above hack but with
added locking?

Ick. I hate Windows :)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5745 bytes
Desc: not available
URL: <>

More information about the openconnect-devel mailing list