Hi Hans, Ack (Code review only)
Regards, Ravi ----- Original Message ----- From: [email protected] To: [email protected], [email protected] Cc: [email protected], [email protected] Sent: Thursday, November 16, 2017 8:16:42 PM GMT +05:30 Chennai, Kolkata, Mumbai, New Delhi Subject: [PATCH 1/1] clm: Fix clm_user_data to not truncate data V2 [#2684] --- scripts/opensaf_scale_out | 20 +++++++++++--------- src/clm/README | 2 +- src/clm/clmnd/main.c | 9 +++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/scripts/opensaf_scale_out b/scripts/opensaf_scale_out index c7e902553..714d0b8b4 100644 --- a/scripts/opensaf_scale_out +++ b/scripts/opensaf_scale_out @@ -36,15 +36,17 @@ export LD_LIBRARY_PATH=$libdir:$LD_LIBRARY_PATH exit 0 # Env variable CLM_IFS contains field separator for the -# input argument, example on usage: -# if [ -n "$CLM_IFS" ]; then -# IFS=$CLM_IFS -# logger "Using ifs [$IFS]" -# fi -# -# for arg in "$@" -# do -# logger "> [$arg]" +# input argument, for example: +# save_ifs=IFS +# for node in "$@" +# do +# logger "> [$node]" +# IFS="," +# for arg in $node +# do +# logger ">> $arg" +# done +# IFS=$save_ifs # done tmpdir=$(mktemp -d -t opensaf_scale_out.XXXXXXXXXX) diff --git a/src/clm/README b/src/clm/README index 50e683ca5..d2dada18c 100644 --- a/src/clm/README +++ b/src/clm/README @@ -75,7 +75,7 @@ entries may be added to the comma-separated list. The first entry in the list is the node id represented as a decimal number. The second entry in the list is the name of the node. The third entry is the IP address of the node. The fourth entry is optional user data that can be entered in a file named -/etc/opensaf/clm_user_data, up to 256 characters can be given. +/etc/opensaf/clm_user_data, up to 255 characters can be given. NOTE: the script must be idempotent, i.e. it must be harmless to call it more than one time with the same parameters. The second call should do nothing since diff --git a/src/clm/clmnd/main.c b/src/clm/clmnd/main.c index 8b8eebc14..45f4d2f27 100644 --- a/src/clm/clmnd/main.c +++ b/src/clm/clmnd/main.c @@ -582,11 +582,12 @@ static void get_user_data(NODE_INFO *node) return; } - if (fgets((char*) node->user_data.value, sizeof(node->user_data.value), - fp) != NULL) { - node->user_data.length = strnlen((char *)node->user_data.value, - sizeof(node->user_data.value)); + size_t size = fread((char*) node->user_data.value, sizeof(char), + sizeof(node->user_data.value) - 1, fp); + if (size > 0) { + node->user_data.length = size; } else { + node->user_data.length = 0; LOG_WA("Could not read file %s", PKGSYSCONFDIR "/clm_user_data"); } -- 2.14.2 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Opensaf-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensaf-devel
