Handle mblen return code when n is zero.
authorOndřej Bílka <neleai@seznam.cz>
Fri, 3 Apr 2015 13:46:29 +0000 (15:46 +0200)
committerOndřej Bílka <neleai@seznam.cz>
Fri, 3 Apr 2015 13:47:12 +0000 (15:47 +0200)
ChangeLog
NEWS
wcsmbs/mbrtoc16.c
wcsmbs/mbrtowc.c

index 9bac298..54831a7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-03  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>
+
+       [BZ #17596]
+       * wcsmbs/mbrtowc.c (__mbrtowc): Add check for n=0.
+       * wcsmbs/mbrtoc16.c (mbrtoc16): Likewise.
+
 2015-04-02  Florian Weimer  <fweimer@redhat.com>
 
        * include/libc-internal.h (libc_max_align_t): Define.
diff --git a/NEWS b/NEWS
index 14d54d6..deadf2e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,11 +11,11 @@ Version 2.22
 
   4719, 13064, 14094, 14841, 14906, 15319, 15467, 15790, 15969, 16351,
   16512, 16560, 16783, 16850, 17090, 17195, 17269, 17523, 17542, 17569,
-  17588, 17620, 17621, 17628, 17631, 17711, 17776, 17779, 17792, 17836,
-  17912, 17916, 17932, 17944, 17949, 17964, 17965, 17967, 17969, 17978,
-  17987, 17991, 17996, 17998, 17999, 18019, 18020, 18029, 18030, 18032,
-  18036, 18038, 18039, 18042, 18043, 18046, 18047, 18068, 18080, 18093,
-  18100, 18104, 18110, 18111, 18128, 18138, 18185.
+  17588, 17596, 17620, 17621, 17628, 17631, 17711, 17776, 17779, 17792,
+  17836, 17912, 17916, 17932, 17944, 17949, 17964, 17965, 17967, 17969,
+  17978, 17987, 17991, 17996, 17998, 17999, 18019, 18020, 18029, 18030,
+  18032, 18036, 18038, 18039, 18042, 18043, 18046, 18047, 18068, 18080,
+  18093, 18100, 18104, 18110, 18111, 18128, 18138, 18185.
 
 * A powerpc and powerpc64 optimization for TLS, similar to TLS descriptors
   for LD and GD on x86 and x86-64, has been implemented.  You will need
index 542e5cf..f23b242 100644 (file)
@@ -77,6 +77,9 @@ mbrtoc16 (char16_t *pc16, const char *s, size_t n, mbstate_t *ps)
       n = 1;
     }
 
+  if (n == 0)
+    return (size_t) -2;
+
   /* Tell where we want the result.  */
   data.__outbuf = outbuf;
   data.__outbufend = outbuf + sizeof (wchar_t);
index 49ca9c2..dbfe940 100644 (file)
@@ -59,6 +59,9 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
       n = 1;
     }
 
+  if (n == 0)
+    return (size_t) -2;
+
   /* Tell where we want the result.  */
   data.__outbuf = outbuf;
   data.__outbufend = outbuf + sizeof (wchar_t);