Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
f749f2d2
Commit
f749f2d2
authored
Dec 13, 2010
by
Dhammika Pathirana
Committed by
Martin Sustrik
Dec 13, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add basic uri validations
Signed-off-by:
Dhammika Pathirana
<
dhammika@gmail.com
>
parent
22b2b9a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
22 deletions
+32
-22
socket_base.cpp
src/socket_base.cpp
+28
-22
socket_base.hpp
src/socket_base.hpp
+4
-0
No files found.
src/socket_base.cpp
View file @
f749f2d2
...
...
@@ -141,6 +141,26 @@ void zmq::socket_base_t::stop ()
send_stop
();
}
int
zmq
::
socket_base_t
::
parse_uri
(
const
char
*
uri_
,
std
::
string
&
protocol_
,
std
::
string
&
address_
)
{
zmq_assert
(
uri_
!=
NULL
);
std
::
string
uri
(
uri_
);
std
::
string
::
size_type
pos
=
uri
.
find
(
"://"
);
if
(
pos
==
std
::
string
::
npos
)
{
errno
=
EINVAL
;
return
-
1
;
}
protocol_
=
uri
.
substr
(
0
,
pos
);
address_
=
uri
.
substr
(
pos
+
3
);
if
(
protocol_
.
empty
()
||
address_
.
empty
())
{
errno
=
EINVAL
;
return
-
1
;
}
return
0
;
}
int
zmq
::
socket_base_t
::
check_protocol
(
const
std
::
string
&
protocol_
)
{
// First check out whether the protcol is something we are aware of.
...
...
@@ -272,18 +292,11 @@ int zmq::socket_base_t::bind (const char *addr_)
// Parse addr_ string.
std
::
string
protocol
;
std
::
string
address
;
{
std
::
string
addr
(
addr_
);
std
::
string
::
size_type
pos
=
addr
.
find
(
"://"
);
if
(
pos
==
std
::
string
::
npos
)
{
errno
=
EINVAL
;
return
-
1
;
}
protocol
=
addr
.
substr
(
0
,
pos
);
address
=
addr
.
substr
(
pos
+
3
);
}
int
rc
=
parse_uri
(
addr_
,
protocol
,
address
);
if
(
rc
!=
0
)
return
-
1
;
int
rc
=
check_protocol
(
protocol
);
rc
=
check_protocol
(
protocol
);
if
(
rc
!=
0
)
return
-
1
;
...
...
@@ -334,18 +347,11 @@ int zmq::socket_base_t::connect (const char *addr_)
// Parse addr_ string.
std
::
string
protocol
;
std
::
string
address
;
{
std
::
string
addr
(
addr_
);
std
::
string
::
size_type
pos
=
addr
.
find
(
"://"
);
if
(
pos
==
std
::
string
::
npos
)
{
errno
=
EINVAL
;
return
-
1
;
}
protocol
=
addr
.
substr
(
0
,
pos
);
address
=
addr
.
substr
(
pos
+
3
);
}
int
rc
=
parse_uri
(
addr_
,
protocol
,
address
);
if
(
rc
!=
0
)
return
-
1
;
int
rc
=
check_protocol
(
protocol
);
rc
=
check_protocol
(
protocol
);
if
(
rc
!=
0
)
return
-
1
;
...
...
src/socket_base.hpp
View file @
f749f2d2
...
...
@@ -128,6 +128,10 @@ namespace zmq
// where it doesn't intersect the object being destroyed.
bool
destroyed
;
// Parse URI string.
int
parse_uri
(
const
char
*
uri_
,
std
::
string
&
protocol_
,
std
::
string
&
address_
);
// Check whether transport protocol, as specified in connect or
// bind, is available and compatible with the socket type.
int
check_protocol
(
const
std
::
string
&
protocol_
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment