]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - iconvdata/cp1258.c
CVE-2014-6040: Crashes on invalid input in IBM gconv modules [BZ #17325]
[thirdparty/glibc.git] / iconvdata / cp1258.c
index 918b39db773e152fd1e9dd67da1ff05e25df6f29..5153eea0746eb81ff809e47c9fe90dbf2a28cb9a 100644 (file)
@@ -1,5 +1,5 @@
 /* Conversion from and to CP1258.
-   Copyright (C) 1998, 2001, 2002, 2004, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1998-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998,
    and Bruno Haible <haible@clisp.cons.org>, 2001.
@@ -31,6 +31,7 @@
 #define TO_LOOP                        to_cp1258
 #define DEFINE_INIT            1
 #define DEFINE_FINI            1
+#define ONE_DIRECTION          0
 #define FROM_LOOP_MIN_NEEDED_FROM      1
 #define FROM_LOOP_MAX_NEEDED_FROM      1
 #define FROM_LOOP_MIN_NEEDED_TO                4
@@ -66,7 +67,7 @@
     {                                                                        \
       if (FROM_DIRECTION)                                                    \
        {                                                                     \
-         if (__builtin_expect (outbuf + 4 <= outend, 1))                     \
+         if (__glibc_likely (outbuf + 4 <= outend))                          \
            {                                                                 \
              /* Write out the last character.  */                            \
              *((uint32_t *) outbuf) = data->__statep->__count >> 3;          \
@@ -375,7 +376,7 @@ static const struct
     if (ch >= 0x80)                                                          \
       {                                                                              \
        ch = to_ucs4[ch - 0x80];                                              \
-       if (__builtin_expect (ch == L'\0', 0))                                \
+       if (__glibc_unlikely (ch == L'\0'))                                   \
          {                                                                   \
            /* This is an illegal character.  */                              \
            STANDARD_FROM_LOOP_ERR_HANDLER (1);                               \
@@ -802,7 +803,7 @@ static const struct
            res = 0;                                                          \
          }                                                                   \
                                                                              \
-       if (__builtin_expect (res != 0, 1))                                   \
+       if (__glibc_likely (res != 0))                                        \
          {                                                                   \
            *outptr++ = res;                                                  \
            inptr += 4;                                                       \
@@ -845,7 +846,7 @@ static const struct
                  }                                                           \
                                                                              \
                /* See whether we have room for two bytes.  */                \
-               if (__builtin_expect (outptr + 1 >= outend, 0))               \
+               if (__glibc_unlikely (outptr + 1 >= outend))                  \
                  {                                                           \
                    result = __GCONV_FULL_OUTPUT;                             \
                    break;                                                    \