summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorThomas Jarosch <thomas.jarosch@intra2net.com>2011-10-13 11:21:07 +0200
committerNeilBrown <neilb@suse.de>2011-10-17 02:15:04 +0200
commit9cf014ec4055d95f32e028f1a004ea165d90ffe4 (patch)
tree2597622f1c17b2f2aeee3653459a9abc1768013f /util.c
parentimsm: fix: stopped resync does not continue after auto-assemblation (diff)
downloadmdadm-9cf014ec4055d95f32e028f1a004ea165d90ffe4.tar.xz
mdadm-9cf014ec4055d95f32e028f1a004ea165d90ffe4.zip
Fix off-by-one in readlink() buffer size handling
readlink() returns the number of bytes in the buffer. If we do something like len = readlink(path, buf, sizeof(buf)); buf[len] = '\0'; we might write one byte past the end of the buffer. Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r--util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util.c b/util.c
index 50c98c1c..f785f030 100644
--- a/util.c
+++ b/util.c
@@ -1594,7 +1594,7 @@ int start_mdmon(int devnum)
if (check_env("MDADM_NO_MDMON"))
return 0;
- len = readlink("/proc/self/exe", pathbuf, sizeof(pathbuf));
+ len = readlink("/proc/self/exe", pathbuf, sizeof(pathbuf)-1);
if (len > 0) {
char *sl;
pathbuf[len] = 0;