Fix for wrong parameter size for IP_MULTICAST_TTL and IP_MULTICAST_LOOP in setsockopt()

Jensen Lars-CLJ016 CLJ016@REDACTED
Wed Apr 21 16:41:01 CEST 2010


The size of parameter setsockopt() is unsigned char for IP_MULTICAST_TTL and IP_MULTICAST_LOOP.

This is needed to work on Solaris10 but linux also accept int that is why this works on linux.


Patch:
--------------------------------------------------------
otp_src_R13B04/erts/emulator/drivers/common/inet_drv.c:
@@ -4542,6 +4542,7 
@@ static int inet_set_opts(inet_descriptor* desc, char* ptr,
     struct ip_mreq mreq_val;
 #endif
     int ival;
+    unsigned char cval; // needed for MULTICAST_TTL and MULTICAST_LOOP
     char* arg_ptr;
     int arg_sz;
     enum PacketParseType old_htype = desc->htype;
@@ -4795,6 +4796,11 @@ static int inet_set_opts(inet_descriptor* desc, char* ptr
 #ifdef HAVE_MULTICAST_SUPPORT
 
        case UDP_OPT_MULTICAST_TTL:
+         /* The datatype is unsigned char*/
+           cval = (unsigned char) ival; 
+           arg_sz = sizeof(cval);
+           arg_ptr = (char*) &cval;
+
            proto = IPPROTO_IP;
            type = IP_MULTICAST_TTL;
            DEBUGF(("inet_set_opts(%ld): s=%d, IP_MULTICAST_TTL=%d\r\n",
@@ -4802,6 +4808,11 @@ static int inet_set_opts(inet_descriptor* desc, char* ptr
            break;
 
        case UDP_OPT_MULTICAST_LOOP:
+         /* The datatype is unsigned char*/
+           cval = (unsigned char) ival; 
+           arg_sz = sizeof(cval);
+           arg_ptr = (char*) &cval;
+
            proto = IPPROTO_IP;
            type = IP_MULTICAST_LOOP;
            DEBUGF(("inet_set_opts(%ld): s=%d, IP_MULTICAST_LOOP=%d\r\n",
--------------------------------------------------------

Lars S. Jensen
----------------------------------------------------------------------------The information contained in this communication has been classified as:
[ X ] Public 
----------------------------------------------------------------------------Motorola A/S, Sydvestvej 15, DK-2600 Glostrup, Denmark, CVR No. 10 29 08 13-Denmark ,VAT No: DK10290813, 
Limited Liability Company, Details of Motorola's subsidiaries in the EU/EEA can be found at: www.motorola.com/legal/euregistrationinfo


More information about the erlang-patches mailing list