[LU-12861] Add and use scnprintf() where using snprintf() is not handling return correctly Created: 15/Oct/19  Updated: 25/Feb/20  Resolved: 25/Feb/20

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

Type: Task Priority: Minor
Reporter: Shaun Tancheff Assignee: Shaun Tancheff
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Related
is related to LU-9325 Improve lustre kernel string handling In Progress
Rank (Obsolete): 9223372036854775807

 Description   

There are a few locations where the return value of snprintf() is being used and not checked against the maximum number of characters in the buffer.

scnprintf() is nearly identical to snprintf() except the return value for scnprintf() is the number of characters written to the buffer (not including the terminating null).

Where as snprintf() returns the number of characters that would have been written to the buffer, if there was no restriction. Alternatively stated the return value is the size of buffer needed to hold the complete result (not including the terminating null).

Add scnprintf() wrapper around snprintf() and start using it.

 



 Comments   
Comment by Gerrit Updater [ 15/Oct/19 ]

Shaun Tancheff (stancheff@cray.com) uploaded a new patch: https://review.whamcloud.com/36453
Subject: LU-12861 libcfs: provide an scnprintf and start using it
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: abd5852355901e1da2e7eb85ca0481c36eab1235

Comment by James A Simmons [ 25/Nov/19 ]

Their are some uses of sprintf for sysfs file handle that needs to be replaced by scnprintf() so don't close once this lands.

Comment by Gerrit Updater [ 30/Nov/19 ]

Shaun Tancheff (stancheff@cray.com) uploaded a new patch: https://review.whamcloud.com/36900
Subject: LU-12861 libcfs: Cleanup libcfs_debug_msg use of snprintf
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 0aa910a8ad97105aeabf9ac003345aac836d6c65

Comment by Gerrit Updater [ 30/Nov/19 ]

Shaun Tancheff (stancheff@cray.com) uploaded a new patch: https://review.whamcloud.com/36901
Subject: LU-12861 libcfs: Cleanup libcfs_debug_msg use of snprintf
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: a28c23ab700dfbacc053d025c372a62577179eb4

Comment by Gerrit Updater [ 17/Dec/19 ]

Shaun Tancheff (stancheff@cray.com) uploaded a new patch: https://review.whamcloud.com/37046
Subject: LU-12861 libcfs: Cleanup use of bare printk
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 22a83a65e67a735b227aec9aa24217dd0dcea3f1

Comment by Gerrit Updater [ 20/Dec/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36453/
Subject: LU-12861 libcfs: provide an scnprintf and start using it
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 998a494fa9a46b92d4c7fb3485a0faeb78beb2cd

Comment by Gerrit Updater [ 28/Jan/20 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37046/
Subject: LU-12861 libcfs: Cleanup use of bare printk
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: b4c8a5180dec2db5bda7c07b8dd3cfbd4f4c1e3f

Comment by Gerrit Updater [ 25/Feb/20 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36901/
Subject: LU-12861 libcfs: Cleanup libcfs_debug_msg use of snprintf
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 4ec32fe7c92dce7f6699d36cebac19d8d1abf9e0

Comment by Peter Jones [ 25/Feb/20 ]

It looks like all existing patches tracked under this ticket have landed for 2.14

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