Commit Graph

41 Commits

Author SHA1 Message Date
John Thacker 13df9b0b64 HTTP: Speed up chunked Transfer-Encoding on TCP
HTTP/1.1 chunked Transfer-Encoding doesn't have a overall length,
but requires scanning through variable length chunks to find the
end. If we determine that additional segments are needed, and
we have a sequence number (or other identifier) for the message,
store the position of the last chunk size found.

Use this to start scanning at that same offset when the next
segment arrives, reducing the algorithm for determining if
when we have the complete chunked message from O(N^2) to O(N),
which can be significant on captures with many chunks.

This does most of #14382, reducing the length of time to process
a file with 2 pass tshark from over 8.5 secs to under 3 seconds
on my machine. There is still some O(N^2) contribution from the
reassembly code itself with many small fragments (see #17311).

Other dissectors need some small changes to enable this for
HTTP over other transport layers. (TLS would be fairly easy and
is the other important case.)
2022-08-10 05:31:36 +00:00
Evan Huus d6d7dd1e56 First pass pinfo->pool conversion
Automated find/replace of wmem_packet_scope() with pinfo->pool in all
files where it didn't cause a build failure.

I also tweaked a few of the docs which got caught up.
2021-07-21 05:38:29 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
Dario Lombardo 25e19aefcf req_resp_hdrs: add initializer (CID: 1445004).
Change-Id: I827efe9aa9d7c8342df6d356e4caa12dbe74d095
Reviewed-on: https://code.wireshark.org/review/33148
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-05-10 20:08:06 +00:00
Peter Wu 69e50be150 HTTP: fix bad reassembly with Content-Type and no Content-Length
Any request or response with the Content-Type header and no
Content-Length header would cause the HTTP dissector to combine all
segments until the end of the connection. This is bogus, it should only
do this for HTTP responses under stricter conditions.

To fix this issue: 1) explicitly disable body desegmentation for
messages that never have a message body, 2) restrict "desegmentat until
the end" to HTTP responses.

The "Connection: Keep-Alive" case was a fix for bug 1142, but that is
now properly addressed by checking for the 304 status code.

Bug: 13116
Change-Id: I02371ac88ec2de6ee966fdc6df0dd246ad49c46d
Reviewed-on: https://code.wireshark.org/review/33035
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-05-08 01:54:41 +00:00
Peter Wu 4802e3300d HTTP: ignore large Content-Length values
The SSTP capture from bug 8239 failed to be recognized as SSTP.  Its
large Content-Length was parsed as -1 which triggered reassembly due to
tvb_bytes_exist returning FALSE for negative lengths.

Test:

    # Expect 'SSTP_DUPLEX_POST /' in the output of:
    tshark -r sstp.pcapng -ossl.keys_list:localhost,443,http,sstp.pem, -Y frame.number==174 -Px

Change-Id: I40afaff8554f34f24e09bab184121ced59045954
Fixes: v2.9.0rc0-531-gd80acae40d ("tvbuff: make tvb_bytes_exist fail with negative values")
Reviewed-on: https://code.wireshark.org/review/29109
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-08-13 07:57:21 +00:00
Dario Lombardo 55c68ee69c epan: use SPDX indentifiers.
Skipping dissectors dir for now.

Change-Id: I717b66bfbc7cc81b83f8c2cbc011fcad643796aa
Reviewed-on: https://code.wireshark.org/review/25694
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 19:29:45 +00:00
Michael Mann 3606f80d9e Officially remove tvb_get_string and tvb_get_stringz.
Almost all replacements were done awhile ago, just put the final nail in the coffin.

Change-Id: I0a708d886da5a500c2a1e2c9ee2736794bdb9411
Reviewed-on: https://code.wireshark.org/review/12206
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-11-27 05:11:25 +00:00
Guy Harris 9fba5f0764 Fix some cases where we're shifting a signed 1 left.
Shift 1U instead, to make sure it's unsigned; the result of, for
example, the result of shifting a signed value left is undefined if the
value times 2^{shift count} doesn't fit in the *signed* type of the
shifted value.  That means, in particular, that the result of shifting 1
left by {number of bits in an int - 1} is undefined.  (In *practice*,
it'll probably be -2^32, with the bit you want set, but that's not
guaranteed, and GCC 5.1 seems not to like it.)

