1 << COREDUMP_FILTER_SHARED_DAX)));
}
-static void test_parse_auxv_one(
+static void test_parse_auxv_two(
uint8_t elf_class,
- int dir_fd,
- const char *filename,
+ size_t offset,
+ const char *data,
+ size_t data_size,
int expect_at_secure,
uid_t expect_uid,
uid_t expect_euid,
gid_t expect_gid,
gid_t expect_egid) {
- _cleanup_free_ char *data;
- size_t data_size;
- log_info("Parsing %s…", filename);
- assert_se(read_full_file_at(dir_fd, filename, &data, &data_size) >= 0);
-
int at_secure;
uid_t uid, euid;
gid_t gid, egid;
assert_se(parse_auxv(LOG_ERR, elf_class, data, data_size,
&at_secure, &uid, &euid, &gid, &egid) == 0);
- log_info("at_secure=%d, uid="UID_FMT", euid="UID_FMT", gid="GID_FMT", egid="GID_FMT,
- at_secure, uid, euid, gid, egid);
+ log_debug("[offset=%zu] at_secure=%d, uid="UID_FMT", euid="UID_FMT", gid="GID_FMT", egid="GID_FMT,
+ offset,
+ at_secure, uid, euid, gid, egid);
assert_se(uid == expect_uid);
assert_se(euid == expect_euid);
assert_se(egid == expect_egid);
}
+static void test_parse_auxv_one(
+ uint8_t elf_class,
+ int dir_fd,
+ const char *filename,
+ int expect_at_secure,
+ uid_t expect_uid,
+ uid_t expect_euid,
+ gid_t expect_gid,
+ gid_t expect_egid) {
+
+ _cleanup_free_ char *buf;
+ const char *data;
+ size_t data_size;
+ log_info("Parsing %s…", filename);
+ assert_se(read_full_file_at(dir_fd, filename, &buf, &data_size) >= 0);
+
+ for (size_t offset = 0; offset < 8; offset++) {
+ _cleanup_free_ char *buf2 = NULL;
+
+ if (offset == 0)
+ data = buf;
+ else {
+ assert_se(buf2 = malloc(offset + data_size));
+ memcpy(buf2 + offset, buf, data_size);
+ data = buf2 + offset;
+ }
+
+ test_parse_auxv_two(elf_class, offset, data, data_size,
+ expect_at_secure, expect_uid, expect_euid, expect_gid, expect_egid);
+ }
+}
+
TEST(test_parse_auxv) {
_cleanup_free_ char *dir = NULL;
_cleanup_close_ int dir_fd = -EBADF;