If the modules are unstripped and/or especially large, then the stack
can overflow.
---
init/init.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/init/init.c b/init/init.c
index 106be02..733d66e 100644
--- a/init/init.c
+++ b/init/init.c
@@ -314,7 +314,11 @@ insmod (const char *filename)
exit (EXIT_FAILURE);
}
size = st.st_size;
- char buf[size];
+ char *buf = malloc (size);
+ if (buf == NULL) {
+ fprintf (stderr, "insmod: malloc (%s, %zu bytes): %m\n", filename, size);
+ exit (EXIT_FAILURE);
+ }
size_t offset = 0;
do {
ssize_t rc = read (fd, buf + offset, size - offset);
@@ -332,6 +336,8 @@ insmod (const char *filename)
* of a missing device.
*/
}
+
+ free (buf);
}
/* Mount /proc unless it's mounted already. */
--
2.7.4