Re: [PATCH] cifs: using strlcpy instead of strncpy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



merged into for-next cifs-2.6.git

On Fri, Jun 21, 2013 at 12:14 PM, Jeff Layton <jlayton@xxxxxxxxxx> wrote:
> On Thu, 20 Jun 2013 18:56:22 +0800
> Zhao Hongjiang <zhaohongjiang@xxxxxxxxxx> wrote:
>
>> for NUL terminated string, need alway set '\0' in the end.
>>
>> Signed-off-by: Zhao Hongjiang <zhaohongjiang@xxxxxxxxxx>
>> ---
>>  fs/cifs/connect.c |    2 +-
>>  fs/cifs/smb2pdu.c |    2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
>> index e3bc39b..2ea78a3 100644
>> --- a/fs/cifs/connect.c
>> +++ b/fs/cifs/connect.c
>> @@ -3738,7 +3738,7 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
>>               }
>>               bcc_ptr += length + 1;
>>               bytes_left -= (length + 1);
>> -             strncpy(tcon->treeName, tree, MAX_TREE_SIZE);
>> +             strlcpy(tcon->treeName, tree, sizeof(tcon->treeName));
>>
>>               /* mostly informational -- no need to fail on error here */
>>               kfree(tcon->nativeFileSystem);
>> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
>> index 2b95ce2..99bf768 100644
>> --- a/fs/cifs/smb2pdu.c
>> +++ b/fs/cifs/smb2pdu.c
>> @@ -792,7 +792,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
>>       tcon->tidStatus = CifsGood;
>>       tcon->need_reconnect = false;
>>       tcon->tid = rsp->hdr.TreeId;
>> -     strncpy(tcon->treeName, tree, MAX_TREE_SIZE);
>> +     strlcpy(tcon->treeName, tree, sizeof(tcon->treeName));
>>
>>       if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) &&
>>           ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0))
>
> Seems like a reasonable cleanup, but if you're going to do that then
> it might not hurt to convert most of the places where MAX_TREE_SIZE is
> used to use sizeof(tcon->treeName) instead.
>
> Either way...
>
> Acked-by: Jeff Layton <jlayton@xxxxxxxxxx>



-- 
Thanks,

Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux