[BusyBox] bug#1103: another potential fix

Matt Kraai kraai at alumni.carnegiemellon.edu
Fri Feb 9 20:25:56 UTC 2001


Howdy,

Here is my second attempt.  That will teach me not to fully
understand compiler warnings before kludging around them.

Matt

Index: insmod.c
===================================================================
RCS file: /var/cvs/busybox/insmod.c,v
retrieving revision 1.45
diff -u -r1.45 insmod.c
--- insmod.c	2001/01/31 19:00:21	1.45
+++ insmod.c	2001/02/09 20:24:17
@@ -2880,6 +2880,7 @@
 	ElfW(Addr) m_addr;
 	FILE *fp;
 	struct obj_file *f;
+	struct stat st;
 	char m_name[BUFSIZ + 1] = "\0";
 	int exit_status = EXIT_FAILURE;
 	int m_has_modinfo;
@@ -2941,7 +2942,8 @@
 	strcat(m_fullName, ".o");
 
 	/* Get a filedesc for the module */
-	if ((fp = fopen(argv[optind], "r")) == NULL) {
+	if (stat(argv[optind], &st) < 0 || !S_ISREG(st.st_mode) ||
+			(fp = fopen(argv[optind], "r")) == NULL) {
 		/* Hmpf.  Could not open it. Search through _PATH_MODULES to find a module named m_name */
 		if (recursive_action(_PATH_MODULES, TRUE, FALSE, FALSE,
 							findNamedModule, 0, m_fullName) == FALSE) 






More information about the busybox mailing list