The following issues were found
tools/perf/tests/perf-record.c
1 issues
Line: 71
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
int err = -1, errs = 0, i, wakeups = 0;
u32 cpu;
int total_events = 0, nr_events[PERF_RECORD_MAX] = { 0, };
char sbuf[STRERR_BUFSIZE];
if (evlist == NULL) /* Fallback for kernels lacking PERF_COUNT_SW_DUMMY */
evlist = evlist__new_default();
if (evlist == NULL) {
Reported by FlawFinder.
tools/perf/tests/python-use.c
1 issues
Line: 22
Column: 8
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
return -1;
pr_debug("python usage test: \"%s\"\n", cmd);
ret = system(cmd) ? -1 : 0;
free(cmd);
return ret;
}
Reported by FlawFinder.
tools/perf/tests/sw-clock.c
1 issues
Line: 33
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
volatile int tmp = 0;
u64 total_periods = 0;
int nr_samples = 0;
char sbuf[STRERR_BUFSIZE];
union perf_event *event;
struct evsel *evsel;
struct evlist *evlist;
struct perf_event_attr attr = {
.type = PERF_TYPE_SOFTWARE,
Reported by FlawFinder.
tools/perf/tests/switch-tracking.c
1 issues
Line: 46
return err;
timersub(&now, &start, &diff);
if (timercmp(&diff, &maxtime, > /* For checkpatch */))
break;
}
ts.tv_nsec = 50 * 1000 * 1000;
ts.tv_sec = 0;
Reported by Cppcheck.
tools/perf/tests/task-exit.c
1 issues
Line: 53
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
.uses_mmap = true,
};
const char *argv[] = { "true", NULL };
char sbuf[STRERR_BUFSIZE];
struct perf_cpu_map *cpus;
struct perf_thread_map *threads;
struct mmap *md;
int retry_count = 0;
Reported by FlawFinder.
tools/perf/tests/unit_number__scnprintf.c
1 issues
Line: 26
Column: 3
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
unsigned i = 0;
while (test[i].str) {
char buf[100];
unit_number__scnprintf(buf, sizeof(buf), test[i].n);
pr_debug("n %" PRIu64 ", str '%s', buf '%s'\n",
test[i].n, test[i].str, buf);
Reported by FlawFinder.
tools/perf/tests/wp.c
1 issues
Line: 26
Column: 12
CWE codes:
120
20
static int wp_read(int fd, long long *count, int size)
{
int ret = read(fd, count, size);
if (ret != size) {
pr_debug("failed to read: %d\n", ret);
return -1;
}
Reported by FlawFinder.
tools/perf/trace/beauty/include/linux/socket.h
1 issues
Line: 34
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
struct sockaddr {
sa_family_t sa_family; /* address family, AF_xxx */
char sa_data[14]; /* 14 bytes of protocol address */
};
struct linger {
int l_onoff; /* Linger active */
int l_linger; /* How long to linger for */
Reported by FlawFinder.
tools/perf/ui/browsers/header.c
1 issues
Line: 21
Column: 16
CWE codes:
126
bool current_entry = ui_browser__is_current_entry(browser, row);
unsigned long offset = (unsigned long)browser->priv;
if (offset >= strlen(str))
str = empty;
else
str = str + offset;
ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED :
Reported by FlawFinder.
tools/lib/perf/Documentation/examples/sampling.c
1 issues
Line: 15
Column: 9
CWE codes:
134
Suggestion:
Use a constant for the format specification
static int libperf_print(enum libperf_print_level level,
const char *fmt, va_list ap)
{
return vfprintf(stderr, fmt, ap);
}
union u64_swap {
__u64 val64;
__u32 val32[2];
Reported by FlawFinder.