Commit Graph

229 Commits

Author SHA1 Message Date
Michael Mann 2717766a9a Use tcp_dissect_pdus in DCE/RPC dissector when running atop TCP.
Yes DCE/RPC runs on top of many dissectors, all which need their own fragmentation support, but TCP can give it to you "for free".  DCE/RPC protocol format is also very conducive to it.

Ping-Bug: 6392
Change-Id: I0d16854fed3d9c4229c3d2973782f676a51dd719
Reviewed-on: https://code.wireshark.org/review/4923
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-10-31 05:33:09 +00:00
Guy Harris c4dc9eda80 Handle an hfindex of -1.
Code generated by the current version of Pidl dissects bitset fields
twice - once with proto_tree_add_item(), which puts the actual item into
the tree, so that we can create a subtree under it, and once with a
dissect_dcerpc_{type}() routine, to fetch the value and step past the
field.  The second call passes an hf_ index value of -1; interpret that
as meaning "don't put this into the protocol tree", rather than just
blindly calling proto_tree_add_XXX with -1 and getting a dissector
assertion.

Change-Id: I42fc023e77514a8a8a25d5c9db11fa3ef053babf
Reviewed-on: https://code.wireshark.org/review/4892
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-21 07:52:13 +00:00
Michael Mann 5e4e17ca5e Remove unnecessary tvb_ensure_bytes_exist calls.
All of the calls removed are followed by proto_tree_add_xxx calls of the same offset/length of the tvb_ensure_bytes_exist call.  The proto_tree_add_xxx calls should throw the exception, so we don't need the "double check".
There are probably more calls that can be removed, these were just obvious as first glance, spurred mostly by noticing the (ab)use in packet-wsp.c

Change-Id: I37cee347c8cf8ab0559e21562c802d3b37f4871e
Reviewed-on: https://code.wireshark.org/review/4833
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-10-19 15:26:43 +00:00
Evan Huus b8065a5b7d dcerpc: correctly initialize certain struct fields
Bug: 10482
Change-Id: I4d39d6a79d4ab89685a17a0c622c6181e4fada3d
Reviewed-on: https://code.wireshark.org/review/4233
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-09-22 02:55:16 +00:00
Michael Mann 06237e4878 proto_tree_add_text -> proto_tree_add_subtree[_format] for DCE/RPC dissectors.
Change-Id: I84755d059ef70ca98b0e7626b6425360daf0529d
Reviewed-on: https://code.wireshark.org/review/4199
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-09-20 11:59:25 +00:00
Michael Mann e489df5024 Don't assert that values fit in 32 bits if the NDR64 flag is set.
For now, this just pacifies fuzz-testing.  If real world examples have this, there needs to be a drastic overhaul to support fields that could be either 32 or 64-bit values.

Bug:9329
Change-Id: I3e28808ca0291868a5f84258b0ee1e2a922703c2
Reviewed-on: https://code.wireshark.org/review/4189
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-09-19 21:54:02 +00:00
Bill Meier b14bf98c06 Fix spelling: cant-->can't, wont-->won't, etc
Change-Id: I4497f1b8b6eab0e576d9dd31b732965f9a6679c6
Reviewed-on: https://code.wireshark.org/review/4124
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-16 13:51:51 +00:00
Evan Huus 8d51a50a81 Remove get_next_di() and just use packet-scope for those
Presumably that was added for tap purposes, but packet-scope is much simpler and
less dangerous. Noticed while investigating the scan-build issues with
stack-local variables being pointed to by globals.

Change-Id: I851d756b103df71079b656e624f7472354c15862
Reviewed-on: https://code.wireshark.org/review/3290
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-08-03 08:42:46 +00:00
Evan Huus a644744fb9 Use packet_scope instead of a stack local
As clang pointed out we end up storing a reference to it in a global and (more
relevantly) pushing that global to a tap which would run after the current frame
has returned.

Thanks to Alexis for bringing this to my attention.

