diff options
Diffstat (limited to 'generic/tclZlib.c')
-rw-r--r-- | generic/tclZlib.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 544fb6e..7f18b9e 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -1613,8 +1613,7 @@ ZlibCmd( if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "command arg ?...?"); return TCL_ERROR; - } - if (Tcl_GetIndexFromObj(interp, objv[1], commands, "command", 0, + } else if (Tcl_GetIndexFromObj(interp, objv[1], commands, "command", 0, &command) != TCL_OK) { return TCL_ERROR; } @@ -1972,8 +1971,7 @@ ZlibCmd( Tcl_SetErrorCode(interp, "TCL", "ZIP", "NOVAL", NULL); return TCL_ERROR; } - if (Tcl_GetIntFromObj(interp, objv[i], - (int *) &limit) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, objv[i], (int *) &limit) != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (in -limit option)"); return TCL_ERROR; } @@ -1984,6 +1982,10 @@ ZlibCmd( } } + /* + * Actually do the push of the instance of the transform. + */ + if (ZlibStackChannelTransform(interp, mode, format, level, chan, headerObj) == NULL) { return TCL_ERROR; @@ -2045,16 +2047,22 @@ ZlibStreamCmd( ao_buffer, ao_finalize, ao_flush, ao_fullflush }; + /* + * Basic syntax checks. + */ + if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option data ?...?"); return TCL_ERROR; - } - - if (Tcl_GetIndexFromObj(interp, objv[1], cmds, "option", 0, + } else if (Tcl_GetIndexFromObj(interp, objv[1], cmds, "option", 0, &command) != TCL_OK) { return TCL_ERROR; } + /* + * Execute a relevant subcommand. + */ + switch ((enum zlibStreamCommands) command) { case zs_add: /* $strm add ?$flushopt? $data */ for (i=2; i<objc-1; i++) { @@ -2104,6 +2112,11 @@ ZlibStreamCmd( NULL); return TCL_ERROR; } + if (buffersize < 1 || buffersize > 65536) { + Tcl_AppendResult(interp, "buffer size must be between " + "1 byte and 64 kibibytes", NULL); + return TCL_ERROR; + } } if (flush == -2) { |