mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 17:04:19 +01:00
Fix a genuine off-by-one error that caused join to dump core when
trying to use field numbers tha weren't present in the input data.
This commit is contained in:
parent
1a85659d68
commit
cefe4f6fa2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=21811
@ -352,9 +352,9 @@ cmp(lp1, fieldno1, lp2, fieldno2)
|
||||
LINE *lp1, *lp2;
|
||||
u_long fieldno1, fieldno2;
|
||||
{
|
||||
if (lp1->fieldcnt < fieldno1)
|
||||
if (lp1->fieldcnt <= fieldno1)
|
||||
return (lp2->fieldcnt < fieldno2 ? 0 : 1);
|
||||
if (lp2->fieldcnt < fieldno2)
|
||||
if (lp2->fieldcnt <= fieldno2)
|
||||
return (-1);
|
||||
return (strcmp(lp1->fields[fieldno1], lp2->fields[fieldno2]));
|
||||
}
|
||||
@ -450,7 +450,7 @@ outfield(lp, fieldno, out_empty)
|
||||
if (needsep++)
|
||||
(void)printf("%c", *tabchar);
|
||||
if (!ferror(stdout))
|
||||
if (lp->fieldcnt < fieldno || out_empty) {
|
||||
if (lp->fieldcnt <= fieldno || out_empty) {
|
||||
if (empty != NULL)
|
||||
(void)printf("%s", empty);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user