aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2016-02-18 16:24:02 -0800
committerRob Landley <rob@landley.net>2016-02-19 17:59:40 -0600
commit81f31e463bd982a8344ea8681938eb43c9114652 (patch)
tree3288839ae781d82a48283f284afd277828688f63 /lib
parent5ec9f52a39c0f5a631cd60f12560698033eba7dc (diff)
downloadtoybox-81f31e463bd982a8344ea8681938eb43c9114652.tar.gz
Implement "insmod -".
Also use finit_module if available. Given that "insmod -" requires init_module, maybe this isn't a worthwhile optimization. Given that "insmod /actual/file.ko" is the common use case, maybe it is. Fix a bug in readfileat where *plen would be corrupted if you didn't supply your own buffer (because ibuf is 0 in that case, not a pointer to the start of the allocated space).
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/lib.c b/lib/lib.c
index e80b8b12..43db2e37 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -475,12 +475,12 @@ char *readfileat(int dirfd, char *name, char *ibuf, off_t *plen)
rbuf = buf+rlen;
len -= rlen;
}
- *plen = len = rlen+(buf-ibuf);
+ *plen = len = rlen+(rbuf-buf);
close(fd);
if (rlen<0) {
if (ibuf != buf) free(buf);
- buf = 0;
+ buf = 0;
} else buf[len] = 0;
return buf;