From 4a2441b8b5fef1d524e602697b7a7629ab11282f Mon Sep 17 00:00:00 2001 From: Ian Craggs <10279016+icraggs@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:50:13 +0100 Subject: [PATCH 1/4] Merge pull request #1485 from haraldreif/fix_memory_initialisation Fix usage of memset --- src/Heap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Heap.c b/src/Heap.c index 13543ddd..55659e4f 100644 --- a/src/Heap.c +++ b/src/Heap.c @@ -180,7 +180,7 @@ void* mymalloc(char* file, int line, size_t size) free(s); goto exit; } - memset(s->file, 0, sizeof(filenamelen)); + memset(s->file, 0, filenamelen); space += filenamelen; strcpy(s->file, file); @@ -193,7 +193,7 @@ void* mymalloc(char* file, int line, size_t size) free(s); goto exit; } - memset(s->stack, 0, sizeof(filenamelen)); + memset(s->stack, 0, STACK_LEN); StackTrace_get(Paho_thread_getid(), s->stack, STACK_LEN); #endif s->line = line; From 2341ce9472b8ab0bb81babec4d45898efe793271 Mon Sep 17 00:00:00 2001 From: Ian Craggs <10279016+icraggs@users.noreply.github.com> Date: Mon, 1 Jul 2024 13:21:20 +0100 Subject: [PATCH 2/4] Merge pull request #1496 from fpagliughi/identifier-misspelled Assigned Client Identifier constant misspelled --- src/MQTTProperties.c | 4 ++-- src/MQTTProperties.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/MQTTProperties.c b/src/MQTTProperties.c index b21f338b..4f704c8b 100644 --- a/src/MQTTProperties.c +++ b/src/MQTTProperties.c @@ -38,7 +38,7 @@ static struct nameToType {MQTTPROPERTY_CODE_CORRELATION_DATA, MQTTPROPERTY_TYPE_BINARY_DATA}, {MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIER, MQTTPROPERTY_TYPE_VARIABLE_BYTE_INTEGER}, {MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL, MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER}, - {MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER, MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING}, + {MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFIER, MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING}, {MQTTPROPERTY_CODE_SERVER_KEEP_ALIVE, MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER}, {MQTTPROPERTY_CODE_AUTHENTICATION_METHOD, MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING}, {MQTTPROPERTY_CODE_AUTHENTICATION_DATA, MQTTPROPERTY_TYPE_BINARY_DATA}, @@ -355,7 +355,7 @@ struct { {MQTTPROPERTY_CODE_CORRELATION_DATA, "CORRELATION_DATA"}, {MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIER, "SUBSCRIPTION_IDENTIFIER"}, {MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL, "SESSION_EXPIRY_INTERVAL"}, - {MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER, "ASSIGNED_CLIENT_IDENTIFER"}, + {MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFIER, "ASSIGNED_CLIENT_IDENTIFIER"}, {MQTTPROPERTY_CODE_SERVER_KEEP_ALIVE, "SERVER_KEEP_ALIVE"}, {MQTTPROPERTY_CODE_AUTHENTICATION_METHOD, "AUTHENTICATION_METHOD"}, {MQTTPROPERTY_CODE_AUTHENTICATION_DATA, "AUTHENTICATION_DATA"}, diff --git a/src/MQTTProperties.h b/src/MQTTProperties.h index 81b8e3af..02835ab3 100644 --- a/src/MQTTProperties.h +++ b/src/MQTTProperties.h @@ -30,7 +30,8 @@ enum MQTTPropertyCodes { MQTTPROPERTY_CODE_CORRELATION_DATA = 9, /**< The value is 9 */ MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIER = 11, /**< The value is 11 */ MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL = 17, /**< The value is 17 */ - MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER = 18,/**< The value is 18 */ + MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFIER = 18,/**< The value is 18 */ + MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER = 18,/**< The value is 18 (obsolete, misspelled) */ MQTTPROPERTY_CODE_SERVER_KEEP_ALIVE = 19, /**< The value is 19 */ MQTTPROPERTY_CODE_AUTHENTICATION_METHOD = 21, /**< The value is 21 */ MQTTPROPERTY_CODE_AUTHENTICATION_DATA = 22, /**< The value is 22 */ From d49e77ca2e7069be50f326dad7cb475ffa51714d Mon Sep 17 00:00:00 2001 From: Ian Craggs <10279016+icraggs@users.noreply.github.com> Date: Mon, 1 Jul 2024 13:23:24 +0100 Subject: [PATCH 3/4] Merge pull request #1495 from fpagliughi/cmake-export-static-always Exporting the -static CMake targets when both shared and static libraries built. --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 59fd8241..0b26e3d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -207,6 +207,7 @@ if(PAHO_BUILD_STATIC) ) else() install(TARGETS paho-mqtt3c-static paho-mqtt3a-static + EXPORT eclipse-paho-mqtt-cTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) endif() @@ -372,6 +373,7 @@ if(PAHO_WITH_SSL OR PAHO_WITH_LIBRESSL) ) else() install(TARGETS paho-mqtt3cs-static paho-mqtt3as-static + EXPORT eclipse-paho-mqtt-cTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) endif() From 577912db0eecaa38cd808fa81cdef3c93b19fab0 Mon Sep 17 00:00:00 2001 From: Ian Craggs Date: Sat, 13 Jul 2024 12:32:48 +0100 Subject: [PATCH 4/4] Widen property type to be able to carry all values #1493 --- src/MQTTProperties.c | 8 ++++---- src/MQTTProperties.h | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/MQTTProperties.c b/src/MQTTProperties.c index 4f704c8b..5f4704c6 100644 --- a/src/MQTTProperties.c +++ b/src/MQTTProperties.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2020 IBM Corp. and others + * Copyright (c) 2017, 2024 IBM Corp. and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 @@ -475,10 +475,10 @@ int MQTTProperties_propertyCount(MQTTProperties *props, enum MQTTPropertyCodes p } -int MQTTProperties_getNumericValueAt(MQTTProperties *props, enum MQTTPropertyCodes propid, int index) +int64_t MQTTProperties_getNumericValueAt(MQTTProperties *props, enum MQTTPropertyCodes propid, int index) { int i = 0; - int rc = -9999999; + int64_t rc = -9999999; int cur_index = 0; for (i = 0; i < props->count; ++i) @@ -515,7 +515,7 @@ int MQTTProperties_getNumericValueAt(MQTTProperties *props, enum MQTTPropertyCod } -int MQTTProperties_getNumericValue(MQTTProperties *props, enum MQTTPropertyCodes propid) +int64_t MQTTProperties_getNumericValue(MQTTProperties *props, enum MQTTPropertyCodes propid) { return MQTTProperties_getNumericValueAt(props, propid, 0); } diff --git a/src/MQTTProperties.h b/src/MQTTProperties.h index 02835ab3..ca2f70e0 100644 --- a/src/MQTTProperties.h +++ b/src/MQTTProperties.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2020 IBM Corp. and others + * Copyright (c) 2017, 2024 IBM Corp. and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 @@ -19,6 +19,8 @@ #include "MQTTExportDeclarations.h" +#include + #define MQTT_INVALID_PROPERTY_ID -2 /** The one byte MQTT V5 property indicator */ @@ -188,7 +190,7 @@ LIBMQTT_API int MQTTProperties_propertyCount(MQTTProperties *props, enum MQTTPro * @param propid the property id to check for. * @return the integer value of the property. -9999999 on failure. */ -LIBMQTT_API int MQTTProperties_getNumericValue(MQTTProperties *props, enum MQTTPropertyCodes propid); +LIBMQTT_API int64_t MQTTProperties_getNumericValue(MQTTProperties *props, enum MQTTPropertyCodes propid); /** * Returns the integer value of a specific property when it's not the only instance. @@ -198,7 +200,7 @@ LIBMQTT_API int MQTTProperties_getNumericValue(MQTTProperties *props, enum MQTTP * @param index the instance number, starting at 0. * @return the integer value of the property. -9999999 on failure. */ -LIBMQTT_API int MQTTProperties_getNumericValueAt(MQTTProperties *props, enum MQTTPropertyCodes propid, int index); +LIBMQTT_API int64_t MQTTProperties_getNumericValueAt(MQTTProperties *props, enum MQTTPropertyCodes propid, int index); /** * Returns a pointer to the property structure for a specific property.