diff options
| author | dsl <dsl@NetBSD.org> | 2009-10-09 20:32:57 +0000 |
|---|---|---|
| committer | dsl <dsl@NetBSD.org> | 2009-10-09 20:32:57 +0000 |
| commit | 43682b02ee71732c60105772da95b312041f8ea9 (patch) | |
| tree | f8ee43436e9ada79b7cd3b5897a7a4643b039e71 /usr.bin/sort | |
| parent | 41b3ada21c29adc801bb11cde21b15068482676b (diff) | |
If anyone is stupid enough to feed records longer than 8MB into sort, don't
sit in an infinite loop, instead eat memory until we have read 8 records.
Diffstat (limited to 'usr.bin/sort')
| -rw-r--r-- | usr.bin/sort/fsort.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/sort/fsort.c b/usr.bin/sort/fsort.c index 247f987d08b..de50b9d5a6a 100644 --- a/usr.bin/sort/fsort.c +++ b/usr.bin/sort/fsort.c @@ -1,4 +1,4 @@ -/* $NetBSD: fsort.c,v 1.44 2009/10/09 20:23:19 dsl Exp $ */ +/* $NetBSD: fsort.c,v 1.45 2009/10/09 20:32:57 dsl Exp $ */ /*- * Copyright (c) 2000-2003 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ #include "fsort.h" #ifndef lint -__RCSID("$NetBSD: fsort.c,v 1.44 2009/10/09 20:23:19 dsl Exp $"); +__RCSID("$NetBSD: fsort.c,v 1.45 2009/10/09 20:32:57 dsl Exp $"); __SCCSID("@(#)fsort.c 8.1 (Berkeley) 6/6/93"); #endif /* not lint */ @@ -149,7 +149,8 @@ fsort(struct filelist *filelist, int nfiles, FILE *outfp, struct field *ftbl) err(2, "%s", filelist->names[file_no]); continue; } - if (nelem >= max_recs || bufsize >= MAXBUFSIZE) + if (nelem >= max_recs + || (bufsize >= MAXBUFSIZE && nelem > 8)) /* Need to sort and save this lot of data */ break; |
