Check for printable ASCII in an ENBName.

I'm not sure why the check is only for alphabetical characters; if
that's correct, change this to use g_ascii_isalpha, and change
is_printable_ascii to is_ascii_alpha or something such as that.

Don't use ctype.h routines, as they are locale-dependent.

Change-Id: I61d0672350d35ad918e95d7e96ed5dd263102da9
Reviewed-on: https://code.wireshark.org/review/4805
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-10-17 17:22:30 -07:00
parent 9f2a87803b
commit 1de3a5bc49
3 changed files with 17 additions and 19 deletions

View File

@ -30,7 +30,6 @@
#include <glib.h>
#include <epan/packet.h>
#include <ctype.h>
#include <epan/strutil.h>
#include <epan/asn1.h>
#include <epan/prefs.h>

View File

@ -206,7 +206,7 @@ MAX_VAL = asn1_param_get_integer(%(ACTX)s,"upperBound")
tvbuff_t *parameter_tvb=NULL;
int length;
int p_offset;
gboolean is_ascii;
gboolean is_printable_ascii;
%(DEFAULT_BODY)s
@ -215,14 +215,14 @@ MAX_VAL = asn1_param_get_integer(%(ACTX)s,"upperBound")
length = tvb_reported_length(parameter_tvb);
is_ascii = TRUE;
is_printable_ascii = TRUE;
for (p_offset=0; p_offset < length; p_offset++){
if(!isalpha(tvb_get_guint8(parameter_tvb, p_offset ))){
is_ascii = FALSE;
if(!g_ascii_isprint(tvb_get_guint8(parameter_tvb, p_offset ))){
is_printable_ascii = FALSE;
break;
}
}
if (is_ascii)
if (is_printable_ascii)
proto_item_append_text(actx->created_item,"(%%s)",tvb_format_text(parameter_tvb, 0, length));
#.END

View File

@ -38,7 +38,6 @@
#include <glib.h>
#include <epan/packet.h>
#include <ctype.h>
#include <epan/strutil.h>
#include <epan/asn1.h>
#include <epan/prefs.h>
@ -362,7 +361,7 @@ typedef enum _ProtocolIE_ID_enum {
} ProtocolIE_ID_enum;
/*--- End of included file: packet-s1ap-val.h ---*/
#line 68 "../../asn1/s1ap/packet-s1ap-template.c"
#line 67 "../../asn1/s1ap/packet-s1ap-template.c"
/* Initialize the protocol and registered fields */
static int proto_s1ap = -1;
@ -920,7 +919,7 @@ static int hf_s1ap_eHRPD_Sector_ID_01 = -1; /* EHRPD_Sector_ID */
static int hf_s1ap_eHRPDSectorLoadReportingResponse = -1; /* EHRPDSectorLoadReportingResponse */
/*--- End of included file: packet-s1ap-hf.c ---*/
#line 75 "../../asn1/s1ap/packet-s1ap-template.c"
#line 74 "../../asn1/s1ap/packet-s1ap-template.c"
/* Initialize the subtree pointers */
static int ett_s1ap = -1;
@ -1209,7 +1208,7 @@ static gint ett_s1ap_EHRPDCompositeAvailableCapacity = -1;
static gint ett_s1ap_EHRPDMultiSectorLoadReportingResponseItem = -1;
/*--- End of included file: packet-s1ap-ett.c ---*/
#line 87 "../../asn1/s1ap/packet-s1ap-template.c"
#line 86 "../../asn1/s1ap/packet-s1ap-template.c"
enum{
INITIATING_MESSAGE,
@ -3442,7 +3441,7 @@ dissect_s1ap_ENBname(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, pr
tvbuff_t *parameter_tvb=NULL;
int length;
int p_offset;
gboolean is_ascii;
gboolean is_printable_ascii;
offset = dissect_per_PrintableString(tvb, offset, actx, tree, hf_index,
1, 150, TRUE);
@ -3453,14 +3452,14 @@ dissect_s1ap_ENBname(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, pr
length = tvb_reported_length(parameter_tvb);
is_ascii = TRUE;
is_printable_ascii = TRUE;
for (p_offset=0; p_offset < length; p_offset++){
if(!isalpha(tvb_get_guint8(parameter_tvb, p_offset ))){
is_ascii = FALSE;
if(!g_ascii_isprint(tvb_get_guint8(parameter_tvb, p_offset ))){
is_printable_ascii = FALSE;
break;
}
}
if (is_ascii)
if (is_printable_ascii)
proto_item_append_text(actx->created_item,"(%s)",tvb_format_text(parameter_tvb, 0, length));
@ -10456,7 +10455,7 @@ int dissect_s1ap_SONtransferCause_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_,
/*--- End of included file: packet-s1ap-fn.c ---*/
#line 134 "../../asn1/s1ap/packet-s1ap-template.c"
#line 133 "../../asn1/s1ap/packet-s1ap-template.c"
static int dissect_ProtocolIEFieldValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
@ -10779,7 +10778,7 @@ proto_reg_handoff_s1ap(void)
/*--- End of included file: packet-s1ap-dis-tab.c ---*/
#line 207 "../../asn1/s1ap/packet-s1ap-template.c"
#line 206 "../../asn1/s1ap/packet-s1ap-template.c"
} else {
if (SctpPort != 0) {
dissector_delete_uint("sctp.port", SctpPort, s1ap_handle);
@ -12996,7 +12995,7 @@ void proto_register_s1ap(void) {
NULL, HFILL }},
/*--- End of included file: packet-s1ap-hfarr.c ---*/
#line 235 "../../asn1/s1ap/packet-s1ap-template.c"
#line 234 "../../asn1/s1ap/packet-s1ap-template.c"
};
/* List of subtrees */
@ -13286,7 +13285,7 @@ void proto_register_s1ap(void) {
&ett_s1ap_EHRPDMultiSectorLoadReportingResponseItem,
/*--- End of included file: packet-s1ap-ettarr.c ---*/
#line 248 "../../asn1/s1ap/packet-s1ap-template.c"
#line 247 "../../asn1/s1ap/packet-s1ap-template.c"
};
module_t *s1ap_module;