aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-07-09 23:17:05 +0000
committerGuy Harris <guy@alum.mit.edu>2004-07-09 23:17:05 +0000
commit7661a992b6e6fa0cd50ae0b9f968a131f299b3cb (patch)
tree2a1ee38f14504ad2092c0d754f48db7845689fb9
parentfe1b0f99c4015d93f71fe35a549da186d5311f2e (diff)
Move the redefinition of "isprint()" to be used by dissectors when
generating strings to put into the printable representation of protocol tree items into an "isprint.h" header, and include it in some additional dissectors. Add bounds checking to one place in the DICOM dissector. svn path=/trunk/; revision=11356
-rw-r--r--Makefile.common3
-rw-r--r--isprint.h46
-rw-r--r--packet-aim.c4
-rw-r--r--packet-cops.c5
-rw-r--r--packet-dcm.c8
-rw-r--r--packet-giop.c4
-rw-r--r--packet-radius.c22
-rw-r--r--packet-snmp.c4
-rw-r--r--packet-tds.c4
9 files changed, 73 insertions, 27 deletions
diff --git a/Makefile.common b/Makefile.common
index f93668b1f3..4aaf2059bb 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -3,7 +3,7 @@
# a) common to both files and
# b) portable between both files
#
-# $Id: Makefile.common,v 1.50 2004/06/27 00:21:56 gerald Exp $
+# $Id: Makefile.common,v 1.51 2004/07/09 23:17:02 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@@ -233,6 +233,7 @@ DISSECTOR_SUPPORT_INCLUDES = \
in_cksum.h \
ip_opts.h \
ipproto.h \
+ isprint.h \
lapd_sapi.h \
llcsaps.h \
nlpid.h \
diff --git a/isprint.h b/isprint.h
new file mode 100644
index 0000000000..7f47ad5e83
--- /dev/null
+++ b/isprint.h
@@ -0,0 +1,46 @@
+/* isprint.h
+ * Temporary redefinition of "isprint()" to cope with GTK+ 1.3 and
+ * later using UTF-8 strings
+ *
+ * $Id: isprint.h,v 1.1 2004/07/09 23:17:02 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * 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 your 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-1307, USA.
+ */
+
+#ifndef __ISPRINT_H__
+#define __ISPRINT_H__
+
+#if GLIB_MAJOR_VERSION >= 2
+/*
+ * XXX - "isprint()" can return "true" for non-ASCII characters, but
+ * those don't work with GTK+ 1.3 or later, as they take UTF-8 strings
+ * as input. Until we fix up Ethereal to properly handle non-ASCII
+ * characters in all output (both GUI displays and text printouts)
+ * in those versions of GTK+, we work around the problem by escaping
+ * all characters that aren't printable ASCII.
+ *
+ * We don't know what version of GTK+ we're using, as dissectors don't
+ * use any GTK+ stuff; we use GLib as a proxy for that, with GLib 2.x
+ * implying GTK+ 1.3 or later (we don't support GLib 1.3[.x]).
+ */
+#undef isprint
+#define isprint(c) (c >= 0x20 && c < 0x7f)
+#endif
+
+#endif
diff --git a/packet-aim.c b/packet-aim.c
index b2e8d86c8d..461ef6eac9 100644
--- a/packet-aim.c
+++ b/packet-aim.c
@@ -4,7 +4,7 @@
* Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
* Copyright 2004, Devin Heitmueller <dheitmueller@netilla.com>
*
- * $Id: packet-aim.c,v 1.43 2004/06/16 07:51:21 guy Exp $
+ * $Id: packet-aim.c,v 1.44 2004/07/09 23:17:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -36,6 +36,8 @@
#include <glib.h>
+#include "isprint.h"
+
#include <epan/packet.h>
#include <epan/strutil.h>
diff --git a/packet-cops.c b/packet-cops.c
index 76118cbfcb..80add6b8aa 100644
--- a/packet-cops.c
+++ b/packet-cops.c
@@ -13,7 +13,7 @@
*
* Implemented in ethereal at April 7-8, 2004
*
- * $Id: packet-cops.c,v 1.48 2004/05/04 06:01:52 guy Exp $
+ * $Id: packet-cops.c,v 1.49 2004/07/09 23:17:03 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -44,6 +44,9 @@
#include <ctype.h>
#include <glib.h>
+
+#include "isprint.h"
+
#include <epan/packet.h>
#include "packet-ipv6.h"
#include "packet-tcp.h"
diff --git a/packet-dcm.c b/packet-dcm.c
index 8b178bfa19..8262e17c9f 100644
--- a/packet-dcm.c
+++ b/packet-dcm.c
@@ -11,7 +11,7 @@
* DICOM packets correctly.
* This should probably be documented somewhere besides here.)
*
- * $Id: packet-dcm.c,v 1.3 2004/05/08 21:31:52 obiot Exp $
+ * $Id: packet-dcm.c,v 1.4 2004/07/09 23:17:04 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -66,6 +66,8 @@
#include <glib.h>
+#include "isprint.h"
+
#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
#endif
@@ -472,7 +474,7 @@ dcm_setSyntax(dcmItem_t *di, char *name)
char *
dcm_tag2str(guint16 grp, guint16 elm, guint8 syntax, tvbuff_t *tvb, int offset, guint32 len)
{
- static char buf[512]; /* bad form ??? */
+ static char buf[512+1]; /* bad form ??? */
const guint8 *vval;
char *p;
guint32 tag, val32;
@@ -549,7 +551,7 @@ dcm_tag2str(guint16 grp, guint16 elm, guint8 syntax, tvbuff_t *tvb, int offset,
vval = tvb_get_ptr(tvb, offset, len);
i = 0;
*p++ = ' ';
- while (i < len && isprint(*(vval+i)))
+ while (i < len && i < 512 && isprint(*(vval+i)))
*p++ = *(vval + i++);
*p = 0;
} break;
diff --git a/packet-giop.c b/packet-giop.c
index d9704c1499..5361b55e9b 100644
--- a/packet-giop.c
+++ b/packet-giop.c
@@ -9,7 +9,7 @@
* Frank Singleton <frank.singleton@ericsson.com>
* Trevor Shepherd <eustrsd@am1.ericsson.se>
*
- * $Id: packet-giop.c,v 1.76 2003/12/28 12:43:38 ulfl Exp $
+ * $Id: packet-giop.c,v 1.77 2004/07/09 23:17:04 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -292,6 +292,8 @@
#include "strerror.h"
#endif
+#include "isprint.h"
+
#include <epan/packet.h>
#include "packet-giop.h"
diff --git a/packet-radius.c b/packet-radius.c
index f4b0ea0f68..651da08218 100644
--- a/packet-radius.c
+++ b/packet-radius.c
@@ -6,7 +6,7 @@
*
* RFC 2865, RFC 2866, RFC 2867, RFC 2868, RFC 2869
*
- * $Id: packet-radius.c,v 1.104 2004/05/29 04:41:25 guy Exp $
+ * $Id: packet-radius.c,v 1.105 2004/07/09 23:17:04 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -37,6 +37,9 @@
#include <ctype.h>
#include <glib.h>
#include <time.h>
+
+#include "isprint.h"
+
#include <epan/packet.h>
#include <epan/resolv.h>
@@ -2747,23 +2750,6 @@ find_radius_attr_info(guint32 attr_type, const radius_attr_info *table)
return(NULL);
}
-#if GLIB_MAJOR_VERSION >= 2
-/*
- * XXX - "isprint()" can return "true" for non-ASCII characters, but
- * those don't work with GTK+ 1.3 or later, as they take UTF-8 strings
- * as input. Until we fix up Ethereal to properly handle non-ASCII
- * characters in all output (both GUI displays and text printouts)
- * in those versions of GTK+, we work around the problem by escaping
- * all characters that aren't printable ASCII.
- *
- * We don't know what version of GTK+ we're using, as dissectors don't
- * use any GTK+ stuff; we use GLib as a proxy for that, with GLib 2.x
- * implying GTK+ 1.3 or later (we don't support GLib 1.3[.x]).
- */
-#undef isprint
-#define isprint(c) (c >= 0x20 && c < 0x7f)
-#endif
-
static void
rdconvertbufftostr(gchar *dest, tvbuff_t *tvb, int offset, int length)
{
diff --git a/packet-snmp.c b/packet-snmp.c
index e579e83fea..2fa26faac1 100644
--- a/packet-snmp.c
+++ b/packet-snmp.c
@@ -10,7 +10,7 @@
*
* See RFCs 2570-2576 for SNMPv3
*
- * $Id: packet-snmp.c,v 1.128 2004/06/28 22:04:12 gerald Exp $
+ * $Id: packet-snmp.c,v 1.129 2004/07/09 23:17:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -47,6 +47,8 @@
#include <glib.h>
+#include "isprint.h"
+
#include <epan/packet.h>
#include <epan/strutil.h>
#include <epan/conversation.h>
diff --git a/packet-tds.c b/packet-tds.c
index b83f5a49bc..2693deef08 100644
--- a/packet-tds.c
+++ b/packet-tds.c
@@ -3,7 +3,7 @@
* Copyright 2000-2002, Brian Bruns <camber@ais.org>
* Copyright 2002, Steve Langasek <vorlon@netexpress.net>
*
- * $Id: packet-tds.c,v 1.27 2004/02/20 08:40:30 guy Exp $
+ * $Id: packet-tds.c,v 1.28 2004/07/09 23:17:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -150,6 +150,8 @@
#include <glib.h>
+#include "isprint.h"
+
#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/strutil.h>