[PATCH v1] Add bounds checking in sys_query_module

zubin.mithra at gmail.com zubin.mithra at gmail.com
Mon Aug 4 03:01:30 UTC 2014


From: Zubin Mithra <zubin.mithra at gmail.com>

* bjm.c (sys_query_module): Add bounds check.

Signed-off-by: Zubin Mithra <zubin.mithra at gmail.com>
---
 bjm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bjm.c b/bjm.c
index b34c6ed..b5ce103 100644
--- a/bjm.c
+++ b/bjm.c
@@ -121,6 +121,8 @@ sys_query_module(struct tcb *tcp)
 								(idx ? ", " : ""),
 								mod);
 							mod += strlen(mod)+1;
+							if (mod-data >= tcp->u_arg[3])
+								break;
 						}
 					}
 					free(data);
@@ -144,6 +146,8 @@ sys_query_module(struct tcb *tcp)
 						tprintf(" /* %lu entries */ ", (unsigned long)ret);
 					} else {
 						for (idx = 0; idx < ret; idx++) {
+							if ((long)sym->name >= tcp->u_arg[3])
+								break;
 							tprintf("%s{name=%s, value=%lu}",
 								(idx ? " " : ""),
 								data+(long)sym->name,
-- 
1.8.4





More information about the Strace-devel mailing list