]> The Tcpdump Group git mirrors - tcpslice/commitdiff
instrument functions: Add a NULL check
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 10 Mar 2023 22:21:00 +0000 (23:21 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 10 Mar 2023 22:30:55 +0000 (23:30 +0100)
This should fix Coverity CID 310986:
Null pointer dereferences  (FORWARD_NULL)
Passing null pointer "func" to "strncmp", which dereferences it.

instrument-functions.c

index aff33ccdc7e9f90d7354e81d2ade5fefae517e82..323497729ac62761147cc96caaff7991e7fc23d1 100644 (file)
@@ -199,7 +199,8 @@ static void print_debug(void *this_fn, void *call_site, action_type action)
                                printf("%s", func);
                        printf(" (%d)", profile_func_level);
                        /* Print the "from" part except for the main function) */
-                       if (action == ENTER && strncmp(func, "main", sizeof("main"))) {
+                       if (action == ENTER && func != NULL &&
+                               strncmp(func, "main", sizeof("main"))) {
                                /* Calling function */
                                if ((bfd_vma)call_site < vma) {
                                        printf("[ERROR address call_site]");