summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Moizard <amoizard@gmail.com>2015-02-02 21:12:03 +0100
committerAymeric Moizard <amoizard@gmail.com>2015-02-02 21:12:03 +0100
commit25f60c8a45747291d4bfe749edf2a9608eae7ae5 (patch)
treedc1799fb1a6cfb685e6ef7ac0c6b1765460b7829
parent2e4e3dd837a84c8ca20151b9cef2f8a996ed97fe (diff)
downloadosip-25f60c8a45747291d4bfe749edf2a9608eae7ae5.tar.gz
improve management of body length // fix a bug when initial value of body is \0
-rw-r--r--src/osipparser2/osip_message_parse.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/osipparser2/osip_message_parse.c b/src/osipparser2/osip_message_parse.c
index e305cf0..28c6411 100644
--- a/src/osipparser2/osip_message_parse.c
+++ b/src/osipparser2/osip_message_parse.c
@@ -706,19 +706,11 @@ msg_osip_body_parse (osip_message_t * sip, const char *start_of_buf, const char
else {
/* if content_length does not exist, set it. */
char tmp[16];
-
- /* case where content-length is missing but the
- body only contains non-binary data */
- if (0 == osip_strcasecmp (sip->content_type->type, "application")
- && 0 == osip_strcasecmp (sip->content_type->subtype, "sdp")) {
- osip_body_len = strlen (start_of_body);
- sprintf (tmp, "%i", (int) osip_body_len);
- i = osip_message_set_content_length (sip, tmp);
- if (i != 0)
- return i;
- }
- else
- return OSIP_SYNTAXERROR; /* Content-type may be non binary data */
+ osip_body_len = length;
+ sprintf (tmp, "%i", (int) osip_body_len);
+ i = osip_message_set_content_length (sip, tmp);
+ if (i != 0)
+ return i;
}
if (length < osip_body_len) {
@@ -866,9 +858,19 @@ _osip_message_parse (osip_message_t * sip, const char *buf, size_t length, int s
}
tmp = (char *) next_header_index;
- /* this is a *very* simple test... (which handle most cases...) */
- if (tmp[0] == '\0' || tmp[1] == '\0' || tmp[2] == '\0') {
- /* this is mantory in the oSIP stack */
+ if (sip->content_length != NULL && sip->content_length->value == NULL) {
+ /* empty content_length header */
+ osip_content_length_free(sip->content_length);
+ sip->content_length=NULL;
+ }
+
+ if (sip->content_length != NULL && sip->content_length->value != NULL && atoi(sip->content_length->value) >0) {
+ /* body exist */
+ } else if (sip->content_length == NULL && '\r' == next_header_index[0] && '\n' == next_header_index[1] && length - (tmp - beg) - (2) >0) {
+ /* body exist */
+ } else if (sip->content_length == NULL && '\n' == next_header_index[0] && length - (tmp - beg) - (1) >0) {
+ /* body exist */
+ } else {
if (sip->content_length == NULL)
osip_message_set_content_length (sip, "0");
osip_free (beg);