The following issues were found
tools/testing/selftests/ir/ir_loopback.c
7 issues
Line: 100
Column: 2
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
char buf[100];
int rlircfd, wlircfd, protocolfd, i, n;
srand(time(NULL));
if (argc != 3)
ksft_exit_fail_msg("Usage: %s <write rcN> <read rcN>\n",
argv[0]);
Reported by FlawFinder.
Line: 65
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 lirc_open(const char *rc)
{
struct dirent *dent;
char buf[SYSFS_PATH_MAX + DNAME_PATH_MAX];
DIR *d;
int fd;
snprintf(buf, sizeof(buf), "/sys/class/rc/%s", rc);
Reported by FlawFinder.
Line: 87
Column: 7
CWE codes:
362
closedir(d);
fd = open(buf, O_RDWR | O_NONBLOCK);
if (fd == -1)
ksft_exit_fail_msg("cannot open: %s: %m\n", buf);
return fd;
}
Reported by FlawFinder.
Line: 97
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 main(int argc, char **argv)
{
unsigned int mode;
char buf[100];
int rlircfd, wlircfd, protocolfd, i, n;
srand(time(NULL));
if (argc != 3)
Reported by FlawFinder.
Line: 118
Column: 15
CWE codes:
362
argv[1]);
snprintf(buf, sizeof(buf), "/sys/class/rc/%s/protocols", argv[2]);
protocolfd = open(buf, O_WRONLY);
if (protocolfd == -1)
ksft_exit_fail_msg("failed to open %s: %m\n", buf);
printf("Sending IR on %s and receiving IR on %s.\n", argv[1], argv[2]);
Reported by FlawFinder.
Line: 126
Column: 6
CWE codes:
126
for (i = 0; i < ARRAY_SIZE(protocols); i++) {
if (write(protocolfd, protocols[i].decoder,
strlen(protocols[i].decoder)) == -1)
ksft_exit_fail_msg("failed to set write decoder\n");
printf("Testing protocol %s for decoder %s (%d/%d)...\n",
protocols[i].name, protocols[i].decoder,
i + 1, (int)ARRAY_SIZE(protocols));
Reported by FlawFinder.
Line: 174
Column: 11
CWE codes:
120
20
bool decoded = true;
while (read(rlircfd, &lsc2, sizeof(lsc2)) < 0) {
if (errno == EINTR)
continue;
ksft_test_result_error("no scancode decoded: %m\n");
decoded = false;
Reported by FlawFinder.
tools/testing/selftests/bpf/prog_tests/btf_skc_cls_ingress.c
7 issues
Line: 52
Column: 12
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
strerror(errno), errno))
return -1;
if (CHECK(system("ip link set dev lo up"),
"ip link set dev lo up", "failed\n"))
return -1;
if (CHECK(system("tc qdisc add dev lo clsact"),
"tc qdisc add dev lo clsact", "failed\n"))
Reported by FlawFinder.
Line: 56
Column: 12
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
"ip link set dev lo up", "failed\n"))
return -1;
if (CHECK(system("tc qdisc add dev lo clsact"),
"tc qdisc add dev lo clsact", "failed\n"))
return -1;
if (CHECK(system("tc filter add dev lo ingress bpf direct-action object-pinned " PROG_PIN_FILE),
"install tc cls-prog at ingress", "failed\n"))
Reported by FlawFinder.
Line: 60
Column: 12
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
"tc qdisc add dev lo clsact", "failed\n"))
return -1;
if (CHECK(system("tc filter add dev lo ingress bpf direct-action object-pinned " PROG_PIN_FILE),
"install tc cls-prog at ingress", "failed\n"))
return -1;
/* Ensure 20 bytes options (i.e. in total 40 bytes tcp header) for the
* bpf_tcp_gen_syncookie() helper.
Reported by FlawFinder.
Line: 29
Column: 7
CWE codes:
362
{
int fd, err, len;
fd = open(sysctl, O_WRONLY);
if (CHECK(fd == -1, "open sysctl", "open(%s): %s (%d)\n",
sysctl, strerror(errno), errno))
return -1;
len = strlen(value);
Reported by FlawFinder.
Line: 108
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (CHECK(err, "getsockname(listen_fd)", "err:%d errno:%d\n", err,
errno))
goto done;
memcpy(&skel->bss->srv_sa6, &srv_sa6, sizeof(srv_sa6));
srv_port = ntohs(srv_sa6.sin6_port);
cli_fd = connect_to_fd(listen_fd, 0);
if (CHECK_FAIL(cli_fd == -1))
goto done;
Reported by FlawFinder.
Line: 157
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (CHECK(err, "getsockname(listen_fd)", "err:%d errno:%d\n", err,
errno))
goto done;
memcpy(&skel->bss->srv_sa6, &srv_sa6, sizeof(srv_sa6));
srv_port = ntohs(srv_sa6.sin6_port);
cli_fd = connect_to_fd(listen_fd, 0);
if (CHECK_FAIL(cli_fd == -1))
goto done;
Reported by FlawFinder.
Line: 34
Column: 8
CWE codes:
126
sysctl, strerror(errno), errno))
return -1;
len = strlen(value);
err = write(fd, value, len);
close(fd);
if (CHECK(err != len, "write sysctl",
"write(%s, %s, %d): err:%d %s (%d)\n",
sysctl, value, len, err, strerror(errno), errno))
Reported by FlawFinder.
tools/testing/selftests/bpf/test_tcpnotify_user.c
7 issues
Line: 129
Column: 6
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
sprintf(test_script,
"iptables -A INPUT -p tcp --dport %d -j DROP",
TESTPORT);
if (system(test_script)) {
printf("FAILED: execute command: %s, err %d\n", test_script, -errno);
goto err;
}
sprintf(test_script,
Reported by FlawFinder.
Line: 137
Column: 6
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
sprintf(test_script,
"nc 127.0.0.1 %d < /etc/passwd > /dev/null 2>&1 ",
TESTPORT);
if (system(test_script))
printf("execute command: %s, err %d\n", test_script, -errno);
sprintf(test_script,
"iptables -D INPUT -p tcp --dport %d -j DROP",
TESTPORT);
Reported by FlawFinder.
Line: 143
Column: 6
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
sprintf(test_script,
"iptables -D INPUT -p tcp --dport %d -j DROP",
TESTPORT);
if (system(test_script)) {
printf("FAILED: execute command: %s, err %d\n", test_script, -errno);
goto err;
}
rv = bpf_map_lookup_elem(bpf_map__fd(global_map), &key, &g);
Reported by FlawFinder.
Line: 81
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 prog_fd, rv, cg_fd = -1;
int error = EXIT_FAILURE;
struct bpf_object *obj;
char test_script[80];
cpu_set_t cpuset;
__u32 key = 0;
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
Reported by FlawFinder.
Line: 126
Column: 2
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
pthread_create(&tid, NULL, poller_thread, pb);
sprintf(test_script,
"iptables -A INPUT -p tcp --dport %d -j DROP",
TESTPORT);
if (system(test_script)) {
printf("FAILED: execute command: %s, err %d\n", test_script, -errno);
goto err;
Reported by FlawFinder.
Line: 134
Column: 2
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
goto err;
}
sprintf(test_script,
"nc 127.0.0.1 %d < /etc/passwd > /dev/null 2>&1 ",
TESTPORT);
if (system(test_script))
printf("execute command: %s, err %d\n", test_script, -errno);
Reported by FlawFinder.
Line: 140
Column: 2
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
if (system(test_script))
printf("execute command: %s, err %d\n", test_script, -errno);
sprintf(test_script,
"iptables -D INPUT -p tcp --dport %d -j DROP",
TESTPORT);
if (system(test_script)) {
printf("FAILED: execute command: %s, err %d\n", test_script, -errno);
goto err;
Reported by FlawFinder.
tools/perf/ui/browsers/annotate.c
7 issues
Line: 424
Column: 3
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
ui_helpline__puts("No source file location.");
else {
char help_line[SYM_TITLE_MAX_SIZE];
sprintf (help_line, "Source file location: %s", al->fileloc);
ui_helpline__puts(help_line);
}
}
static void ui_browser__init_asm_mode(struct ui_browser *browser)
Reported by FlawFinder.
Line: 37
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 arch *arch;
struct annotation_options *opts;
bool searching_backwards;
char search_bf[128];
};
static inline struct annotation *browser__annotation(struct ui_browser *browser)
{
struct map_symbol *ms = browser->priv;
Reported by FlawFinder.
Line: 423
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
else if (al->fileloc == NULL)
ui_helpline__puts("No source file location.");
else {
char help_line[SYM_TITLE_MAX_SIZE];
sprintf (help_line, "Source file location: %s", al->fileloc);
ui_helpline__puts(help_line);
}
}
Reported by FlawFinder.
Line: 459
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 map_symbol *ms = browser->b.priv, target_ms;
struct disasm_line *dl = disasm_line(browser->selection);
struct annotation *notes;
char title[SYM_TITLE_MAX_SIZE];
if (!dl->ops.target.sym) {
ui_helpline__puts("The called function was not found.");
return true;
}
Reported by FlawFinder.
Line: 659
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 annotate_browser *ab = container_of(browser, struct annotate_browser, b);
struct map_symbol *ms = browser->priv;
struct symbol *sym = ms->sym;
char symbol_dso[SYM_TITLE_MAX_SIZE];
if (ui_browser__show(browser, title, help) < 0)
return -1;
sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso), ab->opts->percent_type);
Reported by FlawFinder.
Line: 716
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 annotation *notes = symbol__annotation(ms->sym);
const char *help = "Press 'h' for help on key bindings";
int delay_secs = hbt ? hbt->refresh : 0;
char title[256];
int key;
hists__scnprintf_title(hists, title, sizeof(title));
if (annotate_browser__show(&browser->b, title, help) < 0)
return -1;
Reported by FlawFinder.
Line: 968
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
err = symbol__annotate2(ms, evsel, opts, &browser.arch);
if (err) {
char msg[BUFSIZ];
symbol__strerror_disassemble(ms, err, msg, sizeof(msg));
ui__error("Couldn't annotate %s:\n%s", sym->name, msg);
goto out_free_offsets;
}
Reported by FlawFinder.
tools/perf/builtin-timechart.c
7 issues
Line: 1235
Column: 4
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
}
sprintf(comm, "%s:%i (%3.1f %sbytes)", c->comm ?: "", p->pid, bytes, suf);
svg_text(Y, c->start_time, comm);
c->Y = Y;
Y++;
c = c->next;
Reported by FlawFinder.
Line: 1289
Column: 6
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
if (c->comm) {
char comm[256];
if (c->total_time > 5000000000) /* 5 seconds */
sprintf(comm, "%s:%i (%2.2fs)", c->comm, p->pid, c->total_time / (double)NSEC_PER_SEC);
else
sprintf(comm, "%s:%i (%3.1fms)", c->comm, p->pid, c->total_time / (double)NSEC_PER_MSEC);
svg_text(Y, c->start_time, comm);
}
Reported by FlawFinder.
Line: 1291
Column: 6
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
if (c->total_time > 5000000000) /* 5 seconds */
sprintf(comm, "%s:%i (%2.2fs)", c->comm, p->pid, c->total_time / (double)NSEC_PER_SEC);
else
sprintf(comm, "%s:%i (%3.1fms)", c->comm, p->pid, c->total_time / (double)NSEC_PER_MSEC);
svg_text(Y, c->start_time, comm);
}
c->Y = Y;
Y++;
Reported by FlawFinder.
Line: 1082
Column: 4
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
if (!task_from) {
task_from = malloc(40);
sprintf(task_from, "[%i]", we->waker);
}
if (!task_to) {
task_to = malloc(40);
sprintf(task_to, "[%i]", we->wakee);
}
Reported by FlawFinder.
Line: 1086
Column: 4
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
}
if (!task_to) {
task_to = malloc(40);
sprintf(task_to, "[%i]", we->wakee);
}
if (we->waker == -1)
svg_interrupt(we->time, to, we->backtrace);
else if (from && to && abs(from - to) == 1)
Reported by FlawFinder.
Line: 1135
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
{
const char *suf;
double bytes;
char comm[256];
struct per_pid *p;
struct per_pidcomm *c;
struct io_sample *sample;
int Y = 1;
Reported by FlawFinder.
Line: 1287
Column: 5
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
}
if (c->comm) {
char comm[256];
if (c->total_time > 5000000000) /* 5 seconds */
sprintf(comm, "%s:%i (%2.2fs)", c->comm, p->pid, c->total_time / (double)NSEC_PER_SEC);
else
sprintf(comm, "%s:%i (%3.1fms)", c->comm, p->pid, c->total_time / (double)NSEC_PER_MSEC);
Reported by FlawFinder.
tools/testing/selftests/rtc/rtctest.c
7 issues
Line: 31
Column: 13
CWE codes:
362
};
FIXTURE_SETUP(rtc) {
self->fd = open(rtc_file, O_RDONLY);
ASSERT_NE(-1, self->fd);
}
FIXTURE_TEARDOWN(rtc) {
close(self->fd);
Reported by FlawFinder.
Line: 154
Column: 7
CWE codes:
120
20
rc = ioctl(self->fd, RTC_AIE_OFF, 0);
ASSERT_NE(-1, rc);
rc = read(self->fd, &data, sizeof(unsigned long));
ASSERT_NE(-1, rc);
TH_LOG("data: %lx", data);
rc = ioctl(self->fd, RTC_RD_TIME, &tm);
ASSERT_NE(-1, rc);
Reported by FlawFinder.
Line: 204
Column: 7
CWE codes:
120
20
ASSERT_NE(-1, rc);
ASSERT_NE(0, rc);
rc = read(self->fd, &data, sizeof(unsigned long));
ASSERT_NE(-1, rc);
rc = ioctl(self->fd, RTC_RD_TIME, &tm);
ASSERT_NE(-1, rc);
Reported by FlawFinder.
Line: 256
Column: 7
CWE codes:
120
20
rc = ioctl(self->fd, RTC_AIE_OFF, 0);
ASSERT_NE(-1, rc);
rc = read(self->fd, &data, sizeof(unsigned long));
ASSERT_NE(-1, rc);
TH_LOG("data: %lx", data);
rc = ioctl(self->fd, RTC_RD_TIME, &tm);
ASSERT_NE(-1, rc);
Reported by FlawFinder.
Line: 306
Column: 7
CWE codes:
120
20
ASSERT_NE(-1, rc);
ASSERT_NE(0, rc);
rc = read(self->fd, &data, sizeof(unsigned long));
ASSERT_NE(-1, rc);
rc = ioctl(self->fd, RTC_RD_TIME, &tm);
ASSERT_NE(-1, rc);
Reported by FlawFinder.
tools/testing/selftests/rseq/param_test.c
7 issues
Line: 58
Column: 4
CWE codes:
134
Suggestion:
Use a constant for the format specification
#define printf_verbose(fmt, ...) \
do { \
if (verbose) \
printf(fmt, ## __VA_ARGS__); \
} while (0)
#ifdef __i386__
#define INJECT_ASM_REG "eax"
Reported by FlawFinder.
Line: 988
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
offset = buffer->c[cpu].offset;
if (offset == 0)
return false;
memcpy(item, &buffer->c[cpu].array[offset - 1], sizeof(*item));
buffer->c[cpu].offset = offset - 1;
return true;
}
void *test_percpu_memcpy_buffer_thread(void *arg)
Reported by FlawFinder.
Line: 1400
Column: 33
CWE codes:
190
Suggestion:
If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)
show_usage(argc, argv);
goto error;
}
loop_cnt[argv[i][1] - '0'] = atol(argv[i + 1]);
i++;
break;
case 'm':
if (argc < i + 2) {
show_usage(argc, argv);
Reported by FlawFinder.
Line: 1408
Column: 17
CWE codes:
190
Suggestion:
If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)
show_usage(argc, argv);
goto error;
}
opt_modulo = atol(argv[i + 1]);
if (opt_modulo < 0) {
show_usage(argc, argv);
goto error;
}
i++;
Reported by FlawFinder.
Line: 1420
Column: 16
CWE codes:
190
Suggestion:
If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)
show_usage(argc, argv);
goto error;
}
opt_sleep = atol(argv[i + 1]);
if (opt_sleep < 0) {
show_usage(argc, argv);
goto error;
}
i++;
Reported by FlawFinder.
Line: 1441
Column: 22
CWE codes:
190
Suggestion:
If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)
show_usage(argc, argv);
goto error;
}
opt_disable_mod = atol(argv[i + 1]);
if (opt_disable_mod < 0) {
show_usage(argc, argv);
goto error;
}
i++;
Reported by FlawFinder.
Line: 1453
Column: 18
CWE codes:
190
Suggestion:
If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended)
show_usage(argc, argv);
goto error;
}
opt_threads = atol(argv[i + 1]);
if (opt_threads < 0) {
show_usage(argc, argv);
goto error;
}
i++;
Reported by FlawFinder.
tools/bpf/bpf_jit_disasm.c
7 issues
Line: 46
Column: 8
CWE codes:
362
20
Suggestion:
Reconsider approach
path = strdup(tpath);
assert(path);
len = readlink(path, tpath, size);
tpath[len] = 0;
free(path);
}
Reported by FlawFinder.
Line: 67
Column: 55
CWE codes:
134
Suggestion:
Use a constant for the format specification
assert(bfdf);
assert(bfd_check_format(bfdf, bfd_object));
init_disassemble_info(&info, stdout, (fprintf_ftype) fprintf);
info.arch = bfd_get_arch(bfdf);
info.mach = bfd_get_mach(bfdf);
info.buffer = image;
info.buffer_length = len;
Reported by FlawFinder.
Line: 271
Column: 16
CWE codes:
120
20
Suggestion:
Check implementation on installation, or limit the size of all string inputs
uint8_t *pos;
uint8_t *image = NULL;
while ((opt = getopt(argc, argv, "of:O:")) != -1) {
switch (opt) {
case 'o':
opcodes = 1;
break;
case 'O':
Reported by FlawFinder.
Line: 55
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
static void get_asm_insns(uint8_t *image, size_t len, int opcodes)
{
int count, i, pc = 0;
char tpath[PATH_MAX];
struct disassemble_info info;
disassembler_ftype disassemble;
bfd *bfdf;
memset(tpath, 0, sizeof(tpath));
Reported by FlawFinder.
Line: 132
Column: 7
CWE codes:
362
struct stat fi;
char *buff;
fd = open(file, O_RDONLY);
if (fd < 0)
return NULL;
ret = fstat(fd, &fi);
if (ret < 0 || !S_ISREG(fi.st_mode))
Reported by FlawFinder.
Line: 306
Column: 8
CWE codes:
362
goto done;
}
ofd = open(ofile, O_WRONLY | O_CREAT | O_TRUNC, DEFFILEMODE);
if (ofd < 0) {
fprintf(stderr, "Could not open file %s for writing: ", ofile);
perror(NULL);
goto done;
}
Reported by FlawFinder.
tools/power/cpupower/utils/helpers/msr.c
7 issues
Line: 29
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 read_msr(int cpu, unsigned int idx, unsigned long long *val)
{
int fd;
char msr_file_name[64];
sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
fd = open(msr_file_name, O_RDONLY);
if (fd < 0)
return -1;
Reported by FlawFinder.
Line: 31
Column: 2
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
int fd;
char msr_file_name[64];
sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
fd = open(msr_file_name, O_RDONLY);
if (fd < 0)
return -1;
if (lseek(fd, idx, SEEK_CUR) == -1)
goto err;
Reported by FlawFinder.
Line: 32
Column: 7
CWE codes:
362
char msr_file_name[64];
sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
fd = open(msr_file_name, O_RDONLY);
if (fd < 0)
return -1;
if (lseek(fd, idx, SEEK_CUR) == -1)
goto err;
if (read(fd, val, sizeof *val) != sizeof *val)
Reported by FlawFinder.
Line: 58
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 write_msr(int cpu, unsigned int idx, unsigned long long val)
{
int fd;
char msr_file_name[64];
sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
fd = open(msr_file_name, O_WRONLY);
if (fd < 0)
return -1;
Reported by FlawFinder.
Line: 60
Column: 2
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
int fd;
char msr_file_name[64];
sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
fd = open(msr_file_name, O_WRONLY);
if (fd < 0)
return -1;
if (lseek(fd, idx, SEEK_CUR) == -1)
goto err;
Reported by FlawFinder.
Line: 61
Column: 7
CWE codes:
362
char msr_file_name[64];
sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
fd = open(msr_file_name, O_WRONLY);
if (fd < 0)
return -1;
if (lseek(fd, idx, SEEK_CUR) == -1)
goto err;
if (write(fd, &val, sizeof val) != sizeof val)
Reported by FlawFinder.
tools/testing/selftests/net/ip_defrag.c
7 issues
Line: 435
Column: 14
CWE codes:
120
20
Suggestion:
Check implementation on installation, or limit the size of all string inputs
{
int c;
while ((c = getopt(argc, argv, "46opv")) != -1) {
switch (c) {
case '4':
cfg_do_ipv4 = true;
break;
case '6':
Reported by FlawFinder.
Line: 462
Column: 2
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
{
parse_opts(argc, argv);
seed = time(NULL);
srand(seed);
/* Print the seed to track/reproduce potential failures. */
printf("seed = %d\n", seed);
if (cfg_do_ipv4)
run_test_v4();
Reported by FlawFinder.
Line: 153
Column: 3
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
udphdr.check = udp6_checksum((struct ip6_hdr *)ip_frame, &udphdr);
else
udphdr.check = udp_checksum((struct ip *)ip_frame, &udphdr);
memcpy(frag_start, &udphdr, UDP_HLEN);
}
if (ipv6) {
struct ip6_hdr *ip6hdr = (struct ip6_hdr *)ip_frame;
struct ip6_frag *fraghdr = (struct ip6_frag *)(ip_frame + IP6_HLEN);
Reported by FlawFinder.
Line: 169
Column: 4
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
ip6hdr->ip6_plen = htons(frag_len);
if (offset == 0)
memcpy(frag_start + UDP_HLEN, udp_payload,
frag_len - FRAG_HLEN - UDP_HLEN);
else
memcpy(frag_start, udp_payload + payload_offset,
frag_len - FRAG_HLEN);
frag_len += IP6_HLEN;
Reported by FlawFinder.
Line: 172
Column: 4
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
memcpy(frag_start + UDP_HLEN, udp_payload,
frag_len - FRAG_HLEN - UDP_HLEN);
else
memcpy(frag_start, udp_payload + payload_offset,
frag_len - FRAG_HLEN);
frag_len += IP6_HLEN;
} else {
struct ip *iphdr = (struct ip *)ip_frame;
if (payload_len - payload_offset <= max_frag_len && offset > 0) {
Reported by FlawFinder.
Line: 187
Column: 4
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
}
iphdr->ip_len = htons(frag_len);
if (offset == 0)
memcpy(frag_start + UDP_HLEN, udp_payload,
frag_len - IP4_HLEN - UDP_HLEN);
else
memcpy(frag_start, udp_payload + payload_offset,
frag_len - IP4_HLEN);
}
Reported by FlawFinder.
Line: 190
Column: 4
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
memcpy(frag_start + UDP_HLEN, udp_payload,
frag_len - IP4_HLEN - UDP_HLEN);
else
memcpy(frag_start, udp_payload + payload_offset,
frag_len - IP4_HLEN);
}
res = sendto(fd_raw, ip_frame, frag_len, 0, addr, alen);
if (res < 0 && errno != EPERM)
Reported by FlawFinder.