Skip to content

Commit

Permalink
lib: posix: fix out-of-bound write
Browse files Browse the repository at this point in the history
Ensure that write is in buffer limits

Coverity-CID: 186491

Signed-off-by: Paras Jain <parasjain2000@gmail.com>
  • Loading branch information
parasjain2000 authored and MaureenHelm committed Jun 9, 2018
1 parent eb9df85 commit bf1e019
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/posix/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ struct dirent *readdir(DIR *dirp)
}

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 */
Expand Down

0 comments on commit bf1e019

Please sign in to comment.