The following issues were found
Userland/Utilities/sql.cpp
1 issues
Line: 213
Column: 25
CWE codes:
807
Suggestion:
Use getpwuid(geteuid()) and extract the desired information instead
loop.quit(0);
};
sql_client->connect(getlogin());
auto rc = loop.exec();
s_editor->save_history(s_history_path);
return rc;
Reported by FlawFinder.
AK/Stream.h
1 issues
Line: 60
Column: 20
CWE codes:
120
20
public:
// Reads at least one byte unless none are requested or none are available. Does nothing
// and returns zero if there is already an error.
virtual size_t read(Bytes) = 0;
// If this function returns true, then no more data can be read. If read(Bytes) previously
// returned zero even though bytes were requested, then the inverse is true as well.
virtual bool unreliable_eof() const = 0;
Reported by FlawFinder.
Userland/Utilities/whoami.cpp
1 issues
Line: 24
Column: 10
CWE codes:
807
Suggestion:
Use getpwuid(geteuid()) and extract the desired information instead
unveil(nullptr, nullptr);
puts(getlogin());
return 0;
}
Reported by FlawFinder.
Userland/Utilities/su.cpp
1 issues
Line: 81
Column: 5
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
return 1;
}
execl(account.shell().characters(), account.shell().characters(), nullptr);
perror("execl");
return 1;
}
Reported by FlawFinder.
Userland/Services/DHCPClient/DHCPv4Client.cpp
1 issues
Line: 167
Column: 16
CWE codes:
362
Result<DHCPv4Client::Interfaces, String> DHCPv4Client::get_discoverable_interfaces()
{
auto file = Core::File::construct("/proc/net/adapters");
if (!file->open(Core::OpenMode::ReadOnly)) {
dbgln("Error: Failed to open /proc/net/adapters: {}", file->error_string());
return String { file->error_string() };
}
auto file_contents = file->read_all();
Reported by FlawFinder.
Kernel/Arch/x86/common/Interrupts.cpp
1 issues
Line: 391
Column: 42
CWE codes:
362/367!
Suggestion:
Set up the correct permissions (e.g., using setuid()) and try to open the file directly
if (fault.is_instruction_fetch())
fault_access = "Execute";
else
fault_access = fault.access() == PageFault::Access::Read ? "Read" : "Write";
(void)current_process.try_set_coredump_property("fault_access", fault_access);
}
}
handle_crash(regs, "Page Fault", SIGSEGV, response == PageFaultResponse::OutOfMemory);
Reported by FlawFinder.
Userland/Services/EchoServer/Client.cpp
1 issues
Line: 20
Column: 30
CWE codes:
120
20
{
NonnullRefPtr<Client> protect(*this);
while (m_socket->can_read()) {
auto buf = m_socket->read(1024);
dbgln("Read {} bytes.", buf.size());
if (m_socket->eof()) {
quit();
Reported by FlawFinder.
Kernel/Interrupts/APIC.cpp
1 issues
Line: 303
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
// * aps_to_enable u32 values for ap_cpu_init_stacks
// * aps_to_enable u32 values for ap_cpu_init_processor_info_array
auto apic_startup_region = create_identity_mapped_region(PhysicalAddress(0x8000), Memory::page_round_up(apic_ap_start_size + (2 * aps_to_enable * sizeof(u32))));
memcpy(apic_startup_region->vaddr().as_ptr(), reinterpret_cast<const void*>(apic_ap_start), apic_ap_start_size);
// Allocate enough stacks for all APs
Vector<OwnPtr<Memory::Region>> apic_ap_stacks;
for (u32 i = 0; i < aps_to_enable; i++) {
auto stack_region = MM.allocate_kernel_region(Thread::default_kernel_stack_size, {}, Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow);
Reported by FlawFinder.
AK/MappedFile.cpp
1 issues
Line: 20
Column: 14
CWE codes:
362
Result<NonnullRefPtr<MappedFile>, OSError> MappedFile::map(String const& path)
{
int fd = open(path.characters(), O_RDONLY | O_CLOEXEC, 0);
if (fd < 0)
return OSError(errno);
return map_from_fd_and_close(fd, path);
}
Reported by FlawFinder.
Kernel/Heap/SlabAllocator.cpp
1 issues
Line: 96
Column: 9
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
private:
struct FreeSlab {
FreeSlab* next;
char padding[templated_slab_size - sizeof(FreeSlab*)];
};
Atomic<FreeSlab*> m_freelist { nullptr };
Atomic<size_t, AK::MemoryOrder::memory_order_relaxed> m_num_allocated;
size_t m_slab_count;
Reported by FlawFinder.