commit | bf1e0198a78b7e1a51306a1fe24c73c3cdc5ab9a | [log] [tgz] |
---|---|---|
author | Paras Jain <parasjain2000@gmail.com> | Thu Jun 07 11:12:49 2018 -0700 |
committer | Maureen Helm <maureen.helm@nxp.com> | Sat Jun 09 08:26:18 2018 -0500 |
tree | 2c722532496fac8a0d364c6dd2b588e582a00de7 | |
parent | eb9df85f8412cddd49ef1ab5fa3c9264322cb31a [diff] |
lib: posix: fix out-of-bound write Ensure that write is in buffer limits Coverity-CID: 186491 Signed-off-by: Paras Jain <parasjain2000@gmail.com>
diff --git a/lib/posix/fs.c b/lib/posix/fs.c index 460de8d..6ffc8f3 100644 --- a/lib/posix/fs.c +++ b/lib/posix/fs.c
@@ -293,7 +293,7 @@ } rc = strlen(fdirent.name); - rc = (rc <= PATH_MAX) ? rc : PATH_MAX; + rc = (rc < PATH_MAX) ? rc : (PATH_MAX - 1); memcpy(pdirent.d_name, fdirent.name, rc); /* Make sure the name is NULL terminated */