(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/ftypes/ftype-guid.c) |
| |
| 47 | | | get_guid(char *s, e_guid_t *guid) |
| 48 | | | { |
| 49 | | | size_t i, n; |
| 50 | | | char *p, digits[9]; |
| 51 | | | static const char fmt[] = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; |
| 52 | | | |
| 53 | | | n = strlen(s); |
| 54 | | | if (n != strlen(fmt)) |
Event 1:
Skipping " if". n != strlen(fmt) evaluates to false.
hide
|
|
| 55 | | | return FALSE; |
| 56 | | | for (i=0; i<n; i++) { |
| 57 | | | if (fmt[i] == 'X') { |
| 58 | | | if (!isxdigit((guchar)s[i])) |
| 59 | | | return FALSE; |
| 60 | | | } else { |
| 61 | | | if (s[i] != fmt[i]) |
| 62 | | | return FALSE; |
| 63 | | | } |
| 64 | | | } |
| 65 | | | |
| 66 | | | p = s; |
| 67 | | | strncpy(digits, p, 8); |
| 68 | | | digits[8] = '\0'; |
| 69 | | | guid->data1 = (guint32)strtoul(digits, NULL, 16); |
| 70 | | | p += 9; |
| 71 | | | strncpy(digits, p, 4); |
| 72 | | | digits[4] = '\0'; |
| 73 | | | guid->data2 = (guint16)strtoul(digits, NULL, 16); |
| 74 | | | p += 5; |
| 75 | | | strncpy(digits, p, 4); |
| 76 | | | digits[4] = '\0'; |
| 77 | | | guid->data3 = (guint16)strtoul(digits, NULL, 16); |
| 78 | | | p += 5; |
| 79 | | | for (i=0; i < sizeof(guid->data4); i++) { |
Event 3:
Entering loop body. i < sizeof( guid->data4 ) evaluates to true.
hide
|
|
| 80 | | | if (*p == '-') p++; |
Event 4:
Skipping " if". *p == 45 evaluates to false.
hide
|
|
| 81 | | | digits[0] = *(p++); |
| 82 | | | digits[1] = *(p++); |
| 83 | | | digits[2] = '\0'; |
| 84 | | | guid->data4[i] = (guint8)strtoul(digits, NULL, 16); |
Event 5:
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(digits, (void *)0, 16) is cast from unsigned long to unsigned char. - strtoul(digits, (void *)0, 16) 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 5. Show: All events | Only primary events |
|
| |