diff --git a/lib/libc/tests/nss/getgr_test.c b/lib/libc/tests/nss/getgr_test.c --- a/lib/libc/tests/nss/getgr_test.c +++ b/lib/libc/tests/nss/getgr_test.c @@ -293,6 +293,8 @@ int (*cb)(struct group *, void *)) { struct group *grp; + const int limit = 1024; + int count = 0; setgroupent(1); while ((grp = getgrent()) != NULL) { @@ -303,6 +305,8 @@ } 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 --- a/lib/libc/tests/nss/getpw_test.c +++ b/lib/libc/tests/nss/getpw_test.c @@ -240,6 +240,8 @@ int (*cb)(struct passwd *, void *)) { struct passwd *pwd; + const int limit = 1024; + int count = 0; setpassent(1); while ((pwd = getpwent()) != NULL) { @@ -250,6 +252,8 @@ } 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 --- a/lib/libc/tests/nss/getserv_test.c +++ b/lib/libc/tests/nss/getserv_test.c @@ -283,6 +283,8 @@ 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) { @@ -290,6 +292,8 @@ TEST_DATA_APPEND(servent, td, serv); else return (-1); + if (++count >= limit) + break; } endservent();