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
This commit is contained in:
Guy Harris 2004-07-09 23:17:05 +00:00
parent fe1b0f99c4
commit 7661a992b6
9 changed files with 73 additions and 27 deletions

View File

@ -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 \

46
isprint.h Normal file
View File

@ -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

View File

@ -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>

View File

@ -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"

View File

@ -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;

View File

@ -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"

View File

@ -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)
{

View File

@ -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>

View File

@ -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>