Skip to content

Commit

Permalink
comparse_uris: unescape all characters in user field
Browse files Browse the repository at this point in the history
  • Loading branch information
ionutrazvanionita committed Dec 22, 2015
1 parent ef76542 commit 62e2969
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion parser/parse_uri.c
Expand Up @@ -41,7 +41,7 @@
#include "../error.h"
#include "../errinfo.h"
#include "../core_stats.h"

#include "../strcommon.h"

int parse_uri_headers(str headers, str h_name[], str h_val[], int h_size)
{
Expand Down Expand Up @@ -1387,6 +1387,12 @@ int parse_orig_ruri(struct sip_msg* msg)
int compare_uris(str *raw_uri_a,struct sip_uri* parsed_uri_a,
str *raw_uri_b,struct sip_uri *parsed_uri_b)
{
#define UNESCAPED_BUF_LEN 1024
char unescaped_a[UNESCAPED_BUF_LEN], unescaped_b[UNESCAPED_BUF_LEN];

str unescaped_userA={unescaped_a, UNESCAPED_BUF_LEN};
str unescaped_userB={unescaped_b, UNESCAPED_BUF_LEN};

struct sip_uri first;
struct sip_uri second;
char matched[URI_MAX_U_PARAMS];
Expand Down Expand Up @@ -1443,6 +1449,15 @@ int compare_uris(str *raw_uri_a,struct sip_uri* parsed_uri_a,
return 1;
}

if (unescape_user(&first.user, &unescaped_userA) < 0 ||
unescape_user(&second.user, &unescaped_userB) < 0) {
LM_ERR("Failed to unescape user!\n");
return -1;
}

first.user = unescaped_userA;
second.user = unescaped_userB;

compare_uri_val(user,strncmp);
compare_uri_val(passwd,strncmp);
compare_uri_val(host,strncasecmp);
Expand Down

0 comments on commit 62e2969

Please sign in to comment.