Change-Id: I3aac43a806d217b0dc8a973f6bb2fa48cdd041bb
Reviewed-on: https://code.wireshark.org/review/3289
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-08-01 09:32:30 +00:00
Michael Mann 14824e6adf Revert "Fixup: tvb_* -> tvb_captured"
https://www.wireshark.org/lists/wireshark-dev/201406/msg00131.html

This reverts commit 246fe2ca4c.

Change-Id: Ib24bae0198c13a84bd7f731bf4af921212109a8f
Reviewed-on: https://code.wireshark.org/review/2430
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-06-19 18:25:59 +00:00
Dario Lombardo 246fe2ca4c Fixup: tvb_* -> tvb_captured
Change-Id: I9209c1271967405c34c1b6fa43e1726a4d3a5a3f
Reviewed-on: https://code.wireshark.org/review/2377
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-06-18 14:14:58 +00:00
Bill Meier 7a1848b95d Fix gcc "warning: no previous prototype ... [-Wmissing-prototypes]"; Do some whitespace changes
Change-Id: I8c2e8694223270f1810aa6b13d955f0d08001d30
Reviewed-on: https://code.wireshark.org/review/1239
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Tested-by: Bill Meier <wmeier@newsguy.com>
2014-04-21 16:48:17 +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
Bill Meier 93fe4d53e2 Remove trailing whitespace.
Change-Id: Ia03a1cd4590aceda30ead4aa93ad413d90c6aea6
Reviewed-on: https://code.wireshark.org/review/372
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Tested-by: Bill Meier <wmeier@newsguy.com>
2014-02-25 16:36:38 +00:00
Bill Meier 8ab9c55618 From Ville Skyttä: Spelling Fixes
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9591


svn path=/trunk/; revision=54387
2013-12-23 15:53:13 +00:00
Evan Huus 2ae8edccea Rename more to_str functions to have ep_ in the name if they return ephemeral
buffers. Remove two unused functions.

svn path=/trunk/; revision=54250
2013-12-19 16:28:39 +00:00
Guy Harris 59dddc25ec In dissect_ndr_byte_array(), use the field index from the dcerpc_info
structure, rather than a fixed field.  Get rid of that fixed field, as
it's no longer needed.

Use dissect_ndr_byte_array() rather than dissect_ndr_char_cvstring() in
a case where we have an opaque byte array.

Have dissect_ndr_cvstring() and dissect_ndr_vstring() - and, therefore,
routines that call them, such as dissect_ndr_cstring(),
dissect_ndr_char_cvstring(), dissect_ndr_char_vstring(), and
dissect_ndr_wchar_vstring() - require that the field being used by an
FT_STRING field.  Manually fix a case where the PIDL generator makes
such a field FT_NONE rather than FT_STRING.  Also handle EBCDIC, just in
case we happen to see a packet with EBCDIC strings.

Use tvb_get_string_enc(), rather than tvb_get_unicode_string() or
tvb_get_string(), in dissect_ndr_cvstring() and dissect_ndr_vstring().

svn path=/trunk/; revision=54134
2013-12-15 19:48:15 +00:00
Bill Meier ebaeed5a1f (Trivial)
- Fix indentation to match editor modelines (tabs-->spaces);
 - Rework/add some whitespace;

svn path=/trunk/; revision=53978
2013-12-12 20:16:30 +00:00
Gerald Combs 17a67c3b5c Get the "Decode As" dialog working, albeit with a few warts. It differs
from the GTK flavor in two major ways:

- The "Decode As" and "User Specified Decodes" dialog have been unified.
- You can modify the decode as behavior at any time, not just when you
  have a packet selected.

Revert part of 53498 so that we can move items marked

/*** THE FOLLOWING SHOULD NOT BE USED BY ANY DISSECTORS!!! ***/

from epan/decode_as.h to ui/decode_as_utils.h. 

Move "save" code from decode_as_dlg.c to decode_as_utils.c as well.

In packet-dcerpc.c don't register a table named "ethertype". We might
want to add checks for duplicate table names.

To do:
- Add support for ranges?
- Either add support for DCERPC or make DCERPC use a regular dissector
  table.
- Fix string selectors (i.e. BER).


