[PATCH 09/10] sched_deadline: Check the resulting size returned from snprintf()

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

 



The code simply assumes that the built path does not exceed MAX_PATH.
Since the previous change the compiler started to complain but I don't
see a connection other than the removal of one find_debugfs() user.

Make sure the resulting path is not truncated.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
 src/sched_deadline/cyclicdeadline.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 82e640409ecef..89b7c0b8deb21 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -160,12 +160,16 @@ static int fill_sched_features(char *path)
 	if (strlen(debugfs) == 0)
 		return -1;
 
-	snprintf(path, MAX_PATH, "%s/sched/features", debugfs);
+	ret = snprintf(path, MAX_PATH, "%s/sched/features", debugfs);
+	if (ret >= MAX_PATH)
+		return -1;
 	ret = check_file_exists(path);
 	if (ret)
 		return 0;
 
-	snprintf(path, MAX_PATH, "%s/sched_features", debugfs);
+	ret = snprintf(path, MAX_PATH, "%s/sched_features", debugfs);
+	if (ret >= MAX_PATH)
+		return -1;
 	ret = check_file_exists(path);
 	if (ret)
 		return 0;
-- 
2.51.0





[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux