Commit Graph

34 Commits

Author SHA1 Message Date
Evan Huus a452d16f2c Optimize epan_new/init_dissection
As Anders correctly pointed out in I7d8f84b2e, constantly resetting state will
turn init_dissection into a bit of a hot path. Especially as we will already
bear the overhead of switching files, we don't want to fall any further behind
than we have to.

This change includes three unrelated optimizations that reduce the cost of
init_dissection by about 40% as measured by callgrind:
 - only initialize ares/ADNS if that preference is enabled (this of course only
   applies if you specify -n to tshark or otherwise disable the preference)
 - use memcpy instead of a loop in sigcomp UDVM init
 - use memcpy instead of a loop in bootp dissector

The only remaining obvious hot spot in this path is reassembly_table_init since
it is called by so many dissectors. Suggestions (perhaps to get rid of the
GPtrArray) welcome.

Oh, and one other change to use g_strerror instead of strerror as insisted
upon by the API pre-commit hook.

Change-Id: I18a74f2b64b25498116079bd4e7fc2b335c7703a
Reviewed-on: https://code.wireshark.org/review/2738
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-07-01 04:21:14 +00:00
Peter Wu 4e82d2e34f sigcomp: Add buffer check to STATE-ACCESS
Two conditions were not checked, state_length == 0 && state_begin != 0
and the boundaries of the state buffer. The former is not a big deal,
but the second issue causes a buffer overrun (detected by ASAN).

The buffer size is supposed to be stored in the state buffer, that was
not the case for the initial two SIP SDP and Presence state buffers.
Fix a typo for presence_buf zero-ing while at it.

Bug: 9601
Change-Id: I41dde83185da60b670cca010ecc7b2a2aaaedeb9
Reviewed-on: https://code.wireshark.org/review/1529
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-06 14:03:12 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Evan Huus a6415ece0a Rename a couple of to_str functions to have ep_ in the name. This makes it
obvious that the returned string is ephemeral, and opens up the original names
in the API for versions that take a wmem pool (and thus can work in any scope).

svn path=/trunk/; revision=54249
2013-12-19 15:49:09 +00:00
Jakub Zawadzki 7b64bcf0b8 Move prototype of bytes_to_str, bytes_to_str_punct to correct header.
svn path=/trunk/; revision=53214
2013-11-10 09:44:02 +00:00
Bill Meier 0df5a9390d From beroset:
remove C++ incompatibilities
 https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 attachment #10397

svn path=/trunk/; revision=48438
2013-03-20 01:18:10 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Jakub Zawadzki b18e880040 Update FSF address - part II.
svn path=/trunk/; revision=43538
2012-06-28 23:18:38 +00:00
Bill Meier 4f420ef6cd Fix gcc 4.6 "set but not used [-Wunused-but-set-variable]" warnings
svn path=/trunk/; revision=37600
2011-06-07 22:28:55 +00:00
Sake Blok 6e74ad9097 Adress => Address corrections (also in comments).
(see bug 5600)


svn path=/trunk/; revision=35600
2011-01-21 00:19:03 +00:00
Gerald Combs 5f932275b0 Make sure our addresses are modulo 2^16 in a lot of places. Fixes a
crash found while fuzzing, and hopefully fixes bug 4867.

In sigcomp_init_udvm() initialize the first 8 bytes of our buffers,
which squelches a valgrind complaint.

svn path=/trunk/; revision=33321
2010-06-25 17:14:41 +00:00
Anders Broman 5b2722c6b3 Use g_hash_table_new_full().
svn path=/trunk/; revision=33072
2010-06-03 08:22:08 +00:00
Jaap Keuter cadfc325a8 From S. Ravi:
The svn version of wireshark does not decode a sigcomp message, if presence
static dictionary (RFC 5112) is used. I have attached a patch for adding this support.

svn path=/trunk/; revision=26550
2008-10-25 11:20:38 +00:00
Stephen Fisher 8fd3ee0560 Remove almost all of the casts I committed recently and in place of
them, add -Wno-pointer-sign to CFLAGS when gcc will accept it.


