From 9eb5ce5ae298a13af29f2c85f33ef75773e852ee Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 24 Feb 2015 16:00:36 -0500 Subject: [PATCH] Grow.c: Fix classic readlink() buffer overflow 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 Signed-off-by: NeilBrown --- Grow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Grow.c b/Grow.c index b78d063..a8bbf2b 100644 --- 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);