From ee5dd0a0819eb8d1457cd1b58c19c813994511c7 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sun, 24 Sep 2023 20:12:42 +0200 Subject: [PATCH] lib: assert for VTY_PASSFD expectations Coverity is complaining that vty->state could be VTY_PASSFD here. It can't, it really shouldn't, and if it actually is then something went seriously wrong somewhere earlier so assert()ing out is the best thing to do. Signed-off-by: David Lamparter --- lib/vty.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/vty.c b/lib/vty.c index 8f8effa9cc..15cc340eb0 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2386,9 +2386,14 @@ static void vtysh_read(struct event *thread) * => skip vty_event(VTYSH_READ, vty)! */ return; - } else + } else { + assertf(vty->status != VTY_PASSFD, + "%p address=%s passfd=%d", vty, + vty->address, vty->pass_fd); + /* normalize other invalid values */ vty->pass_fd = -1; + } /* hack for asynchronous "write integrated" * - other commands in "buf" will be ditched