Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc | ||
---|---|---|
2508 | is "res >= targsize" possible? | |
2514 | COMMON_INTERCEPTOR_READ_RANGE(ctx, src, internal_strlen(src) + 1); COMMON_INTERCEPTOR_READ_STRING usually use for parsers which may read just a part of the string | |
2518 | is "res > targsize" possible? | |
compiler-rt/test/msan/Linux/b64.cpp | ||
4 | that change is sanitizer_common | |
4 | in addition to msan/Linux/b64.cpp |
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc | ||
---|---|---|
2508 | Since the code is adding one ('+ 1'), I wanted to avoid writing past the end. So, the check is intended to prevent 'res == targsize'. | |
2514 | READ_STRING depends on null termination, which I believe this method does as well. There is no length provided, how else would the length be determined. https://elixir.bootlin.com/glibc/glibc-2.17/source/resolv/base64.c#L209 | |
2518 | Unit test fails without the '+ 1'. Similar to above, check is to prevent writing beyond end of target. | |
compiler-rt/test/msan/Linux/b64.cpp | ||
4 | I'm not sure what to do. Leave this one here, and clone it with different RUN lines to 'sanitizer_common/TestCases/Linux'? |
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc | ||
---|---|---|
2508 | https://elixir.bootlin.com/glibc/glibc-2.17/source/resolv/base64.c#L184 if (datalength >= targsize) return (-1); target[datalength] = '\0' I do not insist, just recommend, COMMON_INTERCEPTOR_WRITE_RANGE(ctx, target, res + 1) is enough | |
2514 | #define COMMON_INTERCEPTOR_READ_STRING(ctx, s, n) \ COMMON_INTERCEPTOR_READ_RANGE((ctx), (s), \ common_flags()->strict_string_checks ? (internal_strlen(s)) + 1 : (n) ) strict_string_checks (default: false) means even if REAL() reads only few first byte of the string, entire string must be correct up to the null terminator. Otherwise it's UB for some str functions. However this check is hard to enable in real code, a lot code call str functions on non null terminated strings. So the patch as-is is essentially: COMMON_INTERCEPTOR_READ_RANGE(ctx, src, 0); which is NOOP COMMON_INTERCEPTOR_READ_STRING(ctx, src, internal_strlen(src) + 1); can work here, but it's equivalent to | |
2518 |
Same as above (res < targsize) seem unnecessary | |
2518 |
https://elixir.bootlin.com/glibc/glibc-2.17/source/resolv/base64.c#L248 | |
compiler-rt/test/msan/Linux/b64.cpp | ||
4 | yes, and drop CHECK: WARNING stuff as we can't run different sanitizers there | |
13 | there is a leak of dst char dst[dst_len]; ? |
improve unit test (reading and edge cases), add sanitizer_common test, adjust implementation.
a few more adjustments
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc | ||
---|---|---|
2518 | PTAL: I think I was seeing a side effect for 'strlen'. I think you were right the first time. |
is "res >= targsize" possible?
Isn't this return -1 on overflow?