summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-18 15:50:23 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-18 15:50:23 (GMT)
commita55cf1edad4209ab3de602ff4c4a93abb25fce1c (patch)
tree48529fff5ad931726fa1c1faf628b327c84c0da4
parentfaa2dd58c7da0145ca7d1fda1bed3d8de3514db0 (diff)
downloadtcl-a55cf1edad4209ab3de602ff4c4a93abb25fce1c.zip
tcl-a55cf1edad4209ab3de602ff4c4a93abb25fce1c.tar.gz
tcl-a55cf1edad4209ab3de602ff4c4a93abb25fce1c.tar.bz2
Allow larger values for "binary encode base64 -maxlen". Add some more testcases
-rw-r--r--generic/tclBinary.c4
-rw-r--r--tests/binary.test6
-rw-r--r--tests/format.test6
3 files changed, 14 insertions, 2 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 3112f02..b6394a4 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -2701,7 +2701,7 @@ BinaryEncode64(
{
Tcl_Obj *resultObj;
unsigned char *data, *limit;
- int maxlen = 0;
+ Tcl_WideInt maxlen = 0;
const char *wrapchar = "\n";
int wrapcharlen = 1;
int offset, i, index, size, outindex = 0, count = 0, purewrap = 1;
@@ -2720,7 +2720,7 @@ BinaryEncode64(
}
switch (index) {
case OPT_MAXLEN:
- if (Tcl_GetIntFromObj(interp, objv[i + 1], &maxlen) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[i + 1], &maxlen) != TCL_OK) {
return TCL_ERROR;
}
if (maxlen < 0) {
diff --git a/tests/binary.test b/tests/binary.test
index 9a309e0..03ef846 100644
--- a/tests/binary.test
+++ b/tests/binary.test
@@ -2710,6 +2710,12 @@ test binary-72.28 {binary encode base64} -body {
test binary-72.29 {binary encode base64} {
string length [binary encode base64 -maxlen 3 -wrapchar \xCA abc]
} 5
+test binary-72.30 {binary encode base64} {
+ string length [binary encode base64 -maxlen 4294967296 abc]
+} 4
+test binary-72.31 {binary encode base64} -body {
+ string length [binary encode base64 -maxlen 18446744073709551616 abc]
+} -returnCodes 1 -result {integer value too large to represent}
test binary-73.1 {binary decode base64} -body {
binary decode base64
diff --git a/tests/format.test b/tests/format.test
index c5053e8..08490d2 100644
--- a/tests/format.test
+++ b/tests/format.test
@@ -462,6 +462,12 @@ test format-11.11 {XPG3 %$n specifiers} {
test format-11.12 {XPG3 %$n specifiers} {
list [catch {format {%2$*d} 4 5 6} msg] $msg
} {0 { 6}}
+test format-11.13 {XPG3 %$n specifiers} {
+ format {%2$.*s %4$d} 1 -4294967298 abcdefghijklmnop 44
+} { 44}
+test format-11.14 {XPG3 %$n specifiers} {
+ format {%2$.*s %4$d} 1 4294967298 abcdefghijklmnop 44
+} {abcdefghijklmnop 44}
test format-12.1 {negative width specifiers} {
format "%*d" -47 25