static analysis: buffer size violations 63/24163/7
authorMats Wichmann <mats@linux.com>
Thu, 15 Feb 2018 20:15:35 +0000 (13:15 -0700)
committerMats Wichmann <mats@linux.com>
Wed, 18 Apr 2018 13:34:35 +0000 (13:34 +0000)
commitdef7f5fec3a003a70ca7cf7e274506298c83c321
tree544c87fa9e741ccdf0174d3396a06a779bdc11ad
parent5dbe9adce89acd0fef166b40827c5a0c63e9b871
static analysis: buffer size violations

fix reported "might leave destination string unterminated" when
using strncpy and the size argument is the size of the desitnation
buffer. There are several ways to fix, but the IoTivity API OCStrncpy
adjusts the size before calling the underlying fuction and so fixes
the problem. This is the coding standard recommendation anyway.

for instances in examples, oic_string.h is not in the public API,
so just fix up the counts.

bridging/common/messageHandler.cpp had a third strncpy which was not
flagged - but it was using a constant that did not match the size
in the destination - MPMResourceList.href is size MPM_MAX_URI_LEN,
so this was adjusted.

service/notification/src/consumer/NSConsumerCommon.c had this construct:
   sizeof(char) * NS_DEVICE_ID_LENGTH
in several places (one of which was one of these strncpy calls that
was changed). the instances were shortened NS_DEVICE_ID_LENGTH for
readability. This is not fixing any reported problem and can be
dropped if it bothers reviewers.

Change-Id: I8f22f7dd704849477dad0dd1f16cd9276ebf1d04
Signed-off-by: Mats Wichmann <mats@linux.com>
bridging/common/messageHandler.cpp
resource/csdk/security/provisioning/sample/certgenerator.cpp
resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp
service/coap-http-proxy/samples/proxy_client.c
service/notification/src/consumer/NSConsumerCommon.c
service/notification/src/consumer/NSConsumerCommunication.c
service/notification/unittest/NSConsumerTest2.cpp
service/notification/unittest/NSProviderTest2.cpp