Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 341249) +++ channels/chan_sip.c (working copy) @@ -14605,10 +14605,21 @@ SIP_PEDANTIC_DECODE(name); SIP_PEDANTIC_DECODE(domain); - /*! \todo XXX here too we interpret a missing @domain as a name-only - * URI, whereas the RFC says this is a domain-only uri. - */ - if (!ast_strlen_zero(domain) && !AST_LIST_EMPTY(&domain_list)) { + if (ast_strlen_zero(domain)) { + /* , not good */ + transmit_response(p, "404 Not found", &p->initreq); + return AUTH_UNKNOWN_DOMAIN; + } + + if (ast_strlen_zero(name)) { + /* , not valid for registration: + * RFC3261, 10.2: The To header field and the Request-URI field + * typically differ, as the former contains a user name. */ + transmit_response(p, "404 Not found", &p->initreq); + return AUTH_NOT_FOUND; + } + + if (!AST_LIST_EMPTY(&domain_list)) { if (!check_sip_domain(domain, NULL, 0)) { transmit_response(p, "404 Not found (unknown domain)", &p->initreq); return AUTH_UNKNOWN_DOMAIN; @@ -15997,15 +16008,7 @@ SIP_PEDANTIC_DECODE(of); SIP_PEDANTIC_DECODE(domain); - if (ast_strlen_zero(of)) { - /* XXX note: the original code considered a missing @host - * as a username-only URI. The SIP RFC (19.1.1) says that - * this is wrong, and it should be considered as a domain-only URI. - * For backward compatibility, we keep this block, but it is - * really a mistake and should go away. - */ - of = domain; - } else { + if (!ast_strlen_zero(of)) { char *tmp = ast_strdupa(of); /* We need to be able to handle auth-headers looking like @@ -16077,21 +16080,21 @@ static int get_msg_text(char *buf, int len, struct sip_request *req, int addnewline) { int x; - int y; + int linelen; buf[0] = '\0'; - /*XXX isn't strlen(buf) going to always be 0? */ - y = len - strlen(buf) - 5; - if (y < 0) - y = 0; - for (x = 0; x < req->lines; x++) { + --len; /* reserve strncat null */ + for (x = 0; len > 0 && x < req->lines; x++) { const char *line = REQ_OFFSET_TO_STR(req, line[x]); - strncat(buf, line, y); /* safe */ - y -= strlen(line) + 1; - if (y < 0) - y = 0; - if (y != 0 && addnewline) + strncat(buf, line, len); /* safe */ + linelen = strlen(buf); + buf += linelen; + len -= linelen; + if (len && addnewline) { strcat(buf, "\n"); /* safe */ + ++buf; + --len; + } } return 0; } Index: channels/sip/reqresp_parser.c =================================================================== --- channels/sip/reqresp_parser.c (revision 341249) +++ channels/sip/reqresp_parser.c (working copy) @@ -176,23 +176,23 @@ } if (!strcmp(label, "transport")) { - if (params) {params->transport=value;} + params->transport = value; rem = parameters; } else if (!strcmp(label, "user")) { - if (params) {params->user=value;} + params->user = value; rem = parameters; } else if (!strcmp(label, "method")) { - if (params) {params->method=value;} + params->method = value; rem = parameters; } else if (!strcmp(label, "ttl")) { - if (params) {params->ttl=value;} + params->ttl = value; rem = parameters; } else if (!strcmp(label, "maddr")) { - if (params) {params->maddr=value;} + params->maddr = value; rem = parameters; /* Treat "lr", "lr=yes", "lr=on", "lr=1", "lr=almostanything" as lr enabled and "", "lr=no", "lr=off", "lr=0", "lr=" and "lranything" as lr disabled */ } else if ((!strcmp(label, "lr") && strcmp(value, "no") && strcmp(value, "off") && strcmp(value, "0") && strcmp(value, "")) || ((lr) && strcmp(value, "lr"))) { - if (params) {params->lr=1;} + params->lr = 1; rem = parameters; } else { value--;