google / google/sanitizers

getlogin_r + strlen false positive

Open
#586 4 comments 0 reactions 1 assignee Claimed by @eugenis View on GitHub
Priority-Medium ProjectMemorySanitizer Status-Accepted Type-Defect
Dominant language
C
Stars
12.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Originally reported on Google Code with ID 83

```
The code:

#include
#include
#include
int main()
{
char buf[20];
getlogin_r(buf,20);
printf("%s %lu\n", buf, strlen(buf));
return 0;
}

Produces
Uninitialized bytes in __interceptor_strlen at offset 0 inside [0x7fffadd55e40, 8)
==1510== WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7fac569fbf0a in main (/home/rschulz/work/msan/a.out+0x90f0a)
#1 0x7fac55880b04 in __libc_start_main (/lib64/libc.so.6+0x21b04)
#2 0x7fac569a6a5e in _start /home/abuild/rpmbuild/BUILD/glibc-2.19/csu/../sysdeps/x86_64/start.S:112

Uninitialized value was created by an allocation of 'buf' in the stack frame of function
'main'
#0 0x7fac569fbe70 in main (/home/rschulz/work/msan/a.out+0x90e70)

This is with both clang 3.5.0 and 3.6.0rc1.
```

Reported by `roland@rschulz.eu` on 2015-01-27 08:10:28

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.