Whamcloud - gitweb
LU-12844 lnet: fix strncpy bound error 18/36418/3
authorJian Yu <yujian@whamcloud.com>
Wed, 9 Oct 2019 21:41:54 +0000 (14:41 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 21 Nov 2019 07:36:16 +0000 (07:36 +0000)
commit3dc4d86a6795ae8a6af46af2c9b17c621ec18dde
tree573c9edaceed57d196764c820aad33c7a08233e5
parentc310af5b2a35f9010ac2b9348c1d9f3cd4af01e7
LU-12844 lnet: fix strncpy bound error

This patch fixes the following error while using gcc 8:

liblnetconfig.c: In function ‘lustre_lnet_parse_nids’:
liblnetconfig.c:320:3: error: ‘strncpy’ specified bound depends on
the length of the source argument [-Werror=stringop-overflow=]
   strncpy(entry, cur, len - 1);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
liblnetconfig.c:310:10: note: length computed here
    len = strlen(cur) + 1;
          ^~~~~~~~~~~
cc1: all warnings being treated as errors

This patch is back-ported from the following one:
Lustre-commit: cebda7a478f9943f10b9a3388377c61a54957a87
Lustre-change: https://review.whamcloud.com/36417

Change-Id: I2d5840fd58c7b7d27ef1b2aa12f1f187d30abbfd
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36418
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c