]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Make handling of out-of-range Unicode characters consistent with the handling
authorBruno Haible <bruno@clisp.org>
Thu, 11 Sep 2003 17:07:33 +0000 (17:07 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:10:58 +0000 (12:10 +0200)
of invalid multibyte sequences.

gettext-tools/src/ChangeLog
gettext-tools/src/po-lex.c
gettext-tools/tests/msgfmt-14

index 150aacd4282839975f9882b5cd1110b6b56b2a3d..190e7ed39c0a099979cce5efea2a7da5c97b870d 100644 (file)
@@ -1,7 +1,7 @@
 2003-09-11  Bruno Haible  <bruno@clisp.org>
 
-       * po-lex.c (mbfile_getc): Ignore the return value of u8_mbtouc().
-       Reported by Jochen Hein <jochen@jochen.org>.
+       * po-lex.c (mbfile_getc): Handle unexpected return value of
+       u8_mbtouc(). Reported by Jochen Hein <jochen@jochen.org>.
 
 2003-09-09  Bruno Haible  <bruno@clisp.org>
 
index c0b7df2e1f4ebda8b632959782476d686c074295..9564e2b2964c706f66aa2da46ced6229a0a18af1 100644 (file)
@@ -510,12 +510,16 @@ incomplete multibyte sequence at end of line"));
              if (outbytes == 0)
                abort ();
              /* Convert it from UTF-8 to UCS-4.  */
+             if (u8_mbtouc (&mbc->uc, scratchbuf, outbytes) < outbytes)
+               {
+                 /* scratchbuf contains an out-of-range Unicode character
+                    (> 0x10ffff).  */
+                 if (signal_eilseq)
+                   po_gram_error (_("invalid multibyte sequence"));
+                 mbc->uc_valid = false;
+                 break;
+               }
              mbc->uc_valid = true;
-             /* We ignore the return value of u8_mbtouc(): Usually it returns
-                outbytes, but if scratchbuf contains an out-of-range Unicode
-                character (> 0x10ffff), it can also return 1 and set mbc->uc
-                to 0xfffd.  This is precisely what we need.  */
-             u8_mbtouc (&mbc->uc, scratchbuf, outbytes);
              break;
            }
        }
index 61b03ebdf17b0ac94251eb8715a4a5d140c89158..08d2b1db3f90b29ad43f1acafd5b486c102be6c3 100755 (executable)
@@ -30,8 +30,12 @@ EOF
 
 tmpfiles="$tmpfiles mf-test14.mo"
 : ${MSGFMT=msgfmt}
-${MSGFMT} mf-test14.po -o mf-test14.mo
-test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+${MSGFMT} mf-test14.po -o mf-test14.mo 2>/dev/null
+# Exit code must be 1.
+# If the invalid sequence didn't get noticed, it would be 0.
+# If it produced a core dump, it would be 134 (= 128 + SIGABRT).
+test $? = 1
+result=$?
 
 rm -fr $tmpfiles