Fix issues found by Coverity in range_create():
CoverityID: 451797 ("Null pointer dereferences")
Dereferencing a pointer that might be "NULL" "c" when calling
"strscpy".
CoverityID: 451795 ("Integer handling issues")
"netmask > 999" is always false regardless of the values of its
operands. This occurs as the logical operand of "if."
Fixes:
8f6988be44 ("LU-14288 nodemap: Use nidmasks for IPv6 NIDs")
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: I1a6f85f2c9a3591ddd82ed634e9a87902b2b7d0a
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57488
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
char *c;
int rc;
- if (netmask > 999) {
+ if (netmask > 128) {
/* If the netmask is somehow more than three characters
* then the logic below could truncate it which could
* result in creating a valid netmask value from bad
libcfs_nidstr(start_nid));
c = strchr(nidstr, '@');
+ if (!c) {
+ CERROR("Invalid nid %s for netmask\n",
+ libcfs_nidstr(start_nid));
+ return NULL;
+ }
/* net = @<net> */
strscpy(net, c, sizeof(net));