From: patthoyts Date: Sun, 6 Jul 2008 12:39:09 +0000 (+0000) Subject: Applied patch #1828920 (marttj) to prevent a crash calling udp_peek with wrong args. X-Git-Url: https://privyetmir.co.uk/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=tcludp Applied patch #1828920 (marttj) to prevent a crash calling udp_peek with wrong args. --- diff --git a/ChangeLog b/ChangeLog index 77bdc62..c2aee76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2008-07-06 Pat Thoyts + * generic/udp_tcl.c: Applied patch #1828920 (marttj) to prevent a + * tests/udp.test: crash calling udp_peek with wrong args. + * generic/udp_tcl.c: Applied patch #1838467 (marttj) to avoid a crash * tests/udp.test: when exiting with an open mcast socket. diff --git a/generic/udp_tcl.c b/generic/udp_tcl.c index d911ed5..fa961d1 100644 --- a/generic/udp_tcl.c +++ b/generic/udp_tcl.c @@ -482,6 +482,10 @@ udpPeek(ClientData clientData, Tcl_Interp *interp, Tcl_Channel chan; UdpState *statePtr; + if (argc < 2) { + Tcl_WrongNumArgs(interp, 0, NULL, "udp_peek sock ?buffersize?"); + return TCL_ERROR; + } chan = Tcl_GetChannel(interp, (char *)argv[1], NULL); if (chan == (Tcl_Channel) NULL) { return TCL_ERROR; diff --git a/tests/udp.test b/tests/udp.test index 2f6cd79..41f3647 100644 --- a/tests/udp.test +++ b/tests/udp.test @@ -206,7 +206,29 @@ test udp-3.11 {-mcastloop is boolean - on/off} -setup { close $s } -result {1 0} +test udp-4.0 {udp_peek} -constraints unix -setup { + set s [udp_open] +} -body { + udp_peek $s +} -cleanup { + close $s +} -result {FIX ME on a unix box} +test udp-4.1 {udp_peek} -constraints unix -setup { + set s [udp_open] +} -body { + udp_peek $s +} -cleanup { + close $s +} -result {FIX ME on a unix box} + +test udp-4.2 "udp_peek: bug #1828920 - args" -constraints unix -setup { + set s [udp_open] +} -body { + udp_peek +} -cleanup { + close $s +} -returnCodes error -match glob -result {wrong num args: *} test udp-10.1 "bug #1838467 - crash on exit" -setup { set s [udp_open]