summaryrefslogtreecommitdiffstats
path: root/usr.bin/join/join.c
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1997-01-17 18:55:05 +0000
committerjoerg <joerg@FreeBSD.org>1997-01-17 18:55:05 +0000
commita998b593c4cff0a119c72ba75b3f3c4ce46b5155 (patch)
tree58ab1c3bfd0191cf7cecd3638f059374bf97cf0e /usr.bin/join/join.c
parent7b0000acf9cb8dc83a29ab593801b9285d18b8d5 (diff)
downloadFreeBSD-src-a998b593c4cff0a119c72ba75b3f3c4ce46b5155.zip
FreeBSD-src-a998b593c4cff0a119c72ba75b3f3c4ce46b5155.tar.gz
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.
Diffstat (limited to 'usr.bin/join/join.c')
-rw-r--r--usr.bin/join/join.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/join/join.c b/usr.bin/join/join.c
index 15d77ff..a3efd7e 100644
--- a/usr.bin/join/join.c
+++ b/usr.bin/join/join.c
@@ -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 {
OpenPOWER on IntegriCloud