Skip to content

Commit 86182fe

Browse files
committed
merge with master
1 parent 0fd1d3a commit 86182fe

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

libcanard/canard.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#define CAVL2_T struct CanardTreeNode
4444
#define CAVL2_ASSERT(x) CANARD_ASSERT(x) // NOSONAR
4545
#include <cavl2.h>
46+
#include <stdio.h>
47+
#include <stdlib.h>
4648

4749
// --------------------------------------------- COMMON DEFINITIONS ---------------------------------------------
4850

@@ -1384,6 +1386,13 @@ int8_t canardRxSubscribe(struct CanardInstance* const ins,
13841386
{
13851387
int8_t out = -CANARD_ERROR_INVALID_ARGUMENT;
13861388
const size_t tk = (size_t) transfer_kind;
1389+
1390+
assert(port_id >= 49152 && port_id <= 65535);
1391+
if (port_id < 49152 || port_id > 65535)
1392+
{
1393+
fprintf(stderr, "Invalid port: %d. Port should be within 49152 to 65535\n", port_id);
1394+
exit(EXIT_FAILURE);
1395+
}
13871396
if ((ins != NULL) && (out_subscription != NULL) && (tk < CANARD_NUM_TRANSFER_KINDS))
13881397
{
13891398
// Reset to the initial state. This is absolutely critical because the new payload size limit may be larger

0 commit comments

Comments
 (0)