From 924c9af78d535f4920d73a2cd8e5090747479f0f Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Wed, 24 Jun 2015 06:48:16 +0200 Subject: [PATCH] properly handle error cases when kvm_read fails (#1094) --- src/tcpconns.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tcpconns.c b/src/tcpconns.c index f4c61d53..bf07a2a2 100644 --- a/src/tcpconns.c +++ b/src/tcpconns.c @@ -931,7 +931,9 @@ static int conn_read (void) while (next != head) { /* Read the pcb pointed to by `next' into `inpcb' */ - kread ((u_long) next, &inpcb, sizeof (inpcb)); + status = kread ((u_long) next, &inpcb, sizeof (inpcb)); + if (status != 0) + return (-1); /* Advance `next' */ next = (struct inpcb *)CIRCLEQ_NEXT (&inpcb, inp_queue); @@ -949,7 +951,9 @@ static int conn_read (void) continue; #endif - kread ((u_long) inpcb.inp_ppcb, &tcpcb, sizeof (tcpcb)); + status = kread ((u_long) inpcb.inp_ppcb, &tcpcb, sizeof (tcpcb)); + if (status != 0) + return (-1); conn_handle_ports (ntohs(inpcb.inp_lport), ntohs(inpcb.inp_fport), tcpcb.t_state); } /* while (next != head) */ -- 2.11.0