(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/commview.c) |
| |
| 317 | | | static gboolean commview_dump(wtap_dumper *wdh, |
| 318 | | | const struct wtap_pkthdr *phdr, |
| 319 | | | const union *, |
| 320 | | | const guchar *pd, int *err) |
| 321 | | | { |
| 322 | | | cv_hdr; |
| 323 | | | size_t bytes_written = 0; |
| 324 | | | char date_time[5]; |
| 325 | | | |
| 326 | | | memset(&cv_hdr, 0, sizeof(cv_hdr)); |
| 327 | | | |
| 328 | | | cv_hdr.data_len = GUINT16_TO_LE((guint16)phdr->caplen); |
| 329 | | | cv_hdr.source_data_len = GUINT16_TO_LE((guint16)phdr->caplen); |
| 330 | | | cv_hdr.version = 0; |
| 331 | | | |
| 332 | | | strftime(date_time, 5, "%Y", localtime(&phdr->ts.secs)); |
| 333 | | | cv_hdr.year = GUINT16_TO_LE((guint16)strtol(date_time, NULL, 10)); |
| 334 | | | |
| 335 | | | strftime(date_time, 5, "%m", localtime(&phdr->ts.secs)); |
| 336 | | | cv_hdr.month = (guint8)strtol(date_time, NULL, 10); |
| 337 | | | |
| 338 | | | strftime(date_time, 5, "%d", localtime(&phdr->ts.secs)); |
| 339 | | | cv_hdr.day = (guint8)strtol(date_time, NULL, 10); |
| 340 | | | |
| 341 | | | strftime(date_time, 5, "%H", localtime(&phdr->ts.secs)); |
| 342 | | | cv_hdr.hours = (guint8)strtol(date_time, NULL, 10); |
| 343 | | | |
| 344 | | | strftime(date_time, 5, "%M", localtime(&phdr->ts.secs)); |
| 345 | | | cv_hdr.minutes = (guint8)strtol(date_time, NULL, 10); |
| 346 | | | |
| 347 | | | strftime(date_time, 5, "%S", localtime(&phdr->ts.secs)); |
| 348 | | | cv_hdr.seconds = (guint8)strtol(date_time, NULL, 10); |
Event 1:
strtol() 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
strtol(...) is cast from long to unsigned char. - strtol(...) could be -1 or lower.
- Negative values 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 1. Show: All events | Only primary events |
|
| |