From a517d500b4d5bdedba68127d295a37c2dbe4bf2c Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 16 Oct 2014 14:55:06 -0700 Subject: Make sort_alphabet() not fail too badly with characters in [128,255]. Treat all values in the alphabet as unsigned. Change-Id: I4476c75352f32673a9cd131ea233465f3376fa25 Reviewed-on: https://code.wireshark.org/review/4747 Reviewed-by: Guy Harris --- epan/dissectors/packet-per.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'epan/dissectors/packet-per.c') diff --git a/epan/dissectors/packet-per.c b/epan/dissectors/packet-per.c index 2b4f4f180a..d40a860c4d 100644 --- a/epan/dissectors/packet-per.c +++ b/epan/dissectors/packet-per.c @@ -712,15 +712,19 @@ static const char* sort_alphabet(char *sorted_alphabet, const char *alphabet, int alphabet_length) { int i, j; - char c, c_max, c_min; + guchar c, c_max, c_min; char tmp_buf[256]; + /* + * XXX - presumably all members of alphabet will be in the + * range 0 to 127. + */ if (!alphabet_length) return sorted_alphabet; memset(tmp_buf, 0, 256); - c_min = c_max = alphabet[0]; + c_min = c_max = (guchar)alphabet[0]; for (i=0; i c_max) c_max = c; else if (c < c_min) c_min = c; } -- cgit v1.2.3