git: 1486bb0bfcac - stable/13 - Fix lib/libc/nss/getgr_test with large numbers of groups
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 20 Jan 2025 22:42:08 UTC
The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=1486bb0bfcacafe5dd1c2f3add7b92e57f7e1ff2 commit 1486bb0bfcacafe5dd1c2f3add7b92e57f7e1ff2 Author: Alan Somers <asomers@FreeBSD.org> AuthorDate: 2024-12-31 20:41:01 +0000 Commit: Alan Somers <asomers@FreeBSD.org> CommitDate: 2025-01-20 22:41:52 +0000 Fix lib/libc/nss/getgr_test with large numbers of groups These tests create a linked list with one entry for every group on the running system. On a system with about 30,000 groups, the test took 69 seconds to run, and crashed Kyua with the below error: kyua: E: string or blob too big (sqlite op: sqlite3_bind_blob) (sqlite db: /root/.kyua/store/results.usr_tests.20241231-203317-570235.db). Fix the test by limiting it to operating on the first 1024 groups. Apply the same change to getpw_test and getserv_test too, which are vulnerable to the same problem. Sponsored by: ConnectWise Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D48275 (cherry picked from commit d11904b350214943dedb64c7121d4602799d7afd) --- lib/libc/tests/nss/getgr_test.c | 4 ++++ lib/libc/tests/nss/getpw_test.c | 4 ++++ lib/libc/tests/nss/getserv_test.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/lib/libc/tests/nss/getgr_test.c b/lib/libc/tests/nss/getgr_test.c index 28c5e2e98028..f3aef0e1abd1 100644 --- a/lib/libc/tests/nss/getgr_test.c +++ b/lib/libc/tests/nss/getgr_test.c @@ -294,6 +294,8 @@ group_fill_test_data(struct group_test_data *td, int (*cb)(struct group *, void *)) { struct group *grp; + const int limit = 1024; + int count = 0; setgroupent(1); while ((grp = getgrent()) != NULL) { @@ -304,6 +306,8 @@ group_fill_test_data(struct group_test_data *td, } else { return (-1); } + if (++count >= limit) + break; } endgrent(); diff --git a/lib/libc/tests/nss/getpw_test.c b/lib/libc/tests/nss/getpw_test.c index 7525cd28b962..94b8b9373272 100644 --- a/lib/libc/tests/nss/getpw_test.c +++ b/lib/libc/tests/nss/getpw_test.c @@ -241,6 +241,8 @@ passwd_fill_test_data(struct passwd_test_data *td, int (*cb)(struct passwd *, void *)) { struct passwd *pwd; + const int limit = 1024; + int count = 0; setpassent(1); while ((pwd = getpwent()) != NULL) { @@ -251,6 +253,8 @@ passwd_fill_test_data(struct passwd_test_data *td, } else { return (-1); } + if (++count >= limit) + break; } endpwent(); diff --git a/lib/libc/tests/nss/getserv_test.c b/lib/libc/tests/nss/getserv_test.c index d74feb113a69..d7fce475d70d 100644 --- a/lib/libc/tests/nss/getserv_test.c +++ b/lib/libc/tests/nss/getserv_test.c @@ -284,6 +284,8 @@ static int servent_fill_test_data(struct servent_test_data *td) { struct servent *serv; + const int limit = 1024; + int count = 0; setservent(1); while ((serv = getservent()) != NULL) { @@ -291,6 +293,8 @@ servent_fill_test_data(struct servent_test_data *td) TEST_DATA_APPEND(servent, td, serv); else return (-1); + if (++count >= limit) + break; } endservent();