svn path=/trunk/; revision=21253
2007-03-28 21:55:11 +00:00
Stephen Fisher 46b8669566 Fix a bunch more warnings. Add -Werror when using --with-warnings-as-errors
under gcc to tools/lemon, plugins/mate and epan/


svn path=/trunk/; revision=21204
2007-03-26 06:10:52 +00:00
Ulf Lamping 3e32597719 fix some more warnings
svn path=/trunk/; revision=21104
2007-03-22 00:40:04 +00:00
Anders Broman 2f849c368a From Cristian Constantin:
As a workarond for the problem that accsessing a state with a state id > the stored
minimum access length fail,  only store and compare the state with the minimum access
lengt specified in the standard of 6 bytes.

svn path=/trunk/; revision=20041
2006-12-05 06:43:47 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +00:00
Anders Broman 647742574e make n a guint32 to not wrap around at 65536
svn path=/trunk/; revision=16055
2005-09-29 20:22:55 +00:00
Anders Broman 264288023c It's the UDVM_MEMORY_SIZE that should be checked.
svn path=/trunk/; revision=16040
2005-09-28 16:38:40 +00:00
Ulf Lamping 2a1b178691 fix MSVC warning: sigcomp_state_hdlr.c(601) : warning C4101: 'partial_state_str' : unreferenced local variable
svn path=/trunk/; revision=15735
2005-09-09 00:22:37 +00:00
Gerald Combs a67948bac7 Add bounds checking in several places to the SigComp UDVM. Use memset()
instead of while loops to initialize variables.  Use a define instead
of magic numbers.  Don't use guint8s for counters.  Add a corresponding
entry to the release notes.

svn path=/trunk/; revision=15715
2005-09-07 20:09:40 +00:00
Ulf Lamping 0dc9fb3d4a various code cleanup:
-use g_snprintf instead of sprintf and snprintf
-use g_strdup_printf where appropriate
-remove #include "snprintf.h" (as only g_snprintf should be used)
-replace some more alloc/realloc/calloc/free with their glib pendants

svn path=/trunk/; revision=15264
2005-08-08 18:50:39 +00:00
Jörg Mayer 4f693dfae2 Some warning fixes for "no previous declaration"
Remove svn:executable
Add svn:eol-style native
Add svn:keywords Id


