pr -e, with a mix of backspaces and TABs, could corrupt the heap in multibyte locales (analyzed by J.Koncicky)

This commit is contained in:
Ondřej Vašík 2013-08-15 13:26:11 +02:00
parent 0dcc5a0d5e
commit 32c6651930
2 changed files with 17 additions and 3 deletions

View File

@ -2263,7 +2263,7 @@ diff -urNp coreutils-8.21-orig/src/pr.c coreutils-8.21/src/pr.c
{ {
width = TAB_WIDTH (chars_per_c, input_position); width = TAB_WIDTH (chars_per_c, input_position);
@@ -2724,6 +2930,154 @@ char_to_clump (char c) @@ -2724,6 +2930,164 @@ char_to_clump (char c)
return chars; return chars;
} }
@ -2410,7 +2410,17 @@ diff -urNp coreutils-8.21-orig/src/pr.c coreutils-8.21/src/pr.c
+ mbc_pos -= mblength; + mbc_pos -= mblength;
+ } + }
+ +
+ /* Too many backspaces must put us in position 0 -- never negative. */
+ if (width < 0 && input_position == 0)
+ {
+ chars = 0;
+ input_position = 0;
+ }
+ else if (width < 0 && input_position <= -width)
+ input_position = 0;
+ else
+ input_position += width; + input_position += width;
+
+ return chars; + return chars;
+} +}
+#endif +#endif

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.21 Version: 8.21
Release: 17%{?dist} Release: 18%{?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/
@ -375,6 +375,10 @@ fi
%{_sbindir}/chroot %{_sbindir}/chroot
%changelog %changelog
* Thu Aug 15 2013 Ondrej Vasik <ovasik@redhat.com> 8.21-18
- pr -e, with a mix of backspaces and TABs, could corrupt the heap
in multibyte locales (analyzed by J.Koncicky)
* Wed Aug 14 2013 Ondrej Oprala <ooprala@redhat.com> 8.21-17 * Wed Aug 14 2013 Ondrej Oprala <ooprala@redhat.com> 8.21-17
- Fix sort multibyte incompatibilities - Fix sort multibyte incompatibilities