From nobody@FreeBSD.org  Tue Mar  8 02:04:57 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B34A2106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  8 Mar 2011 02:04:57 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id A35458FC19
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  8 Mar 2011 02:04:57 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p2824vO5006847
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 8 Mar 2011 02:04:57 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p2824vH1006846;
	Tue, 8 Mar 2011 02:04:57 GMT
	(envelope-from nobody)
Message-Id: <201103080204.p2824vH1006846@red.freebsd.org>
Date: Tue, 8 Mar 2011 02:04:57 GMT
From: HIROSHI OOTA <nil@mad.dog.cx>
To: freebsd-gnats-submit@FreeBSD.org
Subject: description string is broken
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         155370
>Category:       kern
>Synopsis:       [libpcap] [patch] description string is broken
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    wxs
>State:          feedback
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 08 02:10:01 UTC 2011
>Closed-Date:    
>Last-Modified:  Sun Apr 15 20:30:36 UTC 2012
>Originator:     HIROSHI OOTA
>Release:        9-current
>Organization:
>Environment:
FreeBSD xxxx 9.0-CURRENT FreeBSD 9.0-CURRENT #130 r219237: Fri Mar  4 03:45:57 JST 2011     root@  amd64

>Description:
a description string which is returned from pcap_findalldevs(3) is broken.
>How-To-Repeat:
tcpdump -D
>Fix:


Patch attached with submission follows:

Index: contrib/libpcap/inet.c
===================================================================
--- contrib/libpcap/inet.c	(revision 219237)
+++ contrib/libpcap/inet.c	(working copy)
@@ -432,9 +432,11 @@
 	s = socket(AF_INET, SOCK_DGRAM, 0);
 	if (s >= 0) {
 		for (;;) {
-			free(description);
+			if (description)
+				free(description);
 			if ((description = malloc(descrlen)) != NULL) {
 #ifdef __FreeBSD__
+				description[0] = 0;
 				ifrdesc.ifr_buffer.buffer = description;
 				ifrdesc.ifr_buffer.length = descrlen;
 #else /* __FreeBSD__ */
@@ -467,7 +469,8 @@
 		 */
 		return (-1);
 	}
-	free(description);
+	if (description)
+		free(description);
 	if (curdev == NULL) {
 		/*
 		 * Device wasn't added because it can't be opened.


>Release-Note:
>Audit-Trail:

From: Wesley Shields <wxs@FreeBSD.org>
To: nil@mad.dog.cx
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/155370: [libpcap] [patch] description string is broken
Date: Sat, 29 Oct 2011 22:41:07 -0400

 Would you be able to provide an example of this? I can't seem to be able
 to reproduce it.
 
 -- WXS
State-Changed-From-To: open->feedback 
State-Changed-By: eadler 
State-Changed-When: Sun Apr 15 20:30:32 UTC 2012 
State-Changed-Why:  
wxs@ asked 'Would you be able to provide an example of this? I can't 
seem to be able to reproduce it. 


Responsible-Changed-From-To: freebsd-bugs->wxs 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sun Apr 15 20:30:32 UTC 2012 
Responsible-Changed-Why:  
wxs@ asked 'Would you be able to provide an example of this? I can't 
seem to be able to reproduce it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155370 
>Unformatted:
