]> git.baikalelectronics.ru Git - kernel.git/commit
target: Fix incorrect strlen() NULL terminator checks
authorDan Carpenter <error27@gmail.com>
Wed, 15 Jun 2011 17:03:05 +0000 (10:03 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 24 Jun 2011 00:08:11 +0000 (00:08 +0000)
commit3a711c36c7b27536954e0481452cfb800f06454c
tree656848db8b14b92993df040058df24ce7012cb8b
parentd4c979ac726d34d67ed31e284541698bc6de140e
target: Fix incorrect strlen() NULL terminator checks

This patch fixes a number of cases in target core using an incorrectly

if (strlen(foo) > SOME_MAX_SIZE)

As strlen() returns the number of characters in the string not counting
the NULL character at the end.  So if you do something like:

        char buf[10];

        if (strlen("0123456789") > 10)
                return -ETOOLONG;
        snprintf(buf, 10, "0123456789");
        printf("%s\n", buf);

then the last "9" gets chopped off and only "012345678" is printed.

Plus I threw in one small related cleanup.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/loopback/tcm_loop.c
drivers/target/target_core_configfs.c
drivers/target/target_core_device.c
drivers/target/target_core_pr.c