From b98f465c6deb509a8378960048ffc7784c2dbbff Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Wed, 12 Oct 2011 11:58:46 +0000 Subject: [PATCH 1/1] [RTL] - Handle a NULL buffer in RtlIpv4AddressToStringA as Windows does. Fixes crash in ntdll:rtl test [CRT] - Fail on qsort with 0 size. Fixes hang in ntdll:string test svn path=/trunk/; revision=54093 --- reactos/lib/rtl/network.c | 13 +++++++++---- reactos/lib/sdk/crt/stdlib/qsort.c | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/reactos/lib/rtl/network.c b/reactos/lib/rtl/network.c index e8b0d6b9fd5..e2c61cadfc3 100644 --- a/reactos/lib/rtl/network.c +++ b/reactos/lib/rtl/network.c @@ -22,10 +22,15 @@ NTAPI RtlIpv4AddressToStringA(IN struct in_addr *Addr, OUT PCHAR S) { - return S + sprintf(S, "%u.%u.%u.%u", Addr->S_un.S_un_b.s_b1, - Addr->S_un.S_un_b.s_b2, - Addr->S_un.S_un_b.s_b3, - Addr->S_un.S_un_b.s_b4); + CHAR Buffer[sizeof("255.255.255.255")]; + INT Length; + Length = sprintf(Buffer, "%u.%u.%u.%u", Addr->S_un.S_un_b.s_b1, + Addr->S_un.S_un_b.s_b2, + Addr->S_un.S_un_b.s_b3, + Addr->S_un.S_un_b.s_b4); + if (S) + strcpy(S, Buffer); + return S + Length; } /* diff --git a/reactos/lib/sdk/crt/stdlib/qsort.c b/reactos/lib/sdk/crt/stdlib/qsort.c index 1e1dc8c712d..94bcd02badc 100644 --- a/reactos/lib/sdk/crt/stdlib/qsort.c +++ b/reactos/lib/sdk/crt/stdlib/qsort.c @@ -186,7 +186,8 @@ qsort(void *base0, size_t n, size_t size, int (__cdecl *compar)(const void*, con if (n <= 1) return; - size = size; + if (size == 0) + return; compar = compar; thresh = size * THRESH; max = base + n * size; -- 2.17.1