Whamcloud - gitweb
LU-10973 lnet: initialize buffers properly 83/38083/5
authorAmir Shehata <ashehata@whamcloud.com>
Mon, 11 May 2020 14:32:41 +0000 (10:32 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 20 May 2020 08:25:20 +0000 (08:25 +0000)
Initialize the error message buffer properly to avoid
garbage characters printed out.

Test-Parameters: trivial
Signed-off-by: Amir Shehata <ashehata@whamcloud.com>
Change-Id: I9c0d08ea2baf0cda990e3abb7e7de497a5226bfe
Reviewed-on: https://review.whamcloud.com/38083
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c

index 2dd0a45..10818b4 100644 (file)
@@ -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);