mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-31 14:39:55 +01:00
fix: websocket url without path
websocket urls without a path caused crash!
This commit is contained in:
parent
7ea72e5692
commit
c357c378d8
@ -99,14 +99,17 @@ int zmq::ws_address_t::resolve (const char *name_, bool local_, bool ipv6_)
|
||||
}
|
||||
_host = std::string (name_, delim - name_);
|
||||
|
||||
// find the path part, which is optional
|
||||
// find the path part, which is optional
|
||||
delim = strrchr (name_, '/');
|
||||
if (delim)
|
||||
std::string host_name;
|
||||
if (delim) {
|
||||
_path = std::string (delim);
|
||||
else
|
||||
// remove the path, otherwise resolving the port will fail with wildcard
|
||||
host_name = std::string (name_, delim - name_);
|
||||
} else {
|
||||
_path = std::string ("/");
|
||||
// remove the path, otherwise resolving the port will fail with wildcard
|
||||
std::string host_port = std::string (name_, delim - name_);
|
||||
host_name = name_;
|
||||
}
|
||||
|
||||
ip_resolver_options_t resolver_opts;
|
||||
resolver_opts.bindable (local_)
|
||||
@ -118,7 +121,7 @@ int zmq::ws_address_t::resolve (const char *name_, bool local_, bool ipv6_)
|
||||
|
||||
ip_resolver_t resolver (resolver_opts);
|
||||
|
||||
return resolver.resolve (&_address, host_port.c_str ());
|
||||
return resolver.resolve (&_address, host_name.c_str ());
|
||||
}
|
||||
|
||||
int zmq::ws_address_t::to_string (std::string &addr_) const
|
||||
|
@ -212,8 +212,14 @@ int zmq::ws_listener_t::set_local_address (const char *addr_)
|
||||
|
||||
// remove the path, otherwise resolving the port will fail with wildcard
|
||||
const char *delim = strrchr (addr_, '/');
|
||||
std::string host_port = std::string (addr_, delim - addr_);
|
||||
if (create_socket (host_port.c_str ()) == -1)
|
||||
std::string host_address;
|
||||
if (delim) {
|
||||
host_address = std::string (addr_, delim - addr_);
|
||||
} else {
|
||||
host_address = addr_;
|
||||
}
|
||||
|
||||
if (create_socket (host_address.c_str ()) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user