X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fnidlist.c;h=3af3c30ea530e1aaa42b218e59e6331c30005b0b;hb=bb004b9eea85938bf7e3a8ef93a0b14d96819ab3;hp=0f1fe880925997c888a5ac16ce40c9649a859d33;hpb=d10200a80770f0029d1d665af954187b9ad883df;p=fs%2Flustre-release.git diff --git a/lustre/utils/nidlist.c b/lustre/utils/nidlist.c index 0f1fe88..3af3c30 100644 --- a/lustre/utils/nidlist.c +++ b/lustre/utils/nidlist.c @@ -23,7 +23,7 @@ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2014, 2016, Intel Corporation. + * Copyright (c) 2014, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -262,9 +262,9 @@ char *nl_string(NIDList nl, char *sep) nl_oom(); s[0] = '\0'; for (i = 0; i < nl->count; i++) { - if (i > 0) - strncat(s, sep, len); - strncat(s, nl->nids[i], len); + int cur = strlen(s); + snprintf(s + cur, len - cur, "%s%s", + i > 0 ? sep : "", nl->nids[i]); } return s; } @@ -312,7 +312,7 @@ static void nl_strxcat(char *s, char **nids, int len, const int max_len) "-%s", savedn); free(savedn); } - strncat(s, "]", 1); + strncat(s, "]", max_len - strlen(s)); if (lnet) snprintf(s + strlen(s), max_len - strlen(s), "@%s", lnet);