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 <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
Jes Sorensen 2015-02-24 16:00:36 -05:00 committed by NeilBrown
parent 7a862a020f
commit 9eb5ce5ae2
1 changed files with 1 additions and 1 deletions

2
Grow.c
View File

@ -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);