Commit a09c4913 authored by 4ast's avatar 4ast Committed by GitHub

Merge pull request #1155 from palmtenor/perf_map_check

Improve perf map parsing logic
parents 7ea0e6e6 ddf16491
......@@ -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++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment