Piotr Caban : msvcrt: Don't validate parameters in _itoa function.

Alexandre Julliard julliard at winehq.org
Fri Jan 10 14:44:55 CST 2014


Module: wine
Branch: stable
Commit: dce5c1f8e0f259837e6eabb0f8fd4ca20ccc8c1e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=dce5c1f8e0f259837e6eabb0f8fd4ca20ccc8c1e

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Tue Oct 15 16:29:00 2013 +0200

msvcrt: Don't validate parameters in _itoa function.

(cherry picked from commit f906be9ef46635e55d96944de0e45b5618c7e979)

---

 dlls/msvcrt/string.c |   37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 082029d..7225395 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -991,10 +991,7 @@ unsigned __int64 CDECL MSVCRT_strtoui64(const char *nptr, char **endptr, int bas
     return MSVCRT_strtoui64_l(nptr, endptr, base, NULL);
 }
 
-/*********************************************************************
- *  _ltoa_s (MSVCRT.@)
- */
-int CDECL _ltoa_s(MSVCRT_long value, char *str, MSVCRT_size_t size, int radix)
+static int ltoa_helper(MSVCRT_long value, char *str, MSVCRT_size_t size, int radix)
 {
     MSVCRT_ulong val;
     unsigned int digit;
@@ -1002,14 +999,6 @@ int CDECL _ltoa_s(MSVCRT_long value, char *str, MSVCRT_size_t size, int radix)
     char buffer[33], *pos;
     size_t len;
 
-    if (!MSVCRT_CHECK_PMT(str != NULL)) return MSVCRT_EINVAL;
-    if (!MSVCRT_CHECK_PMT(size > 0)) return MSVCRT_EINVAL;
-    if (!MSVCRT_CHECK_PMT(radix >= 2 && radix <= 36))
-    {
-        str[0] = '\0';
-        return MSVCRT_EINVAL;
-    }
-
     if (value < 0 && radix == 10)
     {
         is_negative = 1;
@@ -1067,6 +1056,22 @@ int CDECL _ltoa_s(MSVCRT_long value, char *str, MSVCRT_size_t size, int radix)
 }
 
 /*********************************************************************
+ *  _ltoa_s (MSVCRT.@)
+ */
+int CDECL _ltoa_s(MSVCRT_long value, char *str, MSVCRT_size_t size, int radix)
+{
+    if (!MSVCRT_CHECK_PMT(str != NULL)) return MSVCRT_EINVAL;
+    if (!MSVCRT_CHECK_PMT(size > 0)) return MSVCRT_EINVAL;
+    if (!MSVCRT_CHECK_PMT(radix >= 2 && radix <= 36))
+    {
+        str[0] = '\0';
+        return MSVCRT_EINVAL;
+    }
+
+    return ltoa_helper(value, str, size, radix);
+}
+
+/*********************************************************************
  *  _ltow_s (MSVCRT.@)
  */
 int CDECL _ltow_s(MSVCRT_long value, MSVCRT_wchar_t *str, MSVCRT_size_t size, int radix)
@@ -1150,6 +1155,14 @@ int CDECL _itoa_s(int value, char *str, MSVCRT_size_t size, int radix)
 }
 
 /*********************************************************************
+ *  _itoa (MSVCRT.@)
+ */
+char* CDECL _itoa(int value, char *str, int radix)
+{
+    return ltoa_helper(value, str, MSVCRT_SIZE_MAX, radix) ? NULL : str;
+}
+
+/*********************************************************************
  *  _itow_s (MSVCRT.@)
  */
 int CDECL _itow_s(int value, MSVCRT_wchar_t *str, MSVCRT_size_t size, int radix)




More information about the wine-cvs mailing list