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
b0309145
Unverified
Commit
b0309145
authored
6 years ago
by
Koen Zandberg
Browse files
Options
Downloads
Patches
Plain Diff
sock_util: Limit URL scheme size
parent
4c183257
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sys/include/net/sock/util.h
+6
-2
6 additions, 2 deletions
sys/include/net/sock/util.h
sys/net/sock/sock_util.c
+6
-1
6 additions, 1 deletion
sys/net/sock/sock_util.c
with
12 additions
and
3 deletions
sys/include/net/sock/util.h
+
6
−
2
View file @
b0309145
...
@@ -53,8 +53,9 @@ int sock_udp_ep_fmt(const sock_udp_ep_t *endpoint, char *addr_str, uint16_t *por
...
@@ -53,8 +53,9 @@ int sock_udp_ep_fmt(const sock_udp_ep_t *endpoint, char *addr_str, uint16_t *por
* "host.name:1234" and "/url/path".
* "host.name:1234" and "/url/path".
*
*
* @note Caller has to make sure hostport and urlpath can hold the results!
* @note Caller has to make sure hostport and urlpath can hold the results!
* Make sure to provide space for SOCK_HOSTPORT_MAXLEN respectively
* Make sure to provide space for @ref SOCK_HOSTPORT_MAXLEN respectively
* SOCK_URLPATH_MAXLEN bytes.
* @ref SOCK_URLPATH_MAXLEN bytes.
* Scheme part of the URL is limited to @ref SOCK_SCHEME_MAXLEN length.
*
*
* @param[in] url URL to split
* @param[in] url URL to split
* @param[out] hostport where to write host:port
* @param[out] hostport where to write host:port
...
@@ -98,6 +99,9 @@ bool sock_udp_ep_equal(const sock_udp_ep_t *a, const sock_udp_ep_t *b);
...
@@ -98,6 +99,9 @@ bool sock_udp_ep_equal(const sock_udp_ep_t *a, const sock_udp_ep_t *b);
* @name helper definitions
* @name helper definitions
* @{
* @{
*/
*/
#define SOCK_SCHEME_MAXLEN (16U)
/**< maximum length of the scheme part
for sock_urlsplit. Ensures a hard
limit on the string iterator */
#define SOCK_HOSTPORT_MAXLEN (64U)
/**< maximum length of host:port part for
#define SOCK_HOSTPORT_MAXLEN (64U)
/**< maximum length of host:port part for
sock_urlsplit() */
sock_urlsplit() */
#define SOCK_URLPATH_MAXLEN (64U)
/**< maximum length path for
#define SOCK_URLPATH_MAXLEN (64U)
/**< maximum length path for
...
...
This diff is collapsed.
Click to expand it.
sys/net/sock/sock_util.c
+
6
−
1
View file @
b0309145
...
@@ -85,8 +85,13 @@ int sock_udp_ep_fmt(const sock_udp_ep_t *endpoint, char *addr_str, uint16_t *por
...
@@ -85,8 +85,13 @@ int sock_udp_ep_fmt(const sock_udp_ep_t *endpoint, char *addr_str, uint16_t *por
static
char
*
_find_hoststart
(
const
char
*
url
)
static
char
*
_find_hoststart
(
const
char
*
url
)
{
{
/* Increment SOCK_SCHEME_MAXLEN due to comparison with the colon after the
* scheme part
*/
size_t
remaining
=
SOCK_SCHEME_MAXLEN
+
1
;
char
*
urlpos
=
(
char
*
)
url
;
char
*
urlpos
=
(
char
*
)
url
;
while
(
*
urlpos
)
{
while
(
*
urlpos
&&
remaining
)
{
remaining
--
;
if
(
*
urlpos
++
==
':'
)
{
if
(
*
urlpos
++
==
':'
)
{
if
(
strncmp
(
urlpos
,
"//"
,
2
)
==
0
)
{
if
(
strncmp
(
urlpos
,
"//"
,
2
)
==
0
)
{
return
urlpos
+
2
;
return
urlpos
+
2
;
...
...
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