Change-Id: I0d27565c382a04ceda9eec65f45a430ceb74cf53
Reviewed-on: https://code.wireshark.org/review/8255
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-04-30 22:22:59 +00:00
Bill Meier a379ac74d2 Fix spelling: cant-->can't, wont-->won't, etc
Change-Id: Ia6c3e7a25615bf8e052c3bacf096d76df775c9c2
Reviewed-on: https://code.wireshark.org/review/4126
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-16 15:31:58 +00:00
AndersBroman 836530e985 - Replace tvb_length_remaining -> tvb_captured_length_remaining,
- Use length_remaining in tvb_find_line_end() rather than -1 it should
  give a faster code path.

Change-Id: Ia6c289f1701add48429b25152db8a8e5cea9e053
Reviewed-on: https://code.wireshark.org/review/1632
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-14 10:50:22 +00:00
AndersBroman d0edbd31eb Use tvb_get_string_enc() with UTF_8 when checking headers as it's faster.
Change-Id: I88cd6f71c1fcbf67948dd0ebdc6e5641d6ba111c
Reviewed-on: https://code.wireshark.org/review/891
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-31 15:59:15 +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
Pascal Quantin a0c53ffaa1 emem -> wmem conversion:
- ep_tvb_get_bits() -> wmem_packet_tvb_get_bits()
- tvb_g_memdup()/ep_tvb_memdup() -> tvb_memdup()
- tvb_fake_unicode()/tvb_get_ephemeral_faked_unicode() -> tvb_get_faked_unicode()
- tvb_get_g_string()/tvb_get_ephemeral_string()/tvb_get_seasonal_string() -> tvb_get_string()
- tvb_get_g_unicode_string()/tvb_get_ephemeral_unicode_string() -> tvb_get_unicode_string()
- tvb_get_ephemeral_string_enc() -> tvb_get_string_enc()
- update docs accordingly

svn path=/trunk/; revision=52172
2013-09-22 15:50:55 +00:00
Evan Huus 40a83d1e2c As per the HTTP spec, prefer chunked transfer-encoding to content-length if we
get both. Fixes reassembly for
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9101

svn path=/trunk/; revision=51785
2013-09-05 15:48:50 +00:00
Evan Huus ba77e3c54d Add an optimization to req_resp_hdrs_do_reassembly that shaves about 20% off
the load time of one of my sample captures that is HTTP-but-not-really.

Also add modelines.

svn path=/trunk/; revision=49551
2013-05-24 02:31:26 +00:00
Guy Harris 8ed7a73e22 Fix a bunch of warnings.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().

Change some data types to avoid those implicit conversion warnings.

When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.

Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers.  Cast
away those warnings in some cases where an API we don't control forces
us to do so.

Enable a bunch of additional warnings by default.  Note why at least
some of the other warnings aren't enabled.

randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.

If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.

svn path=/trunk/; revision=46748
2012-12-26 05:57:06 +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 bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Ronnie Sahlberg 7e0c167eb0 HTTP: RPC/HTTP do a better detection and parsing of RPC over HTTP
From Matthieu Patou <mat@matws.net>

svn path=/trunk/; revision=42773
2012-05-22 06:23:36 +00:00
Anders Broman f19eee998f Try to optimize a bit.
svn path=/trunk/; revision=32973
2010-05-26 11:51:41 +00:00
Jeff Morriss 3138f91c9a Fix a typo
svn path=/trunk/; revision=30267
2009-10-03 09:15:40 +00:00
Jeff Morriss c8df8a78ac Since chunk_size is now unsigned, check to ensure that it is not "too big."
(Prior to rev 30233 there was a check to make sure it was not negative. This
effectively puts that same check back in.)

Fixes the fuzz failure seen in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4083

svn path=/trunk/; revision=30260
2009-10-03 03:09:53 +00:00
Stig Bjørlykke 6b55417b9c Added a cast to avoid another warning.
svn path=/trunk/; revision=30237
2009-10-01 15:03:02 +00:00
Stig Bjørlykke 9a0714cfed Fixed input argument for sscanf "%x" (shall be unsigned int).
Check that this value has been set.

