From ee6142746386f461dd483a2eddc483081f742fd7 Mon Sep 17 00:00:00 2001 From: paulc Date: Mon, 17 Jan 2005 00:42:27 +0000 Subject: [PATCH] Fixed URI parser limitation (protocol is now optional). Fixed possible bug when resolved to non-IPv4 address. git-svn-id: http://yate.null.ro/svn/yate/trunk@208 acf43c95-373e-0410-b603-e72c3f656dc1 --- contrib/ysip/engine.cpp | 7 ++++--- modules/ysipchan.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/contrib/ysip/engine.cpp b/contrib/ysip/engine.cpp index 112e9635..d372e3c2 100644 --- a/contrib/ysip/engine.cpp +++ b/contrib/ysip/engine.cpp @@ -84,11 +84,12 @@ void URI::parse() const DDebug("URI",DebugAll,"new value='%s' [%p]",c_str(),this); } - // proto:[user[:passwd]@]hostname[:port][/path][?param=value[¶m=value...]] - // proto:[user@]hostname[:port][/path][;params][?params][¶ms] - r = "^\\([[:alpha:]]\\+\\):\\([[:alnum:]._-]\\+@\\)\\?\\([[:alnum:]._-]\\+\\)\\(:[0-9]\\+\\)\\?"; + // [proto:][user[:passwd]@]hostname[:port][/path][?param=value[¶m=value...]] + // [proto:][user@]hostname[:port][/path][;params][?params][¶ms] + r = "^\\([[:alpha:]]\\+:\\)\\?\\([[:alnum:]._-]\\+@\\)\\?\\([[:alnum:]._-]\\+\\)\\(:[0-9]\\+\\)\\?"; if (tmp.matches(r)) { m_proto = tmp.matchString(1).toLower(); + m_proto = m_proto.substr(0,m_proto.length()-1); m_user = tmp.matchString(2); m_user = m_user.substr(0,m_user.length()-1); m_host = tmp.matchString(3).toLower(); diff --git a/modules/ysipchan.cpp b/modules/ysipchan.cpp index d4926feb..78214b77 100644 --- a/modules/ysipchan.cpp +++ b/modules/ysipchan.cpp @@ -331,6 +331,8 @@ bool YateUDPParty::setParty(const URI& uri) { if (m_partyPort && m_party && s_cfg.getBoolValue("general","ignorevia")) return true; + if (uri.getHost().null()) + return false; int port = uri.getPort(); if (port <= 0) port = 5060; @@ -342,6 +344,11 @@ bool YateUDPParty::setParty(const URI& uri) err,uri.getHost().safe(),this); return false; } + if (he.h_addrtype != AF_INET) { + Debug("YateUDPParty",DebugWarn,"Address family %d not supported yet [%p]", + he.h_addrtype,this); + return false; + } m_sin.sin_family = he.h_addrtype; m_sin.sin_addr.s_addr = *((u_int32_t*)he.h_addr_list[0]); m_sin.sin_port = htons((short)port); @@ -404,6 +411,11 @@ bool YateSIPEndPoint::buildParty(SIPMessage* message, const char* host, int port Debug(DebugWarn,"Error %d resolving name '%s'",err,host); return false; } + if (he.h_addrtype != AF_INET) { + Debug("YateUDPParty",DebugWarn,"Address family %d not supported yet [%p]", + he.h_addrtype,this); + return false; + } struct sockaddr_in sin; sin.sin_family = he.h_addrtype; sin.sin_addr.s_addr = *((u_int32_t*)he.h_addr_list[0]);