[PATCH] D14714: [compiler-rt] Add internal implementations for strlcat and strlcpy
Alexander Potapenko via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 18 02:44:58 PST 2015
glider added a subscriber: glider.
================
Comment at: lib/sanitizer_common/sanitizer_libc.cc:181
@@ +180,3 @@
+ const uptr dstlen = internal_strnlen(dst, maxlen);
+ if (dstlen == maxlen) return maxlen+srclen;
+ if (srclen < maxlen-dstlen) {
----------------
Nit: missing spaces around '+'
================
Comment at: lib/sanitizer_common/sanitizer_libc.cc:185
@@ +184,3 @@
+ } else {
+ internal_memcpy(dst+dstlen, src, maxlen-dstlen-1);
+ dst[maxlen-1] = '\0';
----------------
Ditto (also '-')
================
Comment at: lib/sanitizer_common/sanitizer_libc.cc:203
@@ +202,3 @@
+ if (srclen < maxlen) {
+ internal_memcpy(dst, src, srclen+1);
+ } else if (maxlen != 0) {
----------------
`dst` and `src` must not overlap, but maybe we use memmove() here just to make sure nothing blows up?
http://reviews.llvm.org/D14714
More information about the llvm-commits
mailing list