Date: Sat, 7 Jun 2008 22:15:59 GMT From: Rui Paulo <rpaulo@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 143091 for review Message-ID: <200806072215.m57MFxEx080249@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=143091 Change 143091 by rpaulo@rpaulo_epsilon on 2008/06/07 22:15:30 Add error checking. Affected files ... .. //depot/projects/soc2008/rpaulo-tcpad/Makefile#5 edit .. //depot/projects/soc2008/rpaulo-tcpad/dumper.c#5 edit Differences ... ==== //depot/projects/soc2008/rpaulo-tcpad/Makefile#5 (text+ko) ==== @@ -1,8 +1,9 @@ -# $P4: //depot/projects/soc2008/rpaulo-tcpad/Makefile#4 $ +# $P4: //depot/projects/soc2008/rpaulo-tcpad/Makefile#5 $ PROG=tcpad SRCS=main.c device.c linkhdr.c handler.c dumper.c CFLAGS+=-DDEBUG +WARNS=5 LDADD=-lpcap .include <bsd.prog.mk> ==== //depot/projects/soc2008/rpaulo-tcpad/dumper.c#5 (text+ko) ==== @@ -23,7 +23,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/soc2008/rpaulo-tcpad/dumper.c#4 $ + * $P4: //depot/projects/soc2008/rpaulo-tcpad/dumper.c#5 $ */ #include <string.h> @@ -43,6 +43,10 @@ struct dumppkt *dp; dp = malloc(sizeof(*dp)); + if (dp == NULL) { + fprintf(stderr, "%s: malloc failed\n", __func__); + return; + } memcpy(&dp->pheader, ph, sizeof(struct pcap_pkthdr)); memcpy(&dp->headers, headers, sizeof(dp->headers)); /* XXX: honour the size of this list */ @@ -59,7 +63,11 @@ struct dumppkt *dp; pd = pcap_dump_open(p, path); + if (pd == NULL) { + fprintf(stderr, "%s: %s\n", __func__, pcap_geterr(p)); + return; + } TAILQ_FOREACH(dp, head, entries) - pcap_dump((u_char *)pd, &dp->pheader, dp->headers); + pcap_dump((u_char *)pd, &dp->pheader, dp->headers); pcap_dump_close(pd); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806072215.m57MFxEx080249>