[RTL]
authorThomas Faber <thomas.faber@reactos.org>
Wed, 12 Oct 2011 11:58:46 +0000 (11:58 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Wed, 12 Oct 2011 11:58:46 +0000 (11:58 +0000)
- 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
reactos/lib/sdk/crt/stdlib/qsort.c

index e8b0d6b..e2c61ca 100644 (file)
@@ -22,10 +22,15 @@ NTAPI
 RtlIpv4AddressToStringA(IN struct in_addr *Addr,
                         OUT PCHAR S)
 {
 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;
 }
 
 /*
 }
 
 /*
index 1e1dc8c..94bcd02 100644 (file)
@@ -186,7 +186,8 @@ qsort(void *base0, size_t n, size_t size, int (__cdecl *compar)(const void*, con
   if (n <= 1)
     return;
 
   if (n <= 1)
     return;
 
-  size = size;
+  if (size == 0)
+    return;
   compar = compar;
   thresh = size * THRESH;
   max = base + n * size;
   compar = compar;
   thresh = size * THRESH;
   max = base + n * size;