mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
sort: fix --debug buffer overrun
* src/sort.c (debug_key): Fix undefined behavior when a key ends before it starts. Problem reported by Bruno Haible <https://bugs.gnu.org/75606>.
This commit is contained in:
@@ -2373,7 +2373,11 @@ debug_key (struct line const *line, struct keyfield const *key)
|
||||
if (key->sword != SIZE_MAX)
|
||||
beg = begfield (line, key);
|
||||
if (key->eword != SIZE_MAX)
|
||||
lim = limfield (line, key);
|
||||
{
|
||||
lim = limfield (line, key);
|
||||
/* Treat field ends before field starts as empty fields. */
|
||||
lim = MAX (beg, lim);
|
||||
}
|
||||
|
||||
if ((key->skipsblanks && key->sword == SIZE_MAX)
|
||||
|| key->month || key_numeric (key))
|
||||
|
||||
Reference in New Issue
Block a user