代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/systemd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 61ca9b34258e4786d9a8e68b9b28c4e794a65d1f Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Tue, 28 Sep 2021 00:48:59 +0900
Subject: [PATCH] test: add tests for reading unaligned data
(cherry picked from commit e620104956dff64244c0e73e86c3138c0b13b875)
Conflict:NA
Reference:https://github.com/systemd/systemd/commit/61ca9b34258e4786d9a8e68b9b28c4e794a65d1f
---
src/libsystemd-network/test-dhcp6-client.c | 29 ++++++++++++++++------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c
index 5d1f709f11..b22297dcd5 100644
--- a/src/libsystemd-network/test-dhcp6-client.c
+++ b/src/libsystemd-network/test-dhcp6-client.c
@@ -156,7 +156,7 @@ static int test_parse_domain(sd_event *e) {
static int test_option(sd_event *e) {
uint8_t packet[] = {
- 'F', 'O', 'O',
+ 'F', 'O', 'O', 'H', 'O', 'G', 'E',
0x00, SD_DHCP6_OPTION_ORO, 0x00, 0x07,
'A', 'B', 'C', 'D', 'E', 'F', 'G',
0x00, SD_DHCP6_OPTION_VENDOR_CLASS, 0x00, 0x09,
@@ -164,12 +164,13 @@ static int test_option(sd_event *e) {
'B', 'A', 'R',
};
uint8_t result[] = {
- 'F', 'O', 'O',
+ 'F', 'O', 'O', 'H', 'O', 'G', 'E',
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
'B', 'A', 'R',
};
+ _cleanup_free_ uint8_t *buf = NULL;
size_t offset, pos, optlen, outlen = sizeof(result);
const uint8_t *optval;
uint16_t optcode;
@@ -185,16 +186,28 @@ static int test_option(sd_event *e) {
offset = 3;
assert_se(dhcp6_option_parse(packet, 0, &offset, &optcode, &optlen, &optval) == -EBADMSG);
- offset = 3;
+ /* Tests for reading unaligned data. */
+ assert_se(buf = new(uint8_t, sizeof(packet)));
+ for (size_t i = 0; i <= 7; i++) {
+ memcpy(buf, packet + i, sizeof(packet) - i);
+ offset = 7 - i;
+ assert_se(dhcp6_option_parse(buf, sizeof(packet), &offset, &optcode, &optlen, &optval) >= 0);
+
+ assert_se(optcode == SD_DHCP6_OPTION_ORO);
+ assert_se(optlen == 7);
+ assert_se(optval == buf + 11 - i);
+ }
+
+ offset = 7;
assert_se(dhcp6_option_parse(packet, sizeof(packet), &offset, &optcode, &optlen, &optval) >= 0);
assert_se(optcode == SD_DHCP6_OPTION_ORO);
assert_se(optlen == 7);
- assert_se(optval == packet + 7);
+ assert_se(optval == packet + 11);
- pos = 3;
- outlen -= 3;
- out = &result[3];
+ pos = 7;
+ outlen -= 7;
+ out = &result[pos];
assert_se(dhcp6_option_append(&out, &outlen, optcode, optlen, optval) >= 0);
@@ -206,7 +219,7 @@ static int test_option(sd_event *e) {
assert_se(optcode == SD_DHCP6_OPTION_VENDOR_CLASS);
assert_se(optlen == 9);
- assert_se(optval == packet + 18);
+ assert_se(optval == packet + 22);
assert_se(dhcp6_option_append(&out, &outlen, optcode, optlen, optval) >= 0);
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。