Tcl UDP

Check-in [229382a356]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Solved bug; crash when assigning and ipv4 group to an ipv6 socket
Timelines: family | ancestors | descendants | both | trunk | ver_10_0_9
Files: files | file ages | folders
SHA1: 229382a356ed9d33d55e313dadd3eb350741c418
User & Date: huubeikens 2014-03-02 07:22:20
Context
2014-08-29
14:58
Bringing in changes from the official CVS sources Leaf check-in: ed109dff36 user: hypnotoad tags: ver_1_0_11, cvshead
2014-04-25
20:48
Updated the package version to match the stated package version check-in: 163ebf00e6 user: seandeelywoods tags: trunk
2014-03-02
07:22
Solved bug; crash when assigning and ipv4 group to an ipv6 socket check-in: 229382a356 user: huubeikens tags: trunk, ver_10_0_9
2014-02-22
21:06
Clarified the keywords in the manual a bit. check-in: 85598020ca user: huubeikens tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/udp_tcl.c.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
....
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309

1310



1311
1312
1313
1314
1315
1316
1317
 *
 * Copyright (c) 1999-2000 by Columbia University; all rights reserved
 * Copyright (c) 2003-2005 Pat Thoyts <[email protected]>
 *
 * Written by Xiaotao Wu
 * Last modified: 11/03/2000
 *
 * $Id: udp_tcl.c,v 1.45 2014/02/13 20:49:57 huubeikens Exp $
 ******************************************************************************/

#if defined(_DEBUG) && !defined(DEBUG)
#define DEBUG
#endif

#include "udp_tcl.h"
................................................................................
		memset(&hints, 0, sizeof(hints));

		hints.ai_family = statePtr->ss_family;
		hints.ai_socktype = SOCK_DGRAM;
		hints.ai_protocol = IPPROTO_UDP;
		
		r = getaddrinfo(Tcl_GetString(multicastgrp), NULL, &hints, &result);
		memcpy(&mreq6.ipv6mr_multiaddr, &((struct sockaddr_in6*)(result->ai_addr))->sin6_addr,sizeof(mreq6.ipv6mr_multiaddr));
		freeaddrinfo(result);

		if (r != 0 ) {
			Tcl_SetResult(interp, "invalid group name", TCL_STATIC);	

			return TCL_ERROR;



		}

		if (nwinterface_index == -1) {
			/* Let the system choose the default multicast network interface. */
			mreq6.ipv6mr_interface = 0;
 		} else {
			/* Use the specified network interface. */






|







 







<
<



>

>
>
>







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
....
1298
1299
1300
1301
1302
1303
1304


1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
 *
 * Copyright (c) 1999-2000 by Columbia University; all rights reserved
 * Copyright (c) 2003-2005 Pat Thoyts <[email protected]>
 *
 * Written by Xiaotao Wu
 * Last modified: 11/03/2000
 *
 * $Id: udp_tcl.c,v 1.46 2014/03/02 07:22:20 huubeikens Exp $
 ******************************************************************************/

#if defined(_DEBUG) && !defined(DEBUG)
#define DEBUG
#endif

#include "udp_tcl.h"
................................................................................
		memset(&hints, 0, sizeof(hints));

		hints.ai_family = statePtr->ss_family;
		hints.ai_socktype = SOCK_DGRAM;
		hints.ai_protocol = IPPROTO_UDP;
		
		r = getaddrinfo(Tcl_GetString(multicastgrp), NULL, &hints, &result);



		if (r != 0 ) {
			Tcl_SetResult(interp, "invalid group name", TCL_STATIC);	
			freeaddrinfo(result);
			return TCL_ERROR;
		} else {
			memcpy(&mreq6.ipv6mr_multiaddr, &((struct sockaddr_in6*)(result->ai_addr))->sin6_addr,sizeof(mreq6.ipv6mr_multiaddr));
			freeaddrinfo(result);
		}

		if (nwinterface_index == -1) {
			/* Let the system choose the default multicast network interface. */
			mreq6.ipv6mr_interface = 0;
 		} else {
			/* Use the specified network interface. */

Changes to tests/udp.test.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
295
296
297
298
299
300
301
























302
303
304
305
306
307
308
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2003 by Pat Thoyts <[email protected]>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: udp.test,v 1.9 2014/02/13 20:49:57 huubeikens Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

package require udp
................................................................................
} -match glob -result {1}

test udp-6.0 {udp_open with ipv6} -body {
    set s [udp_open 9001 ipv6]
} -cleanup {
    close $s
} -match regexp -result {sock\d+}

























test udp-10.1 "bug #1838467 - crash on exit" -setup {
    set s [udp_open]
} -body {
    # Note: this test actually causes a crash on process exit when it
    # fails. The socket needs to be left open ...
    fconfigure $s -mcastadd 224.0.10.10






|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2003 by Pat Thoyts <[email protected]>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: udp.test,v 1.10 2014/03/02 07:24:15 huubeikens Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

package require udp
................................................................................
} -match glob -result {1}

test udp-6.0 {udp_open with ipv6} -body {
    set s [udp_open 9001 ipv6]
} -cleanup {
    close $s
} -match regexp -result {sock\d+}

test udp-6.1 {test ipv6 mcastadd with an ipv6 group} -setup {
    set s [udp_open ipv6]
} -body {
   fconfigure $s -mcastadd ff15::e755
} -cleanup {
    close $s
} -match regexp -result {ff15::e755}

test udp-6.2 {test ipv6 mcastadd with an ipv4 group} -setup {
    set s [udp_open ipv6]
} -body {
   fconfigure $s -mcastadd 224.0.10.10
} -cleanup {
    close $s
} -returnCodes error -match glob -result {*}

test udp-6.3 {test ipv4 mcastadd with an ipv6 group} -setup {
    set s [udp_open]
} -body {
   fconfigure $s -mcastadd ff15::e755
} -cleanup {
    close $s
} -returnCodes error -match glob -result {*}

test udp-10.1 "bug #1838467 - crash on exit" -setup {
    set s [udp_open]
} -body {
    # Note: this test actually causes a crash on process exit when it
    # fails. The socket needs to be left open ...
    fconfigure $s -mcastadd 224.0.10.10