(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/strutil.c) |
| |
| 426 | | | hex_str_to_bytes(const char *hex_str, GByteArray *bytes, gboolean force_separators) { |
| 427 | | | guint8 val; |
| 428 | | | const guchar *p, *q, *r, *s, *punct; |
| 429 | | | char four_digits_first_half[3]; |
| 430 | | | char four_digits_second_half[3]; |
| 431 | | | char two_digits[3]; |
| 432 | | | char one_digit[2]; |
| 433 | | | |
| 434 | | | if (! hex_str || ! bytes) { |
Event 1:
Skipping " if". - hex_str evaluates to true.
- bytes evaluates to true.
hide
|
|
| 435 | | | return FALSE; |
| 436 | | | } |
| 437 | | | g_byte_array_set_size(bytes, 0); |
| 438 | | | p = (const guchar *)hex_str; |
| 439 | | | while (*p) { |
Event 3:
Entering loop body. *p evaluates to true.
hide
|
|
| 440 | | | q = p+1; |
| 441 | | | r = p+2; |
| 442 | | | s = p+3; |
| 443 | | | |
| 444 | | | if (*q && *r && *s |
| 445 | | | && isxdigit(*p) && isxdigit(*q) && |
| 446 | | | isxdigit(*r) && isxdigit(*s)) { |
| 447 | | | four_digits_first_half[0] = *p; |
| 448 | | | four_digits_first_half[1] = *q; |
| 449 | | | four_digits_first_half[2] = '\0'; |
| 450 | | | four_digits_second_half[0] = *r; |
| 451 | | | four_digits_second_half[1] = *s; |
| 452 | | | four_digits_second_half[2] = '\0'; |
| 453 | | | |
| 454 | | | |
| 455 | | | |
| 456 | | | |
| 457 | | | val = (guint8) strtoul(four_digits_first_half, NULL, 16); |
| 458 | | | g_byte_array_append(bytes, &val, 1); |
| 459 | | | val = (guint8) strtoul(four_digits_second_half, NULL, 16); |
Event 6:
strtoul() returns a potentially dangerous value [ ?potentially dangerous: the value cannot be determined and may come from program input]. - Determines the value that is cast in the Cast Alters Value warning later.
hide
Cast Alters Value
strtoul(...) is cast from unsigned long to unsigned char. - strtoul(...) could be 256 or higher.
- Values 256 or higher cannot be stored as unsigned char. Casting them to unsigned char can cause data loss or sign change.
The issue can occur if the highlighted code executes. See related event 6. Show: All events | Only primary events |
|
| |