3w-9xxx.c: Cleaning up missing null-terminate in conjunction with strncpy
authorRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Sun, 27 Jul 2014 15:11:18 +0000 (17:11 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 9 Jan 2015 14:44:21 +0000 (15:44 +0100)
Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
And use the sizeof on the to string rather than strlen on the from string.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Acked-by: Adam Radford <aradford@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/3w-9xxx.c

index cd4129f..7600639 100644 (file)
@@ -608,7 +608,8 @@ static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed)
        }
 
        /* Load rest of compatibility struct */
-       strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION));
+       strlcpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION,
+               sizeof(tw_dev->tw_compat_info.driver_version));
        tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL;
        tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
        tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD;