[LU-10728] lnet/utils/lnetconfig/liblnetconfig.c uses sizeof on pointers Created: 27/Feb/18  Updated: 03/Nov/20  Resolved: 03/Nov/20

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.14.0

Type: Bug Priority: Minor
Reporter: John Hammond Assignee: Cyril Bordage
Resolution: Fixed Votes: 0
Labels: None

Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   
static int lustre_lnet_resolve_ip2nets_rule(struct lustre_lnet_ip2nets *ip2nets,
					    lnet_nid_t **nids, __u32 *nnids,
					    char *err_str, size_t str_len)
{
...
	rc = lustre_lnet_intf2nids(&ip2nets->ip2nets_net, nids, nnids,
				   err_str, sizeof(err_str));
...
}


 Comments   
Comment by John Hammond [ 27/Feb/18 ]

There are also several places where we do

char err_str[LNET_MAX_STR_LEN];
snprintf(err_str, sizeof(err_str), "\"success\"");

instead of just

char err_str[LNET_MAX_STR_LEN] = "\"success\"";

and where we explicitly '\0' terminate a buffer after calling snprintf():

snprintf(err_str, str_len,
			 "\"failed to get interface addresses: %d\"", -errno);
err_str[str_len - 1] = '\0';
Comment by John Hammond [ 15/Oct/20 ]

cbordage, could you take a look?

Comment by Gerrit Updater [ 16/Oct/20 ]

Cyril Bordage (cbordage@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/40268
Subject: LU-10728 utils: fix str length in error string
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 598822099fa8aa747fb65a274387c5909703dc61

Comment by Gerrit Updater [ 03/Nov/20 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/40268/
Subject: LU-10728 utils: fix str length in error string
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 4b2a760fc4747c748ce460289854b76ed17b9ca2

Comment by Peter Jones [ 03/Nov/20 ]

Landed for 2.14

Generated at Sat Feb 10 02:37:40 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.