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 + size_t mblength; /* The byte size of a multibyte character which shows
+ as same character as WC. */ + as same character as WC. */
+ mbstate_t state; /* State of the stream. */ + 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; + idx = 0;
+ buflen = 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 i_state_bak; /* Back up the I_STATE. */
+ mbstate_t o_state; /* Current shift state of the output stream. */ + mbstate_t o_state; /* Current shift state of the output stream. */
+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ + 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. */ + size_t buflen = 0; /* The length of the byte sequence in buf. */
+ wchar_t wc; /* A gotten wide character. */ + wchar_t wc; /* A gotten wide character. */
+ size_t mblength; /* The byte size of a multibyte 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. */ /* Look for the last blank. */
while (logical_end) 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; 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. */ + char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */
+ size_t buflen = 0; /* The length of the byte sequence in buf. */ + 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. */ + wint_t wc; /* A gotten wide character. */
+ size_t mblength; /* The byte size of a multibyte character which shows + size_t mblength; /* The byte size of a multibyte character which shows
+ as same character as WC. */ + as same character as WC. */
+ mbstate_t state, state_bak; /* State of the stream. */ + 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; + static char *line_out = NULL;
+ size_t offset_out = 0; /* Index in `line_out' for next char. */ + 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; + break;
+ +
+ /* Get a wide character. */ + /* Get a wide character. */
+ convfail = 0;
+ state_bak = state; + state_bak = state;
+ mblength = mbrtowc ((wchar_t *)&wc, bufpos, buflen, &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 i_state_bak; /* Back up the I_STATE. */
+ mbstate_t o_state; /* Current shift state of the output stream. */ + mbstate_t o_state; /* Current shift state of the output stream. */
+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ + 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. */ + size_t buflen = 0; /* The length of the byte sequence in buf. */
+ wint_t wc; /* A gotten wide character. */ + wint_t wc; /* A gotten wide character. */
+ size_t mblength; /* The byte size of a multibyte 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; + size_t mblength;
+ wchar_t wc; + wchar_t wc;
+ mbstate_t *statep; + mbstate_t *statep;
+ int convfail; + int convfail = 0;
+ +
+ pos = 0; + pos = 0;
+ statep = &(line->state); + statep = &(line->state);
@ -3933,19 +3932,18 @@ diff -urNp coreutils-8.10-orig/src/uniq.c coreutils-8.10/src/uniq.c
char *thisfield; char *thisfield;
size_t thislen; size_t thislen;
+#if HAVE_MBRTOWC +#if HAVE_MBRTOWC
+ mbstate_t thisstate; + mbstate_t thisstate = thisline->state;
+#endif +#endif
if (readlinebuffer_delim (thisline, stdin, delimiter) == 0) if (readlinebuffer_delim (thisline, stdin, delimiter) == 0)
{ {
if (ferror (stdin)) 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); thisfield = find_field (thisline);
thislen = thisline->length - 1 - (thisfield - thisline->buffer); thislen = thisline->length - 1 - (thisfield - thisline->buffer);
+#if HAVE_MBRTOWC +#if HAVE_MBRTOWC
+ if (MB_CUR_MAX > 1) + if (MB_CUR_MAX > 1)
+ { + {
+ thisstate = thisline->state;
+ match = !different_multi (thisfield, prevfield, + match = !different_multi (thisfield, prevfield,
+ thislen, prevlen, thisstate, prevstate); + thislen, prevlen, thisstate, prevstate);
+ } + }

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.10 Version: 8.10
Release: 5%{?dist} Release: 6%{?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/
@ -329,6 +329,10 @@ fi
%{_libdir}/coreutils %{_libdir}/coreutils
%changelog %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 * Fri Mar 4 2011 Ondrej Vasik <ovasik@redhat.com> - 8.10-5
- make coreutils build even without patches (with - make coreutils build even without patches (with
nopam, norunuser and noselinux variables) nopam, norunuser and noselinux variables)