(/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); |
Event 3:
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 short. - strtoul(digits, (void *)0, 16) could be 65536 or higher.
- Values 65536 or higher cannot be stored as unsigned short. Casting them to unsigned short can cause data loss or sign change.
The issue can occur if the highlighted code executes. See related event 3. Show: All events | Only primary events |
|
| |