git-subtree-dir: Security Research and Development with LLVM - Andrew Reiter git-subtree-mainline: aa7a9fc1e16c3c5be7ba312c4b4e37775e005101 git-subtree-split: 0605b5174c2bc286d3e95d6c0df620800bef96c7
39 строки
400 B
C
39 строки
400 B
C
/*
|
|
* NFDL002
|
|
*
|
|
* Naive File Descriptor Leak 002
|
|
* .. well this does not leak.
|
|
*
|
|
*/
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <unistd.h>
|
|
|
|
void
|
|
foo(char *k)
|
|
{
|
|
return;
|
|
}
|
|
|
|
void
|
|
leaks_fd()
|
|
{
|
|
int fd;
|
|
|
|
|
|
fd = socket(AF_INET, SOCK_STREAM, 0);
|
|
if (fd == -1) {
|
|
perror("socket");
|
|
}
|
|
close(fd);
|
|
return;
|
|
}
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
leaks_fd();
|
|
return 0;
|
|
}
|