FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We are updating our platform to a new
system.
Read more: Important
information on the platform change.
08-06-2021 07:14 PM
The SDK example "datalayer.register.node" contains the following code: (line breaks added by me)
auto bfbsPath = getenv("SNAP") != nullptr
? strcat(getenv("SNAP"), "/sampleSchema.bfbs")
: "bfbs/sampleSchema.bfbs";
This seems incorrect to me: strcat() modifies the buffer pointed to by its first argument, but the man page for getenv() states:
... getenv() returns a pointer to a string within the environment list. The caller must take care not to modify this string ...
Instead, I think the sample code should do something like:
const char * snapPath = getenv("SNAP");
char bfbsPath[256];
strcpy(bfbsPath, (snapPath == nullptr) ? "bfbs" : snapPath);
strcat(bfbsPath, "/sampleSchema.fbs");
Of course, it would be even better to replace strcpy/strcat with functions that check the destination buffer size.
Solved! Go to Solution.
07-01-2022 01:48 PM
Did you have a look in the latest version of our SDK for ctrlX AUTOMATION? Probably you will find something that looks better for you.