selinuxfs: use scnprintf to get real length for inode
The return value of snprintf maybe over the size of TMPBUFLEN, use scnprintf instead in sel_read_class and sel_read_perm. Signed-off-by: liuyang34 <liuyang34@xiaomi.com> [PM: cleaned up the description] Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
Родитель
f126853402
Коммит
7e78c87514
|
@ -1728,7 +1728,7 @@ static ssize_t sel_read_class(struct file *file, char __user *buf,
|
||||||
{
|
{
|
||||||
unsigned long ino = file_inode(file)->i_ino;
|
unsigned long ino = file_inode(file)->i_ino;
|
||||||
char res[TMPBUFLEN];
|
char res[TMPBUFLEN];
|
||||||
ssize_t len = snprintf(res, sizeof(res), "%d", sel_ino_to_class(ino));
|
ssize_t len = scnprintf(res, sizeof(res), "%d", sel_ino_to_class(ino));
|
||||||
return simple_read_from_buffer(buf, count, ppos, res, len);
|
return simple_read_from_buffer(buf, count, ppos, res, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1742,7 +1742,7 @@ static ssize_t sel_read_perm(struct file *file, char __user *buf,
|
||||||
{
|
{
|
||||||
unsigned long ino = file_inode(file)->i_ino;
|
unsigned long ino = file_inode(file)->i_ino;
|
||||||
char res[TMPBUFLEN];
|
char res[TMPBUFLEN];
|
||||||
ssize_t len = snprintf(res, sizeof(res), "%d", sel_ino_to_perm(ino));
|
ssize_t len = scnprintf(res, sizeof(res), "%d", sel_ino_to_perm(ino));
|
||||||
return simple_read_from_buffer(buf, count, ppos, res, len);
|
return simple_read_from_buffer(buf, count, ppos, res, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче