Fix insmod module size
read_file() used to append a new line character to the end of the buffer it
returns, because parse_config() isn't able to cope with input that's not
'\n'-terminated. Fix read_file() to be less insane, and push the workarounds
into the parse_config() callers.
Longer term we should rewrite parse_config().
Change-Id: Ie9d9a7adcd33b66621726aef20c4b8cc51c08be7
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 88d6165..9e5f9ff 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -57,16 +57,13 @@
static int insmod(const char *filename, char *options)
{
- std::string module;
char filename_val[PROP_VALUE_MAX];
- int ret;
-
- ret = expand_props(filename_val, filename, sizeof(filename_val));
- if (ret) {
+ if (expand_props(filename_val, filename, sizeof(filename_val)) == -1) {
ERROR("insmod: cannot expand '%s'\n", filename);
return -EINVAL;
}
+ std::string module;
if (!read_file(filename_val, &module)) {
return -1;
}