summaryrefslogtreecommitdiffstats
path: root/generic/tclZlib.c
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-03-01 07:19:07 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-03-01 07:19:07 (GMT)
commit9522e3788042247359e535da5bf235eac4c37541 (patch)
tree804fe277e92a7b078ef1528f9675a77a350ab892 /generic/tclZlib.c
parent00e1068c039491b579117c6b38d7d415cb345e68 (diff)
parent62d9150ef53073a2ab29f2ba1b46551f273e56ec (diff)
downloadtcl-9522e3788042247359e535da5bf235eac4c37541.zip
tcl-9522e3788042247359e535da5bf235eac4c37541.tar.gz
tcl-9522e3788042247359e535da5bf235eac4c37541.tar.bz2
Merge 9.0
Diffstat (limited to 'generic/tclZlib.c')
-rw-r--r--generic/tclZlib.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index dc7c3f3..1df84d7 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -443,10 +443,21 @@ GenerateHeader(
if (GetValue(interp, dictObj, "comment", &value) != TCL_OK) {
goto error;
} else if (value != NULL) {
- valueStr = Tcl_GetStringFromObj(value, &length);
- Tcl_UtfToExternal(NULL, latin1enc, valueStr, length, 0, NULL,
+ Tcl_EncodingState state;
+ valueStr = Tcl_GetStringFromObj(value, &len);
+ result = Tcl_UtfToExternal(NULL, latin1enc, valueStr, len,
+ TCL_ENCODING_START|TCL_ENCODING_END|TCL_ENCODING_PROFILE_STRICT, &state,
headerPtr->nativeCommentBuf, MAX_COMMENT_LEN-1, NULL, &len,
NULL);
+ if (result != TCL_OK) {
+ if (result == TCL_CONVERT_UNKNOWN) {
+ Tcl_AppendResult(interp, "Comment contains characters > 0xFF", NULL);
+ } else {
+ Tcl_AppendResult(interp, "Comment too large for zip", NULL);
+ }
+ result = TCL_ERROR;
+ goto error;
+ }
headerPtr->nativeCommentBuf[len] = '\0';
headerPtr->header.comment = (Bytef *) headerPtr->nativeCommentBuf;
if (extraSizePtr != NULL) {
@@ -464,9 +475,21 @@ GenerateHeader(
if (GetValue(interp, dictObj, "filename", &value) != TCL_OK) {
goto error;
} else if (value != NULL) {
- valueStr = Tcl_GetStringFromObj(value, &length);
- Tcl_UtfToExternal(NULL, latin1enc, valueStr, length, 0, NULL,
- headerPtr->nativeFilenameBuf, MAXPATHLEN-1, NULL, &len, NULL);
+ Tcl_EncodingState state;
+ valueStr = Tcl_GetStringFromObj(value, &len);
+ result = Tcl_UtfToExternal(NULL, latin1enc, valueStr, len,
+ TCL_ENCODING_START|TCL_ENCODING_END|TCL_ENCODING_PROFILE_STRICT, &state,
+ headerPtr->nativeFilenameBuf, MAXPATHLEN-1, NULL, &len,
+ NULL);
+ if (result != TCL_OK) {
+ if (result == TCL_CONVERT_UNKNOWN) {
+ Tcl_AppendResult(interp, "Filename contains characters > 0xFF", NULL);
+ } else {
+ Tcl_AppendResult(interp, "Filename too large for zip", NULL);
+ }
+ result = TCL_ERROR;
+ goto error;
+ }
headerPtr->nativeFilenameBuf[len] = '\0';
headerPtr->header.name = (Bytef *) headerPtr->nativeFilenameBuf;
if (extraSizePtr != NULL) {
@@ -547,8 +570,8 @@ ExtractHeader(
}
}
- Tcl_ExternalToUtfDStringEx(NULL, latin1enc, (char *) headerPtr->comment, -1,
- TCL_ENCODING_PROFILE_TCL8, &tmp, NULL);
+ Tcl_ExternalToUtfDString(latin1enc, (char *) headerPtr->comment, -1,
+ &tmp);
SetValue(dictObj, "comment", Tcl_DStringToObj(&tmp));
}
SetValue(dictObj, "crc", Tcl_NewBooleanObj(headerPtr->hcrc));
@@ -564,8 +587,8 @@ ExtractHeader(
}
}
- Tcl_ExternalToUtfDStringEx(NULL, latin1enc, (char *) headerPtr->name, -1,
- TCL_ENCODING_PROFILE_TCL8, &tmp, NULL);
+ Tcl_ExternalToUtfDString(latin1enc, (char *) headerPtr->name, -1,
+ &tmp);
SetValue(dictObj, "filename", Tcl_DStringToObj(&tmp));
}
if (headerPtr->os != 255) {