[LU-4353] strncmp() used bogusly Created: 05/Dec/13  Updated: 18/Jan/14  Resolved: 18/Jan/14

Status: Closed
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.6.0
Fix Version/s: Lustre 2.6.0

Type: Bug Priority: Minor
Reporter: John Hammond Assignee: John Hammond
Resolution: Fixed Votes: 0
Labels: easy, patch, strncmp

Severity: 3
Rank (Obsolete): 11923

 Description   

There are a few places where strncmp() is used but strcmp() was meant. For example in lod_xattr_set()

        if (S_ISDIR(attr)) {
                if (strncmp(name, XATTR_NAME_LOV, strlen(XATTR_NAME_LOV)) == 0)
                        rc = lod_xattr_set_lov_on_dir(env, dt, buf, name,
                                                      fl, th, capa);
                else
                        rc = dt_xattr_set(env, next, buf, name, fl, th, capa);

Clearly we do not meant to do this for all xattrs whose names start with trusted.lov, but only for those whose name is trusted.lov. There are several more such uses out of the 200-odd calls to strncmp(). mgs_setparam() uses the interesting but wrong condition

strncmp(param, PARAM_LLITE, sizeof(PARAM_LLITE)) == 0

Note: I don't know if these bugs can cause anything bad to happen. But they are bugs and I have seen a few patches in gerrit which would add more.



 Comments   
Comment by Swapnil Pimpale (Inactive) [ 03/Jan/14 ]

Patch: http://review.whamcloud.com/#/c/8702/

Comment by John Hammond [ 18/Jan/14 ]

Patch landed to master. Thanks Swapnil!

Generated at Sat Feb 10 01:41:58 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.