svn path=/trunk/; revision=30233
2009-10-01 14:38:37 +00:00
Bill Meier 94f28dd8f9 (FWIW) One step towards including stdio.h & stdlib.h only when req'd.
svn path=/trunk/; revision=29568
2009-08-26 19:27:49 +00:00
Gerald Combs f0eeb0bdf1 More size_t fixes. Use a string buffer in range.c.
svn path=/trunk/; revision=27999
2009-04-08 16:50:20 +00:00
Anders Broman 63c5c71cf8 Remove:
#ifdef NEED_G_ASCII_STRCASECMP_H
#include "g_ascii_strcasecmp.h"
#endif

svn path=/trunk/; revision=24859
2008-04-09 05:36:08 +00:00
Guy Harris 9c89cdaaa3 strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est.  Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).

In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.

We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot.  This causes strings that should
match not to match.

This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.

svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
Mike Duigou a8a69a14f6 From Yaniv kaul:
Adds const declarations to req_resp_hdrs_do_reassembly() and re-orders some actions to occur after tests which may decide that the actions were not required.


svn path=/trunk/; revision=23504
2007-11-19 21:28:08 +00:00
Sake Blok a4decea55b Fixes reassembly of chunked http-responses spanning multiple tcp segments
(bugs 1581,1851 and 1868)


svn path=/trunk/; revision=23061
2007-10-03 17:07:19 +00:00
Richard van der Hoff 969bb158f6 From Mike Duigou <wireshark@duigou.org> (bug 1698):
Enclosed is a patch with fixes problems with the desegmentation of chunked HTTP
message bodies.

...

Changing the value of pinfo->desegment_len to DESEGMENT_ONE_MORE_SEGMENT rather
than the current 1 or 2 seems to make everything work. (I'm kind of confused as
to why the headers resassembly code already used DESEGMENT_ONE_MORE_SEGMENT and
the body reassembly code did not).


svn path=/trunk/; revision=22570
2007-08-21 20:57:52 +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
Ronnie Sahlberg b6059df9e2 fix for bug 1142
if we dont have a content-length   but we do have a keepalive in the header then we should not do reassemble-until-fin.

convert some tvb_get_String into tvb_get_ephemeral_string at the same time


svn path=/trunk/; revision=19874
2006-11-10 20:53:42 +00:00
Ronnie Sahlberg 5a0ba5b0c7 fix for bug 1200
there used to be a bug in tcp reassembly that even if the dissector only asked for x more bytes from the next segment   the entire segment would still be added to reassembly.
this caused some issues when there was a new multisegment pdu that started at the end of the segment   but this bug was fixed when tcp reassembly was refactored semi-recently.


there was also another "bug" in the http reassembly that it would only ask for one more byte at a time when doing reassembly.
this did work well however when we still had the bug in tcp reassembly   but made wireshark become very very very slow once this tcp bug was fixed  since it is very very very slow to reassemble a huge http pdu just one byte at a time.


this patch adds partial support (what we need for http   which does not use tcp_dissect_pdus() ) for the desegmentation flag : DESEGMENT_ONE_MORE_SEGMENT and also to the http dissector   so that reassembly of http headers spanning multiple semgents now become fast again



svn path=/trunk/; revision=19859
2006-11-07 13:19:31 +00:00
Ronnie Sahlberg 6d3c94a53a implement support to reassemble tcp sessions until the end of the session (FIN)
add required code to the http (and others) code in req_resp_hdrs.c to signal to tcp
when it wants a session to be reassembled to the FIN.

This is currently done for all HTTP packets where we have a Content-type in the header but no content-length.




svn path=/trunk/; revision=19185
2006-09-10 14:03:08 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +00:00
Guy Harris c04a9a4180 There's no guaranteee that "req_resp_hdrs_do_reassembly()" gets called
only at the beginning of a tvbuff, so it needs an argument that's the
starting offset in the tvbuff.

svn path=/trunk/; revision=13128
2005-01-20 04:37:03 +00:00
Guy Harris fe833fc123 From Chris Maynard: free strings fetched with "tvb_get_string()" when
we're done with them.

svn path=/trunk/; revision=12975
2005-01-07 10:49:05 +00:00
Guy Harris 31158d0d0e Move the request/response header helper routines to the epan directory.
svn path=/trunk/; revision=12129
2004-09-29 00:25:05 +00:00