svn path=/trunk/; revision=53910
2013-12-10 19:23:26 +00:00
Michael Mann 6505190fb7 Move DCERPC data in packet_info needed for Decode As into packet scoped proto data.
svn path=/trunk/; revision=53559
2013-11-25 00:14:50 +00:00
Michael Mann e2df7c83cb Move dceprc_procedure_name from packet_info to dcerpc_info. Doesn't appear to be "used" by dissectors, just stored (for help in debugging?).
svn path=/trunk/; revision=53552
2013-11-24 20:55:55 +00:00
Michael Mann 32b66a9671 Fix memory leak from formatted string.
svn path=/trunk/; revision=53468
2013-11-21 03:26:42 +00:00
Guy Harris 8b8cf5671d strncpy() consideered unsafe (it doesn't, for example, guarantee that
the result is null-terminated); use g_strlcpy() (which *does* guarantee
null termination) instead.

svn path=/trunk/; revision=53461
2013-11-21 00:38:22 +00:00
Pascal Quantin ff6a590edb Mark another parameter as unused
svn path=/trunk/; revision=53451
2013-11-20 20:36:22 +00:00
Michael Mann 01c8945438 Provide "Decode As" functionality through dissectors themselves instead of the GUI. Bug 9450 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9450)
The basic idea behind this design is to have dissectors register with a "decode as list" with their name and dissector table.  When "Decode As" dialog is launched, any "registered" dissector found in the packet will cause a tab to be created in the dialog.  Any GUI (GTK+/Qt/tshark) can just hook into the "decode as list" to see what can be provided.

This patch includes the GUI portion of the functionality (including packet-dcerpc.[ch] because it had some GUI dependencies that are now removed).

Other notes:
1. Some "GUI text" (UTF8_LEFTWARDS_ARROW and similar) made their way into the dissector code.  Not sure how necessary it is and if reformatting the strings to avoid the macros is desired (TCP/UDP use it, SCTP doesn't).

2. I converted the SCTP functionality to have 2 tabs (instead of radio button), currently both are labeled "Transport" which could be confusing to users.  Naming suggestions welcome (as well as for naming of tabs from other dissectors).

3. BER and DCERPC have more opportunity to use Decode As now that they are selected based on dissector presense, not packet_info values.

4. Catapult DCT2000 populates pinfo->ipproto, yet under new design will not show up to do Decode As.  Should a "decode as item" be created for it?

5. BER dissector doesn't have Clear/Show Current functionality working (never did)

6. Bluetooth (in old design) could have been used "capture wide" instead of single packet (creating tabs of values not present in current packet), which goes against what I believe to be in the intent of Decode As, but I'm willing to hear counter-arguments.

svn path=/trunk/; revision=53446
2013-11-20 19:23:02 +00:00
Evan Huus 2809240ead Add a cast to try and fix the OSX buildbot.
svn path=/trunk/; revision=53313
2013-11-14 13:07:53 +00:00
Evan Huus bfca717c45 Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9303 based on patch and
help from Matthieu Patou.

If the DCE-RPC heuristic failed to identify a TVB, *but* we've already decoded
a DCE-RPC layer in this packet *and* the heuristic failed because we didn't have
enough data, make the reasonable assumption that it actually is another DCE-RPC
packet, and ask TCP to desegment more data for us and try again.

svn path=/trunk/; revision=53310
2013-11-14 03:34:01 +00:00
Jakub Zawadzki ae59b09443 Add missing includes in order to remove exceptions.h from proto.h (next commit).
svn path=/trunk/; revision=53230
2013-11-10 15:59:37 +00:00
Michael Mann 22760b2d2a Remove pinfo->private_data from DCERPC dissectors and instead have dcerpc_info* infomation be passed in as a function parameter. Bug 9387 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9387)
All "generated" source was manually modified (with the power of search/replace), but I believe the "source input" files have been adjusted (checked into revs 53098 and 53099) to reflect the necessary changes (with possible whitespace formatting differences).

The Microsoft compiler doesn't flag "unused function parameters", so I apologize in advance if I may have missed a few.  The "dcerpc_info* di" parameter is used in almost every function.

