diff options
author | dgp <dgp@users.sourceforge.net> | 2020-03-28 16:33:50 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2020-03-28 16:33:50 (GMT) |
commit | f5621cf8539eb6b5c64826e06254cbf2121a52bd (patch) | |
tree | c25863768baad5a43b4feb82e47ee9c62265040c /generic/tclBinary.c | |
parent | a30671934a6bd8c3448cb1a57634210fa24edbb0 (diff) | |
parent | c619f65f15cd0877658ae9a0c0e3748b8fc0896b (diff) | |
download | tcl-f5621cf8539eb6b5c64826e06254cbf2121a52bd.zip tcl-f5621cf8539eb6b5c64826e06254cbf2121a52bd.tar.gz tcl-f5621cf8539eb6b5c64826e06254cbf2121a52bd.tar.bz2 |
merge 8.6
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r-- | generic/tclBinary.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index a050122..ce816d9 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -3173,7 +3173,7 @@ BinaryDecode64( if (c == '=' && i > 1) { value <<= 6; cut++; - } else if (!strict && TclIsSpaceProc(c)) { + } else if (!strict) { i--; } else { goto bad64; @@ -3197,7 +3197,7 @@ BinaryDecode64( if (i) { cut++; } - } else if (strict || !TclIsSpaceProc(c)) { + } else if (strict) { goto bad64; } else { i--; @@ -3217,11 +3217,6 @@ BinaryDecode64( if (strict) { goto bad64; } - for (; data < dataend; data++) { - if (!TclIsSpaceProc(*data)) { - goto bad64; - } - } } } Tcl_SetByteArrayLength(resultObj, cursor - begin - cut); @@ -3229,11 +3224,21 @@ BinaryDecode64( return TCL_OK; bad64: - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "invalid base64 character \"%c\" at position %d", - (char) c, (int) (data - datastart - 1))); - TclDecrRefCount(resultObj); - return TCL_ERROR; + { + /* The decoder is byte-oriented. If we saw a byte that's not a + * valid member of the base64 alphabet, it could be the lead byte + * of a multi-byte character. */ + Tcl_UniChar ch; + + /* Safe because we know data is NUL-terminated */ + TclUtfToUniChar((const char *)(data - 1), &ch); + + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "invalid base64 character \"%c\" at position %d", ch, + (int) (data - datastart - 1))); + TclDecrRefCount(resultObj); + return TCL_ERROR; + } } /* |