aboutsummaryrefslogtreecommitdiffstats
path: root/req_resp_hdrs.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-05-04 06:53:47 +0000
committerGuy Harris <guy@alum.mit.edu>2004-05-04 06:53:47 +0000
commit0dd6ee92dec2c440e4ca1c394581bd149bab4bf1 (patch)
treec212ac1ed1149dc08be9f23b007715c80cede153 /req_resp_hdrs.c
parenteecdd42293af1175fbf6c1772cfcdcdb351fbe92 (diff)
"tvb_get_string()" returns a pointer to "g_malloc()"ed data, so you have
to free it when you're done with it. It never returns a null pointer, however, so there's no need to check for that. Clean up the code to process Transfer-Encoding a bit. svn path=/trunk/; revision=10786
Diffstat (limited to 'req_resp_hdrs.c')
-rw-r--r--req_resp_hdrs.c61
1 files changed, 30 insertions, 31 deletions
diff --git a/req_resp_hdrs.c b/req_resp_hdrs.c
index c62fd86345..3ff5318491 100644
--- a/req_resp_hdrs.c
+++ b/req_resp_hdrs.c
@@ -2,7 +2,7 @@
* Routines handling protocols with a request/response line, headers,
* a blank line, and an optional body.
*
- * $Id: req_resp_hdrs.c,v 1.4 2004/04/26 17:10:40 obiot Exp $
+ * $Id: req_resp_hdrs.c,v 1.5 2004/05/04 06:53:47 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -46,6 +46,7 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, packet_info *pinfo,
gint next_offset_sav;
gint length_remaining, reported_length_remaining;
int linelen;
+ gchar *header_val;
long int content_length;
gboolean content_length_found = FALSE;
gboolean chunked_encoding = FALSE;
@@ -146,51 +147,49 @@ req_resp_hdrs_do_reassembly(tvbuff_t *tvb, packet_info *pinfo,
*/
if (tvb_strncaseeql(tvb, next_offset_sav,
"Content-Length:", 15) == 0) {
- if (sscanf(
- tvb_get_string(tvb,
- next_offset_sav + 15,
- linelen - 15),
+ header_val = tvb_get_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,
"Transfer-Encoding:", 18) == 0) {
- gchar *chunk_type = tvb_get_string(tvb,
- next_offset_sav + 18, linelen - 18);
/*
* Find out if this Transfer-Encoding is
* chunked. It should be, since there
* really aren't any other types, but
* RFC 2616 allows for them.
*/
+ gchar *p;
+ gint len;
- if (chunk_type != NULL) {
- gchar *c = chunk_type;
- gint len = strlen(chunk_type);
-
-
- /* start after any white-space */
- while (c != NULL && c <
- chunk_type + len &&
- (*c == ' ' ||
- *c == 0x09)) {
- c++;
- }
-
- if (c <= chunk_type + len ) {
- if (strncasecmp(c, "chunked", 7)
- == 0) {
- /*
- * Don't bother looking for extensions;
- * since we don't understand them,
- * they should be ignored.
- */
- chunked_encoding = TRUE;
- }
+ header_val = tvb_get_string(tvb,
+ next_offset_sav + 18, linelen - 18);
+ p = header_val;
+ len = strlen(header_val);
+ /* Skip white space */
+ while (p < header_val + len &&
+ (*p == ' ' || *p == '\t'))
+ p++;
+ if (p <= header_val + len) {
+ if (strncasecmp(p, "chunked", 7)
+ == 0) {
+ /*
+ * Don't bother looking
+ * for extensions;
+ * since we don't
+ * understand them,
+ * they should be
+ * ignored.
+ */
+ chunked_encoding = TRUE;
}
- g_free(chunk_type);
}
+ g_free(header_val);
}
}
}