ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-bugs: [Wireshark-bugs] [Bug 2037] New: Bad use of the C fwrite function in pcapio.c

Date: Wed, 28 Nov 2007 14:39:08 +0000 (GMT)
http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2037

           Summary: Bad use of the C fwrite function in pcapio.c
           Product: Wireshark
           Version: 0.99.4
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: High
         Component: Wireshark
        AssignedTo: wireshark-bugs@xxxxxxxxxxxxx
        ReportedBy: daniel-jamet@xxxxxxxxxxxxxxxxxxxx


Build Information:
wireshark 0.99.4

Copyright 1998-2006 Gerald Combs <gerald@xxxxxxxxxxxxx> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiled with GTK+ 2.4.13, with GLib 2.4.7, with libpcap 0.8.3, with libz
1.2.1.2, without libpcre, without UCD-SNMP or Net-SNMP, without ADNS, without
Lua, without GnuTLS, without Gcrypt, with MIT Kerberos, without PortAudio,
without AirPcap.
NOTE: this build doesn't support the "matches" operator for Wireshark filter
syntax.

Running on Linux 2.6.9-34.EL, with libpcap version 0.8.3.

Built using gcc 3.4.5 20051201 (Red Hat 3.4.5-2).
--
In the file pcapio.c, The libpcap_fdopen and the libpcap_write_packet functions
use the fwrite funcion badly. 

The return value of the fwrite function is the total number of elements
successfully written but the code is write as if the return value is the number
of bytes successfully written.

For example, in the libpcap_write_packet function, we find:
        nwritten = fwrite(&rec_hdr, 1, sizeof rec_hdr, fp);
        if (nwritten != sizeof rec_hdr) {
                if (nwritten == 0 && ferror(fp))
                        *err = errno;
                else
                        *err = 0;       /* short write */
                return FALSE;
        }

Kind Regards


-- 
Configure bugmail: http://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.