From: Landry Breuil Date: Wed, 24 Jun 2015 04:48:16 +0000 (+0200) Subject: properly handle error cases when kvm_read fails (#1094) X-Git-Tag: collectd-5.5.1~68^2~18 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=924c9af78d535f4920d73a2cd8e5090747479f0f;p=collectd.git properly handle error cases when kvm_read fails (#1094) --- 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) */