mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04: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
1 changed files with 3 additions and 3 deletions
|
|
@ -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 a new issue