cifs: replace snprintf with scnprintf
a trivial patch that replaces all use of snprintf with scnprintf. scnprintf() is generally seen as a safer function to use than snprintf for many use cases. In our case, there is no actual difference between the two since we never look at the return value. Thus we did not have any of the bugs that scnprintf protects against and the patch does nothing. However, for people reading our code it will be a receipt that we have done our due dilligence and checked our code for this type of bugs. See the presentation "Making C Less Dangerous In The Linux Kernel" at this years LCA Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:

committed by
Steve French

parent
68e2672f8f
commit
74ea5f983f
@@ -103,9 +103,9 @@ parse_mf_symlink(const u8 *buf, unsigned int buf_len, unsigned int *_link_len,
|
||||
return rc;
|
||||
}
|
||||
|
||||
snprintf(md5_str2, sizeof(md5_str2),
|
||||
CIFS_MF_SYMLINK_MD5_FORMAT,
|
||||
CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
|
||||
scnprintf(md5_str2, sizeof(md5_str2),
|
||||
CIFS_MF_SYMLINK_MD5_FORMAT,
|
||||
CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
|
||||
|
||||
if (strncmp(md5_str1, md5_str2, 17) != 0)
|
||||
return -EINVAL;
|
||||
@@ -142,10 +142,10 @@ format_mf_symlink(u8 *buf, unsigned int buf_len, const char *link_str)
|
||||
return rc;
|
||||
}
|
||||
|
||||
snprintf(buf, buf_len,
|
||||
CIFS_MF_SYMLINK_LEN_FORMAT CIFS_MF_SYMLINK_MD5_FORMAT,
|
||||
link_len,
|
||||
CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
|
||||
scnprintf(buf, buf_len,
|
||||
CIFS_MF_SYMLINK_LEN_FORMAT CIFS_MF_SYMLINK_MD5_FORMAT,
|
||||
link_len,
|
||||
CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
|
||||
|
||||
ofs = CIFS_MF_SYMLINK_LINK_OFFSET;
|
||||
memcpy(buf + ofs, link_str, link_len);
|
||||
|
Reference in New Issue
Block a user