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.28342
Similar Warnings: 22014.28341
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_298151 <= -1197 GIOChannel *dcc_listen(GIOChannel *iface, IPADDR *ip, int *port) 
 198 {
 199         GIOChannel *handle;
&$unknown_298157 <= -1200         IPADDR *listen_ip = NULL;
 201         const char *dcc_port, *p, *own_ip;
 202         int first, last;
 203  
&$unknown_298163 <= -1204         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_298196 <= -1209         own_ip = settings_get_str("dcc_own_ip");
&$unknown_298210 <= -1210         if (*own_ip != '\0') {   /* Null Pointer Dereference (ID: 7260.28344) */
&$unknown_298213 <= -1211                 if (is_ipv4_address(own_ip))
&$unknown_298225 <= -1212                         listen_ip = &ip4_any;
 213         } else {
 214                 if (!IPADDR_IS_V6(ip))
 215                         listen_ip = &ip4_any;
 216         }
 217  
 218         /* get first port */ 
&$unknown_298228 <= -1219         dcc_port = settings_get_str("dcc_port");
&$unknown_298238 <= -1220         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 <= -1241         for (*port = first; *port <= last; (*port)++) {
*port <= -1242                 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 <= -1272           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 <= -1111                     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_298254 != 10
&$unknown_298257 != 0
&$unknown_298259 != 0
$unknown_298255 != 0
strlen(&$unknown_298255) != 0
$unknown_298258 != 32
$unknown_298258 != 45
ip4_any.family = 10
$input_12 = &$unknown_298257
$input_3156 = 0
Postconditions
_g_boolean_var_' = 1
dcc_port' = &$unknown_298259
first' = &$unknown_298257
last' = &$unknown_298257
listen_ip' = &ip4_any.family
my_ip' = &ip4_any.family
opt' = 1
own_ip' = &$unknown_298255
p' = &$unknown_298259
port' = &$unknown_298257
port' = port
so' = &so
so' = ip4_any.family
((char*)&so)[8]' = ip4_any.ip.in6_u




Change Warning 22014.28342 : Cast Alters Value

Because they are very similar, this warning shares annotations with warning 22014.28341.
CodeSonar has selected warning 22014.28341 to represent this group of similar warnings. In order to edit this group, you must edit warning 22014.28341.