]> Savannah Git Hosting - gnulib.git/commitdiff
unistr/u{8,16,32}-uctomb: Avoid possible trouble with huge strings.
authorBruno Haible <bruno@clisp.org>
Sat, 5 Sep 2020 13:24:53 +0000 (15:24 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 5 Sep 2020 13:29:58 +0000 (15:29 +0200)
* lib/unistr.in.h (u8_uctomb_aux, u8_uctomb, u16_uctomb_aux, u16_uctomb,
u32_uctomb): Change type of last argument to ptrdiff_t.
* lib/unistr/u8-uctomb.c (u8_uctomb): Likewise.
* lib/unistr/u8-uctomb-aux.c (u8_uctomb_aux): Likewise.
* lib/unistr/u16-uctomb.c (u16_uctomb): Likewise.
* lib/unistr/u16-uctomb-aux.c (u16_uctomb_aux): Likewise.
* lib/unistr/u32-uctomb.c (u32_uctomb): Likewise.

ChangeLog
lib/unistr.in.h
lib/unistr/u16-uctomb-aux.c
lib/unistr/u16-uctomb.c
lib/unistr/u32-uctomb.c
lib/unistr/u8-uctomb-aux.c
lib/unistr/u8-uctomb.c

index 92320c5c96cdbc7d4b1840ad8b38a4dd3fa3add9..0d50b68411057828867dc9efcffc37b2867c0ce9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-09-05  Bruno Haible  <bruno@clisp.org>
+
+       unistr/u{8,16,32}-uctomb: Avoid possible trouble with huge strings.
+       * lib/unistr.in.h (u8_uctomb_aux, u8_uctomb, u16_uctomb_aux, u16_uctomb,
+       u32_uctomb): Change type of last argument to ptrdiff_t.
+       * lib/unistr/u8-uctomb.c (u8_uctomb): Likewise.
+       * lib/unistr/u8-uctomb-aux.c (u8_uctomb_aux): Likewise.
+       * lib/unistr/u16-uctomb.c (u16_uctomb): Likewise.
+       * lib/unistr/u16-uctomb-aux.c (u16_uctomb_aux): Likewise.
+       * lib/unistr/u32-uctomb.c (u32_uctomb): Likewise.
+
 2020-09-01  Paul Eggert  <eggert@cs.ucla.edu>
 
        manywarnings: remove -Wchkp and -Wabi from C++ too
index 0acfae63fc070d45d37c92f13388b1658a5885ab..a0fe3db374bea5a815db7b2215e8bb78d64f958d 100644 (file)
@@ -25,7 +25,7 @@
 /* Get bool.  */
 #include <stdbool.h>
 
-/* Get size_t.  */
+/* Get size_t, ptrdiff_t.  */
 #include <stddef.h>
 
 #ifdef __cplusplus
@@ -305,13 +305,13 @@ extern int
 #if GNULIB_UNISTR_U8_UCTOMB || HAVE_LIBUNISTRING
 /* Auxiliary function, also used by u8_chr, u8_strchr, u8_strrchr.  */
 extern int
-       u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n);
+       u8_uctomb_aux (uint8_t *s, ucs4_t uc, ptrdiff_t n);
 # if !HAVE_INLINE
 extern int
-       u8_uctomb (uint8_t *s, ucs4_t uc, int n);
+       u8_uctomb (uint8_t *s, ucs4_t uc, ptrdiff_t n);
 # else
 static inline int
-u8_uctomb (uint8_t *s, ucs4_t uc, int n)
+u8_uctomb (uint8_t *s, ucs4_t uc, ptrdiff_t n)
 {
   if (uc < 0x80 && n > 0)
     {
@@ -327,13 +327,13 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
 #if GNULIB_UNISTR_U16_UCTOMB || HAVE_LIBUNISTRING
 /* Auxiliary function, also used by u16_chr, u16_strchr, u16_strrchr.  */
 extern int
-       u16_uctomb_aux (uint16_t *s, ucs4_t uc, int n);
+       u16_uctomb_aux (uint16_t *s, ucs4_t uc, ptrdiff_t n);
 # if !HAVE_INLINE
 extern int
-       u16_uctomb (uint16_t *s, ucs4_t uc, int n);
+       u16_uctomb (uint16_t *s, ucs4_t uc, ptrdiff_t n);
 # else
 static inline int
-u16_uctomb (uint16_t *s, ucs4_t uc, int n)
+u16_uctomb (uint16_t *s, ucs4_t uc, ptrdiff_t n)
 {
   if (uc < 0xd800 && n > 0)
     {
@@ -349,10 +349,10 @@ u16_uctomb (uint16_t *s, ucs4_t uc, int n)
 #if GNULIB_UNISTR_U32_UCTOMB || HAVE_LIBUNISTRING
 # if !HAVE_INLINE
 extern int
-       u32_uctomb (uint32_t *s, ucs4_t uc, int n);
+       u32_uctomb (uint32_t *s, ucs4_t uc, ptrdiff_t n);
 # else
 static inline int
-u32_uctomb (uint32_t *s, ucs4_t uc, int n)
+u32_uctomb (uint32_t *s, ucs4_t uc, ptrdiff_t n)
 {
   if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000))
     {
index a136b0a34837b5772f97992c150640ba8b83dfc5..44fbdd5b3d0e4bc098ce5043b6acf0473cbfbba4 100644 (file)
@@ -21,7 +21,7 @@
 #include "unistr.h"
 
 int
-u16_uctomb_aux (uint16_t *s, ucs4_t uc, int n)
+u16_uctomb_aux (uint16_t *s, ucs4_t uc, ptrdiff_t n)
 {
   if (uc < 0xd800)
     {
index b4f2b88ed14c0d65572fe2b72f13d41ee7505bb1..77e52e5b8318e6f68c8e592c41d74e5ee099f3a5 100644 (file)
@@ -28,7 +28,7 @@
 #if !HAVE_INLINE
 
 int
-u16_uctomb (uint16_t *s, ucs4_t uc, int n)
+u16_uctomb (uint16_t *s, ucs4_t uc, ptrdiff_t n)
 {
   if (uc < 0xd800)
     {
index 53e835d189648ee741e753b90e4a64fa323932a2..73554f1dc604ddcdaace966ca123cc4d5b739c53 100644 (file)
@@ -28,7 +28,7 @@
 #if !HAVE_INLINE
 
 int
-u32_uctomb (uint32_t *s, ucs4_t uc, int n)
+u32_uctomb (uint32_t *s, ucs4_t uc, ptrdiff_t n)
 {
   if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000))
     {
index 0b5ec906429bd097e56530b4859891d916d62d03..4e66c95073da266b27438ff463ca2b88e3e305fb 100644 (file)
@@ -23,7 +23,7 @@
 #include "attribute.h"
 
 int
-u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n)
+u8_uctomb_aux (uint8_t *s, ucs4_t uc, ptrdiff_t n)
 {
   int count;
 
index 7cf33896323ce3f0dca30f24726c2e8365c0e553..395be772541d51d42b8169b6c899a5fa893336a8 100644 (file)
@@ -30,7 +30,7 @@
 #if !HAVE_INLINE
 
 int
-u8_uctomb (uint8_t *s, ucs4_t uc, int n)
+u8_uctomb (uint8_t *s, ucs4_t uc, ptrdiff_t n)
 {
   if (uc < 0x80)
     {