[PATCH 1/2] msvcrt: Added qsort_s implementation. (try 6)

Vincas Miliūnas vincas.miliunas at gmail.com
Wed Nov 17 10:07:47 CST 2010


* Used qsort implementation from ntdll as the base instead the one from git.

* The tests should check for errno values, but the only way I could access the real errno (qsort_s returns void) was by GetProcAddress'ing _get_errno/_set_errno functions (this isn't included in the patch). The errno variable itself was unaffected by msvcr90 calls and maps to somethings other that the errno used by the VC runtime. The issue is present in all of the testbot VMs.

* NTDLL_qsort has a multiplication overflow (nmemb*size) issue. This qsort_s implementation does a subsequent division to check for an overflow (this also doesn't directly require 128bit variables in 64bit mode). The reaction to an overflow is to set errno to EINVAL and return without touching the data.
Given overflow values, Windows implementation in one case returns without side effects (test case is included in the patch), in others - crashes.

---
 dlls/msvcr100/msvcr100.spec |    2 +-
 dlls/msvcr80/msvcr80.spec   |    2 +-
 dlls/msvcr90/msvcr90.spec   |    2 +-
 dlls/msvcrt/misc.c          |   69 ++++++++++++++++++++++++++++++++++++++++++-
 dlls/msvcrt/msvcrt.spec     |    2 +-
 5 files changed, 72 insertions(+), 5 deletions(-)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-msvcrt-Added-qsort_s-implementation.-try-6.patch
Type: text/x-patch
Size: 4544 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20101117/a1d0fee2/attachment.bin>


More information about the wine-patches mailing list