[BusyBox] [PATCH] Ignore extra empty lines in fgets_str

Stefan Soucek ssoucek at coactive.com
Wed Oct 17 19:25:40 UTC 2001


Hi,

I've discovered that dpkg exits with a SEGV if the status file has extra
empty lines at the end of the file. They should rather be ignored than
causing a SEGV. This small patch in fgets_str() takes care of the problem.

-Stefan

--- libbb/fgets_str.c	Wed Jun 13 00:34:03 2001
+++ libbb/fgets_str.c	Wed Oct 17 12:35:28 2001
@@ -55,7 +55,7 @@ char *fgets_str(FILE *file, const char *
 			break;
 		}
 	}
-	if (idx == 0) {
+	if (idx == 0 || linebuf[0] == '\n') {
 		return NULL;
 	}
 	linebuf[idx] = '\0';


--
Stefan Soucek, ssoucek at coactive.com
Coactive Networks, 28 Liberty Ship Way, Sausalito, CA 94965
Ph: (415) 289 7840, Fax: (415) 289 1320





More information about the busybox mailing list