From 2be7a39beaa4e640153f5a5919db93fff2a11700 Mon Sep 17 00:00:00 2001 From: Luke Dennis Date: Thu, 9 Jun 2022 12:54:46 +1000 Subject: [PATCH] Add check for n_users to prevent segfault When doinkd is started with 0 current users, `user` is uninitialised when passed to `chk_maxuser()`. Adding this check prevents `user` being accessed when unitialised. --- doinkd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doinkd.c b/doinkd.c index 4a6f6d8..90e2517 100644 --- a/doinkd.c +++ b/doinkd.c @@ -651,7 +651,7 @@ void chk_maxuser(user, n_users) int grpcnt = 0; int tgrpcnt = 0; - if (user->mgroup != 0) { + if (n_users && user->mgroup != 0) { for (i = 0; i < n_users; i++) { if ( (*pusers[i]).uid == user->uid) who = i;