From: Amir Shehata Date: Mon, 11 May 2020 14:32:41 +0000 (-0400) Subject: LU-10973 lnet: initialize buffers properly X-Git-Tag: 2.13.54~48 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=36a97084791899e73b32b381a98f4f9f51348fe9;p=fs%2Flustre-release.git LU-10973 lnet: initialize buffers properly Initialize the error message buffer properly to avoid garbage characters printed out. Test-Parameters: trivial Signed-off-by: Amir Shehata Change-Id: I9c0d08ea2baf0cda990e3abb7e7de497a5226bfe Reviewed-on: https://review.whamcloud.com/38083 Reviewed-by: James Simmons Reviewed-by: Chris Horn Tested-by: jenkins Reviewed-by: Serguei Smirnov Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index 2dd0a45..10818b4 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -831,6 +831,9 @@ int lustre_lnet_route_common(char *nw, char *nidstr, int hops, int prio, struct lnet_ioctl_config_data data; lnet_nid_t lnet_nidlist[LNET_MAX_NIDS_PER_PEER]; + memset(err_str, 0, LNET_MAX_STR_LEN); + snprintf(err_str, LNET_MAX_STR_LEN, "\"generic error\""); + if (nw == NULL || nidstr == NULL) { snprintf(err_str, LNET_MAX_STR_LEN, "\"missing mandatory parameter:'%s'\"", @@ -905,6 +908,8 @@ int lustre_lnet_config_route(char *nw, char *nidstr, int hops, int prio, { int rc; char err_str[LNET_MAX_STR_LEN]; + memset(err_str, 0, LNET_MAX_STR_LEN); + snprintf(err_str, LNET_MAX_STR_LEN, "\"generic error\""); if (hops == -1) { hops = LNET_UNDEFINED_HOPS; @@ -938,6 +943,7 @@ int lustre_lnet_config_route(char *nw, char *nidstr, int hops, int prio, rc = lustre_lnet_route_common(nw, nidstr, hops, prio, sen, seq_no, err_rc, LNETCTL_ADD_CMD); + return rc; out: cYAML_build_error(rc, seq_no, ADD_CMD, "route", err_str, err_rc);