This brings IoTivoity to version 1.1.0 The old @lantiq.com address does not work any more, update to the @intel.com address. The removed patches were merged upstream, but there are still some new ones needed. Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com>lilik-openwrt-22.03
@ -1,26 +0,0 @@ | |||
From d647872aee4871e286ddedf4931792086f5b4565 Mon Sep 17 00:00:00 2001 | |||
From: Hauke Mehrtens <hauke.mehrtens@lantiq.com> | |||
Date: Mon, 26 Oct 2015 14:32:39 +0100 | |||
Subject: [PATCH] libcoap: remove fix build error on big endian systems | |||
In the big endian case an additional typedef is added in a wrong | |||
position in TinyDTLS. This breaks compiling this code on big endian | |||
systems. | |||
Change-Id: Iad854aba112ddb23bf490b064ec6fbf5d01ce6b6 | |||
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@lantiq.com> | |||
--- | |||
resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h | 2 +- | |||
1 file changed, 1 insertion(+), 1 deletion(-) | |||
--- a/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h | |||
+++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/pdu.h | |||
@@ -194,7 +194,7 @@ typedef enum | |||
#ifdef WORDS_BIGENDIAN | |||
typedef union | |||
{ | |||
- typedef struct | |||
+ struct | |||
{ | |||
unsigned int version:2; /* protocol version */ | |||
unsigned int type:2; /* type flag */ |
@ -1,31 +0,0 @@ | |||
From 9510445c5002b0e3502d2ac09723e1b2ddd03704 Mon Sep 17 00:00:00 2001 | |||
From: Hauke Mehrtens <hauke.mehrtens@lantiq.com> | |||
Date: Mon, 26 Oct 2015 14:39:55 +0100 | |||
Subject: [PATCH] tinydtls: use types from inittype.h, fix musl libc | |||
The SHA2 code currently uses u_int32_t and similar types without | |||
defining them. This type is not defined by the POSIX standard, but many | |||
libc implementations have it as a non standard extension. In the musl | |||
libc it is not implemented and I am getting a compile error when using | |||
u_int32_t, I should use uint32_t, which is done when | |||
SHA2_USE_INTTYPES_H is set. | |||
This fixes build with musl libs used in OpenWrt. | |||
Change-Id: I485435ddb8b1a2359caedd335ab54f91ca5e3f3e | |||
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@lantiq.com> | |||
--- | |||
extlibs/tinydtls/SConscript | 2 +- | |||
1 file changed, 1 insertion(+), 1 deletion(-) | |||
--- a/extlibs/tinydtls/SConscript | |||
+++ b/extlibs/tinydtls/SConscript | |||
@@ -68,7 +68,7 @@ if not env.get('RELEASE'): | |||
else: | |||
env.AppendUnique(CPPDEFINES = ['NDEBUG']) | |||
-env.AppendUnique(CPPDEFINES = ['DTLSV12', 'WITH_SHA256', 'DTLS_CHECK_CONTENTTYPE']) | |||
+env.AppendUnique(CPPDEFINES = ['DTLSV12', 'WITH_SHA256', 'DTLS_CHECK_CONTENTTYPE', 'SHA2_USE_INTTYPES_H']) | |||
libtinydtls = env.StaticLibrary('libtinydtls', env.get('TINYDTLS_SRC'), OBJPREFIX='libtinydtls_') |
@ -1,161 +0,0 @@ | |||
From 75a19e9059e671442abe40908ba80c2da614118d Mon Sep 17 00:00:00 2001 | |||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||
Date: Mon, 26 Oct 2015 22:42:40 +0100 | |||
Subject: [PATCH] connectivity: fix getnameinfo() call for musl libc | |||
The musl libc and also the libc from net/freebsd are currently checking | |||
if the size of the sockaddr given to getnameinfo() matches the size for | |||
this family and it fails when giving sizeof(struct sockaddr_storage). | |||
This patch fixes this problem by making the caller also provide the | |||
size of the struct sockaddr_storage. | |||
I am currently trying to get a fix for this problem into musl libc, but | |||
IoTivity should still fix this. | |||
This also fixes a wrong error message. | |||
Change-Id: Ie9b89523b5ba20e536c03e3ad85c65bd5ff2ba53 | |||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||
--- | |||
resource/csdk/connectivity/inc/caadapterutils.h | 12 ++++++++---- | |||
.../csdk/connectivity/src/adapter_util/caadapternetdtls.c | 10 +++++----- | |||
resource/csdk/connectivity/src/adapter_util/caadapterutils.c | 9 +++++---- | |||
resource/csdk/connectivity/src/ip_adapter/caipserver.c | 2 +- | |||
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c | 2 +- | |||
5 files changed, 20 insertions(+), 15 deletions(-) | |||
--- a/resource/csdk/connectivity/inc/caadapterutils.h | |||
+++ b/resource/csdk/connectivity/inc/caadapterutils.h | |||
@@ -212,13 +212,16 @@ void CAClearNetInterfaceInfoList(u_array | |||
*/ | |||
void CAClearServerInfoList(u_arraylist_t *serverInfoList); | |||
+#ifndef WITH_ARDUINO | |||
/** | |||
* Convert address from binary to string. | |||
- * @param[in] ipaddr IP address info. | |||
- * @param[out] host address string (must be CA_IPADDR_SIZE). | |||
- * @param[out] port host order port number. | |||
+ * @param[in] sockAddr IP address info. | |||
+ * @param[in] sockAddrLen size of sockAddr. | |||
+ * @param[out] host address string (must be CA_IPADDR_SIZE). | |||
+ * @param[out] port host order port number. | |||
*/ | |||
-void CAConvertAddrToName(const struct sockaddr_storage *sockaddr, char *host, uint16_t *port); | |||
+void CAConvertAddrToName(const struct sockaddr_storage *sockAddr, socklen_t sockAddrLen, | |||
+ char *host, uint16_t *port); | |||
/** | |||
* Convert address from string to binary. | |||
@@ -227,6 +230,7 @@ void CAConvertAddrToName(const struct so | |||
* @param[out] ipaddr IP address info. | |||
*/ | |||
void CAConvertNameToAddr(const char *host, uint16_t port, struct sockaddr_storage *sockaddr); | |||
+#endif /* WITH_ARDUINO */ | |||
#ifdef __ANDROID__ | |||
/** | |||
--- a/resource/csdk/connectivity/src/adapter_util/caadapternetdtls.c | |||
+++ b/resource/csdk/connectivity/src/adapter_util/caadapternetdtls.c | |||
@@ -417,7 +417,7 @@ static int32_t CAReadDecryptedPayload(dt | |||
((addrInfo->addr.st.ss_family == AF_INET) ? CA_IPV4 : CA_IPV6) | CA_SECURE, .port = 0 }, | |||
.identity = | |||
{ 0 } }; | |||
- CAConvertAddrToName(&(addrInfo->addr.st), sep.endpoint.addr, &sep.endpoint.port); | |||
+ CAConvertAddrToName(&(addrInfo->addr.st), addrInfo->size, sep.endpoint.addr, &sep.endpoint.port); | |||
if (NULL == g_caDtlsContext) | |||
{ | |||
@@ -468,7 +468,7 @@ static int32_t CASendSecureData(dtls_con | |||
CAEndpoint_t endpoint = {.adapter = CA_DEFAULT_ADAPTER}; | |||
- CAConvertAddrToName(&(addrInfo->addr.st), endpoint.addr, &endpoint.port); | |||
+ CAConvertAddrToName(&(addrInfo->addr.st), addrInfo->size, endpoint.addr, &endpoint.port); | |||
endpoint.flags = addrInfo->addr.st.ss_family == AF_INET ? CA_IPV4 : CA_IPV6; | |||
endpoint.flags |= CA_SECURE; | |||
endpoint.adapter = CA_ADAPTER_IP; | |||
@@ -515,7 +515,7 @@ static int32_t CAHandleSecureEvent(dtls_ | |||
stCADtlsAddrInfo_t *addrInfo = (stCADtlsAddrInfo_t *)session; | |||
char peerAddr[MAX_ADDR_STR_SIZE_CA] = { 0 }; | |||
uint16_t port = 0; | |||
- CAConvertAddrToName(&(addrInfo->addr.st), peerAddr, &port); | |||
+ CAConvertAddrToName(&(addrInfo->addr.st), addrInfo->size, peerAddr, &port); | |||
CARemovePeerFromPeerInfoList(peerAddr, port); | |||
} | |||
@@ -553,7 +553,7 @@ static int32_t CAGetPskCredentials(dtls_ | |||
stCADtlsAddrInfo_t *addrInfo = (stCADtlsAddrInfo_t *)session; | |||
char peerAddr[MAX_ADDR_STR_SIZE_CA] = { 0 }; | |||
uint16_t port = 0; | |||
- CAConvertAddrToName(&(addrInfo->addr.st), peerAddr, &port); | |||
+ CAConvertAddrToName(&(addrInfo->addr.st), addrInfo->size, peerAddr, &port); | |||
if(CA_STATUS_OK != CAAddIdToPeerInfoList(peerAddr, port, desc, descLen) ) | |||
{ | |||
@@ -933,7 +933,7 @@ static int CAVerifyCertificate(struct dt | |||
stCADtlsAddrInfo_t *addrInfo = (stCADtlsAddrInfo_t *)session; | |||
char peerAddr[MAX_ADDR_STR_SIZE_CA] = { 0 }; | |||
uint16_t port = 0; | |||
- CAConvertAddrToName(&(addrInfo->addr.st), peerAddr, &port); | |||
+ CAConvertAddrToName(&(addrInfo->addr.st), addrInfo->size, peerAddr, &port); | |||
CAResult_t result = CAAddIdToPeerInfoList(peerAddr, port, | |||
crtChain[0].subject.data + DER_SUBJECT_HEADER_LEN + 2, crtChain[0].subject.data[DER_SUBJECT_HEADER_LEN + 1]); | |||
--- a/resource/csdk/connectivity/src/adapter_util/caadapterutils.c | |||
+++ b/resource/csdk/connectivity/src/adapter_util/caadapterutils.c | |||
@@ -122,14 +122,15 @@ CAResult_t CAParseIPv4AddressInternal(co | |||
* These two conversion functions return void because errors can't happen | |||
* (because of NI_NUMERIC), and there's nothing to do if they do happen. | |||
*/ | |||
-void CAConvertAddrToName(const struct sockaddr_storage *sockAddr, char *host, uint16_t *port) | |||
+void CAConvertAddrToName(const struct sockaddr_storage *sockAddr, socklen_t sockAddrLen, | |||
+ char *host, uint16_t *port) | |||
{ | |||
VERIFY_NON_NULL_VOID(sockAddr, CA_ADAPTER_UTILS_TAG, "sockAddr is null"); | |||
VERIFY_NON_NULL_VOID(host, CA_ADAPTER_UTILS_TAG, "host is null"); | |||
VERIFY_NON_NULL_VOID(port, CA_ADAPTER_UTILS_TAG, "port is null"); | |||
int r = getnameinfo((struct sockaddr *)sockAddr, | |||
- sizeof (struct sockaddr_storage), | |||
+ sockAddrLen, | |||
host, MAX_ADDR_STR_SIZE_CA, | |||
NULL, 0, | |||
NI_NUMERICHOST|NI_NUMERICSERV); | |||
@@ -138,12 +139,12 @@ void CAConvertAddrToName(const struct so | |||
if (EAI_SYSTEM == r) | |||
{ | |||
OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG, | |||
- "getaddrinfo failed: errno %s", strerror(errno)); | |||
+ "getnameinfo failed: errno %s", strerror(errno)); | |||
} | |||
else | |||
{ | |||
OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG, | |||
- "getaddrinfo failed: %s", gai_strerror(r)); | |||
+ "getnameinfo failed: %s", gai_strerror(r)); | |||
} | |||
return; | |||
} | |||
--- a/resource/csdk/connectivity/src/ip_adapter/caipserver.c | |||
+++ b/resource/csdk/connectivity/src/ip_adapter/caipserver.c | |||
@@ -299,7 +299,7 @@ static CAResult_t CAReceiveMessage(int f | |||
} | |||
} | |||
- CAConvertAddrToName(&srcAddr, sep.endpoint.addr, &sep.endpoint.port); | |||
+ CAConvertAddrToName(&srcAddr, msg.msg_namelen, sep.endpoint.addr, &sep.endpoint.port); | |||
if (flags & CA_SECURE) | |||
{ | |||
--- a/resource/csdk/connectivity/src/tcp_adapter/catcpserver.c | |||
+++ b/resource/csdk/connectivity/src/tcp_adapter/catcpserver.c | |||
@@ -478,7 +478,7 @@ static void CAAcceptHandler(void *data) | |||
} | |||
svritem->u4tcp.fd = sockfd; | |||
- CAConvertAddrToName((struct sockaddr_storage *)&clientaddr, | |||
+ CAConvertAddrToName((struct sockaddr_storage *)&clientaddr, clientlen, | |||
(char *) &svritem->addr, &svritem->u4tcp.port); | |||
ca_mutex_lock(g_mutexObjectList); |
@ -0,0 +1,24 @@ | |||
From 4488170af944163b62051b2afee60386a9973c72 Mon Sep 17 00:00:00 2001 | |||
From: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||
Date: Thu, 31 Mar 2016 10:23:48 +0200 | |||
Subject: [PATCH] remove building of provisioning service | |||
The provisioning service is not used in this build and depends on boost_thread | |||
which would add an additional unused dependency. | |||
Change-Id: Ic7edab3ae96d77339ea0f48fc76ab2534c49b6ba | |||
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||
--- | |||
resource/src/SConscript | 4 ++-- | |||
1 file changed, 2 insertions(+), 2 deletions(-) | |||
--- a/resource/src/SConscript | |||
+++ b/resource/src/SConscript | |||
@@ -116,5 +116,5 @@ oclib_env.UserInstallTargetHeader(header | |||
oclib_env.UserInstallTargetHeader(header_dir + 'CAManager.h', 'resource', 'CAManager.h') | |||
# Add Provisioning library | |||
-if target_os in ['linux', 'android', 'tizen'] and env.get('SECURED') == '1': | |||
- SConscript('../provisioning/SConscript') | |||
+# if target_os in ['linux', 'android', 'tizen'] and env.get('SECURED') == '1': | |||
+# SConscript('../provisioning/SConscript') |
@ -0,0 +1,38 @@ | |||
From 8a1a5562904c1bbdb2bcb332c0a74482d7cdea15 Mon Sep 17 00:00:00 2001 | |||
From: Hauke Mehrtens <hauke.mehrtens@lantiq.com> | |||
Date: Wed, 11 Nov 2015 18:10:03 +0100 | |||
Subject: [PATCH 5/5] resource-encapsulation: deactivate test covergae | |||
Change-Id: I9c9b5853ee1521f5963c73c3025b1c0f10393a96 | |||
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@lantiq.com> | |||
--- | |||
.../resource-encapsulation/src/common/SConscript | 4 ---- | |||
.../src/serverBuilder/SConscript | 4 ---- | |||
2 files changed, 8 deletions(-) | |||
--- a/service/resource-encapsulation/src/common/SConscript | |||
+++ b/service/resource-encapsulation/src/common/SConscript | |||
@@ -66,10 +66,6 @@ if target_os == 'android': | |||
rcs_common_env.AppendUnique(LIBS = ['dl', 'oc']) | |||
-if not release: | |||
- rcs_common_env.AppendUnique(CXXFLAGS = ['--coverage']) | |||
- rcs_common_env.PrependUnique(LIBS = ['gcov']) | |||
- | |||
###################################################################### | |||
# Source files and Targets | |||
###################################################################### | |||
--- a/service/resource-encapsulation/src/serverBuilder/SConscript | |||
+++ b/service/resource-encapsulation/src/serverBuilder/SConscript | |||
@@ -67,10 +67,6 @@ server_builder_env.AppendUnique(LIBS = [ | |||
if env.get('LOGGING'): | |||
server_builder_env.AppendUnique(LIBS = ['octbstack']) | |||
-if not release: | |||
- server_builder_env.AppendUnique(CXXFLAGS = ['--coverage']) | |||
- server_builder_env.PrependUnique(LIBS = ['gcov']) | |||
- | |||
###################################################################### | |||
# Source files and Targets | |||
###################################################################### |
@ -0,0 +1,39 @@ | |||
From b1c29c35cba3eb39af18fb8db0ec676e3d658b1d Mon Sep 17 00:00:00 2001 | |||
From: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||
Date: Fri, 17 Jun 2016 17:38:35 +0200 | |||
Subject: [PATCH] security: fix reading of permission attribute from | |||
configuration | |||
Casting the pointer to the permission attribute from uint16_t to uint64_t | |||
causes problems on MIPS Big Endian systems and probably othrs as well. | |||
When the calling method interprets it as uint64_t not the value is | |||
converted but the pointer is interpreted as it would point to a 64 bit | |||
integer, but it is only a 16 bit wide integer. On MIPS BE permission was | |||
always 0 independent of which value between 0 and 32 the permission | |||
attribute had, this was probably written to some padding area or into | |||
some other member of the struct. | |||
This patch fixes the memory corruption and makes the code work for me with | |||
a MIPS BE CPU. | |||
Change-Id: Ifa843e69980ad4309b1e3076b8e2c98c03324352 | |||
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||
--- | |||
resource/csdk/security/src/aclresource.c | 5 ++++- | |||
1 file changed, 4 insertions(+), 1 deletion(-) | |||
--- a/resource/csdk/security/src/aclresource.c | |||
+++ b/resource/csdk/security/src/aclresource.c | |||
@@ -602,8 +602,11 @@ OicSecAcl_t* CBORPayloadToAcl(const uint | |||
// Permissions -- Mandatory | |||
if (strcmp(name, OIC_JSON_PERMISSION_NAME) == 0) | |||
{ | |||
- cborFindResult = cbor_value_get_uint64(&aclMap, (uint64_t *) &acl->permission); | |||
+ uint64_t tmp64; | |||
+ | |||
+ cborFindResult = cbor_value_get_uint64(&aclMap, &tmp64); | |||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding a PERM Value."); | |||
+ acl->permission = tmp64; | |||
} | |||
// Period -- Not mandatory |
@ -0,0 +1,87 @@ | |||
From f182119e571a1b520b4e5ef4ee5e5b5cd243b931 Mon Sep 17 00:00:00 2001 | |||
From: Chul Lee <chuls.lee@samsung.com> | |||
Date: Wed, 22 Jun 2016 12:40:21 +0900 | |||
Subject: [PATCH] Remove the endianness dependency in cbor conversion. | |||
A similar bug reported from https://gerrit.iotivity.org/gerrit/#/c/8755/ | |||
Change-Id: I631bab77f7486f1f45eaff96c67d39606e37c6b6 | |||
Signed-off-by: Chul Lee <chuls.lee@samsung.com> | |||
Reviewed-on: https://gerrit.iotivity.org/gerrit/8829 | |||
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org> | |||
Reviewed-by: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||
Reviewed-by: Randeep Singh <randeep.s@samsung.com> | |||
(cherry picked from commit 24474a8d2555229efb425b6cb63e19b3279ba810) | |||
Reviewed-on: https://gerrit.iotivity.org/gerrit/9053 | |||
--- | |||
resource/csdk/security/src/credresource.c | 8 ++++++-- | |||
resource/csdk/security/src/pconfresource.c | 5 +++-- | |||
resource/csdk/stack/src/ocpayloadparse.c | 8 ++++++-- | |||
3 files changed, 15 insertions(+), 6 deletions(-) | |||
--- a/resource/csdk/security/src/credresource.c | |||
+++ b/resource/csdk/security/src/credresource.c | |||
@@ -435,8 +435,10 @@ OCStackResult CBORPayloadToCred(const ui | |||
//credid | |||
if (strcmp(name, OIC_JSON_CREDID_NAME) == 0) | |||
{ | |||
- cborFindResult = cbor_value_get_uint64(&credMap, (uint64_t *) &cred->credId); | |||
+ uint64_t credId = 0; | |||
+ cborFindResult = cbor_value_get_uint64(&credMap, &credId); | |||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CredId."); | |||
+ cred->credId = (uint16_t)credId; | |||
} | |||
// subjectid | |||
if (strcmp(name, OIC_JSON_SUBJECTID_NAME) == 0) | |||
@@ -451,8 +453,10 @@ OCStackResult CBORPayloadToCred(const ui | |||
// credtype | |||
if (strcmp(name, OIC_JSON_CREDTYPE_NAME) == 0) | |||
{ | |||
- cborFindResult = cbor_value_get_uint64(&credMap, (uint64_t *) &cred->credType); | |||
+ uint64_t credType = 0; | |||
+ cborFindResult = cbor_value_get_uint64(&credMap, &credType); | |||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CredType."); | |||
+ cred->credType = (OicSecCredType_t)credType; | |||
} | |||
// privatedata | |||
if (strcmp(name, OIC_JSON_PRIVATEDATA_NAME) == 0) | |||
--- a/resource/csdk/security/src/pconfresource.c | |||
+++ b/resource/csdk/security/src/pconfresource.c | |||
@@ -642,8 +642,9 @@ OCStackResult CBORPayloadToPconf(const u | |||
// Permissions -- Mandatory | |||
if (strcmp(name, OIC_JSON_PERMISSION_NAME) == 0) | |||
{ | |||
- cborFindResult = cbor_value_get_uint64(&pdAclMap, | |||
- (uint64_t *) &pdacl->permission); | |||
+ uint64_t permission = 0; | |||
+ cborFindResult = cbor_value_get_uint64(&pdAclMap, &permission); | |||
+ pdacl->permission = (uint16_t)permission; | |||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value"); | |||
} | |||
--- a/resource/csdk/stack/src/ocpayloadparse.c | |||
+++ b/resource/csdk/stack/src/ocpayloadparse.c | |||
@@ -1169,17 +1169,21 @@ static OCStackResult OCParsePresencePayl | |||
if (cbor_value_is_map(rootValue)) | |||
{ | |||
CborValue curVal; | |||
+ uint64_t temp = 0; | |||
// Sequence Number | |||
CborError err = cbor_value_map_find_value(rootValue, OC_RSRVD_NONCE, &curVal); | |||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding nonce tag"); | |||
- err = cbor_value_get_uint64(&curVal, (uint64_t *)&payload->sequenceNumber); | |||
+ err = cbor_value_get_uint64(&curVal, &temp); | |||
+ payload->sequenceNumber = (uint32_t)temp; | |||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding nonce value"); | |||
// Max Age | |||
err = cbor_value_map_find_value(rootValue, OC_RSRVD_TTL, &curVal); | |||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding ttl tag"); | |||
- err = cbor_value_get_uint64(&curVal, (uint64_t *)&payload->maxAge); | |||
+ temp = 0; | |||
+ err = cbor_value_get_uint64(&curVal, &temp); | |||
+ payload->maxAge = (uint32_t)temp; | |||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding ttl value"); | |||
// Trigger |
@ -0,0 +1,93 @@ | |||
From 7c99ef8bfa024f11452311c36329eeeeece4fd74 Mon Sep 17 00:00:00 2001 | |||
From: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||
Date: Wed, 22 Jun 2016 11:41:43 +0200 | |||
Subject: [PATCH] Fix memory corruption when reading inetgers from cbor | |||
When the cbor_value_get_*() function is called with a pointer to some int, it | |||
should have the correct size. When we cast it to something else it is treated | |||
as a pointer to an uint64_t in the function for example and them 64 bits gets | |||
written to memory even with the real type is only 32 bit long. When the real | |||
type is only 32 bit long some other memory gets overwritten. On Big endian | |||
systems the least significant bits are cut of so in most cases 0 is read. | |||
With this patch a value cast is used and the value is converted to the other size. | |||
This is the same as in commit 0d64c7c95a5c11a9fb5201e729fd8c75da210c80 | |||
"security: fix reading of permission attribute from configuration" | |||
Change-Id: If5965491241e25ebf60a22dc45d37d74a33cb02f | |||
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||
--- | |||
resource/csdk/security/src/pconfresource.c | 5 ++++- | |||
resource/csdk/stack/src/ocpayloadparse.c | 19 +++++++++++++++---- | |||
2 files changed, 19 insertions(+), 5 deletions(-) | |||
--- a/resource/csdk/security/src/pconfresource.c | |||
+++ b/resource/csdk/security/src/pconfresource.c | |||
@@ -507,8 +507,11 @@ OCStackResult CBORPayloadToPconf(const u | |||
while (cbor_value_is_valid(&prm)) | |||
{ | |||
- cborFindResult = cbor_value_get_int(&prm, (int *)&pconf->prm[i++]); | |||
+ int prm_val; | |||
+ | |||
+ cborFindResult = cbor_value_get_int(&prm, &prm_val); | |||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value"); | |||
+ pconf->prm[i++] = (OicSecPrm_t)prm_val; | |||
cborFindResult = cbor_value_advance(&prm); | |||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance value"); | |||
} | |||
--- a/resource/csdk/stack/src/ocpayloadparse.c | |||
+++ b/resource/csdk/stack/src/ocpayloadparse.c | |||
@@ -287,6 +287,8 @@ static OCStackResult OCParseDiscoveryPay | |||
while (cbor_value_is_map(&resourceMap)) | |||
{ | |||
+ int bitmap; | |||
+ | |||
resource = (OCResourcePayload *)OICCalloc(1, sizeof(OCResourcePayload)); | |||
VERIFY_PARAM_NON_NULL(TAG, resource, "Failed allocating resource payload"); | |||
@@ -319,8 +321,9 @@ static OCStackResult OCParseDiscoveryPay | |||
// Bitmap | |||
err = cbor_value_map_find_value(&policyMap, OC_RSRVD_BITMAP, &curVal); | |||
VERIFY_CBOR_SUCCESS(TAG, err, "to find bitmap tag"); | |||
- err = cbor_value_get_int(&curVal, (int *)&resource->bitmap); | |||
+ err = cbor_value_get_int(&curVal, &bitmap); | |||
VERIFY_CBOR_SUCCESS(TAG, err, "to find bitmap value"); | |||
+ resource->bitmap = (uint8_t)bitmap; | |||
// Secure Flag | |||
err = cbor_value_map_find_value(&policyMap, OC_RSRVD_SECURE, &curVal); | |||
@@ -336,8 +339,11 @@ static OCStackResult OCParseDiscoveryPay | |||
VERIFY_CBOR_SUCCESS(TAG, err, "to find port tag"); | |||
if (cbor_value_is_valid(&curVal)) | |||
{ | |||
- err = cbor_value_get_int(&curVal, (int *)&resource->port); | |||
+ int port; | |||
+ | |||
+ err = cbor_value_get_int(&curVal, &port); | |||
VERIFY_CBOR_SUCCESS(TAG, err, "to find port value"); | |||
+ resource->port = (uint16_t)port; | |||
} | |||
err = cbor_value_advance(&resourceMap); | |||
@@ -1170,6 +1176,7 @@ static OCStackResult OCParsePresencePayl | |||
{ | |||
CborValue curVal; | |||
uint64_t temp = 0; | |||
+ uint8_t trigger; | |||
// Sequence Number | |||
CborError err = cbor_value_map_find_value(rootValue, OC_RSRVD_NONCE, &curVal); | |||
@@ -1189,8 +1196,9 @@ static OCStackResult OCParsePresencePayl | |||
// Trigger | |||
err = cbor_value_map_find_value(rootValue, OC_RSRVD_TRIGGER, &curVal); | |||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding trigger tag"); | |||
- err = cbor_value_get_simple_type(&curVal, (uint8_t *)&payload->trigger); | |||
+ err = cbor_value_get_simple_type(&curVal, &trigger); | |||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding trigger value"); | |||
+ payload->trigger = (OCPresenceTrigger)trigger; | |||
// Resource type name | |||
err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &curVal); |
@ -0,0 +1,36 @@ | |||
From e093390b2839f6039a6ff94ed4942fa45c53a418 Mon Sep 17 00:00:00 2001 | |||
From: Philippe Coval <philippe.coval@osg.samsung.com> | |||
Date: Tue, 26 Apr 2016 15:28:17 +0200 | |||
Subject: [PATCH] [Resource-container] Backported init fix to 1.1-rel | |||
[Resource-container] Fix member var initialization | |||
Incorrect type was used causing build error. | |||
Origin: 6a10062f1fe64ca75ac6d34541bbd295ef052dcb | |||
Author: Inga Stotland <inga.stotland@intel.com> | |||
Change-Id: I701096c3b6512546847cf4e120430f690e920453 | |||
Signed-off-by: Inga Stotland <inga.stotland@intel.com> | |||
Reviewed-on: https://gerrit.iotivity.org/gerrit/7759 | |||
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org> | |||
Reviewed-by: George Nash <george.nash@intel.com> | |||
Reviewed-by: Markus Jung <markus.jung85@gmail.com> | |||
Reviewed-by: Uze Choi <uzchoi@samsung.com> | |||
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com> | |||
Reviewed-on: https://gerrit.iotivity.org/gerrit/7929 | |||
--- | |||
service/resource-container/src/BundleInfoInternal.cpp | 2 +- | |||
1 file changed, 1 insertion(+), 1 deletion(-) | |||
--- a/service/resource-container/src/BundleInfoInternal.cpp | |||
+++ b/service/resource-container/src/BundleInfoInternal.cpp | |||
@@ -32,8 +32,8 @@ namespace OIC | |||
m_resourceCreator = nullptr; | |||
m_resourceDestroyer = nullptr; | |||
m_bundleHandle = nullptr; | |||
- m_so_bundle = nullptr; | |||
+ m_so_bundle = false; | |||
m_loaded = false; | |||
m_activated = false; | |||
m_java_bundle = false; |