Commit 0472587c authored by Philip Gladstone's avatar Philip Gladstone Committed by Marcel Stör
Browse files

Added length checking (#1260)

Made the code clearer
parent 25b4285c
...@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment