diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-11-10 20:53:42 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-11-10 20:53:42 +0000 |
commit | b6059df9e224158d1dfac15a510f2c6231145602 (patch) | |
tree | 2119f45d33ad5d3d2ca3980e707648db61f71937 /epan/req_resp_hdrs.c | |
parent | 82203cdb6c31936468d1db3ca58b60dfd0534896 (diff) | |
download | wireshark-b6059df9e224158d1dfac15a510f2c6231145602.tar.gz wireshark-b6059df9e224158d1dfac15a510f2c6231145602.tar.bz2 wireshark-b6059df9e224158d1dfac15a510f2c6231145602.zip |
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
Diffstat (limited to 'epan/req_resp_hdrs.c')
-rw-r--r-- | epan/req_resp_hdrs.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/epan/req_resp_hdrs.c b/epan/req_resp_hdrs.c index 8d861ec62a..6947c47052 100644 --- a/epan/req_resp_hdrs.c +++ b/epan/req_resp_hdrs.c @@ -50,6 +50,7 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, int offset, packet_info *pinfo, gboolean content_length_found = FALSE; gboolean content_type_found = FALSE; gboolean chunked_encoding = FALSE; + gboolean keepalive_found = FALSE; /* * Do header desegmentation if we've been told to. @@ -147,17 +148,30 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, int offset, packet_info *pinfo, */ if (tvb_strncaseeql(tvb, next_offset_sav, "Content-Length:", 15) == 0) { - header_val = tvb_get_string(tvb, + header_val = tvb_get_ephemeral_string(tvb, next_offset_sav + 15, linelen - 15); if (sscanf(header_val, "%li", &content_length) == 1) content_length_found = TRUE; - g_free(header_val); } else if (tvb_strncaseeql(tvb, next_offset_sav, "Content-Type:", 13) == 0) { content_type_found = TRUE; + } else if (tvb_strncaseeql(tvb, next_offset_sav, + "Connection:", 11) == 0) { + /* Check for keep-alive */ + header_val = tvb_get_ephemeral_string(tvb, + next_offset_sav + 11, + linelen - 11); + if(header_val){ + while(*header_val==' '){ + header_val++; + } + if(!strncasecmp(header_val, "Keep-Alive", 10)){ + keepalive_found = TRUE; + } + } } else if (tvb_strncaseeql(tvb, next_offset_sav, "Transfer-Encoding:", 18) == 0) { @@ -170,7 +184,7 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, int offset, packet_info *pinfo, gchar *p; gint len; - header_val = tvb_get_string(tvb, + header_val = tvb_get_ephemeral_string(tvb, next_offset_sav + 18, linelen - 18); p = header_val; len = strlen(header_val); @@ -192,7 +206,6 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, int offset, packet_info *pinfo, chunked_encoding = TRUE; } } - g_free(header_val); } } } @@ -269,7 +282,7 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, int offset, packet_info *pinfo, } /* We have a line with the chunk size in it.*/ - chunk_string = tvb_get_string(tvb, next_offset, + chunk_string = tvb_get_ephemeral_string(tvb, next_offset, linelen); c = chunk_string; @@ -285,10 +298,8 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, int offset, packet_info *pinfo, /* We couldn't get the chunk size, * so stop trying. */ - g_free(chunk_string); return TRUE; } - g_free(chunk_string); if (chunk_size == 0) { /* @@ -337,7 +348,10 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, int offset, packet_info *pinfo, /* We found a content-type but no content-length. * This is probably a HTTP header for a session with * only one HTTP PDU and where the content spans - * until the end of the tcp session. + * until the end of the tcp session, unless there + * is a keepalive header present in which case we + * assume there is no message body at all and thus + * we wont do any reassembly. * Set up tcp reassembly until the end of this session. */ length_remaining = tvb_length_remaining(tvb, next_offset); @@ -350,6 +364,14 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, int offset, packet_info *pinfo, return TRUE; } + if (keepalive_found) { + /* We have a keep-alive but no content-length. + * Assume there is no message body and dont + * do any reassembly. + */ + return TRUE; + } + pinfo->desegment_offset = offset; pinfo->desegment_len = DESEGMENT_UNTIL_FIN; |