fix pr -c and pr -v segfault with multibyte locales

This commit is contained in:
Ondřej Vašík 2012-01-05 15:34:33 +01:00
parent f531c8b978
commit 586a3174f1
2 changed files with 8 additions and 4 deletions

View File

@ -2271,7 +2271,7 @@ diff -urNp coreutils-8.13-orig/src/pr.c coreutils-8.13/src/pr.c
{ {
width = TAB_WIDTH (chars_per_c, input_position); width = TAB_WIDTH (chars_per_c, input_position);
@@ -2741,6 +2942,154 @@ char_to_clump (char c) @@ -2741,6 +2942,155 @@ char_to_clump (char c)
return chars; return chars;
} }
@ -2279,6 +2279,7 @@ diff -urNp coreutils-8.13-orig/src/pr.c coreutils-8.13/src/pr.c
+static int +static int
+char_to_clump_multi (char c) +char_to_clump_multi (char c)
+{ +{
+ unsigned char uc = c;
+ static size_t mbc_pos = 0; + static size_t mbc_pos = 0;
+ static char mbc[MB_LEN_MAX] = {'\0'}; + static char mbc[MB_LEN_MAX] = {'\0'};
+ static mbstate_t state = {'\0'}; + static mbstate_t state = {'\0'};
@ -2365,7 +2366,7 @@ diff -urNp coreutils-8.13-orig/src/pr.c coreutils-8.13/src/pr.c
+ width += 4; + width += 4;
+ chars += 4; + chars += 4;
+ *s++ = '\\'; + *s++ = '\\';
+ sprintf (esc_buff, "%03o", c); + sprintf (esc_buff, "%03o", uc);
+ for (j = 0; j <= 2; ++j) + for (j = 0; j <= 2; ++j)
+ *s++ = (int) esc_buff[j]; + *s++ = (int) esc_buff[j];
+ } + }
@ -2386,7 +2387,7 @@ diff -urNp coreutils-8.13-orig/src/pr.c coreutils-8.13/src/pr.c
+ width += 4; + width += 4;
+ chars += 4; + chars += 4;
+ *s++ = '\\'; + *s++ = '\\';
+ sprintf (esc_buff, "%03o", c); + sprintf (esc_buff, "%03o", uc);
+ for (j = 0; j <= 2; ++j) + for (j = 0; j <= 2; ++j)
+ *s++ = (int) esc_buff[j]; + *s++ = (int) esc_buff[j];
+ } + }

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils Name: coreutils
Version: 8.14 Version: 8.14
Release: 3%{?dist} Release: 4%{?dist}
License: GPLv3+ License: GPLv3+
Group: System Environment/Base Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/ Url: http://www.gnu.org/software/coreutils/
@ -322,6 +322,9 @@ fi
%{?!norunuser:/sbin/runuser} %{?!norunuser:/sbin/runuser}
%changelog %changelog
* Thu Jan 05 2011 Ondrej Vasik <ovasik@redhat.com> - 8.14-4
- fix pr -c and pr -v segfault with multibyte locales
* Mon Oct 24 2011 Ondrej Vasik <ovasik@redhat.com> - 8.14-3 * Mon Oct 24 2011 Ondrej Vasik <ovasik@redhat.com> - 8.14-3
- require at least pam 1.1.3-7 (#748215) - require at least pam 1.1.3-7 (#748215)