diff options
author | apnadkarni <apnmbx-wits@yahoo.com> | 2022-11-02 16:28:59 (GMT) |
---|---|---|
committer | apnadkarni <apnmbx-wits@yahoo.com> | 2022-11-02 16:28:59 (GMT) |
commit | 5a3d2ddfede6842bc089bd78d0c80fad82f911b0 (patch) | |
tree | 8b4007b0d14d6ff6ec373006c43fe62948e7f33f /generic/tclStringObj.c | |
parent | 59ee35fd388827c8ca20bf08a63bd827a42519ec (diff) | |
download | tcl-5a3d2ddfede6842bc089bd78d0c80fad82f911b0.zip tcl-5a3d2ddfede6842bc089bd78d0c80fad82f911b0.tar.gz tcl-5a3d2ddfede6842bc089bd78d0c80fad82f911b0.tar.bz2 |
Bug #0f98bce669 - string cat support for > 2**31 characters. Tests pending
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r-- | generic/tclStringObj.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 60dfa4d..008ece9 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -3089,7 +3089,7 @@ TclStringCat( { Tcl_Obj *objResultPtr, * const *ov; int oc, binary = 1; - size_t length = 0; + size_t length = 0; int allowUniChar = 1, requestUniChar = 0, forceUniChar = 0; int first = objc - 1; /* Index of first value possibly not empty */ int last = 0; /* Index of last value possibly not empty */ @@ -3171,6 +3171,9 @@ TclStringCat( if (length == 0) { first = last; } + if (length > (TCL_SIZE_SMAX-numBytes)) { + goto overflow; + } length += numBytes; } } @@ -3194,6 +3197,9 @@ TclStringCat( if (length == 0) { first = last; } + if (length > ((TCL_SIZE_SMAX/sizeof(Tcl_UniChar))-numChars)) { + goto overflow; + } length += numChars; } } @@ -3258,7 +3264,7 @@ TclStringCat( if (numBytes) { first = last; } - } else if (numBytes + length > (size_t)INT_MAX) { + } else if (numBytes > (TCL_SIZE_SMAX - length)) { goto overflow; } length += numBytes; @@ -3275,7 +3281,7 @@ TclStringCat( numBytes = objPtr->length; if (numBytes) { last = objc - oc; - if (numBytes + length > (size_t)INT_MAX) { + if (numBytes > (TCL_SIZE_SMAX - length)) { goto overflow; } length += numBytes; @@ -3434,7 +3440,7 @@ TclStringCat( overflow: if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "max size for a Tcl value (%d bytes) exceeded", INT_MAX)); + "max size for a Tcl value (%u" TCL_Z_MODIFIER " bytes) exceeded", TCL_SIZE_SMAX)); Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL); } return NULL; |