From 70572e02ff7c8896299249401cb83dd0929a172f Mon Sep 17 00:00:00 2001 From: b2m <> Date: Wed, 3 Dec 2014 16:35:30 -0500 Subject: [PATCH] readdir: string length bug fix If len is 32 (maximum possible value), then we going to write at buf->d_name[31]. Since the d_name length is 31, write is performed outside the string boundaries. --- Library/libs/readdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/libs/readdir.c b/Library/libs/readdir.c index e326dfe5..44f0afe2 100644 --- a/Library/libs/readdir.c +++ b/Library/libs/readdir.c @@ -34,6 +34,6 @@ struct dirent *readdir(DIR * dir) buf->d_off = -1; /* FIXME */ buf->d_reclen = len + 1; strncpy(buf->d_name, (char *) direntry.d_name, len - 2); - buf->d_name[len - 1] = 0; + buf->d_name[len - 2] = 0; return buf; } -- 2.34.1