]> git.baikalelectronics.ru Git - kernel.git/commit
rtc: fix snprintf() checking in is_rtc_hctosys()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 11 May 2021 07:19:26 +0000 (10:19 +0300)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 24 May 2021 22:36:11 +0000 (00:36 +0200)
commit4ceca49a79f4b34e00fc64abe5ae6c91f187b58e
tree2ad4d017e7517a8f19f2ccffd8ab3108da26d2c8
parentd4c4f047c6b19148ada51818c56ee05c3893d9da
rtc: fix snprintf() checking in is_rtc_hctosys()

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: 0584f0e520b9 ("rtc-proc: permit the /proc/driver/rtc device to use other devices")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/YJov/pcGmhLi2pEl@mwanda
drivers/rtc/proc.c