Accepting request 330437 from home:berny:branches:Base:System

- coreutils-i18n.patch: Fix a glaring mem leak in the i18n patch
  for sort -M (boo#945361):

OBS-URL: https://build.opensuse.org/request/show/330437
OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=267
This commit is contained in:
Bernhard Voelker 2015-09-11 00:16:04 +00:00 committed by Git OBS Bridge
parent d1e520db96
commit f928838445
3 changed files with 40 additions and 23 deletions

View File

@ -2,9 +2,9 @@
src/cut.c | 443 ++++++++++++++++++++++++-
src/expand.c | 165 +++++++++
src/fold.c | 308 ++++++++++++++++-
src/join.c | 363 ++++++++++++++++++--
src/join.c | 363 ++++++++++++++++++---
src/pr.c | 444 +++++++++++++++++++++++--
src/sort.c | 763 +++++++++++++++++++++++++++++++++++++++++---
src/sort.c | 760 +++++++++++++++++++++++++++++++++++++++++---
src/unexpand.c | 228 +++++++++++++
src/uniq.c | 265 ++++++++++++++-
tests/i18n/sort.sh | 29 +
@ -19,7 +19,7 @@
tests/misc/unexpand.pl | 39 ++
tests/misc/uniq.pl | 55 +++
tests/pr/pr-tests.pl | 49 ++
21 files changed, 3255 insertions(+), 180 deletions(-)
21 files changed, 3252 insertions(+), 180 deletions(-)
Index: lib/linebuffer.h
===================================================================
@ -3063,7 +3063,7 @@ Index: src/sort.c
&& ((!key->skipsblanks && !(implicit_skip || maybe_space_aligned))
|| (!key->skipsblanks && key->schar)
|| (!key->skipeblanks && key->echar)))
@@ -2489,11 +2853,87 @@ key_warnings (struct keyfield const *gke
@@ -2489,11 +2853,84 @@ key_warnings (struct keyfield const *gke
error (0, 0, _("option '-r' only applies to last-resort comparison"));
}
@ -3076,8 +3076,8 @@ Index: src/sort.c
+ register int lo = 0, hi = MONTHS_PER_YEAR, result;
+ char *tmp;
+ size_t wclength, mblength;
+ const char **pp;
+ const wchar_t **wpp;
+ const char *pp;
+ const wchar_t *wpp;
+ wchar_t *month_wcs;
+ mbstate_t state;
+
@ -3092,15 +3092,14 @@ Index: src/sort.c
+
+ month = (char *) xmalloc (len + 1);
+
+ tmp = (char *) xmalloc (len + 1);
+ pp = tmp = (char *) xmalloc (len + 1);
+ memcpy (tmp, s, len);
+ tmp[len] = '\0';
+ pp = (const char **)&tmp;
+ month_wcs = (wchar_t *) xmalloc ((len + 1) * sizeof (wchar_t));
+ wpp = month_wcs = (wchar_t *) xmalloc ((len + 1) * sizeof (wchar_t));
+ memset (&state, '\0', sizeof(mbstate_t));
+
+ wclength = mbsrtowcs (month_wcs, pp, len + 1, &state);
+ if (wclength == (size_t)-1 || *pp != NULL)
+ wclength = mbsrtowcs (month_wcs, &pp, len + 1, &state);
+ if (wclength == (size_t)-1 || pp != NULL)
+ error (SORT_FAILURE, 0, _("Invalid multibyte input %s."), quote(s));
+
+ for (i = 0; i < wclength; i++)
@ -3113,10 +3112,8 @@ Index: src/sort.c
+ }
+ }
+
+ wpp = (const wchar_t **)&month_wcs;
+
+ mblength = wcsrtombs (month, wpp, len + 1, &state);
+ assert (mblength != (-1) && *wpp == NULL);
+ mblength = wcsrtombs (month, &wpp, len + 1, &state);
+ assert (mblength != (-1) && wpp == NULL);
+
+ do
+ {
@ -3152,7 +3149,7 @@ Index: src/sort.c
{
struct keyfield *key = keylist;
@@ -2578,7 +3018,7 @@ keycompare (struct line const *a, struct
@@ -2578,7 +3015,7 @@ keycompare (struct line const *a, struct
else if (key->human_numeric)
diff = human_numcompare (ta, tb);
else if (key->month)
@ -3161,7 +3158,7 @@ Index: src/sort.c
else if (key->random)
diff = compare_random (ta, tlena, tb, tlenb);
else if (key->version)
@@ -2694,6 +3134,211 @@ keycompare (struct line const *a, struct
@@ -2694,6 +3131,211 @@ keycompare (struct line const *a, struct
return key->reverse ? -diff : diff;
}
@ -3373,7 +3370,7 @@ Index: src/sort.c
/* Compare two lines A and B, returning negative, zero, or positive
depending on whether A compares less than, equal to, or greater than B. */
@@ -2721,7 +3366,7 @@ compare (struct line const *a, struct li
@@ -2721,7 +3363,7 @@ compare (struct line const *a, struct li
diff = - NONZERO (blen);
else if (blen == 0)
diff = 1;
@ -3382,7 +3379,7 @@ Index: src/sort.c
{
/* Note xmemcoll0 is a performance enhancement as
it will not unconditionally write '\0' after the
@@ -4120,6 +4765,7 @@ set_ordering (char const *s, struct keyf
@@ -4120,6 +4762,7 @@ set_ordering (char const *s, struct keyf
break;
case 'f':
key->translate = fold_toupper;
@ -3390,7 +3387,7 @@ Index: src/sort.c
break;
case 'g':
key->general_numeric = true;
@@ -4197,7 +4843,7 @@ main (int argc, char **argv)
@@ -4197,7 +4840,7 @@ main (int argc, char **argv)
initialize_exit_failure (SORT_FAILURE);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
@ -3399,7 +3396,7 @@ Index: src/sort.c
hard_LC_TIME = hard_locale (LC_TIME);
#endif
@@ -4218,6 +4864,29 @@ main (int argc, char **argv)
@@ -4218,6 +4861,29 @@ main (int argc, char **argv)
thousands_sep = -1;
}
@ -3429,7 +3426,7 @@ Index: src/sort.c
have_read_stdin = false;
inittables ();
@@ -4492,13 +5161,34 @@ main (int argc, char **argv)
@@ -4492,13 +5158,34 @@ main (int argc, char **argv)
case 't':
{
@ -3468,7 +3465,7 @@ Index: src/sort.c
else
{
/* Provoke with 'sort -txx'. Complain about
@@ -4509,9 +5199,12 @@ main (int argc, char **argv)
@@ -4509,9 +5196,12 @@ main (int argc, char **argv)
quote (optarg));
}
}

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Thu Sep 10 23:14:47 UTC 2015 - mail@bernhard-voelker.de
- coreutils-i18n.patch: Fix a glaring mem leak in the i18n patch
for sort -M (boo#945361):
Sync I18N patch from semi-official repository (shared among
distributions, maintained by Padraig Brady):
https://github.com/pixelb/coreutils/tree/i18n
commit fbbe8c06
-------------------------------------------------------------------
Sun Aug 30 21:52:13 UTC 2015 - mail@bernhard-voelker.de

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Thu Sep 10 23:14:47 UTC 2015 - mail@bernhard-voelker.de
- coreutils-i18n.patch: Fix a glaring mem leak in the i18n patch
for sort -M (boo#945361):
Sync I18N patch from semi-official repository (shared among
distributions, maintained by Padraig Brady):
https://github.com/pixelb/coreutils/tree/i18n
commit fbbe8c06
-------------------------------------------------------------------
Sun Aug 30 21:52:13 UTC 2015 - mail@bernhard-voelker.de