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

Pavel A pavel_a at live.com
Wed Jul 30 12:31:20 PDT 2014


But we've only recently fixed strerror_r for WinXP. in v. 0.20.3
http://lists.freedesktop.org/archives/p11-glue/2014-July/000449.html

Use strerror_r in stead of Microsoft's proprietary strerror_s.

-- Pavel A.

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 https://bugzilla.redhat.com/show_bug.cgi?id=1124731

> 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 http://david.woodhou.se/libp11-kit-0.dll (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));
 #else
  #error no strerror_r implementation
 #endif

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

-- 
dwmw2


More information about the p11-glue mailing list