From 0238507b951857360461b0635111e7376ffd44d1 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Wed, 19 Nov 2014 11:52:00 +0100 Subject: firewire: core: document fw_csr_string's truncation of long strings 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 Reviewed-by: Takashi Sakamoto --- drivers/firewire/core-device.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/firewire') diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 2c6d5e118ac1..f9e3aee6a211 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -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) -- cgit v1.2.3-59-g8ed1b