svn path=/trunk/; revision=53100
2013-11-06 14:31:29 +00:00
Alexis La Goutte 39f4eb2edd Fix Dead Store (Dead assignement/Dead increment) warning found by Clang
svn path=/trunk/; revision=52874
2013-10-26 17:18:12 +00:00
Michael Mann 15294a1261 Add a new api to allow dissection of the array payload as a whole. Bug 9307 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9307)
From Matthieu Patou 

svn path=/trunk/; revision=52743
2013-10-21 18:46:52 +00:00
Michael Mann 772fb97f76 We can't really have conformant strings they are always conformant and
varying but pidl insists on having a different function.  Bug 9306 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9306)

From Matthieu Patou.

svn path=/trunk/; revision=52742
2013-10-21 18:33:14 +00:00
Michael Mann a8d18748ab dce-rpc: properly dissect multiple PDU in the same packet. Bug 9302 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9302).
From Matthieu Patou

svn path=/trunk/; revision=52736
2013-10-21 16:00:37 +00:00
Michael Mann e5846873f4 Convert proto_tree_add_time_format to either proto_tree_add_time or proto_tree_add_time_format_value.
Only proto_tree_add_time_format calls remaining are in packet-ncp2222.inc, which may just need some additional filters.

svn path=/trunk/; revision=52269
2013-09-29 16:40:01 +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 6df83e8078 Add _g_ to the names of functions that allocate glib memory. This is a bit more
explicit, and frees up the "generic" names (like tvb_memdup) for new signatures
that take the appropriate wmem pool.

Majority of the conversion done with sed.

svn path=/trunk/; revision=52164
2013-09-21 17:04:41 +00:00
Michael Mann b38ee917b1 Convert proto_tree_add_uint_format to proto_tree_add_uint_format_value if hf_ field name is the first part of the formatted string. This was done with a perl script on the dissectors directory (packet-*.c), followed by manual inspection of the output. The manual inspection yielded a few cases that really should have been proto_tree_add_uint or proto_tree_add_item, so I updated them accordingly.
The script didn't catch as many as I would have liked, but it's a start.

The most common (ab)use of proto_tree_add_uint_format was for appending strings to CRC/checksum values to note good or bad CRC/checksum.

svn path=/trunk/; revision=52045
2013-09-15 01:48:30 +00:00
Pascal Quantin 074349264e Convert some dissectors to wmem (leaving uat-like memory with emem for now)
svn path=/trunk/; revision=52031
2013-09-14 10:53:29 +00:00
Michael Mann 9e3f9b449f expert_add_info_format_text -> expert_add_info_format
svn path=/trunk/; revision=51852
2013-09-09 00:44:09 +00:00
Michael Mann e597acdc48 Batch of filterable expert info.
svn path=/trunk/; revision=51625
2013-09-01 13:05:27 +00:00
Jeff Morriss 26197c1693 From Dirk via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8952 :
Microsoft describes a feature called Bind Time Feature Negotiation used in
DCE/RPC Bind/BindAck PDUs. See http://msdn.microsoft.com/en-us/library/cc243715.aspx

In the Bind PDU they encode 2 bits into the Transfer Syntax UUID. In the
BindAck PDU they encode 2 bits into the result code. The attached patch
dissects these two special bits. For the UUID I've simply added 4 UUIDs each
with the same name; this works best with the DCE/RPC UUID lookup code. If
Microsoft would ever introduce more bits we could change this to a better
handling, since the current solution obviously doesn't scale.

Apart from adding new hf_ and ett_ variables and using them, I've also renamed
"Transport Syntax" to "Transfer Syntax", since the specifications only use
"Transfer".

svn path=/trunk/; revision=50901
2013-07-26 01:18:34 +00:00
Jakub Zawadzki a18172147f Remove fragment_data, add fragment_head, fragment_item - for now alias it to the same structure.
This is begin of work to split fragment head and fragments items.

