From 8dfb8619f928d58ac7369c42e9f94dd0dabfed4b Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 18 Jul 2008 16:37:18 +1000 Subject: [PATCH 1/1] sysfs: avoid possible data corruption in sys_load. Don't retry to remove a newline from the end of an empty string. Signed-off-by: Neil Brown --- sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysfs.c b/sysfs.c index bc021cc7..8979ec4e 100644 --- a/sysfs.c +++ b/sysfs.c @@ -37,7 +37,7 @@ int load_sys(char *path, char *buf) if (n <0 || n >= 1024) return -1; buf[n] = 0; - if (buf[n-1] == '\n') + if (n && buf[n-1] == '\n') buf[n-1] = 0; return 0; } -- 2.39.2