summaryrefslogtreecommitdiffstats
path: root/generic/tclBinary.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r--generic/tclBinary.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 33b1e3e..6306159 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -2649,7 +2649,37 @@ BinaryEncodeUu(
lineLength = ((lineLength - 1) & -4) + 1; /* 5, 9, 13 ... */
break;
case OPT_WRAPCHAR:
- wrapchar = Tcl_GetByteArrayFromObj(objv[i + 1], &wrapcharlen);
+ wrapchar = (const unsigned char *) TclGetStringFromObj(
+ objv[i + 1], &wrapcharlen);
+ {
+ const unsigned char *p = wrapchar;
+ int numBytes = wrapcharlen;
+
+ while (numBytes) {
+ switch (*p) {
+ case '\t':
+ case '\v':
+ case '\f':
+ case '\r':
+ p++; numBytes--;
+ continue;
+ case '\n':
+ numBytes--;
+ break;
+ default:
+ badwrap:
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "invalid wrapchar; will defeat decoding",
+ -1));
+ Tcl_SetErrorCode(interp, "TCL", "BINARY",
+ "ENCODE", "WRAPCHAR", NULL);
+ return TCL_ERROR;
+ }
+ }
+ if (numBytes) {
+ goto badwrap;
+ }
+ }
break;
}
}