svn path=/trunk/; revision=50708
2013-07-17 21:12:24 +00:00
Jakub Zawadzki c766e78cfa Rewrite reassemble API to use TVBs instead of raw data.
(it seems to be working for TCP ^^)

svn path=/trunk/; revision=50580
2013-07-14 14:42:05 +00:00
Guy Harris 7d17d600b5 Report the operation number in all places where we note that we don't
know about a given operation number.

svn path=/trunk/; revision=49653
2013-05-31 19:00:28 +00:00
Guy Harris a2414d8909 Don't wire into the reassembly code the notion that reassemblies should
be done on flows from one address to another; reassembly for protocols
running atop TCP should be done on flows from one TCP endpoint to
another.

We do this by:

	adding "reassembly table" as a data structure;

	associating hash tables for both in-progress reassemblies and
	completed reassemblies with that data structure (currently, not
	all reassemblies use the latter; they might keep completed
	reassemblies in the first table);

	having functions to create and destroy keys in that table;

	offering standard routines for doing address-based and
	address-and-port-based flow processing, so that dissectors not
	needing their own specialized flow processing can just use them.

This fixes some mis-reassemblies of NIS YPSERV YPALL responses (where
the second YPALL response is processed as if it were a continuation of
a previous response between different endpoints, even though said
response is already reassembled), and also allows the DCE RPC-specific
stuff to be moved out of epan/reassembly.c into the DCE RPC dissector.

svn path=/trunk/; revision=48491
2013-03-22 23:59:54 +00:00
Evan Huus a6d37fe9f3 From Dirk Jagdmann via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8475
Tidy up the display of Bind and BindAck slightly for DCE-RPC.

From me:
- fix indentation
- add modelines

svn path=/trunk/; revision=48431
2013-03-19 23:17:59 +00:00
Pascal Quantin 0a17799d61 From Ed Beroset via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 :
Remove C++ incompatibilities from most of the dcerpc code

svn path=/trunk/; revision=48023
2013-03-02 22:54:39 +00:00
Guy Harris 6b629c4d92 Move show_exception() and show_reported_bounds_error() to
epan/show_exception.c, as it's used outside
epan/dissectors/packet-frame.c.  Update their callers to include
<epan/show_exception.h> to get their declaration.

Add a CATCH_NONFATAL_ERRORS macro that catches all exceptions that, if
there's more stuff in the packet to dissect after the dissector call
that threw the exception, doesn't mean you shouldn't go ahead and
dissect that stuff.  Use it in all those cases, including ones where
BoundsError was inappropriately being caught (you want those passed up
to the top level, so that the packet is reported as having been cut
short in the capture process).

Add a CATCH_BOUNDS_ERRORS macro that catches all exceptions that
correspond to running past the end of the data for a tvbuff; use it
rather than explicitly catching those exceptions individually, and
rather than just catching all exceptions (the only place that
DissectorError should be caught, for example, is at the top level, so
dissector bugs show up in the protocol tree).

Don't catch and then immediately rethrow exceptions without doing
anything else; just let the exceptions go up to the final catcher.

Use show_exception() to report non-fatal errors, rather than doing it
yourself.
 
If a dissector is called from Lua, catch all non-fatal errors and use
show_exception() to report them rather than catching only
ReportedBoundsError and adding a proto_malformed item.

Don't catch exceptions when constructing a trailer tvbuff in
packet-ieee8023.c - just construct it after the payload has been
dissected, and let whatever exceptions that throws be handled at the top
level.

Avoid some TRY/CATCH/ENDTRY cases by using checks such as
tvb_bytes_exist() before even looking in the tvbuff.

svn path=/trunk/; revision=47924
2013-02-27 22:43:54 +00:00
Bill Meier 1823aa007c it's ==> its & its ==> it's as needed.
svn path=/trunk/; revision=47891
2013-02-26 01:06:19 +00:00
Evan Huus 1390569a99 Use wmem epan-scoped memory when initializing dcerpc so that it gets freed when
we shut down. Cleans up 5Kb worth of valgrind sorta-false-positive leaks.

svn path=/trunk/; revision=47168
2013-01-19 19:36:20 +00:00