chore(security): avoid use of strcpy#1159
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Signed the CLA |
sergiud
left a comment
There was a problem hiding this comment.
Thanks for the PR.
Silencing the static analyzer by reimplementing strcpy is not meaningful. Given the bounds are checked I don't understand what the current changes actually fix.
Fair. I would have preferred to use something like 'strlcpy' which Xcode actually suggested, but I wasn't sure that would be portable enough, as I'm not sure what Google's C / C++ standards are. Would you have an idea? |
|
@sergiud Would |
|
@Saadnajmi I suggest we test this in ng-log that supersedes glog which is being deprecated. Please open a PR there. |
Internally, we use this library with React Native. We noticed that Xcode's static analysis would point out a potentially unsafe call to
strcpy. We are doing a proper bound check, but to be safer, we could also use something likestrncpy/strncpy_s/strlcpy/memcpyto handle this case. Of those, the latter felt the most portable, so I went with that.