diff options
author | Nick Kralevich <nnk@google.com> | 2013-09-27 13:21:24 -0700 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2013-09-27 13:21:24 -0700 |
commit | d13c2b1ba6681fdbee73a044d988c3f9e1172d30 (patch) | |
tree | 009f871a52478fef08570ac9365b5be3af08c397 /libc/kernel/tools/cpp.py | |
parent | 8427b7450fe068db6484d161f7004661c4698858 (diff) |
Fix unnecessary call to __strncpy_chk2
If "n" is smaller than the size of "src", then we'll
never read off the end of src. It makes no sense to call
__strncpy_chk2 in those circumstances.
For example, consider the following code:
int main() {
char src[10];
char dst[5];
memcpy(src, "0123456789", sizeof(src));
strncpy(dst, src, sizeof(dst));
dst[4] = '\0';
printf("%s\n", dst);
return 0;
}
In this code, it's clear that the strncpy will never read off
the end of src.
Change-Id: I9cf58857a0c5216b4576d21d3c1625e2913ccc03
Diffstat (limited to 'libc/kernel/tools/cpp.py')
0 files changed, 0 insertions, 0 deletions