Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/sort If anyone is stupid enough to feed records long...
details: https://anonhg.NetBSD.org/src/rev/4f906b37040a
branches: trunk
changeset: 748025:4f906b37040a
user: dsl <dsl%NetBSD.org@localhost>
date: Fri Oct 09 20:32:57 2009 +0000
description:
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:
usr.bin/sort/fsort.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diffs (28 lines):
diff -r 10f10b814c2b -r 4f906b37040a usr.bin/sort/fsort.c
--- a/usr.bin/sort/fsort.c Fri Oct 09 20:29:43 2009 +0000
+++ b/usr.bin/sort/fsort.c Fri Oct 09 20:32:57 2009 +0000
@@ -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 @@
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;
Home |
Main Index |
Thread Index |
Old Index