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: 22016.28364
Similar Warnings: 22016.28363
Procedure: sin_set_port
Trace: view
Modified: Thu Nov 26 11:09:05 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-server.c
   Enter cmd_dcc_server
 314 static void cmd_dcc_server(const char *data, IRC_SERVER_REC *server) 
 315 {
 316         void *free_arg;
 317         GIOChannel *handle;
 318         SERVER_DCC_REC *dcc;
 319         IPADDR own_ip;
 320         char *flags, *port;
 321  
 322         g_return_if_fail(data != NULL);
 323  
 324         if (!cmd_get_params(data, &free_arg, 2, &flags, &port))
 325                 return;
 326  
 327         dcc = dcc_server_find_port(port);
 328         if (dcc != NULL) {
 329                 /* Server is already running, update it */ 
 330                 dcc_server_update_flags(dcc, flags);
 331                 cmd_params_free(free_arg);
 332                 return;
 333         }
 334  
 335         /* start listening */ 
$input_12 <= -1336         if (!IS_IRC_SERVER(server) || !server->connected) {
 337                 cmd_param_error(CMDERR_NOT_CONNECTED);
 338         }
 339  
atoi$result135 <= -1340         handle = dcc_listen_port(net_sendbuffer_handle(server->handle),
$input_12 <= -1341                                  &own_ip, atoi(port));
     Enter cmd_dcc_server / dcc_listen_port
 52   static GIOChannel *dcc_listen_port(GIOChannel *iface, IPADDR *ip, int port) 
 53   {
 54           if (net_getsockname(iface, ip, NULL) == -1)
 55                   return NULL;
 56    
 57           if (IPADDR_IS_V6(ip))
port <= -158                   return net_listen(NULL, &port);
       /kat0/fletcher/SATE/2010/irssi-0.8.14/src/core/network.c
       Enter cmd_dcc_server / dcc_listen_port / 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 cmd_dcc_server / dcc_listen_port / 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: 22014.28342) */
         Exit cmd_dcc_server / dcc_listen_port / net_listen / sin_set_port
       Exit cmd_dcc_server / dcc_listen_port / net_listen
     Exit cmd_dcc_server / dcc_listen_port
Preconditions
so != 0
((char*)port)[32] != 0
((char*)*port)[36] != 0
Postconditions
_g_boolean_var_' = 1
_g_boolean_var_' = 1
dcc' = 0
iface' = server->handle->handle
ip' = &own_ip.family
my_ip' = 0
opt' = 1
own_ip.family' = 10
port' = $input_12
port' = $input_12
port' = 0
port' = &port
so' = 10
so' = &so
strlen(&so)' = strlen(&in6addr_any.in6_u) + 8
((char*)&so)[8]' = in6addr_any.in6_u




Change Warning 22016.28364 : Cast Alters Value

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