[PATCH] D56125: [Sanitizer] Intercept arc4random_buf / arc4random_addrandom on FreeBSD/NetBSD
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 28 07:57:46 PST 2018
krytarowski accepted this revision.
krytarowski added inline comments.
This revision is now accepted and ready to land.
================
Comment at: test/sanitizer_common/TestCases/Posix/arc4random.cc:13
+ for (auto i = 0; i < buflen; i ++)
+ printf("%" PRIx8, buf[i]);
+ printf("'\n");
----------------
devnexen wrote:
> krytarowski wrote:
> > `printf("%" PRIx8, (unsigned char)buf[i]);`
> The buf itself is unsigned char pointer (print_buf sig.)
OK, you are right. unsigned char will force this to work correctly.
```
$ cat sign.c
#include <stdio.h>
#include <inttypes.h>
int
main(int argc, char **argv)
{
signed char c = 0xfa;
printf("%" PRIx8 "\n", c);
return 0;
}
$ gcc sign.c
$ ./a.out
fffffffa
$ mg sign.c # changed to unsigned
$ gcc sign.c
$ ./a.out
fa
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56125/new/
https://reviews.llvm.org/D56125
More information about the llvm-commits
mailing list