summaryrefslogtreecommitdiffstats
path: root/generic/tclBinary.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2013-09-01 20:08:50 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2013-09-01 20:08:50 (GMT)
commit22515fc47ff9d489579d2363c0cb240b2235acd7 (patch)
tree0b39c71d35007a231dd0f7dabb817657474cb439 /generic/tclBinary.c
parent6b45d21b4b5cf1d203ccaba63c88551b37c31b97 (diff)
downloadtcl-22515fc47ff9d489579d2363c0cb240b2235acd7.zip
tcl-22515fc47ff9d489579d2363c0cb240b2235acd7.tar.gz
tcl-22515fc47ff9d489579d2363c0cb240b2235acd7.tar.bz2
[b98fa55285]: Fix handling of whitespace at end of hex strings to decode.
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r--generic/tclBinary.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 901237b..7625d39 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -2386,29 +2386,32 @@ BinaryDecodeHex(
while (data < dataend) {
value = 0;
for (i=0 ; i<2 ; i++) {
- if (data < dataend) {
- c = *data++;
-
- if (!isxdigit((int) c)) {
- if (strict || !isspace(c)) {
- goto badChar;
- }
- i--;
- continue;
- }
+ if (data >= dataend) {
value <<= 4;
- c -= '0';
- if (c > 9) {
- c += ('0' - 'A') + 10;
- }
- if (c > 16) {
- c += ('A' - 'a');
+ break;
+ }
+
+ c = *data++;
+ if (!isxdigit((int) c)) {
+ if (strict || !isspace(c)) {
+ goto badChar;
}
- value |= (c & 0xf);
- } else {
- value <<= 4;
- cut++;
+ i--;
+ continue;
}
+
+ value <<= 4;
+ c -= '0';
+ if (c > 9) {
+ c += ('0' - 'A') + 10;
+ }
+ if (c > 16) {
+ c += ('A' - 'a');
+ }
+ value |= (c & 0xf);
+ }
+ if (i < 2) {
+ cut++;
}
*cursor++ = UCHAR(value);
value = 0;