From 89b93a44d1ce24ec208ee244f7e5b1689fc6ff1a Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Thu, 11 Oct 2012 10:37:38 +0200 Subject: nss_cmd_retpwent(): do not go into infinite loop if n < 0 https://fedorahosted.org/sssd/ticket/1551 --- src/responder/nss/nsssrv_cmd.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c index 370c3d29..26a34736 100644 --- a/src/responder/nss/nsssrv_cmd.c +++ b/src/responder/nss/nsssrv_cmd.c @@ -1618,6 +1618,14 @@ static int nss_cmd_retpwent(struct cli_ctx *cctx, int num) if (!n) break; + if (n < 0) { + DEBUG(SSSDBG_CRIT_FAILURE, ("BUG: Negative difference" + "[%d - %d = %d]\n", pdom->res->count, cctx->pwent_cur, n)); + DEBUG(SSSDBG_CRIT_FAILURE, ("Domain: %d (total %d)\n", + cctx->pwent_dom_idx, pctx->num)); + break; + } + if (n > num) n = num; msgs = &(pdom->res->msgs[cctx->pwent_cur]); -- cgit