(/home/sate/Testcases/c/cve/wireshark-1.2.0/tap-rpcstat.c) |
| |
| 271 | | | rpcstat_init(const char *optarg, void* userdata _U_) |
| 272 | | | { |
| 273 | | | rpcstat_t *rs; |
| 274 | | | guint32 i; |
| 275 | | | int program, version; |
| 276 | | | int pos=0; |
| 277 | | | const char *filter=NULL; |
| 278 | | | GString *error_string; |
| 279 | | | |
| 280 | | | if(sscanf(optarg,"rpc,rtt,%d,%d,%n",&program,&version,&pos)==2){ |
| 281 | | | if(pos){ |
| 282 | | | filter=optarg+pos; |
| 283 | | | } else { |
| 284 | | | filter=NULL; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 285 | | | } |
| 286 | | | } else { |
| 287 | | | fprintf(stderr, "tshark: invalid \"-z rpc,rtt,<program>,<version>[,<filter>]\" argument\n"); |
| 288 | | | exit(1); |
| 289 | | | } |
| 290 | | | |
| 291 | | | rs=g_malloc(sizeof(rpcstat_t)); |
| 292 | | | rs->prog=rpc_prog_name(program); |
| 293 | | | rs->program=program; |
| 294 | | | rs->version=version; |
| 295 | | | if(filter){ |
| 296 | | | rs->filter=g_strdup(filter); |
| 297 | | | } else { |
| 298 | | | rs->filter=NULL; |
| 299 | | | } |
| 300 | | | rpc_program=program; |
| 301 | | | rpc_version=version; |
| 302 | | | rpc_min_proc=-1; |
| 303 | | | rpc_max_proc=-1; |
| 304 | | | g_hash_table_foreach(rpc_procs, (GHFunc)rpcstat_find_procs, NULL); |
| 305 | | | if(rpc_min_proc==-1){ |
| 306 | | | fprintf(stderr,"tshark: Invalid -z rpc,rrt,%d,%d\n",rpc_program,rpc_version); |
| 307 | | | fprintf(stderr," Program:%d version:%d isn't supported by tshark.\n", rpc_program, rpc_version); |
| 308 | | | exit(1); |
| 309 | | | } |
| 310 | | | |
| 311 | | | |
| 312 | | | rs->num_procedures=rpc_max_proc+1; |
| 313 | | | rs->procedures=g_malloc(sizeof(rpc_procedure_t)*(rs->num_procedures+1)); |
| 314 | | | for(i=0;i<rs->num_procedures;i++){ |
| 315 | | | rs->procedures[i].proc=rpc_proc_name(program, version, i); |
| 316 | | | rs->procedures[i].num=0; |
| 317 | | | rs->procedures[i].min.secs=0; |
| 318 | | | rs->procedures[i].min.nsecs=0; |
| 319 | | | rs->procedures[i].max.secs=0; |
| 320 | | | rs->procedures[i].max.nsecs=0; |
| 321 | | | rs->procedures[i].tot.secs=0; |
| 322 | | | rs->procedures[i].tot.nsecs=0; |
| 323 | | | } |
| 324 | | | |
| 325 | | | |
| 326 | | | |
| 327 | | | |
| 328 | | | |
| 329 | | | |
| 330 | | | |
| 331 | | | |
| 332 | | | |
| 333 | | | |
| 334 | | | |
| 335 | | | error_string=register_tap_listener("rpc", rs, filter, rpcstat_reset, rpcstat_packet, rpcstat_draw); |
| 336 | | | if(error_string){ |
| 337 | | | |
| 338 | | | g_free(rs->procedures); |
| 339 | | | g_free(rs->filter); |
| 340 | | | g_free(rs); |
| 341 | | | |
| 342 | | | fprintf(stderr, "tshark: Couldn't register rpc,rtt tap: %s\n", |
| 343 | | | error_string->str); |
| 344 | | | g_string_free(error_string, TRUE); |
| 345 | | | exit(1); |
| 346 | | | } |
| 347 | | | } |
| |