Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 tcpick (0.2.1-6.1) UNRELEASED; urgency=medium
 .
   * Non-maintainer upload (but really a QA upload as maintainer is likely
     MIA).
   * Change source format to 3.0 (quilt) so that we can properly handle
     upstream patches.
Author: Raphaël Hertzog <hertzog@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- tcpick-0.2.1.orig/src/args.c
+++ tcpick-0.2.1/src/args.c
@@ -149,7 +149,7 @@ parse_display_rebuild ( char * s )
 void
 parse_args(int argc, char ** argv)
 {
-	char opt;
+	int opt;
 
 #ifdef HAVE_GETOPT_LONG
 	static struct option long_options[]=
@@ -386,7 +386,7 @@ parse_args(int argc, char ** argv)
 	if(flags.versionandquit) {
 		color( c_USAGE, stdout, PACKAGE_STRING "\n"
 			     " Author: " AUTHOR "\n"
-			     " for other info try `man 1 tcpick', or `%s --help'\n\n"
+			     " for other info try `man tcpick', or `%s --help'\n\n"
 			     TERMS ,TCPICK_NAME);
 		exit( TCPICK_SUCCESS );
 	}
--- /dev/null
+++ tcpick-0.2.1/src/datalink.h
@@ -0,0 +1,29 @@
+/*
+ * datalink.h -- calculates datalink offsets
+ * Part of the tcpick project
+ *
+ * Author: Francesco Stablum <duskdruid @ despammed.com>
+ *
+ * Copyright (C) 2003, 2004  Francesco Stablum
+ * Licensed under the GPL
+ *
+ */
+
+/* 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at you option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111,
+ * USA.
+ */
+
+char *datalink2str(int dl_id);
--- tcpick-0.2.1.orig/src/display.c
+++ tcpick-0.2.1/src/display.c
@@ -28,6 +28,7 @@
 /* FIXME: most code is duplicated: find a better solution! */
 
 #include "tcpick.h"
+#include "lookup.h"
 #include "extern.h"
 
 char * 
--- tcpick-0.2.1.orig/src/lookup.h
+++ tcpick-0.2.1/src/lookup.h
@@ -26,6 +26,8 @@
  * USA.
  */
 
+#ifndef _LOOKUP_H
+#define _LOOKUP_H
 
 struct _l_node /* the node/leaf of the tree */
 {
@@ -40,3 +42,9 @@ struct _l_node /* the node/leaf of the t
 	char * name;
 	struct in_addr ip;
 };
+
+char *lookup(struct in_addr ia);
+struct _l_node *_l_alloc(struct in_addr, char *);
+char *_l_get(struct in_addr);
+
+#endif
--- tcpick-0.2.1.orig/src/tcpick.c
+++ tcpick-0.2.1/src/tcpick.c
@@ -49,6 +49,7 @@
 
 #include "tcpick.h"
 #include "globals.h"
+#include "datalink.h"
 
 char *errbuf[PCAP_ERRBUF_SIZE];
 struct bpf_program filter_compiled;
--- tcpick-0.2.1.orig/src/tracker.c
+++ tcpick-0.2.1/src/tracker.c
@@ -99,8 +99,9 @@ int rmconn( struct CONN * prev_ring )
 	if( curr->next == NULL )
 		last_conn = prev_ring;
 	
-	free_desc( &(curr->client) );
-	free_desc( &(curr->server) );
+	free_desc( &(curr->client), 1);
+	if (flags.writer.type == UNIQUE) free_desc( &(curr->server), 0);
+	else free_desc( &(curr->server), 1);
 	S_free( curr );
 
 	conn = first_conn;
@@ -124,7 +125,7 @@ int rmconn( struct CONN * prev_ring )
 		count_opened--;
 }
 
-int free_desc( struct HOST_DESC * desc )
+int free_desc( struct HOST_DESC * desc, int freedescfilename )
 /* frees the host descriptor and closes the file */
 {
 	struct FRAGMENT * tmp;
@@ -134,7 +135,7 @@ int free_desc( struct HOST_DESC * desc )
 		if (flags.writer.type == UNIQUE)
 			desc->oth->file = NULL;
 	}
-	if( desc->filename ) {
+	if( desc->filename && freedescfilename ) {
 		S_free( desc->filename );
 		desc->filename = NULL;
 	}
--- tcpick-0.2.1.orig/src/write.c
+++ tcpick-0.2.1/src/write.c
@@ -25,8 +25,11 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
+#define _GNU_SOURCE
+#include <string.h>
 #include "tcpick.h"
 #include "extern.h"
+#include "lookup.h"
 
 __inline__ char * 
 avail_filename(struct CONN * conn_ptr, 
@@ -241,6 +244,9 @@ out_flavour( enum FLAVOUR flavour,
 	if( flags.separator && ( out == stdout ) ) /* FIXME: sucks? */
 		color( c_SEPARATOR, stdout, SEPARATOR "\n" );
 
+	/* Temporary fix for CVE-2006-0048 */
+	if (buflen < 0) buflen = 0;
+	
 	switch ( flavour ) {
 	case HEX_ASCII_DUMP:
 		out_xa( out, buf, buflen );
