Skip to content

Commit

Permalink
firewire: core: document fw_csr_string's truncation of long strings
Browse files Browse the repository at this point in the history
fw_csr_string() truncates and terminates target strings like strlcpy()
does.  Unlike strlcpy(), it returns the target strlen, not the source
strlen, hence users of fw_csr_string() are unable to detect truncation.

Point this behavior out in the kerneldoc comment.

Signed-off-by: Stefan Richter <[email protected]>
Reviewed-by: Takashi Sakamoto <[email protected]>
  • Loading branch information
Stefan Richter committed Dec 10, 2014
1 parent 51b04d5 commit 0238507
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/firewire/core-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ static int textual_leaf_to_string(const u32 *block, char *buf, size_t size)
*
* The string is taken from a minimal ASCII text descriptor leaf after
* the immediate entry with @key. The string is zero-terminated.
* An overlong string is silently truncated such that it and the
* zero byte fit into @size.
*
* Returns strlen(buf) or a negative error code.
*/
int fw_csr_string(const u32 *directory, int key, char *buf, size_t size)
Expand Down

0 comments on commit 0238507

Please sign in to comment.