[ktap] [PATCH 6/6] stap: fix possible segmentation fault without symbol

  • From: Azat Khuzhin <a3at.mail@xxxxxxxxx>
  • To: ktap@xxxxxxxxxxxxx
  • Date: Mon, 11 Nov 2013 18:57:01 +0400

As Jovi noticed:
    Segmentation fault for "trace sdt:/lib64/libc.so.6 {...}"
    No symbol given in that case.

Signed-off-by: Azat Khuzhin <a3at.mail@xxxxxxxxx>
---
 userspace/eventdef.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/userspace/eventdef.c b/userspace/eventdef.c
index 8be17e3..052a9e1 100644
--- a/userspace/eventdef.c
+++ b/userspace/eventdef.c
@@ -306,10 +306,14 @@ static int parse_events_add_kprobe(char *old_event)
 
 static char *parse_events_resolve_symbol(char *event, int type)
 {
-       char *colon = strchr(event, ':');
-       vaddr_t symbol_address = strtol(colon + 1 /* skip ":" */, NULL, 0);
+       char *colon, *end, *tail, *binary, *symbol;
+       vaddr_t symbol_address;
 
-       char *end, *tail, *binary, *symbol;
+       colon = strchr(event, ':');
+       if (!colon)
+               return event;
+
+       symbol_address = strtol(colon + 1 /* skip ":" */, NULL, 0);
 
        /**
         * We already have address, no need in resolving.
-- 
1.8.4.rc3


Other related posts: