mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
db929e0fcf
Previously, attempting to update an ext2 inode with a UID or GID larger than 65535 would overflow. We now write the high bits of UIDs and GIDs to the same place that Linux does within the `osd2` struct.
31 lines
697 B
C++
31 lines
697 B
C++
/*
|
|
* Copyright (c) 2023, Tim Ledbetter <timledbetter@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibTest/TestCase.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
|
|
TEST_CASE(test_uid_and_gid_high_bits_are_set)
|
|
{
|
|
static constexpr auto TEST_FILE_PATH = "/home/anon/.ext2_test";
|
|
|
|
auto uid = geteuid();
|
|
EXPECT_EQ(uid, 0u);
|
|
|
|
auto fd = open(TEST_FILE_PATH, O_CREAT);
|
|
auto cleanup_guard = ScopeGuard([&] {
|
|
close(fd);
|
|
unlink(TEST_FILE_PATH);
|
|
});
|
|
|
|
EXPECT_EQ(setuid(0), 0);
|
|
EXPECT_EQ(fchown(fd, 65536, 65536), 0);
|
|
|
|
struct stat st;
|
|
EXPECT_EQ(fstat(fd, &st), 0);
|
|
EXPECT_EQ(st.st_uid, 65536u);
|
|
EXPECT_EQ(st.st_gid, 65536u);
|
|
}
|