fix possible uninitalized variables usage caused by i18n patch(#683799)

This commit is contained in:
Ondřej Vašík 2011-03-14 09:43:52 +01:00
parent 9207a1510e
commit 7a041cc0d8
2 changed files with 14 additions and 12 deletions

View File

@ -250,7 +250,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
+ size_t mblength; /* The byte size of a multibyte character which shows
+ as same character as WC. */
+ mbstate_t state; /* State of the stream. */
+ int convfail; /* 1, when conversion is failed. Otherwise 0. */
+ int convfail = 0; /* 1, when conversion is failed. Otherwise 0. */
+
+ idx = 0;
+ buflen = 0;
@ -662,7 +662,7 @@ diff -urNp coreutils-8.10-orig/src/expand.c coreutils-8.10/src/expand.c
+ mbstate_t i_state_bak; /* Back up the I_STATE. */
+ mbstate_t o_state; /* Current shift state of the output stream. */
+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */
+ char *bufpos; /* Next read position of BUF. */
+ char *bufpos = buf; /* Next read position of BUF. */
+ size_t buflen = 0; /* The length of the byte sequence in buf. */
+ wchar_t wc; /* A gotten wide character. */
+ size_t mblength; /* The byte size of a multibyte character
@ -956,7 +956,7 @@ diff -urNp coreutils-8.10-orig/src/fold.c coreutils-8.10/src/fold.c
/* Look for the last blank. */
while (logical_end)
{
@@ -217,11 +254,222 @@ fold_file (char const *filename, size_t
@@ -217,11 +254,221 @@ fold_file (char const *filename, size_t
line_out[offset_out++] = c;
}
@ -974,12 +974,12 @@ diff -urNp coreutils-8.10-orig/src/fold.c coreutils-8.10/src/fold.c
+{
+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */
+ size_t buflen = 0; /* The length of the byte sequence in buf. */
+ char *bufpos = NULL; /* Next read position of BUF. */
+ char *bufpos = buf; /* Next read position of BUF. */
+ wint_t wc; /* A gotten wide character. */
+ size_t mblength; /* The byte size of a multibyte character which shows
+ as same character as WC. */
+ mbstate_t state, state_bak; /* State of the stream. */
+ int convfail; /* 1, when conversion is failed. Otherwise 0. */
+ int convfail = 0; /* 1, when conversion is failed. Otherwise 0. */
+
+ static char *line_out = NULL;
+ size_t offset_out = 0; /* Index in `line_out' for next char. */
@ -1034,7 +1034,6 @@ diff -urNp coreutils-8.10-orig/src/fold.c coreutils-8.10/src/fold.c
+ break;
+
+ /* Get a wide character. */
+ convfail = 0;
+ state_bak = state;
+ mblength = mbrtowc ((wchar_t *)&wc, bufpos, buflen, &state);
+
@ -3407,7 +3406,7 @@ diff -urNp coreutils-8.10-orig/src/unexpand.c coreutils-8.10/src/unexpand.c
+ mbstate_t i_state_bak; /* Back up the I_STATE. */
+ mbstate_t o_state; /* Current shift state of the output stream. */
+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */
+ char *bufpos; /* Next read position of BUF. */
+ char *bufpos = buf; /* Next read position of BUF. */
+ size_t buflen = 0; /* The length of the byte sequence in buf. */
+ wint_t wc; /* A gotten wide character. */
+ size_t mblength; /* The byte size of a multibyte character
@ -3715,7 +3714,7 @@ diff -urNp coreutils-8.10-orig/src/uniq.c coreutils-8.10/src/uniq.c
+ size_t mblength;
+ wchar_t wc;
+ mbstate_t *statep;
+ int convfail;
+ int convfail = 0;
+
+ pos = 0;
+ statep = &(line->state);
@ -3933,19 +3932,18 @@ diff -urNp coreutils-8.10-orig/src/uniq.c coreutils-8.10/src/uniq.c
char *thisfield;
size_t thislen;
+#if HAVE_MBRTOWC
+ mbstate_t thisstate;
+ mbstate_t thisstate = thisline->state;
+#endif
if (readlinebuffer_delim (thisline, stdin, delimiter) == 0)
{
if (ferror (stdin))
@@ -351,6 +571,15 @@ check_file (const char *infile, const ch
@@ -351,6 +571,14 @@ check_file (const char *infile, const ch
}
thisfield = find_field (thisline);
thislen = thisline->length - 1 - (thisfield - thisline->buffer);
+#if HAVE_MBRTOWC
+ if (MB_CUR_MAX > 1)
+ {
+ thisstate = thisline->state;
+ match = !different_multi (thisfield, prevfield,
+ thislen, prevlen, thisstate, prevstate);
+ }

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.10
Release: 5%{?dist}
Release: 6%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -329,6 +329,10 @@ fi
%{_libdir}/coreutils
%changelog
* Mon Mar 14 2011 Ondrej Vasik <ovasik@redhat.com> - 8.10-6
- fix possible uninitalized variables usage caused by i18n
patch(#683799)
* Fri Mar 4 2011 Ondrej Vasik <ovasik@redhat.com> - 8.10-5
- make coreutils build even without patches (with
nopam, norunuser and noselinux variables)