Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
0c43dc74
Unverified
Commit
0c43dc74
authored
6 years ago
by
Koen Zandberg
Browse files
Options
Downloads
Patches
Plain Diff
sock_util: Limit recursion in str2ep
parent
b024ff1c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sys/net/sock/sock_util.c
+4
-7
4 additions, 7 deletions
sys/net/sock/sock_util.c
with
4 additions
and
7 deletions
sys/net/sock/sock_util.c
+
4
−
7
View file @
0c43dc74
...
...
@@ -32,9 +32,6 @@
#include
"fmt.h"
#endif
#define SOCK_HOST_MAXLEN (64U)
/**< maximum length of host part for
sock_udp_str2ep() */
int
sock_udp_ep_fmt
(
const
sock_udp_ep_t
*
endpoint
,
char
*
addr_str
,
uint16_t
*
port
)
{
void
*
addr_ptr
;
...
...
@@ -152,7 +149,7 @@ int sock_udp_str2ep(sock_udp_ep_t *ep_out, const char *str)
char
*
hoststart
=
(
char
*
)
str
;
char
*
hostend
=
hoststart
;
char
hostbuf
[
SOCK_HOST_MAXLEN
];
char
hostbuf
[
SOCK_HOST
PORT
_MAXLEN
];
memset
(
ep_out
,
0
,
sizeof
(
sock_udp_ep_t
));
...
...
@@ -160,15 +157,15 @@ int sock_udp_str2ep(sock_udp_ep_t *ep_out, const char *str)
brackets_flag
=
1
;
for
(
hostend
=
++
hoststart
;
*
hostend
&&
*
hostend
!=
']'
;
hostend
++
);
if
(
!
*
hostend
)
{
if
(
!
*
hostend
||
((
size_t
)(
hostend
-
hoststart
)
>=
sizeof
(
hostbuf
))
)
{
/* none found, bail out */
return
-
EINVAL
;
}
}
else
{
brackets_flag
=
0
;
for
(
hostend
=
hoststart
;
*
hostend
&&
*
hostend
!=
':'
;
hostend
++
)
;
for
(
hostend
=
hoststart
;
*
hostend
&&
(
*
hostend
!=
':'
)
&&
\
((
size_t
)(
hostend
-
hoststart
)
<
sizeof
(
hostbuf
));
hostend
++
)
{}
}
size_t
hostlen
=
hostend
-
hoststart
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment