Wireshark-bugs: [Wireshark-bugs] [Bug 3467] Memcache Textual Protocol dissector patch

Date: Tue, 19 May 2009 14:01:52 -0700 (PDT)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3467





--- Comment #17 from Rama Chitta <rama@xxxxxxxxx>  2009-05-19 14:01:51 PDT ---
> > 
> > Have a look in desegment_pdus, where you set pinfo->desegment_len.  You should
> > add 2 for the last \r\n.  Or maybe add them in get_payload_length()?
> > 
> > pinfo->desegment_offset = offset; /* start of the packet. */
> > pinfo->desegment_len = content_length - length_remaining + 2; /* add 2 for \r\n
> > */
> Yes...I'll try that. That should fix the problem I think.
> 

That  worked like a charm. Thought I was missing a couple of more bytes when I
was doing PDU reassembly. Thanks.


> > 
> > Frame 10 and 11 is not decoded correctly, did I break something in my cleanup?
> > 

Yeah, I got to the bottom of the problem here. This was my goofy logic around
comparing an opcode with OP_GET. Earlier when OP_GET was 0x00 my assignment  of
*opcode = OP_GET conditionally evaluated to 0 and failed the
is_memcache_request_or_reply() check. That is why I had to change OP_GET to
something other than 0x00 (which was inherently wrong). 


After in your patch you changed OP_GET back to 0x00 the incorrect logic kicked
in again and caused the problem.


My fix: in function is_memcache_request_or_reply()

  case 5:
    if (strncmp(data, "VALUE", indx) == 0) {
      *opcode = OP_GET;
      is_request_or_response = TRUE;
      *type = MEMCACHE_RESPONSE;
      *expect_content_length = TRUE;
    }
    break;

and... in the same function further down

 /* is it a request?  */
  switch (indx) {
  case 3:
    if (((strncmp(data, "get", indx) == 0) ? ((*opcode = OP_GET) || 1) : 0)  ||
        (strncmp(data, "set", indx) == 0 && (*opcode = OP_SET) &&
         (*expect_content_length = TRUE)) ||
        (strncmp(data, "add", indx) == 0 && (*opcode = OP_ADD) &&
         (*expect_content_length = TRUE)) ||
        (strncmp(data, "cas", indx) == 0 && (*opcode = OP_CAS) &&
         (*expect_content_length = TRUE))) {
      is_request_or_response = TRUE;
      *type = MEMCACHE_REQUEST;
    }


should take care of it... sorry for the trouble


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