Patch "rtc: fix snprintf() checking in is_rtc_hctosys()" has been added to the 5.10-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    rtc: fix snprintf() checking in is_rtc_hctosys()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     rtc-fix-snprintf-checking-in-is_rtc_hctosys.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit ada82ec4b53b4f77401babe7bae931d767a8845b
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Tue May 11 10:19:26 2021 +0300

    rtc: fix snprintf() checking in is_rtc_hctosys()
    
    [ Upstream commit 54b909436ede47e0ee07f1765da27ec2efa41e84 ]
    
    The scnprintf() function silently truncates the printf() and returns
    the number bytes that it was able to copy (not counting the NUL
    terminator).  Thus, the highest value it can return here is
    "NAME_SIZE - 1" and the overflow check is dead code.  Fix this by
    using the snprintf() function which returns the number of bytes that
    would have been copied if there was enough space and changing the
    condition from "> NAME_SIZE" to ">= NAME_SIZE".
    
    Fixes: 92589c986b33 ("rtc-proc: permit the /proc/driver/rtc device to use other devices")
    Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/YJov/pcGmhLi2pEl@mwanda
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/rtc/proc.c b/drivers/rtc/proc.c
index 73344598fc1b..cbcdbb19d848 100644
--- a/drivers/rtc/proc.c
+++ b/drivers/rtc/proc.c
@@ -23,8 +23,8 @@ static bool is_rtc_hctosys(struct rtc_device *rtc)
 	int size;
 	char name[NAME_SIZE];
 
-	size = scnprintf(name, NAME_SIZE, "rtc%d", rtc->id);
-	if (size > NAME_SIZE)
+	size = snprintf(name, NAME_SIZE, "rtc%d", rtc->id);
+	if (size >= NAME_SIZE)
 		return false;
 
 	return !strncmp(name, CONFIG_RTC_HCTOSYS_DEVICE, NAME_SIZE);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux