]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow.c: Fix classic readlink() buffer overflow
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 24 Feb 2015 21:00:36 +0000 (16:00 -0500)
committerNeilBrown <neilb@suse.de>
Tue, 24 Feb 2015 21:06:45 +0000 (08:06 +1100)
The buffer passed on to readlink() needs to contain space for the
terminating \0. See 'man 3 readlink' for details.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Grow.c

diff --git a/Grow.c b/Grow.c
index b78d063820934ba08ab33172d415016237e0d451..a8bbf2bf19a5c58610145bff0e0e5e2aafcc6fa3 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -3319,7 +3319,7 @@ started:
                bul = make_backup(sra->sys_name);
                if (bul) {
                        char buf[1024];
-                       int l = readlink(bul, buf, sizeof(buf));
+                       int l = readlink(bul, buf, sizeof(buf) - 1);
                        if (l > 0) {
                                buf[l]=0;
                                unlink(buf);