test: fix -Wstringop-overread warning (#4993)

Check the length before doing the compare like we do a few lines below,
not the other way around. It's a false positive because the length is
capped well below the maximum object size but it's an easy fix.

Fixes the following warning:

    test/test-poll-oob.c:94:19: warning: ‘strncmp’ specified bound
    [18446744071562067968, 18446744073709551615] exceeds maximum
    object size 9223372036854775807 [-Wstringop-overread]
This commit is contained in:
Ben Noordhuis 2026-01-13 14:35:19 +01:00 committed by GitHub
parent f420c2bd57
commit d67f9d2fba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -91,8 +91,8 @@ static void poll_cb(uv_poll_t* handle, int status, int events) {
while (n == -1 && errno == EINTR); while (n == -1 && errno == EINTR);
ASSERT(n >= 0 || errno != EINVAL); ASSERT(n >= 0 || errno != EINVAL);
if (cli_rd_check == 1) { if (cli_rd_check == 1) {
ASSERT_OK(strncmp(buffer, "world", n));
ASSERT_EQ(5, n); ASSERT_EQ(5, n);
ASSERT_OK(strncmp(buffer, "world", n));
cli_rd_check = 2; cli_rd_check = 2;
} }
if (cli_rd_check == 0) { if (cli_rd_check == 0) {