Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
0472587c
Commit
0472587c
authored
Apr 24, 2016
by
Philip Gladstone
Committed by
Marcel Stör
Apr 24, 2016
Browse files
Added length checking (#1260)
Made the code clearer
parent
25b4285c
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/coap.c
View file @
0472587c
...
@@ -326,7 +326,7 @@ static int coap_request( lua_State* L, coap_method_t m )
...
@@ -326,7 +326,7 @@ static int coap_request( lua_State* L, coap_method_t m )
stack
++
;
stack
++
;
pesp_conn
=
cud
->
pesp_conn
;
pesp_conn
=
cud
->
pesp_conn
;
ip_addr_t
ipaddr
;
ip_addr_t
ipaddr
;
uint8_t
host
[
32
];
uint8_t
host
[
64
];
unsigned
t
;
unsigned
t
;
if
(
lua_isnumber
(
L
,
stack
)
)
if
(
lua_isnumber
(
L
,
stack
)
)
...
@@ -348,6 +348,9 @@ static int coap_request( lua_State* L, coap_method_t m )
...
@@ -348,6 +348,9 @@ static int coap_request( lua_State* L, coap_method_t m )
coap_uri_t
*
uri
=
coap_new_uri
(
url
,
l
);
// should call free(uri) somewhere
coap_uri_t
*
uri
=
coap_new_uri
(
url
,
l
);
// should call free(uri) somewhere
if
(
uri
==
NULL
)
if
(
uri
==
NULL
)
return
luaL_error
(
L
,
"uri wrong format."
);
return
luaL_error
(
L
,
"uri wrong format."
);
if
(
uri
->
host
.
length
+
1
/* for the null */
>
sizeof
(
host
))
{
return
luaL_error
(
L
,
"host too long"
);
}
pesp_conn
->
proto
.
udp
->
remote_port
=
uri
->
port
;
pesp_conn
->
proto
.
udp
->
remote_port
=
uri
->
port
;
NODE_DBG
(
"UDP port is set: %d.
\n
"
,
uri
->
port
);
NODE_DBG
(
"UDP port is set: %d.
\n
"
,
uri
->
port
);
...
...
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