Module Name:    src
Committed By:   dsl
Date:           Fri Oct  9 20:32:57 UTC 2009

Modified Files:
        src/usr.bin/sort: fsort.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/sort/fsort.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/sort/fsort.c
diff -u src/usr.bin/sort/fsort.c:1.44 src/usr.bin/sort/fsort.c:1.45
--- src/usr.bin/sort/fsort.c:1.44	Fri Oct  9 20:23:19 2009
+++ src/usr.bin/sort/fsort.c	Fri Oct  9 20:32:57 2009
@@ -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;
 

Reply via email to