Resolves: #1259942 - fix memory leak in sort/I18N
Patches written by Pádraig. Note that the corresponding i18n/sort-month test was not included because it breaks unless sort is compiled -Dlint and we do not want to decrease performance of the resulting RPMs (and valgrind is not installed in production buildroots anyway).
This commit is contained in:
parent
2ad92d25c0
commit
c7c3ee3fab
@ -3046,8 +3046,8 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
|
|||||||
+ register int lo = 0, hi = MONTHS_PER_YEAR, result;
|
+ register int lo = 0, hi = MONTHS_PER_YEAR, result;
|
||||||
+ char *tmp;
|
+ char *tmp;
|
||||||
+ size_t wclength, mblength;
|
+ size_t wclength, mblength;
|
||||||
+ const char **pp;
|
+ const char *pp;
|
||||||
+ const wchar_t **wpp;
|
+ const wchar_t *wpp;
|
||||||
+ wchar_t *month_wcs;
|
+ wchar_t *month_wcs;
|
||||||
+ mbstate_t state;
|
+ mbstate_t state;
|
||||||
+
|
+
|
||||||
@ -3060,17 +3060,19 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
|
|||||||
+ if (len == 0)
|
+ if (len == 0)
|
||||||
+ return 0;
|
+ return 0;
|
||||||
+
|
+
|
||||||
+ month = (char *) xmalloc (len + 1);
|
+ if (SIZE_MAX - len < 1)
|
||||||
|
+ xalloc_die ();
|
||||||
+
|
+
|
||||||
+ tmp = (char *) xmalloc (len + 1);
|
+ month = (char *) xnmalloc (len + 1, MB_CUR_MAX);
|
||||||
|
+
|
||||||
|
+ pp = tmp = (char *) xnmalloc (len + 1, MB_CUR_MAX);
|
||||||
+ memcpy (tmp, s, len);
|
+ memcpy (tmp, s, len);
|
||||||
+ tmp[len] = '\0';
|
+ tmp[len] = '\0';
|
||||||
+ pp = (const char **)&tmp;
|
+ wpp = month_wcs = (wchar_t *) xnmalloc (len + 1, sizeof (wchar_t));
|
||||||
+ month_wcs = (wchar_t *) xmalloc ((len + 1) * sizeof (wchar_t));
|
+ memset (&state, '\0', sizeof (mbstate_t));
|
||||||
+ memset (&state, '\0', sizeof(mbstate_t));
|
|
||||||
+
|
+
|
||||||
+ wclength = mbsrtowcs (month_wcs, pp, len + 1, &state);
|
+ wclength = mbsrtowcs (month_wcs, &pp, len + 1, &state);
|
||||||
+ if (wclength == (size_t)-1 || *pp != NULL)
|
+ if (wclength == (size_t)-1 || pp != NULL)
|
||||||
+ error (SORT_FAILURE, 0, _("Invalid multibyte input %s."), quote(s));
|
+ error (SORT_FAILURE, 0, _("Invalid multibyte input %s."), quote(s));
|
||||||
+
|
+
|
||||||
+ for (i = 0; i < wclength; i++)
|
+ for (i = 0; i < wclength; i++)
|
||||||
@ -3083,10 +3085,8 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ wpp = (const wchar_t **)&month_wcs;
|
+ mblength = wcsrtombs (month, &wpp, (len + 1) * MB_CUR_MAX, &state);
|
||||||
+
|
+ assert (mblength != (-1) && wpp == NULL);
|
||||||
+ mblength = wcsrtombs (month, wpp, len + 1, &state);
|
|
||||||
+ assert (mblength != (-1) && *wpp == NULL);
|
|
||||||
+
|
+
|
||||||
+ do
|
+ do
|
||||||
+ {
|
+ {
|
||||||
@ -3343,7 +3343,7 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
|
|||||||
/* Compare two lines A and B, returning negative, zero, or positive
|
/* Compare two lines A and B, returning negative, zero, or positive
|
||||||
depending on whether A compares less than, equal to, or greater than B. */
|
depending on whether A compares less than, equal to, or greater than B. */
|
||||||
|
|
||||||
@@ -2721,7 +3364,7 @@ compare (struct line const *a, struct li
|
@@ -2721,7 +3366,7 @@ compare (struct line const *a, struct line const *b)
|
||||||
diff = - NONZERO (blen);
|
diff = - NONZERO (blen);
|
||||||
else if (blen == 0)
|
else if (blen == 0)
|
||||||
diff = 1;
|
diff = 1;
|
||||||
@ -3352,7 +3352,7 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
|
|||||||
{
|
{
|
||||||
/* Note xmemcoll0 is a performance enhancement as
|
/* Note xmemcoll0 is a performance enhancement as
|
||||||
it will not unconditionally write '\0' after the
|
it will not unconditionally write '\0' after the
|
||||||
@@ -4120,6 +4763,7 @@ set_ordering (char const *s, struct keyf
|
@@ -4120,6 +4765,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype)
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
key->translate = fold_toupper;
|
key->translate = fold_toupper;
|
||||||
@ -3360,7 +3360,7 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
|
|||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
key->general_numeric = true;
|
key->general_numeric = true;
|
||||||
@@ -4197,7 +4841,7 @@ main (int argc, char **argv)
|
@@ -4197,7 +4843,7 @@ main (int argc, char **argv)
|
||||||
initialize_exit_failure (SORT_FAILURE);
|
initialize_exit_failure (SORT_FAILURE);
|
||||||
|
|
||||||
hard_LC_COLLATE = hard_locale (LC_COLLATE);
|
hard_LC_COLLATE = hard_locale (LC_COLLATE);
|
||||||
@ -3369,7 +3369,7 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
|
|||||||
hard_LC_TIME = hard_locale (LC_TIME);
|
hard_LC_TIME = hard_locale (LC_TIME);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -4218,6 +4862,29 @@ main (int argc, char **argv)
|
@@ -4218,6 +4864,29 @@ main (int argc, char **argv)
|
||||||
thousands_sep = -1;
|
thousands_sep = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3399,7 +3399,7 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
|
|||||||
have_read_stdin = false;
|
have_read_stdin = false;
|
||||||
inittables ();
|
inittables ();
|
||||||
|
|
||||||
@@ -4492,13 +5159,34 @@ main (int argc, char **argv)
|
@@ -4492,13 +5161,34 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
{
|
{
|
||||||
@ -3438,7 +3438,7 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Provoke with 'sort -txx'. Complain about
|
/* Provoke with 'sort -txx'. Complain about
|
||||||
@@ -4509,9 +5197,12 @@ main (int argc, char **argv)
|
@@ -4509,9 +5199,12 @@ main (int argc, char **argv)
|
||||||
quote (optarg));
|
quote (optarg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3453,6 +3453,33 @@ diff -urNp coreutils-8.24-orig/src/sort.c coreutils-8.24/src/sort.c
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -4681,10 +5374,10 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
|
if (nfiles == 0)
|
||||||
|
{
|
||||||
|
- static char *minus = (char *) "-";
|
||||||
|
nfiles = 1;
|
||||||
|
free (files);
|
||||||
|
- files = −
|
||||||
|
+ files = xmalloc (sizeof *files);
|
||||||
|
+ *files = (char *) "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Need to re-check that we meet the minimum requirement for memory
|
||||||
|
@@ -4742,6 +5435,13 @@ main (int argc, char **argv)
|
||||||
|
sort (files, nfiles, outfile, nthreads);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#ifdef lint
|
||||||
|
+ if (files_from)
|
||||||
|
+ readtokens0_free (&tok);
|
||||||
|
+ else
|
||||||
|
+ free (files);
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
if (have_read_stdin && fclose (stdin) == EOF)
|
||||||
|
die (_("close failed"), "-");
|
||||||
|
|
||||||
diff -urNp coreutils-8.24-orig/src/unexpand.c coreutils-8.24/src/unexpand.c
|
diff -urNp coreutils-8.24-orig/src/unexpand.c coreutils-8.24/src/unexpand.c
|
||||||
--- coreutils-8.24-orig/src/unexpand.c 2015-06-26 19:05:22.000000000 +0200
|
--- coreutils-8.24-orig/src/unexpand.c 2015-06-26 19:05:22.000000000 +0200
|
||||||
+++ coreutils-8.24/src/unexpand.c 2015-07-05 09:04:33.032546980 +0200
|
+++ coreutils-8.24/src/unexpand.c 2015-07-05 09:04:33.032546980 +0200
|
||||||
|
@ -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.24
|
Version: 8.24
|
||||||
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/
|
||||||
@ -376,6 +376,9 @@ fi
|
|||||||
%{_sbindir}/chroot
|
%{_sbindir}/chroot
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Sep 16 2015 Kamil Dudka <kdudka@redhat.com> - 8.24-4
|
||||||
|
- fix memory leak in sort/I18N (patches written by Pádraig, #1259942)
|
||||||
|
|
||||||
* Sat Sep 12 2015 Ondrej Vasik <ovasik@redhat.com> 8.24-3
|
* Sat Sep 12 2015 Ondrej Vasik <ovasik@redhat.com> 8.24-3
|
||||||
- fix one still existing occurance of non-full path in colorls.sh
|
- fix one still existing occurance of non-full path in colorls.sh
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user