[PATCH] D54527: Add new interceptor for strtonum(3)
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 6 19:39:51 PST 2018
krytarowski marked an inline comment as done.
krytarowski added inline comments.
================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:7742
}
- return ret;
+
+ saved_errno = errno;
----------------
vitalybuka wrote:
> ```
> INTERCEPTOR(long long, strtonum, const char *nptr, long long minval,
> long long maxval, const char **errstr) {
> void *ctx;
> COMMON_INTERCEPTOR_ENTER(ctx, strtonum, nptr, minval, maxval, errstr);
>
> char *real_endptr;
> long long ret = REAL(strtoll)(nptr, &real_endptr, 10);
> StrtolFixAndCheck(ctx, nptr, nullptr, real_endptr, 10);
>
> ret = REAL(strtonum)(nptr, minval, maxval, errstr);
> if (errstr) {
> COMMON_INTERCEPTOR_WRITE_RANGE(ctx, errstr, sizeof(const char *));
> if (*errstr)
> COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *errstr, REAL(strlen)(*errstr) + 1);
> }
> return ret;
> }
> ```
Hmm.. this is evaluating the input string twice... but performance impact is probably marginal, so I will switch to it.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54527/new/
https://reviews.llvm.org/D54527
More information about the llvm-commits
mailing list