(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ipsec.c) |
| |
| 258 | | | static int get_ipv6_suffix(char* ipv6_suffix, char *ipv6_address) |
| 259 | | | { |
| 260 | | | char suffix[IPSEC_STRLEN_IPV6 + 1]; |
| 261 | | | int cpt = 0; |
| 262 | | | int cpt_suffix = 0; |
| 263 | | | int cpt_seg = 0; |
| 264 | | | int j =0; |
| 265 | | | int ipv6_len = 0; |
| 266 | | | gboolean found = FALSE; |
| 267 | | | |
| 268 | | | ipv6_len = strlen(ipv6_address); |
| 269 | | | if(ipv6_len == 0) |
| 270 | | | { |
| 271 | | | |
| 272 | | | found = TRUE; |
Unused Value
The value assigned to found is never subsequently used on any execution path. |
|
| 273 | | | } |
| 274 | | | else |
| 275 | | | { |
| 276 | | | while ( (cpt_suffix < IPSEC_STRLEN_IPV6) && (ipv6_len - cpt -1 >= 0) && (found == FALSE)) |
| 277 | | | { |
| 278 | | | if(ipv6_address[ipv6_len - cpt - 1] == ':') |
| 279 | | | { |
| 280 | | | |
| 281 | | | for(j = cpt_seg; j < 4; j++) |
| 282 | | | { |
| 283 | | | suffix[IPSEC_STRLEN_IPV6 -1 -cpt_suffix] = '0'; |
| 284 | | | cpt_suffix ++; |
| 285 | | | } |
| 286 | | | cpt_seg = 0; |
| 287 | | | |
| 288 | | | if(ipv6_len - cpt - 1 == 0) |
| 289 | | | { |
| 290 | | | |
| 291 | | | found = TRUE; |
| 292 | | | } |
| 293 | | | else |
| 294 | | | if(ipv6_address[ipv6_len - cpt - 2] == ':') |
| 295 | | | { |
| 296 | | | |
| 297 | | | cpt +=2; |
| 298 | | | found = TRUE; |
| 299 | | | } |
| 300 | | | |
| 301 | | | else |
| 302 | | | { |
| 303 | | | cpt++; |
| 304 | | | } |
| 305 | | | } |
| 306 | | | else |
| 307 | | | { |
| 308 | | | suffix[IPSEC_STRLEN_IPV6 -1 -cpt_suffix] = toupper(ipv6_address[ipv6_len - cpt - 1]); |
| 309 | | | cpt_seg ++; |
| 310 | | | cpt_suffix ++; |
| 311 | | | cpt++; |
| 312 | | | } |
| 313 | | | } |
| 314 | | | |
| 315 | | | if(cpt_suffix % 4 != 0) |
| 316 | | | { |
| 317 | | | for(j = cpt_seg; j < 4; j++) |
| 318 | | | { |
| 319 | | | suffix[IPSEC_STRLEN_IPV6 -1 -cpt_suffix] = '0'; |
| 320 | | | cpt_suffix ++; |
| 321 | | | } |
| 322 | | | cpt_seg = 0; |
| 323 | | | } |
| 324 | | | |
| 325 | | | } |
| 326 | | | |
| 327 | | | for(j = 0 ; j < cpt_suffix ; j ++) |
| 328 | | | { |
| 329 | | | suffix[j] = suffix[j + IPSEC_STRLEN_IPV6 - cpt_suffix] ; |
| 330 | | | } |
| 331 | | | |
| 332 | | | suffix[j] = '\0'; |
| 333 | | | memcpy(ipv6_suffix,suffix,j + 1); |
| 334 | | | return cpt; |
| 335 | | | } |
| |