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)
commit0576e11ae0dee27fb806110d84024c8aff28f941 (patch)
tree0b39c71d35007a231dd0f7dabb817657474cb439 /generic/tclBinary.c
parent1d512f82013b5c80636c8522357aabe3b429f143 (diff)
downloadtcl-0576e11ae0dee27fb806110d84024c8aff28f941.zip
tcl-0576e11ae0dee27fb806110d84024c8aff28f941.tar.gz
tcl-0576e11ae0dee27fb806110d84024c8aff28f941.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;