aboutsummaryrefslogtreecommitdiffstats
path: root/epan/uat.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@zing.org>2016-08-14 13:49:19 -0700
committerGerald Combs <gerald@wireshark.org>2016-08-15 20:37:22 +0000
commit4b403b0b5472333fb3751b695632e219c364f4d5 (patch)
tree4ad1cf2a77e11c1a2d609388e6b8f7b0cb17e588 /epan/uat.c
parent777061b196c39c8ddb64ce19b59377886994dd72 (diff)
Fix UAT escape widths.
Pass unsigned values to the %x format specifier so that naming an IO graph 你好 TCP Segments doesn't end up saving "\xffffffe4\xffffffbd\xffffffa0\xffffffe5\xffffffa5\xffffffbd TCP Segments" to io_graphs. Fixes https://ask.wireshark.org/questions/54781/statistic-io-graph-add-a-new-graph-if-graph-name-use-chinese-it-will-cause-all-graph-name-garbled Change-Id: I5bcae05ef9b3e17532edbb293f323586c9aeb471 Reviewed-on: https://code.wireshark.org/review/17053 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'epan/uat.c')
-rw-r--r--epan/uat.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/epan/uat.c b/epan/uat.c
index 084c3f8504..07f994bc67 100644
--- a/epan/uat.c
+++ b/epan/uat.c
@@ -44,6 +44,11 @@
#include "uat-int.h"
+/*
+ * XXX Files are encoded as ASCII. We might want to encode them as UTF8
+ * instead.
+ */
+
static GPtrArray* all_uats = NULL;
void uat_init(void) {
@@ -268,7 +273,7 @@ static void putfld(FILE* fp, void* rec, uat_field_t* f) {
char c = fld_ptr[i];
if (c == '"' || c == '\\' || ! g_ascii_isprint((guchar)c) ) {
- fprintf(fp,"\\x%.2x",c);
+ fprintf(fp,"\\x%02x", (guchar) c);
} else {
putc(c,fp);
}
@@ -281,7 +286,7 @@ static void putfld(FILE* fp, void* rec, uat_field_t* f) {
guint i;
for(i=0;i<fld_len;i++) {
- fprintf(fp,"%.2x",((const guint8*)fld_ptr)[i]);
+ fprintf(fp,"%02x", (guchar)fld_ptr[i]);
}
break;
@@ -741,7 +746,7 @@ char* uat_esc(const char* buf, guint len) {
for (b = (const guint8 *)buf; b < end; b++) {
if (*b == '"' || *b == '\\' || ! g_ascii_isprint(*b) ) {
- g_snprintf(s,5,"\\x%.2x",((guint)*b));
+ g_snprintf(s,5,"\\x%02x",((guint)*b));
s+=4;
} else {
*(s++) = (*b);
@@ -756,9 +761,9 @@ gboolean uat_fld_chk_str_isprint(void* u1 _U_, const char* strptr, guint len, co
guint i;
for (i = 0; i < len; i++) {
- char c = strptr[i];
- if (! g_ascii_isprint(c)) {
- *err = g_strdup_printf("invalid char pos=%d value=%.2x",i,c);
+ char c = strptr[i];
+ if (! g_ascii_isprint(c)) {
+ *err = g_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
return FALSE;
}
}
@@ -770,9 +775,9 @@ gboolean uat_fld_chk_str_isalpha(void* u1 _U_, const char* strptr, guint len, co
guint i;
for (i = 0; i < len; i++) {
- char c = strptr[i];
- if (! g_ascii_isalpha(c)) {
- *err = g_strdup_printf("invalid char pos=%d value=%.2x",i,c);
+ char c = strptr[i];
+ if (! g_ascii_isalpha(c)) {
+ *err = g_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
return FALSE;
}
}
@@ -784,9 +789,9 @@ gboolean uat_fld_chk_str_isalnum(void* u1 _U_, const char* strptr, guint len, co
guint i;
for (i = 0; i < len; i++) {
- char c = strptr[i];
- if (! g_ascii_isalnum(c)) {
- *err = g_strdup_printf("invalid char pos=%d value=%.2x",i,c);
+ char c = strptr[i];
+ if (! g_ascii_isalnum(c)) {
+ *err = g_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
return FALSE;
}
}
@@ -798,9 +803,9 @@ gboolean uat_fld_chk_str_isdigit(void* u1 _U_, const char* strptr, guint len, co
guint i;
for (i = 0; i < len; i++) {
- char c = strptr[i];
- if (! g_ascii_isdigit(c)) {
- *err = g_strdup_printf("invalid char pos=%d value=%.2x",i,c);
+ char c = strptr[i];
+ if (! g_ascii_isdigit(c)) {
+ *err = g_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
return FALSE;
}
}
@@ -812,9 +817,9 @@ gboolean uat_fld_chk_str_isxdigit(void* u1 _U_, const char* strptr, guint len, c
guint i;
for (i = 0; i < len; i++) {
- char c = strptr[i];
- if (! g_ascii_isxdigit(c)) {
- *err = g_strdup_printf("invalid char pos=%d value=%.2x",i,c);
+ char c = strptr[i];
+ if (! g_ascii_isxdigit(c)) {
+ *err = g_strdup_printf("invalid char pos=%d value=%02x", i, (guchar) c);
return FALSE;
}
}