(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/k12text.c) |
| |
| 2457 | | | static gboolean k12text_dump(wtap_dumper *wdh _U_, const struct wtap_pkthdr *phdr, |
| 2458 | | | const union * _U_, |
| 2459 | | | const guchar *pd, int *err _U_) { |
| 2460 | | | char buf[196808]; |
| 2461 | | | size_t left = 196808; |
| 2462 | | | gint wl; |
| 2463 | | | char* p=buf; |
| 2464 | | | const char* str_enc = ""; |
| 2465 | | | guint i; |
| 2466 | | | guint ns; |
| 2467 | | | guint ms; |
| 2468 | | | |
| 2469 | | | ms = phdr->ts.nsecs / 1000000; |
| 2470 | | | ns = (phdr->ts.nsecs - (1000000*ms))/1000; |
| 2471 | | | |
| 2472 | | | for(i=0; encaps[i].s; i++) { |
| 2473 | | | str_enc = encaps[i].s; |
| 2474 | | | if (phdr->pkt_encap == encaps[i].e) break; |
| 2475 | | | } |
| 2476 | | | |
| 2477 | | | strftime(p,90,"+---------+---------------+----------+\r\n%H:%M:%S,",gmtime(&phdr->ts.secs)); |
| 2478 | | | wl = strlen(p); |
| 2479 | | | p += wl; |
| 2480 | | | left -= wl; |
| 2481 | | | |
| 2482 | | | wl = g_snprintf(p,left,"%.3d,%.3d %s\r\n|0 |",ms,ns,str_enc); |
| 2483 | | | p+= wl; |
| 2484 | | | left -= wl; |
| 2485 | | | |
| 2486 | | | for(i=0;i < phdr->caplen && left > 2; i++) { |
| 2487 | | | wl = g_snprintf(p,left,"%.2x|",pd[i]); |
| 2488 | | | p += wl; |
| 2489 | | | left -= wl; |
| 2490 | | | } |
| 2491 | | | |
| 2492 | | | wl = g_snprintf(p,left,"\r\n\r\n"); |
| 2493 | | | p+= wl; |
| 2494 | | | left -= wl; |
| 2495 | | | |
| 2496 | | | fwrite(buf, 1, strlen(buf), wdh->fh); |
Ignored Return Value
The return value of fwrite() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- CodeSonar is configured to enforce Ignored Return Value checks for fwrite(). (To change the set of enforced Ignored Return Value checks, use configuration file parameters RETURN_CHECKER_CHECKED_FUNCS and RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 2497 | | | |
| 2498 | | | return TRUE; |
Event 2:
!0 evaluates to true.
hide
|
|
| 2499 | | | } |
| |