Merge pull request #272 from NOVBobLee/pr_patch
Some checks failed
build-deploy-assets / build (push) Has been cancelled
deploy-github-page / build (push) Has been cancelled
status-checks / validate (push) Has been cancelled

Fix a wierd behavior of a function
This commit is contained in:
Jim Huang 2024-10-07 12:11:10 +08:00 committed by GitHub
commit 2eadbb1ecf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,13 +48,13 @@ static ssize_t procfile_write(struct file *file, const char __user *buff,
size_t len, loff_t *off)
{
procfs_buffer_size = len;
if (procfs_buffer_size > PROCFS_MAX_SIZE)
procfs_buffer_size = PROCFS_MAX_SIZE;
if (procfs_buffer_size >= PROCFS_MAX_SIZE)
procfs_buffer_size = PROCFS_MAX_SIZE - 1;
if (copy_from_user(procfs_buffer, buff, procfs_buffer_size))
return -EFAULT;
procfs_buffer[procfs_buffer_size & (PROCFS_MAX_SIZE - 1)] = '\0';
procfs_buffer[procfs_buffer_size] = '\0';
*off += procfs_buffer_size;
pr_info("procfile write %s\n", procfs_buffer);