Skip to content

Commit 912d2fe

Browse files
author
Richard Holme
committed
2023-01-05: Bug fixes
Fixed - Updated Dockerfile to use Ubuntu Kinetic which includes the required versions of libmosquitto and libwebsockets - If 'obuspa -c get' truncates the printing of a parameter value, this is now indicated - Added note that start transaction vendor hook must never return a failure, as it is not possible for OBUSPA to handle the failure in all cases
1 parent dcb7ae7 commit 912d2fe

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

Dockerfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
FROM ubuntu:focal
1+
# Ubuntu 22.10 (Kinetic Kudu) includes libmosquitto 2.0.11 and libwebsockets 4.1.6
2+
FROM ubuntu:kinetic
23

34
ENV MAKE_JOBS=8
45
ENV OBUSPA_ARGS="-v4"
56

6-
# Add mosquitto latest ppa
7-
RUN apt-get update && \
8-
apt-get install -y software-properties-common && \
9-
add-apt-repository ppa:mosquitto-dev/mosquitto-ppa
10-
117
# Install dependencies
128
RUN apt-get update &&\
139
apt-get -y install \

src/core/cli_server.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ int ExecuteCli_Set(char *arg1, char *arg2, char *usage)
761761
{
762762
int i;
763763
int err;
764-
char path[USP_ERR_MAXLEN];
764+
char path[MAX_DM_PATH];
765765
dm_trans_vector_t trans;
766766
str_vector_t objects;
767767
char param_name[MAX_DM_PATH];
@@ -847,7 +847,7 @@ int ExecuteCli_Add(char *arg1, char *arg2, char *usage)
847847
{
848848
int i;
849849
int err;
850-
char path[USP_ERR_MAXLEN];
850+
char path[MAX_DM_PATH];
851851
dm_trans_vector_t trans;
852852
str_vector_t objects;
853853
char *instance_str;
@@ -1790,7 +1790,9 @@ int SplitSetExpression(char *expr, char *search_path, int search_path_len, char
17901790
**
17911791
** SendCliResponse
17921792
**
1793-
** Sends the printf-style formatted message back to the CLI client
1793+
** Sends the printf-style formatted message back to the CLI client. In the
1794+
** event that the buffer is too small, truncate the response, and make it
1795+
** clear that it has been truncated
17941796
**
17951797
** \param fmt - printf style format
17961798
**
@@ -1799,15 +1801,24 @@ int SplitSetExpression(char *expr, char *search_path, int search_path_len, char
17991801
**************************************************************************/
18001802
void SendCliResponse(char *fmt, ...)
18011803
{
1804+
#define MAX_CLI_RSP_LEN 4096
18021805
va_list ap;
1803-
char buf[USP_ERR_MAXLEN];
1806+
char buf[MAX_CLI_RSP_LEN];
1807+
int chars_written;
18041808

1805-
// Write the USP error message into the local store
1809+
// Write the message into the local store
18061810
va_start(ap, fmt);
1807-
vsnprintf(buf, sizeof(buf), fmt, ap);
1811+
chars_written = vsnprintf(buf, sizeof(buf), fmt, ap);
18081812
buf[sizeof(buf)-1] = '\0';
18091813
va_end(ap);
18101814

1815+
// Ensure that if the message has been truncated, that it is reported
1816+
if (chars_written >= sizeof(buf)-1)
1817+
{
1818+
#define TRUNCATED_STR "...[truncated]...\n"
1819+
memcpy(&buf[sizeof(buf)-sizeof(TRUNCATED_STR)], TRUNCATED_STR, sizeof(TRUNCATED_STR));
1820+
}
1821+
18111822
CLI_SERVER_SendResponse(buf);
18121823
}
18131824

src/include/usp_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ typedef int (*dm_vendor_reboot_cb_t)(void);
263263
typedef int (*dm_vendor_factory_reset_cb_t)(void);
264264

265265
// Vendor hooks associated with vendor database transactions
266+
// NOTE: The start transaction vendor hook must only return when the start transaction has completed successfully.
267+
// It must never return an error. This is necessary because there are some cases where the agent cannot sensibly
268+
// handle success followed by failure as it would lead to data model inconsistencies.
269+
// e.g. when the result of one USP Set request cascades to other parts of the data model
266270
typedef int (*dm_vendor_start_trans_cb_t)(void);
267271
typedef int (*dm_vendor_commit_trans_cb_t)(void);
268272
typedef int (*dm_vendor_abort_trans_cb_t)(void);

0 commit comments

Comments
 (0)