aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/portsnap
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2005-11-20 00:50:30 +0000
committerColin Percival <cperciva@FreeBSD.org>2005-11-20 00:50:30 +0000
commit3d19fd319099ed12ef7a113b7ebe7740c9e86faa (patch)
treead00b3e35fa74549712d1671839ab2ddf98580b2 /usr.sbin/portsnap
parent359d4388857a28a7afe8bca195cb5ca5f675f1b7 (diff)
downloadsrc-3d19fd319099ed12ef7a113b7ebe7740c9e86faa.tar.gz
src-3d19fd319099ed12ef7a113b7ebe7740c9e86faa.zip
An empty file does not have a positive number of lines.
Make sure that the number of lines read is non-zero before in order to avoid dumping core. Reported by: Wojciech A. Koszek Pointy hat to: cperciva
Notes
Notes: svn path=/head/; revision=152625
Diffstat (limited to 'usr.sbin/portsnap')
-rw-r--r--usr.sbin/portsnap/make_index/make_index.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/usr.sbin/portsnap/make_index/make_index.c b/usr.sbin/portsnap/make_index/make_index.c
index c02bba8b0deb..410b5b7cc45c 100644
--- a/usr.sbin/portsnap/make_index/make_index.c
+++ b/usr.sbin/portsnap/make_index/make_index.c
@@ -411,6 +411,7 @@ printport(PORT * p)
/*
* Algorithm:
* 1. Suck in all the data, splitting into fields.
+ * 1a. If there are no ports, there is no INDEX.
* 2. Sort the ports according to port directory.
* 3. Using a binary search, translate each dependency from a
* port directory name into a pointer to a port.
@@ -470,6 +471,12 @@ main(int argc, char *argv[])
err(1, "fclose(%s)", argv[1]);
/*
+ * 1a. If there are no ports, there is no INDEX.
+ */
+ if (pplen == 0)
+ return 0;
+
+ /*
* 2. Sort the ports according to port directory.
*/
for (i = pplen; i > 0; i--)