From: Pat Thoyts Date: Mon, 19 Nov 2007 23:17:01 +0000 (+0000) Subject: Avoid crash when calling sinflate with incorrect args X-Git-Url: http://privyetmir.co.uk/gitweb.cgi?a=commitdiff_plain;h=819aab1f7ed2e23b2ed5f739534f314bd26d8ca4;p=kitgen Avoid crash when calling sinflate with incorrect args git-svn-id: svn://svn.equi4.com/kitgen/trunk@1845 9e558909-932a-0410-a563-af77432da1eb --- diff --git a/zlib.c b/zlib.c index afbadbb..12711df 100644 --- a/zlib.c +++ b/zlib.c @@ -21,7 +21,11 @@ zstreamincmd(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) Tcl_Obj *obj; static CONST84 char* cmds[] = { "fill", "drain", NULL, }; - + + if (objc < 2 || objc > 3) { + Tcl_WrongNumArgs(ip, 2, objv, "fill|drain data"); + return TCL_ERROR; + } if (Tcl_GetIndexFromObj(ip, objv[1], cmds, "option", 0, &index) != TCL_OK) return TCL_ERROR; @@ -143,6 +147,10 @@ ZlibCmd(ClientData dummy, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) { if (objc < 4) flag = 16 * 1024; + if (flag < 1) { + Tcl_SetResult(ip, "invalid buffer size", TCL_STATIC); + return TCL_ERROR; + } for (;;) { stream.zalloc = 0;