svn path=/trunk/; revision=15179
2005-08-02 05:39:45 +00:00
Anders Broman 681f2bbdef From Paul Ollis:
epan/sigcomp_state_hdlr.c epan/sigcomp_state_hdlr.h
  ---------------------------------------------------

    Function udvm_state_access:

        1. Removed the state_vars_valid parameter. It is no longer used.

        2. The function now correctly updates each of state_length,
           state_address and state_instruction with saved state value.

           [Previously this was only done for state referenced in the SigComp
            message header.]

        3. Removed code that (incorrectly) read byte_copy_left from UDVM memory
           within the loop that writes the state to UDVM memory.

        4. Removed the code that set the useful values in UDVM memory. This
           should only be done for state referenced in the SigComp message
           header. (The decompress_sigcomp_message function, sets the useful
           values.)


  epan/sigcomp-udvm.c epan/sigcomp-udvm.h
  ---------------------------------------

    Function decompress_sigcomp_message:

        1. Added three new parameters; header_len, byte_code_state_len,
           byte_code_id_len.  The byte_code_state_len and byte_code_id_len
           are used to set the useful values in UDVM memory. The
           header_len is required to calculate the cycles available
           for decompression.

        2. Various minor corrections to spellings, etc in generated
           messages.

        3. Reduced the number of lines of output for print_level_1. Now
           the execution trace shows the instruction name and parameter
           values on one line.

           [This was done because, we found that even at the lowest
           level of detail ethereal became unusably slow; running on
           a 500 MHz SPARC. This seems to be related to the number of
           lines produced by the SigComp trace, which can easily be over
           1000 with the modified code.]

        4. Removed the used of some floating point functions. In all
           cases they were unnecessary and could potentially cause the
           code to produce the wrong results on some platforms (although
           this is unlikely).

        5. The useful values are now set correctly, using the new
           byte_code_state_len and byte_code_id_len parameters.

        6. The message header length is now included in the calculation of
           maximum_UDVM_cycles. Previously, the calculation could underestimate
           the value, resulting in the (small) chance that some legitimate
           messages might fail to decompress.

           Note: The calculation might now slightly over-estimate the cycles
           but this is a reasonable thing to do.

        7. Implemented the PUSH, POP, CALL and RETURN instructions.

           Note: The two SORT instructions and the CRC and SHA-1 instructions
           are still not implemented.

        8. The COPY and COPY-LITERAL instructions now apply the
           byte-copying-rules to the source address as well as the destination
           address.

        9. The COPY-LITERAL and COPY-OFFSET now correctly handle the
           destination operand. Previously, it was possible for the destination
           to be left at byte_copy_right when it should be left at
           byte_copy_left.

        10. All three COPY instructions will now behave correctly if the source
            or destination start at byte_copy_right; i.e. they read/write to
            byte_copy_right, byte_copy_right+1, etc. Previously the parameters
            would wrap to byte_copy_left.

        11. The COPY-OFFSET instruction now correctly calculates the source
            address for all values of offset. Previously a very large offset
            (greater than the circular buffer size) could cause the starting
            position to be mis-calculated.

        12. Modulo 65536 arithmetic has been added in some places where it was
            missing.

            [Only when noticed, we have not been able to check all the code.]

        13. Some redundant code was removed for the INPUT-BITS instruction.
            Also, INPUT-BITS (0, x, x) now correctly discards spare bits when
            the P-bit, has changed.

        14. Corrected the cycles used calculation for the INPUT-BITS
            instruction.

        15. Corrected some minor cases where the used_udvm_cycles was not
            incremented.

            [Not really a problem, but it allowed us to verify correctness with
            some of the SigComp torture tests.]

        16. Removed some redundant code in INPUT-HUFFMAN (and reorganised some
            comments to keep them making sense).


    Function decomp_dispatch_get_bits:

        1. This has been rewritten. The original version could not correctly
           handle requests for more than 8 bits. The new version is cleaner and
           correctly handles all cases.

svn path=/trunk/; revision=14666
2005-06-16 21:15:12 +00:00
Ulf Lamping 2f836c20a8 fix a typo: lenght -> length
This seems to be a "more common" typo, fixed it 13 times throughout the code ...

svn path=/trunk/; revision=13452
2005-02-20 22:36:34 +00:00
Anders Broman 000ed1ead4 Bugfix incorect while condition from Mutsuya Irie
svn path=/trunk/; revision=13166
2005-01-24 19:25:28 +00:00
Jörg Mayer 3b125f22e8 Add NL to last line
svn path=/trunk/; revision=12788
2004-12-20 10:56:25 +00:00
Anders Broman 91c42c8655 Don't free string that don't need it. Added filter possibillity on Partial state
svn path=/trunk/; revision=12582
2004-11-23 22:02:00 +00:00
Anders Broman 214d684823 Fix some memmory leaks
svn path=/trunk/; revision=12579
2004-11-22 22:18:18 +00:00
Anders Broman 010995250b Clean-up hash table at reloading of file.
svn path=/trunk/; revision=12568
2004-11-21 22:26:53 +00:00
Anders Broman 8ee46e0006 Free the statebuff and the string
svn path=/trunk/; revision=12567
2004-11-21 22:08:40 +00:00
Anders Broman ca2b359041 Implemented state-create, handling of g_hash_table at redesection needs more work.
svn path=/trunk/; revision=12531
2004-11-16 22:15:14 +00:00
Anders Broman 136da6ad35 Add sigcomp Universal Decompressor Virtual Machine (UDVM) and state handler, for decompression of
sigcomp messages. Currently states are or not saved so only messages with bytecode can be decompressed.

svn path=/trunk/; revision=12236
2004-10-08 15:54:06 +00:00