<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7264">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Use reasonable buffer lengths for endpoint identification<br><br>Domains themselves can be up to 255 characters long (per RFC 1035), so<br>our current buffer sizes are wholly inadequate for many use cases.<br><br>Change-Id: If3f30a68307f1365a1fe06bc4b854c62842c9292<br>---<br>M res/res_pjsip_endpoint_identifier_anonymous.c<br>M res/res_pjsip_endpoint_identifier_user.c<br>2 files changed, 13 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip_endpoint_identifier_anonymous.c b/res/res_pjsip_endpoint_identifier_anonymous.c<br>index a529466..a1144a8 100644<br>--- a/res/res_pjsip_endpoint_identifier_anonymous.c<br>+++ b/res/res_pjsip_endpoint_identifier_anonymous.c<br>@@ -56,9 +56,11 @@<br>        return 0;<br> }<br> <br>+#define DOMAIN_NAME_LEN 255<br>+<br> static struct ast_sip_endpoint *anonymous_identify(pjsip_rx_data *rdata)<br> {<br>-     char domain_name[64], id[AST_UUID_STR_LEN];<br>+  char domain_name[DOMAIN_NAME_LEN + 1];<br>        struct ast_sip_endpoint *endpoint;<br>    RAII_VAR(struct ast_sip_domain_alias *, alias, NULL, ao2_cleanup);<br>    RAII_VAR(struct ao2_container *, transport_states, NULL, ao2_cleanup);<br>@@ -70,6 +72,8 @@<br>     }<br> <br>  if (!ast_sip_get_disable_multi_domain()) {<br>+           char id[sizeof("anonymous@") + DOMAIN_NAME_LEN];<br>+<br>                 /* Attempt to find the endpoint given the name and domain provided */<br>                 snprintf(id, sizeof(id), "anonymous@%s", domain_name);<br>              if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {<br>diff --git a/res/res_pjsip_endpoint_identifier_user.c b/res/res_pjsip_endpoint_identifier_user.c<br>index 369cb62..ff97a62 100644<br>--- a/res/res_pjsip_endpoint_identifier_user.c<br>+++ b/res/res_pjsip_endpoint_identifier_user.c<br>@@ -74,10 +74,12 @@<br>         return 0;<br> }<br> <br>+#define DOMAIN_NAME_LEN 255<br>+#define USERNAME_LEN    255<br>+<br> static struct ast_sip_endpoint *find_endpoint(pjsip_rx_data *rdata, char *endpoint_name,<br>    char *domain_name)<br> {<br>-       char id[AST_UUID_STR_LEN];<br>    struct ast_sip_endpoint *endpoint;<br>    RAII_VAR(struct ast_sip_domain_alias *, alias, NULL, ao2_cleanup);<br>    RAII_VAR(struct ao2_container *, transport_states, NULL, ao2_cleanup);<br>@@ -85,6 +87,8 @@<br>     RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);<br> <br>        if (!ast_sip_get_disable_multi_domain()) {<br>+           char id[DOMAIN_NAME_LEN + USERNAME_LEN + sizeof("@")];<br>+<br>           /* Attempt to find the endpoint given the name and domain provided */<br>                 snprintf(id, sizeof(id), "%s@%s", endpoint_name, domain_name);<br>              if ((endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", id))) {<br>@@ -116,8 +120,8 @@<br> <br> static struct ast_sip_endpoint *username_identify(pjsip_rx_data *rdata)<br> {<br>-        char username[64];<br>-   char domain[64];<br>+     char username[USERNAME_LEN + 1];<br>+     char domain[DOMAIN_NAME_LEN + 1];<br>     struct ast_sip_endpoint *endpoint;<br> <br>         if (get_from_header(rdata, username, sizeof(username), domain, sizeof(domain))) {<br>@@ -149,7 +153,7 @@<br> <br> static struct ast_sip_endpoint *auth_username_identify(pjsip_rx_data *rdata)<br> {<br>- char username[64], realm[64];<br>+        char username[USERNAME_LEN + 1], realm[DOMAIN_NAME_LEN + 1];<br>  struct ast_sip_endpoint *endpoint;<br>    pjsip_authorization_hdr *auth_header = NULL;<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7264">change 7264</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7264"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: If3f30a68307f1365a1fe06bc4b854c62842c9292 </div>
<div style="display:none"> Gerrit-Change-Number: 7264 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>