]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
vasnprintf: Fix crash in %ls directive.
authorBruno Haible <bruno@clisp.org>
Sat, 10 Apr 2010 20:48:28 +0000 (22:48 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Apr 2010 14:05:50 +0000 (16:05 +0200)
gettext-runtime/intl/ChangeLog
gettext-runtime/intl/vasnprintf.c
gettext-runtime/libasprintf/ChangeLog
gettext-runtime/libasprintf/vasnprintf.c

index 516952d6043d9e8b1f54b11735f13b87839a2eea..4563e37cd6836ceb48f1bf03eb8a9a4b2b26fdbe 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-10  Bruno Haible  <bruno@clisp.org>
+
+       vasnprintf: Fix crash in %ls directive.
+       * vasnprintf.c (VASNPRINTF): Don't abort when a unconvertible wide
+       string is passed as argument to %ls, with no precision and no width.
+       Reported by Jarno Rajahalme <jarno.rajahalme@nsn.com>.
+
 2010-04-10  Bruno Haible  <bruno@clisp.org>
 
        vasnprintf: Fix multiple test failures on mingw.
index 11d92b4e1f1c1a6cc3ac2baf9cadabe033edf0b9..1926da63f5bd54a1026133c47c01c0eaa167debb 100644 (file)
@@ -2606,8 +2606,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                           count = wctomb (cbuf, *arg);
 #   endif
                           if (count <= 0)
-                            /* Inconsistency.  */
-                            abort ();
+                            {
+                              /* Cannot convert.  */
+                              if (!(result == resultbuf || result == NULL))
+                                free (result);
+                              if (buf_malloced != NULL)
+                                free (buf_malloced);
+                              CLEANUP ();
+                              errno = EILSEQ;
+                              return NULL;
+                            }
                           ENSURE_ALLOCATION (xsum (length, count));
                           memcpy (result + length, cbuf, count);
                           length += count;
index 65f315cb453d3e072fae49568c04800ccbb188ce..559ff6308beae59b898fa5bde671d727af3abb78 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-10  Bruno Haible  <bruno@clisp.org>
+
+       vasnprintf: Fix crash in %ls directive.
+       * vasnprintf.c (VASNPRINTF): Don't abort when a unconvertible wide
+       string is passed as argument to %ls, with no precision and no width.
+       Reported by Jarno Rajahalme <jarno.rajahalme@nsn.com>.
+
 2010-04-10  Bruno Haible  <bruno@clisp.org>
 
        vasnprintf: Fix multiple test failures on mingw.
index 11d92b4e1f1c1a6cc3ac2baf9cadabe033edf0b9..1926da63f5bd54a1026133c47c01c0eaa167debb 100644 (file)
@@ -2606,8 +2606,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                           count = wctomb (cbuf, *arg);
 #   endif
                           if (count <= 0)
-                            /* Inconsistency.  */
-                            abort ();
+                            {
+                              /* Cannot convert.  */
+                              if (!(result == resultbuf || result == NULL))
+                                free (result);
+                              if (buf_malloced != NULL)
+                                free (buf_malloced);
+                              CLEANUP ();
+                              errno = EILSEQ;
+                              return NULL;
+                            }
                           ENSURE_ALLOCATION (xsum (length, count));
                           memcpy (result + length, cbuf, count);
                           length += count;