diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-10-16 14:55:06 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-10-16 21:56:03 +0000 |
commit | a517d500b4d5bdedba68127d295a37c2dbe4bf2c (patch) | |
tree | 18027381098ff1c5ce081229328e074068770ead /epan/dissectors | |
parent | aa1f2c5e4c1e98158a3bdc4e7238ebac78bc3042 (diff) |
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 <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-per.c | 12 |
1 files changed, 8 insertions, 4 deletions
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<alphabet_length; i++) { - c = alphabet[i]; - tmp_buf[(int)c] = 1; + c = (guchar)alphabet[i]; + tmp_buf[c] = 1; if (c > c_max) c_max = c; else if (c < c_min) c_min = c; } |