diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e9d9726..8ce2933f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ The git repositories are hosted at the following sites: ### Fixed +* Fix timesync recipient encoding to check for OBJECT_DEVICE type before + encoding. (#1153) * Fixed segmented ComplexACK in MS/TP by adding postpone reply because transmission of the segmented ComplexACK cannot begin until the node holds the token. (#1116) diff --git a/src/bacnet/timesync.c b/src/bacnet/timesync.c index 41f8d37f..04fecf53 100644 --- a/src/bacnet/timesync.c +++ b/src/bacnet/timesync.c @@ -166,10 +166,12 @@ int timesync_encode_timesync_recipients( if (pRecipient->tag == 0) { if (max_apdu >= (1 + 4)) { /* CHOICE - device [0] BACnetObjectIdentifier */ - len = encode_context_object_id( - &apdu[apdu_len], 0, pRecipient->type.device.type, - pRecipient->type.device.instance); - apdu_len += len; + if (pRecipient->type.device.type == OBJECT_DEVICE) { + len = encode_context_object_id( + &apdu[apdu_len], 0, pRecipient->type.device.type, + pRecipient->type.device.instance); + apdu_len += len; + } } else { return BACNET_STATUS_ABORT; } diff --git a/test/bacnet/timesync/src/main.c b/test/bacnet/timesync/src/main.c index 9e8ff935..63475357 100644 --- a/test/bacnet/timesync/src/main.c +++ b/test/bacnet/timesync/src/main.c @@ -101,6 +101,7 @@ static void testTimeSyncRecipient(void) recipient[2].type.address.adr[0] = 127; recipient[2].type.address.len = 1; /* network = zero */ + recipient[3].tag = 1; recipient[3].type.address.net = 0; recipient[3].type.address.mac[0] = 10; recipient[3].type.address.mac[1] = 1;