Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iotivity-lite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
31
Issues
31
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
IoTivity
iotivity-lite
Commits
19a67b95
Commit
19a67b95
authored
Sep 28, 2020
by
Kishen Maloor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oc_free_string:check string length before freeing
Signed-off-by:
Kishen Maloor
<
kishen.maloor@intel.com
>
parent
c0ed0c51
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
116 additions
and
202 deletions
+116
-202
api/oc_blockwise.c
api/oc_blockwise.c
+1
-3
api/oc_client_api.c
api/oc_client_api.c
+8
-12
api/oc_core_res.c
api/oc_core_res.c
+4
-8
api/oc_endpoint.c
api/oc_endpoint.c
+2
-4
api/oc_helpers.c
api/oc_helpers.c
+5
-3
api/oc_ri.c
api/oc_ri.c
+3
-9
api/oc_swupdate.c
api/oc_swupdate.c
+29
-43
apps/client_arduino.cpp
apps/client_arduino.cpp
+31
-29
apps/client_multithread_linux.c
apps/client_multithread_linux.c
+1
-2
apps/simpleclient.c
apps/simpleclient.c
+2
-4
apps/simpleclient_windows.c
apps/simpleclient_windows.c
+2
-4
messaging/coap/separate.c
messaging/coap/separate.c
+1
-2
security/oc_acl.c
security/oc_acl.c
+4
-12
security/oc_cred.c
security/oc_cred.c
+9
-25
security/oc_obt.c
security/oc_obt.c
+11
-33
security/oc_roles.c
security/oc_roles.c
+3
-9
No files found.
api/oc_blockwise.c
View file @
19a67b95
...
...
@@ -76,9 +76,7 @@ oc_blockwise_free_buffer(oc_list_t list, struct oc_memb *pool,
return
;
}
if
(
oc_string_len
(
buffer
->
uri_query
)
>
0
)
{
oc_free_string
(
&
buffer
->
uri_query
);
}
oc_free_string
(
&
buffer
->
uri_query
);
oc_free_string
(
&
buffer
->
href
);
oc_list_remove
(
list
,
buffer
);
#ifdef OC_DYNAMIC_ALLOCATION
...
...
api/oc_client_api.c
View file @
19a67b95
...
...
@@ -603,9 +603,8 @@ oc_do_site_local_ipv6_discovery(const char *rt, oc_discovery_handler_t handler,
}
bool
status
=
multi_scope_ipv6_discovery
(
NULL
,
0x05
,
oc_string
(
uri_query
),
handlers
,
user_data
);
if
(
oc_string_len
(
uri_query
)
>
0
)
{
oc_free_string
(
&
uri_query
);
}
oc_free_string
(
&
uri_query
);
return
status
;
}
...
...
@@ -633,9 +632,8 @@ oc_do_realm_local_ipv6_discovery(const char *rt, oc_discovery_handler_t handler,
}
bool
status
=
multi_scope_ipv6_discovery
(
NULL
,
0x03
,
oc_string
(
uri_query
),
handlers
,
user_data
);
if
(
oc_string_len
(
uri_query
)
>
0
)
{
oc_free_string
(
&
uri_query
);
}
oc_free_string
(
&
uri_query
);
return
status
;
}
...
...
@@ -657,9 +655,8 @@ oc_do_ip_discovery(const char *rt, oc_discovery_handler_t handler,
#endif
bool
status
=
multi_scope_ipv6_discovery
(
cb4
,
0x02
,
oc_string
(
uri_query
),
handlers
,
user_data
);
if
(
oc_string_len
(
uri_query
)
>
0
)
{
oc_free_string
(
&
uri_query
);
}
oc_free_string
(
&
uri_query
);
return
status
;
}
...
...
@@ -700,9 +697,8 @@ oc_do_ip_discovery_at_endpoint(const char *rt, oc_discovery_handler_t handler,
}
bool
status
=
dispatch_ip_discovery
(
NULL
,
oc_string
(
uri_query
),
handlers
,
endpoint
,
user_data
);
if
(
oc_string_len
(
uri_query
)
>
0
)
{
oc_free_string
(
&
uri_query
);
}
oc_free_string
(
&
uri_query
);
return
status
;
}
...
...
api/oc_core_res.c
View file @
19a67b95
...
...
@@ -76,12 +76,9 @@ oc_core_free_device_info_properties(oc_device_info_t *oc_device_info_item)
{
if
(
oc_device_info_item
)
{
if
(
oc_string_len
(
oc_device_info_item
->
name
))
oc_free_string
(
&
(
oc_device_info_item
->
name
));
if
(
oc_string_len
(
oc_device_info_item
->
icv
))
oc_free_string
(
&
(
oc_device_info_item
->
icv
));
if
(
oc_string_len
(
oc_device_info_item
->
dmv
))
oc_free_string
(
&
(
oc_device_info_item
->
dmv
));
oc_free_string
(
&
(
oc_device_info_item
->
name
));
oc_free_string
(
&
(
oc_device_info_item
->
icv
));
oc_free_string
(
&
(
oc_device_info_item
->
dmv
));
}
}
...
...
@@ -89,8 +86,7 @@ void
oc_core_shutdown
(
void
)
{
size_t
i
;
if
(
oc_string_len
(
oc_platform_info
.
mfg_name
))
oc_free_string
(
&
(
oc_platform_info
.
mfg_name
));
oc_free_string
(
&
(
oc_platform_info
.
mfg_name
));
#ifdef OC_DYNAMIC_ALLOCATION
if
(
oc_device_info
)
{
...
...
api/oc_endpoint.c
View file @
19a67b95
...
...
@@ -472,15 +472,13 @@ oc_parse_endpoint_string(oc_string_t *endpoint_str, oc_endpoint_t *endpoint,
#else
/* OC_IPV4 */
else
{
#ifdef OC_DNS_LOOKUP
if
(
oc_string_len
(
ipaddress
)
>
0
)
oc_free_string
(
&
ipaddress
);
oc_free_string
(
&
ipaddress
);
#endif
/* OC_DNS_LOOKUP */
return
-
1
;
}
#endif
/* !OC_IPV4 */
#ifdef OC_DNS_LOOKUP
if
(
oc_string_len
(
ipaddress
)
>
0
)
oc_free_string
(
&
ipaddress
);
oc_free_string
(
&
ipaddress
);
#endif
/* OC_DNS_LOOKUP */
return
0
;
}
...
...
api/oc_helpers.c
View file @
19a67b95
...
...
@@ -95,11 +95,13 @@ _oc_free_string(
#endif
oc_string_t
*
ocstring
)
{
oc_free
(
if
(
ocstring
&&
ocstring
->
size
>
0
)
{
oc_free
(
#ifdef OC_MEMORY_TRACE
func
,
func
,
#endif
ocstring
,
BYTE_POOL
);
ocstring
,
BYTE_POOL
);
}
}
void
...
...
api/oc_ri.c
View file @
19a67b95
...
...
@@ -378,12 +378,8 @@ void
oc_ri_free_resource_properties
(
oc_resource_t
*
resource
)
{
if
(
resource
)
{
if
(
oc_string_len
(
resource
->
name
)
>
0
)
{
oc_free_string
(
&
(
resource
->
name
));
}
if
(
oc_string_len
(
resource
->
uri
)
>
0
)
{
oc_free_string
(
&
(
resource
->
uri
));
}
oc_free_string
(
&
(
resource
->
name
));
oc_free_string
(
&
(
resource
->
uri
));
if
(
oc_string_array_get_allocated_size
(
resource
->
types
)
>
0
)
{
oc_free_string_array
(
&
(
resource
->
types
));
}
...
...
@@ -1153,9 +1149,7 @@ free_client_cb(oc_client_cb_t *cb)
oc_blockwise_scrub_buffers_for_client_cb
(
cb
);
#endif
/* OC_BLOCK_WISE */
oc_free_string
(
&
cb
->
uri
);
if
(
oc_string_len
(
cb
->
query
))
{
oc_free_string
(
&
cb
->
query
);
}
oc_free_string
(
&
cb
->
query
);
oc_memb_free
(
&
client_cbs_s
,
cb
);
}
...
...
api/oc_swupdate.c
View file @
19a67b95
...
...
@@ -132,15 +132,9 @@ oc_swupdate_free(void)
for
(
i
=
0
;
i
<
oc_core_get_num_devices
();
i
++
)
{
oc_swupdate_t
*
s
=
&
sw
[
i
];
oc_dump_sw
(
i
);
if
(
oc_string_len
(
s
->
purl
)
>
0
)
{
oc_free_string
(
&
s
->
purl
);
}
if
(
oc_string_len
(
s
->
nv
)
>
0
)
{
oc_free_string
(
&
s
->
nv
);
}
if
(
oc_string_len
(
s
->
signage
)
>
0
)
{
oc_free_string
(
&
s
->
signage
);
}
oc_free_string
(
&
s
->
purl
);
oc_free_string
(
&
s
->
nv
);
oc_free_string
(
&
s
->
signage
);
}
#ifdef OC_DYNAMIC_ALLOCATION
if
(
sw
)
{
...
...
@@ -218,10 +212,8 @@ oc_swupdate_notify_upgrading(size_t device, const char *version,
oc_swupdate_t
*
s
=
&
sw
[
device
];
s
->
swupdatestate
=
OC_SWUPDATE_STATE_UPGRADING
;
s
->
swupdateresult
=
result
;
if
(
oc_string_len
(
s
->
nv
)
>
0
)
{
oc_free_string
(
&
s
->
nv
);
oc_new_string
(
&
s
->
nv
,
version
,
strlen
(
version
));
}
oc_free_string
(
&
s
->
nv
);
oc_new_string
(
&
s
->
nv
,
version
,
strlen
(
version
));
s
->
lastupdate
=
timestamp
;
#ifdef OC_SERVER
oc_notify_observers
(
oc_core_get_resource_by_index
(
OCF_SW_UPDATE
,
device
));
...
...
@@ -404,9 +396,7 @@ oc_swupdate_decode(oc_rep_t *rep, size_t device)
}
if
(
oc_string_len
(
rep
->
name
)
==
2
&&
memcmp
(
oc_string
(
rep
->
name
),
"nv"
,
2
)
==
0
)
{
if
(
oc_string_len
(
s
->
nv
)
>
0
)
{
oc_free_string
(
&
s
->
nv
);
}
oc_free_string
(
&
s
->
nv
);
if
(
oc_string_len
(
rep
->
value
.
string
)
>
0
)
{
oc_new_string
(
&
s
->
nv
,
oc_string
(
rep
->
value
.
string
),
oc_string_len
(
rep
->
value
.
string
));
...
...
@@ -414,9 +404,7 @@ oc_swupdate_decode(oc_rep_t *rep, size_t device)
}
if
(
oc_string_len
(
rep
->
name
)
==
4
&&
memcmp
(
oc_string
(
rep
->
name
),
"purl"
,
4
)
==
0
)
{
if
(
oc_string_len
(
s
->
purl
)
>
0
)
{
oc_free_string
(
&
s
->
purl
);
}
oc_free_string
(
&
s
->
purl
);
if
(
oc_string_len
(
rep
->
value
.
string
)
>
0
)
{
oc_new_string
(
&
s
->
purl
,
oc_string
(
rep
->
value
.
string
),
oc_string_len
(
rep
->
value
.
string
));
...
...
@@ -424,9 +412,7 @@ oc_swupdate_decode(oc_rep_t *rep, size_t device)
}
if
(
oc_string_len
(
rep
->
name
)
==
6
&&
memcmp
(
oc_string
(
rep
->
name
),
"signed"
,
6
)
==
0
)
{
if
(
oc_string_len
(
s
->
signage
)
>
0
)
{
oc_free_string
(
&
s
->
signage
);
}
oc_free_string
(
&
s
->
signage
);
if
(
oc_string_len
(
rep
->
value
.
string
)
>
0
)
{
oc_new_string
(
&
s
->
signage
,
oc_string
(
rep
->
value
.
string
),
oc_string_len
(
rep
->
value
.
string
));
...
...
@@ -466,16 +452,16 @@ oc_swupdate_decode(oc_rep_t *rep, size_t device)
/**
* post method for "/sw" resource.
* The function has as input the request body, which are the input values of the
* POST method.
* The input values (as a set) are checked if all supplied values are correct.
* If the input values are correct, they will be assigned to the global
property
* values.
* Resource Description:
* Mechanism to schedule a start of the software update.
*
* @param requestRep the request representation.
*/
* The function has as input the request body, which are the input values of the
* POST method.
* The input values (as a set) are checked if all supplied values are correct.
* If the input values are correct, they will be assigned to the global
property
* values.
* Resource Description:
* Mechanism to schedule a start of the software update.
*
* @param requestRep the request representation.
*/
static
void
post_sw
(
oc_request_t
*
request
,
oc_interface_mask_t
interfaces
,
void
*
user_data
)
{
...
...
@@ -587,17 +573,17 @@ post_sw(oc_request_t *request, oc_interface_mask_t interfaces, void *user_data)
}
/**
* get method for "/sw" resource.
* function is called to intialize the return values of the GET method.
* initialisation of the returned values are done from the global property
* values.
* Resource Description:
* The Resource performing scheduled software update.
*
* @param request the request representation.
* @param interfaces the interface used for this call
* @param user_data the user data.
*/
* get method for "/sw" resource.
* function is called to intialize the return values of the GET method.
* initialisation of the returned values are done from the global property
* values.
* Resource Description:
* The Resource performing scheduled software update.
*
* @param request the request representation.
* @param interfaces the interface used for this call
* @param user_data the user data.
*/
static
void
get_sw
(
oc_request_t
*
request
,
oc_interface_mask_t
interfaces
,
void
*
user_data
)
...
...
apps/client_arduino.cpp
View file @
19a67b95
...
...
@@ -10,13 +10,15 @@
#ifdef __AVR__
#ifdef OC_XMEM
void
extRAMinit
(
void
)
__attribute__
((
used
,
naked
,
section
(
".init3"
)));
void
extRAMinit
(
void
)
{
// set up the xmem registers
XMCRB
=
0
;
XMCRA
=
1
<<
SRE
;
DDRD
|=
_BV
(
PD7
);
DDRL
|=
(
_BV
(
PL6
)
|
_BV
(
PL7
));
void
extRAMinit
(
void
)
__attribute__
((
used
,
naked
,
section
(
".init3"
)));
void
extRAMinit
(
void
)
{
// set up the xmem registers
XMCRB
=
0
;
XMCRA
=
1
<<
SRE
;
DDRD
|=
_BV
(
PD7
);
DDRL
|=
(
_BV
(
PL6
)
|
_BV
(
PL7
));
}
#endif
#endif
...
...
@@ -66,8 +68,7 @@ observe_light(oc_client_response_t *data)
break
;
case
OC_REP_STRING
:
OC_DBG
(
"%s"
,
oc_string
(
rep
->
value
.
string
));
if
(
oc_string_len
(
name
))
oc_free_string
(
&
name
);
oc_free_string
(
&
name
);
oc_new_string
(
&
name
,
oc_string
(
rep
->
value
.
string
),
oc_string_len
(
rep
->
value
.
string
));
break
;
...
...
@@ -159,8 +160,7 @@ get_light(oc_client_response_t *data)
break
;
case
OC_REP_STRING
:
OC_DBG
(
"%s"
,
oc_string
(
rep
->
value
.
string
));
if
(
oc_string_len
(
name
))
oc_free_string
(
&
name
);
oc_free_string
(
&
name
);
oc_new_string
(
&
name
,
oc_string
(
rep
->
value
.
string
),
oc_string_len
(
rep
->
value
.
string
));
break
;
...
...
@@ -244,9 +244,9 @@ OC_PROCESS_THREAD(sample_client_process, ev, data)
{
(
void
)
data
;
static
struct
oc_etimer
et
;
static
const
oc_handler_t
handler
=
{.
init
=
app_init
,
.
signal_event_loop
=
signal_event_loop
,
.
requests_entry
=
issue_requests
};
static
const
oc_handler_t
handler
=
{
.
init
=
app_init
,
.
signal_event_loop
=
signal_event_loop
,
.
requests_entry
=
issue_requests
};
static
oc_clock_time_t
next_event
;
oc_set_mtu_size
(
1024
);
oc_set_max_app_data_size
(
1024
);
...
...
@@ -255,32 +255,31 @@ OC_PROCESS_THREAD(sample_client_process, ev, data)
while
(
ev
!=
OC_PROCESS_EVENT_EXIT
)
{
oc_etimer_set
(
&
et
,
(
oc_clock_time_t
)
next_event
);
if
(
ev
==
OC_PROCESS_EVENT_INIT
)
{
if
(
ev
==
OC_PROCESS_EVENT_INIT
)
{
int
init
=
oc_main_init
(
&
handler
);
if
(
init
<
0
){
if
(
init
<
0
)
{
OC_DBG
(
"Client Init failed!"
);
return
init
;
}
OC_DBG
(
"Client process init!"
);
}
else
if
(
ev
==
OC_PROCESS_EVENT_TIMER
){
}
else
if
(
ev
==
OC_PROCESS_EVENT_TIMER
)
{
next_event
=
oc_main_poll
();
next_event
-=
oc_clock_time
();
}
OC_PROCESS_WAIT_EVENT
();
}
OC_PROCESS_END
();
OC_PROCESS_END
();
}
// Arduino Ethernet Shield
uint8_t
ConnectToNetwork
()
uint8_t
ConnectToNetwork
()
{
// Note: ****Update the MAC address here with your shield's MAC address****
uint8_t
ETHERNET_MAC
[]
=
{
0x90
,
0xA2
,
0xDA
,
0x11
,
0x44
,
0xA9
};
uint8_t
ETHERNET_MAC
[]
=
{
0x90
,
0xA2
,
0xDA
,
0x11
,
0x44
,
0xA9
};
Ethernet
.
init
(
5
);
// CS Pin for MKRZERO
uint8_t
error
=
Ethernet
.
begin
(
ETHERNET_MAC
);
if
(
error
==
0
)
{
if
(
error
==
0
)
{
OC_ERR
(
"Error connecting to Network: %d"
,
error
);
return
-
1
;
}
...
...
@@ -289,18 +288,19 @@ uint8_t ConnectToNetwork()
return
0
;
}
void
setup
()
{
void
setup
()
{
#if defined(__arm__) && defined(__SAMD21G18A__) || defined(__SAM3X8E__)
Serial
.
begin
(
250000
);
Serial
.
begin
(
250000
);
#else
Serial
.
begin
(
115200
);
Serial
.
begin
(
115200
);
#endif
#if defined(__SAMD21G18A__)
while
(
!
Serial
)
{
}
#endif
if
(
ConnectToNetwork
()
!=
0
)
{
if
(
ConnectToNetwork
()
!=
0
)
{
OC_ERR
(
"Unable to connect to network"
);
return
;
}
...
...
@@ -312,7 +312,9 @@ void setup() {
delay
(
200
);
}
void
loop
()
{
void
loop
()
{
oc_process_run
();
}
apps/client_multithread_linux.c
View file @
19a67b95
...
...
@@ -157,8 +157,7 @@ parse_payload(oc_client_response_t *data)
break
;
case
OC_REP_STRING
:
printf
(
"%s
\n
"
,
oc_string
(
rep
->
value
.
string
));
if
(
oc_string_len
(
name
))
oc_free_string
(
&
name
);
oc_free_string
(
&
name
);
oc_new_string
(
&
name
,
oc_string
(
rep
->
value
.
string
),
oc_string_len
(
rep
->
value
.
string
));
break
;
...
...
apps/simpleclient.c
View file @
19a67b95
...
...
@@ -70,8 +70,7 @@ observe_light(oc_client_response_t *data)
break
;
case
OC_REP_STRING
:
PRINT
(
"%s
\n
"
,
oc_string
(
rep
->
value
.
string
));
if
(
oc_string_len
(
name
))
oc_free_string
(
&
name
);
oc_free_string
(
&
name
);
oc_new_string
(
&
name
,
oc_string
(
rep
->
value
.
string
),
oc_string_len
(
rep
->
value
.
string
));
break
;
...
...
@@ -163,8 +162,7 @@ get_light(oc_client_response_t *data)
break
;
case
OC_REP_STRING
:
PRINT
(
"%s
\n
"
,
oc_string
(
rep
->
value
.
string
));
if
(
oc_string_len
(
name
))
oc_free_string
(
&
name
);
oc_free_string
(
&
name
);
oc_new_string
(
&
name
,
oc_string
(
rep
->
value
.
string
),
oc_string_len
(
rep
->
value
.
string
));
break
;
...
...
apps/simpleclient_windows.c
View file @
19a67b95
...
...
@@ -68,8 +68,7 @@ observe_light(oc_client_response_t *data)
break
;
case
OC_REP_STRING
:
PRINT
(
"%s
\n
"
,
oc_string
(
rep
->
value
.
string
));
if
(
oc_string_len
(
name
))
oc_free_string
(
&
name
);
oc_free_string
(
&
name
);
oc_new_string
(
&
name
,
oc_string
(
rep
->
value
.
string
),
oc_string_len
(
rep
->
value
.
string
));
break
;
...
...
@@ -161,8 +160,7 @@ get_light(oc_client_response_t *data)
break
;
case
OC_REP_STRING
:
PRINT
(
"%s
\n
"
,
oc_string
(
rep
->
value
.
string
));
if
(
oc_string_len
(
name
))
oc_free_string
(
&
name
);
oc_free_string
(
&
name
);
oc_new_string
(
&
name
,
oc_string
(
rep
->
value
.
string
),
oc_string_len
(
rep
->
value
.
string
));
break
;
...
...
messaging/coap/separate.c
View file @
19a67b95
...
...
@@ -190,8 +190,7 @@ coap_separate_clear(oc_separate_response_t *separate_response,
coap_separate_t
*
separate_store
)
{
#ifdef OC_BLOCK_WISE
if
(
oc_string_len
(
separate_store
->
uri
)
>
0
)
oc_free_string
(
&
separate_store
->
uri
);
oc_free_string
(
&
separate_store
->
uri
);
#endif
/* OC_BLOCK_WISE */
oc_list_remove
(
separate_response
->
requests
,
separate_store
);
oc_memb_free
(
&
separate_requests
,
separate_store
);
...
...
security/oc_acl.c
View file @
19a67b95
...
...
@@ -683,9 +683,7 @@ oc_ace_free_resources(size_t device, oc_sec_ace_t **ace, const char *href)
if
(
href
==
NULL
||
(
oc_string_len
(
res
->
href
)
==
strlen
(
href
)
&&
memcmp
(
href
,
oc_string
(
res
->
href
),
strlen
(
href
))
==
0
))
{
if
(
oc_string_len
(
res
->
href
)
>
0
)
{
oc_free_string
(
&
res
->
href
);
}
oc_free_string
(
&
res
->
href
);
oc_list_remove
((
*
ace
)
->
resources
,
res
);
oc_memb_free
(
&
res_l
,
res
);
}
...
...
@@ -742,9 +740,7 @@ oc_acl_remove_ace(int aceid, size_t device)
oc_ace_free_resources
(
device
,
&
ace
,
NULL
);
if
(
ace
->
subject_type
==
OC_SUBJECT_ROLE
)
{
oc_free_string
(
&
ace
->
subject
.
role
.
role
);
if
(
oc_string_len
(
ace
->
subject
.
role
.
authority
)
>
0
)
{
oc_free_string
(
&
ace
->
subject
.
role
.
authority
);
}
oc_free_string
(
&
ace
->
subject
.
role
.
authority
);
}
oc_memb_free
(
&
ace_l
,
ace
);
removed
=
true
;
...
...
@@ -764,9 +760,7 @@ oc_sec_clear_acl(size_t device)
oc_ace_free_resources
(
device
,
&
ace
,
NULL
);
if
(
ace
->
subject_type
==
OC_SUBJECT_ROLE
)
{
oc_free_string
(
&
ace
->
subject
.
role
.
role
);
if
(
oc_string_len
(
ace
->
subject
.
role
.
authority
)
>
0
)
{
oc_free_string
(
&
ace
->
subject
.
role
.
authority
);
}
oc_free_string
(
&
ace
->
subject
.
role
.
authority
);
}
oc_memb_free
(
&
ace_l
,
ace
);
ace
=
(
oc_sec_ace_t
*
)
oc_list_pop
(
acl_d
->
subjects
);
...
...
@@ -1048,9 +1042,7 @@ oc_sec_decode_acl(oc_rep_t *rep, bool from_storage, size_t device)
if
(
subject_type
==
OC_SUBJECT_ROLE
)
{
oc_free_string
(
&
subject
.
role
.
role
);
if
(
oc_string_len
(
subject
.
role
.
authority
)
>
0
)
{
oc_free_string
(
&
subject
.
role
.
authority
);
}
oc_free_string
(
&
subject
.
role
.
authority
);
}
aclist2
=
aclist2
->
next
;
...
...
security/oc_cred.c
View file @
19a67b95
...
...
@@ -158,18 +158,12 @@ oc_sec_remove_cred(oc_sec_cred_t *cred, size_t device)
oc_sec_remove_role_cred
(
oc_string
(
cred
->
role
.
role
),
oc_string
(
cred
->
role
.
authority
));
#endif
/* OC_PKI && OC_CLIENT */
oc_free_string
(
&
cred
->
role
.
role
);
if
(
oc_string_len
(
cred
->
role
.
authority
)
>
0
)
{
oc_free_string
(
&
cred
->
role
.
authority
);
}
}
if
(
oc_string_len
(
cred
->
privatedata
.
data
)
>
0
)
{
oc_free_string
(
&
cred
->
privatedata
.
data
);
}
oc_free_string
(
&
cred
->
role
.
role
);
oc_free_string
(
&
cred
->
role
.
authority
);
oc_free_string
(
&
cred
->
privatedata
.
data
);
#ifdef OC_PKI
if
(
oc_string_len
(
cred
->
publicdata
.
data
)
>
0
)
{
oc_free_string
(
&
cred
->
publicdata
.
data
);
}
oc_free_string
(
&
cred
->
publicdata
.
data
);
if
(
cred
->
credtype
==
OC_CREDTYPE_CERT
)
{
if
(
cred
->
credusage
!=
OC_CREDUSAGE_TRUSTCA
&&
...
...
@@ -440,9 +434,7 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
#endif
/* OC_PKI */
)
{
#ifdef OC_PKI
if
(
oc_string_len
(
public_key
)
>
0
)
{
oc_free_string
(
&
public_key
);
}
oc_free_string
(
&
public_key
);
#endif
/* OC_PKI */
return
credid
;
}
else
{
...
...
@@ -475,9 +467,7 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
publicdata_size
==
oc_string_len
(
cred
->
publicdata
.
data
)
&&
memcmp
(
publicdata
,
oc_string
(
cred
->
publicdata
.
data
),
publicdata_size
)
==
0
)
{
if
(
oc_string_len
(
public_key
)
>
0
)
{
oc_free_string
(
&
public_key
);
}
oc_free_string
(
&
public_key
);
return
cred
->
credid
;
}
}
...
...
@@ -494,9 +484,7 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
if
((
oc_string_len
(
roles
->
publicdata
.
data
)
==
publicdata_size
)
&&
memcmp
(
oc_string
(
roles
->
publicdata
.
data
),
publicdata
,
publicdata_size
)
==
0
)
{
if
(
oc_string_len
(
public_key
)
>
0
)
{
oc_free_string
(
&
public_key
);
}
oc_free_string
(
&
public_key
);
return
roles
->
credid
;
}
roles
=
roles
->
next
;
...
...
@@ -616,16 +604,12 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
}
#endif
/* OC_PKI */
#ifdef OC_PKI
if
(
oc_string_len
(
public_key
)
>
0
)
{
oc_free_string
(
&
public_key
);
}
oc_free_string
(
&
public_key
);
#endif
/* OC_PKI */
return
cred
->
credid
;
add_new_cred_error:
#ifdef OC_PKI
if
(
oc_string_len
(
public_key
)
>
0
)
{
oc_free_string
(
&
public_key
);
}
oc_free_string
(
&
public_key
);
#endif
/* OC_PKI */
return
-
1
;
}
...
...
security/oc_obt.c
View file @
19a67b95
...
...
@@ -1120,9 +1120,7 @@ oc_obt_free_roleid(oc_role_t *roles)
while
(
r
)
{
next
=
r
->
next
;
oc_free_string
(
&
r
->
role
);
if
(
oc_string_len
(
r
->
authority
)
>
0
)
{
oc_free_string
(
&
r
->
authority
);
}
oc_free_string
(
&
r
->
authority
);
oc_memb_free
(
&
oc_roles
,
r
);
r
=
next
;
}
...
...
@@ -1312,12 +1310,8 @@ device_CSR(oc_client_response_t *data)
}
}
err_device_CSR:
if
(
oc_string_len
(
subject
)
>
0
)
{
oc_free_string
(
&
subject
);
}
if
(
oc_string_len
(
cert
)
>
0
)
{
oc_free_string
(
&
cert
);
}
oc_free_string
(
&
subject
);
oc_free_string
(
&
cert
);
free_credprov_state
(
p
,
-
1
);
}
...
...
@@ -1653,9 +1647,7 @@ void
oc_obt_ace_resource_set_href
(
oc_ace_res_t
*
resource
,
const
char
*
href
)
{
if
(
resource
)
{
if
(
oc_string_len
(
resource
->
href
)
>
0
)
{
oc_free_string
(
&
resource
->
href
);
}
oc_free_string
(
&
resource
->
href
);
oc_new_string
(
&
resource
->
href
,
href
,
strlen
(
href
));
}
}
...
...
@@ -1682,19 +1674,13 @@ free_ace(oc_sec_ace_t *ace)
if
(
ace
)
{
oc_ace_res_t
*
res
=
(
oc_ace_res_t
*
)
oc_list_pop
(
ace
->
resources
);
while
(
res
!=
NULL
)
{
if
(
oc_string_len
(
res
->
href
)
>
0
)
{
oc_free_string
(
&
res
->
href
);
}
oc_free_string
(
&
res
->
href
);
oc_memb_free
(
&
oc_res_m
,
res
);
res
=
(
oc_ace_res_t
*
)
oc_list_pop
(
ace
->
resources
);
}
if
(
ace
->
subject_type
==
OC_SUBJECT_ROLE
)
{
if
(
oc_string_len
(
ace
->
subject
.
role
.
role
)
>
0
)
{
oc_free_string
(
&
ace
->
subject
.
role
.
role
);
}
if
(
oc_string_len
(
ace
->
subject
.
role
.
authority
)
>
0
)
{
oc_free_string
(
&
ace
->
subject
.
role
.
authority
);
}
oc_free_string
(
&
ace
->
subject
.
role
.
role
);
oc_free_string
(
&
ace
->
subject
.
role
.
authority
);
}
oc_memb_free
(
&
oc_aces_m
,
ace
);
}
...
...
@@ -1906,19 +1892,11 @@ oc_obt_free_creds(oc_sec_creds_t *creds)
oc_sec_cred_t
*
cred
=
oc_list_head
(
creds
->
creds
),
*
next
;
while
(
cred
!=
NULL
)
{
next
=
cred
->
next
;
if
(
oc_string_len
(
cred
->
role
.
role
)
>
0
)
{
oc_free_string
(
&
cred
->
role
.
role
);
if
(
oc_string_len
(
cred
->
role
.
authority
)
>
0
)
{
oc_free_string
(
&
cred
->
role
.
authority
);
}
}
if
(
oc_string_len
(
cred
->
privatedata
.
data
)
>
0
)
{