Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/header_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ void uri_replace(char *mes, char *uri)
void set_cl(char* mes, int contentlen) {
char *cl, *cr, *backup;

if ((cl=STRCASESTR(mes, CON_LEN_STR)) == NULL &&
(cl=STRCASESTR(mes, CON_LEN_SHORT_STR)) == NULL) {
if ((cl=STRCASESTR(mes, CON_LEN_STR_SEARCH)) == NULL &&
(cl=STRCASESTR(mes, CON_LEN_SHORT_STR_SEARCH)) == NULL) {
printf("missing Content-Length in message\n");
return;
}
Expand All @@ -258,9 +258,12 @@ void set_cl(char* mes, int contentlen) {
backup=str_alloc(strlen(cr)+1);
strncpy(backup, cr, strlen(cr));
if (*cl == 'C')
cr=cl + CON_LEN_STR_LEN;
cr=cl + CON_LEN_STR_SEARCH_LEN;
else
cr=cl + 3;
cr=cl + CON_LEN_SHORT_STR_SEARCH_LEN;
/* skip optional whitespace after colon */
while (*cr == ' ')
cr++;
snprintf(cr, 6, "%i\r\n", contentlen);
cr=strchr(cr, '\n');
cr++;
Expand All @@ -277,18 +280,21 @@ void set_cl(char* mes, int contentlen) {
int get_cl(char* mes) {
char *cl;

if ((cl=STRCASESTR(mes, CON_LEN_STR)) == NULL &&
(cl=STRCASESTR(mes, CON_LEN_SHORT_STR)) == NULL) {
if ((cl=STRCASESTR(mes, CON_LEN_STR_SEARCH)) == NULL &&
(cl=STRCASESTR(mes, CON_LEN_SHORT_STR_SEARCH)) == NULL) {
if (verbose > 1)
printf("missing Content-Length in message\n");
return -1;
}
if (*cl == '\n') {
cl+=3;
cl+=CON_LEN_SHORT_STR_SEARCH_LEN;
}
else {
cl+=15;
cl+=CON_LEN_STR_SEARCH_LEN;
}
/* skip optional whitespace after colon */
while (*cl == ' ')
cl++;
return str_to_int(1, cl);
}

Expand Down
4 changes: 4 additions & 0 deletions src/sip_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
#define CON_LEN_STR_LEN (sizeof(CON_LEN_STR) - 1)
#define CON_LEN_SHORT_STR "\nl: "
#define CON_LEN_SHORT_STR_LEN (sizeof(CON_LEN_SHORT_STR) - 1)
#define CON_LEN_STR_SEARCH "Content-Length:"
#define CON_LEN_STR_SEARCH_LEN (sizeof(CON_LEN_STR_SEARCH) - 1)
#define CON_LEN_SHORT_STR_SEARCH "\nl:"
#define CON_LEN_SHORT_STR_SEARCH_LEN (sizeof(CON_LEN_SHORT_STR_SEARCH) - 1)

#define RR_STR "Record-Route: "
#define RR_STR_LEN (sizeof(RR_STR) - 1)
Expand Down
Loading