summaryrefslogtreecommitdiff
path: root/kmodloader.c
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2017-01-14 01:00:33 +0800
committerFelix Fietkau <nbd@nbd.name>2017-01-15 18:52:42 +0100
commit9371411715c8dd882f1d65a712f1f38b6d38d01f (patch)
tree7ac73a1d3968c23624f1fe23a2044211b56cc77c /kmodloader.c
parenta62c946ecdced9468ad16738325ee322029b0476 (diff)
downloadubox-9371411715c8dd882f1d65a712f1f38b6d38d01f.tar.gz
kmodloader: fix out-of-bound access when parsing .modinfo
Fixes output of "modinfo nf_conntrack_ipv4" module: /lib/modules/4.4.40/nf_conntrack_ipv4.ko license: GPL alias: ip_conntrack alias: nf_conntrack-2 depends: nf_conntrack,nf_defrag_ipv4 src: %pI4 dst=%pI4 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Diffstat (limited to 'kmodloader.c')
-rw-r--r--kmodloader.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/kmodloader.c b/kmodloader.c
index 065ac82..c780379 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -302,12 +302,14 @@ static struct module* get_module_info(const char *module, const char *name)
}
strings = map + offset;
- while (strings && (strings < map + offset + size)) {
+ while (true) {
char *sep;
int len;
while (!strings[0])
strings++;
+ if (strings >= map + offset + size)
+ break;
sep = strstr(strings, "=");
if (!sep)
break;
@@ -410,12 +412,14 @@ static int print_modinfo(char *module)
strings = map + offset;
printf("module:\t\t%s\n", module);
- while (strings && (strings < map + offset + size)) {
+ while (true) {
char *dup = NULL;
char *sep;
while (!strings[0])
strings++;
+ if (strings >= map + offset + size)
+ break;
sep = strstr(strings, "=");
if (!sep)
break;