Improve perf map parsing logic
authorTeng Qin <qinteng@fb.com>
Thu, 4 May 2017 07:58:51 +0000 (00:58 -0700)
committerTeng Qin <qinteng@fb.com>
Fri, 5 May 2017 17:53:08 +0000 (10:53 -0700)
src/cc/bcc_perf_map.c

index 70ffbe8f89b5b00c27d95d0014835e31e5cb6bed..5ef1c1129853745c900b2ae0a7b41fede96b23d5 100644 (file)
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 #include <ctype.h>
+#include <errno.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -82,13 +84,15 @@ int bcc_perf_map_foreach_sym(const char *path, bcc_perf_map_symcb callback,
     char *newline, *sep;
 
     begin = strtoull(cursor, &sep, 16);
-    if (*sep != ' ' || (sep == cursor && begin == 0))
+    if (begin == 0 || *sep != ' ' || (begin == ULLONG_MAX && errno == ERANGE))
       continue;
     cursor = sep;
     while (*cursor && isspace(*cursor)) cursor++;
 
     len = strtoull(cursor, &sep, 16);
-    if (*sep != ' ' || (sep == cursor && begin == 0))
+    if (*sep != ' ' ||
+        (sep == cursor && len == 0) ||
+        (len == ULLONG_MAX && errno == ERANGE))
       continue;
     cursor = sep;
     while (*cursor && isspace(*cursor)) cursor++;