Text  |   XML   |   Visible Warnings:

irssi-0.8.14 : irssi-0.8.14 analysis 2 : Cast Alters Value  at network.c:111

Categories: LANG.CAST.VALUE CWE:192
Warning ID: 22014.28341
Similar Warnings: 22014.28342
Procedure: sin_set_port
Trace: view
Modified: Thu Nov 26 11:08:56 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
ProblemLineSource
   /kat0/fletcher/SATE/2010/irssi-0.8.14/src/irc/dcc/dcc.c
   Enter dcc_listen
&$unknown_297917 >= 65536197 GIOChannel *dcc_listen(GIOChannel *iface, IPADDR *ip, int *port) 
 198 {
 199         GIOChannel *handle;
&$unknown_297923 >= 65536200         IPADDR *listen_ip = NULL;
 201         const char *dcc_port, *p, *own_ip;
 202         int first, last;
 203  
&$unknown_297929 >= 65536204         if (net_getsockname(iface, ip, NULL) == -1)
 205                 return NULL;
 206  
 207         /* figure out if we want to listen in IPv4 address or in "any" address,
 208            which may mean IPv4+IPv6 or just IPv6 depending on OS. */ 
&$unknown_297962 >= 65536209         own_ip = settings_get_str("dcc_own_ip");
&$unknown_297976 >= 65536210         if (*own_ip != '\0') {   /* Null Pointer Dereference (ID: 7260.28344) */
&$unknown_297979 >= 65536211                 if (is_ipv4_address(own_ip))
&$unknown_297991 >= 65536212                         listen_ip = &ip4_any;
 213         } else {
 214                 if (!IPADDR_IS_V6(ip))
 215                         listen_ip = &ip4_any;
 216         }
 217  
 218         /* get first port */ 
&$unknown_297994 >= 65536219         dcc_port = settings_get_str("dcc_port");
&$unknown_298004 >= 65536220         first = atoi(dcc_port);
 221         if (first == 0) {
 222                 /* random port */ 
 223                 *port = 0;
 224                 return net_listen(listen_ip, port);
 225         }
 226  
 227         /* get last port */ 
 228         p = strchr(dcc_port, ' ');   /* Null Pointer Dereference (ID: 7259.28343) */
 229         if (p == NULL) p = strchr(dcc_port, '-');
 230  
 231         dcc_port = p;
 232         if (dcc_port == NULL)
 233                 last = first;
 234         else {
 235                 last = atoi(dcc_port+1);
 236                 if (last == 0)
 237                         last = first;
 238         }
 239  
 240         /* use the first available port */ 
first >= 65536241         for (*port = first; *port <= last; (*port)++) {
*port >= 65536242                 handle = net_listen(listen_ip, port);
     /kat0/fletcher/SATE/2010/irssi-0.8.14/src/core/network.c
     Enter dcc_listen / net_listen
 262   GIOChannel *net_listen(IPADDR *my_ip, int *port) 
 263   {
 264           union sockaddr_union so;
 265           int ret, handle, opt = 1;
 266           socklen_t len;
 267    
 268           g_return_val_if_fail(port != NULL, NULL);
 269    
 270           memset(&so, 0, sizeof(so));
 271           sin_set_ip(&so, my_ip);
*port >= 65536272           sin_set_port(&so, *port);
       Enter dcc_listen / net_listen / sin_set_port
 107     static void sin_set_port(union sockaddr_union *so, int port) 
 108     {
 109     #ifdef HAVE_IPV6 
 110             if (so->sin.sin_family == AF_INET6)
port >= 65536111                     so->sin6.sin6_port = htons((unsigned short)port);     /* Cast Alters Value */  /* Cast Alters Value (ID: 22016.28364) */
       Exit dcc_listen / net_listen / sin_set_port
     Exit dcc_listen / net_listen
Preconditions
so != 0
&$unknown_298020 != 10
&$unknown_298023 != 0
&$unknown_298025 != 0
$unknown_298021 != 0
strlen(&$unknown_298021) != 0
$unknown_298024 != 32
$unknown_298024 != 45
ip4_any.family = 10
$input_12 = &$unknown_298023
$input_2748 = 0
Postconditions
_g_boolean_var_' = 1
dcc_port' = &$unknown_298025
first' = &$unknown_298023
last' = &$unknown_298023
listen_ip' = &ip4_any.family
my_ip' = &ip4_any.family
opt' = 1
own_ip' = &$unknown_298021
p' = &$unknown_298025
port' = &$unknown_298023
port' = port
so' = &so
so' = ip4_any.family
((char*)&so)[8]' = ip4_any.ip.in6_u




Change Warning 22014.28341 : Cast Alters Value

Because they are very similar, this warning shares annotations with warning 22014.28342.

Priority:
State:
Finding:
Owner:
Note: