The following issues were found
Tests/LibCpp/test-cpp-preprocessor.cpp
1 issues
Line: 21
Column: 31
CWE codes:
362
static String read_all(const String& path)
{
auto result = Core::File::open(path, Core::OpenMode::ReadOnly);
VERIFY(!result.is_error());
auto content = result.value()->read_all();
return { reinterpret_cast<const char*>(content.data()), content.size() };
}
Reported by FlawFinder.
Tests/LibCore/TestLibCoreArgsParser.cpp
1 issues
Line: 19
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
size_t idx = 0;
for (auto& argument : arguments) {
auto char_argument = new char[argument.length() + 1];
memcpy(char_argument, argument.characters(), argument.length());
char_argument[argument.length()] = '\0';
argv[idx++] = char_argument;
}
argv[idx++] = nullptr;
return argv;
Reported by FlawFinder.
Tests/LibC/snprintf-correctness.cpp
1 issues
Line: 66
Column: 25
CWE codes:
134
Suggestion:
Use a constant for the format specification
char* dst = reinterpret_cast<char*>(actual.offset_pointer(SANDBOX_CANARY_SIZE));
// The actual call:
int actual_return = snprintf(dst, testcase.dest_n, testcase.fmt, testcase.arg);
// Checking the results:
bool return_ok = actual_return == testcase.expected_return;
bool canary_1_ok = actual.slice(0, SANDBOX_CANARY_SIZE) == expected.slice(0, SANDBOX_CANARY_SIZE);
bool main_ok = actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n) == expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n);
Reported by FlawFinder.
Tests/LibC/memmem-tests.cpp
1 issues
Line: 49
Column: 5
CWE codes:
134
Suggestion:
Use a constant for the format specification
++i;
}
printf(failed ? "FAIL\n" : "PASS\n");
return failed ? 1 : 0;
}
Reported by FlawFinder.
Tests/LibC/TestStackSmash.cpp
1 issues
Line: 24
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
// Note: Needs to be 'noline' so stack canary isn't optimized out.
static void __attribute__((noinline)) stack_to_smash()
{
char string[8] = {};
smasher(string);
}
TEST_CASE(stack_smash)
{
Reported by FlawFinder.
Tests/LibC/TestLibCString.cpp
1 issues
Line: 15
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
{
EXPECT_EQ(strerror_r(1000, nullptr, 0), EINVAL);
EXPECT_EQ(strerror_r(EFAULT, nullptr, 0), ERANGE);
char buf[64];
EXPECT_EQ(strerror_r(EFAULT, buf, sizeof(buf)), 0);
EXPECT_EQ(strcmp(buf, "Bad address"), 0);
}
Reported by FlawFinder.
Userland/Libraries/LibCore/FileWatcher.cpp
1 issues
Line: 30
Column: 14
CWE codes:
120
20
static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, String> const& wd_to_path)
{
u8 buffer[MAXIMUM_EVENT_SIZE];
int rc = read(fd, &buffer, MAXIMUM_EVENT_SIZE);
if (rc == 0) {
return {};
} else if (rc < 0) {
dbgln_if(FILE_WATCHER_DEBUG, "get_event_from_fd: Reading from wd {} failed: {}", fd, strerror(errno));
return {};
Reported by FlawFinder.
Tests/LibC/TestLibCInodeWatcher.cpp
1 issues
Tests/Kernel/kill-pidtid-confusion.cpp
1 issues
Line: 67
Column: 20
CWE codes:
676
Suggestion:
Use nanosleep(2) or setitimer(2) instead
static void sleep_steps(useconds_t steps)
{
const int rc = usleep(steps * STEP_SIZE);
if (rc < 0) {
perror("usleep");
VERIFY_NOT_REACHED();
}
}
Reported by FlawFinder.
Userland/Libraries/LibCore/LocalSocket.cpp
1 issues
Line: 89
Column: 27
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
VERIFY(!s_overtaken_sockets_parsed);
constexpr auto socket_takeover = "SOCKET_TAKEOVER";
const char* sockets = getenv(socket_takeover);
if (!sockets) {
s_overtaken_sockets_parsed = true;
return;
}
Reported by FlawFinder.