diff options
author | NeilBrown <neilb@suse.de> | 2008-07-18 16:37:18 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2008-07-18 16:37:18 +1000 |
commit | 8dfb8619f928d58ac7369c42e9f94dd0dabfed4b (patch) | |
tree | 597f328125b904bc1d4855840b07c66ecbebe6a0 /sysfs.c | |
parent | 7364918895b6b014d1a675c38973845cdf3baf41 (diff) |
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 <neilb@suse.de>
Diffstat (limited to 'sysfs.c')
-rw-r--r-- | sysfs.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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; } |