Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions rules/dirent/src.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2022-present INESC-ID.
// Distributed under the MIT license that can be found in the LICENSE file.

#include <dirent.h>

using t1 = DIR *;

DIR *f1(const char *name) { return opendir(name); }

struct dirent *f2(DIR *dirp) { return readdir(dirp); }

int f3(DIR *dirp) { return closedir(dirp); }
18 changes: 18 additions & 0 deletions rules/dirent/tgt_unsafe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2022-present INESC-ID.
// Distributed under the MIT license that can be found in the LICENSE file.

fn t1() -> *mut ::libc::DIR {
std::ptr::null_mut()
}

unsafe fn f1(a0: *const u8) -> *mut ::libc::DIR {
libc::opendir(a0 as *const i8)
}

unsafe fn f2(a0: *mut ::libc::DIR) -> *mut ::libc::dirent {
libc::readdir(a0)
}

unsafe fn f3(a0: *mut ::libc::DIR) -> i32 {
libc::closedir(a0)
}
8 changes: 8 additions & 0 deletions rules/fnmatch/src.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2022-present INESC-ID.
// Distributed under the MIT license that can be found in the LICENSE file.

#include <fnmatch.h>

int f1(const char *pattern, const char *string, int flags) {
return fnmatch(pattern, string, flags);
}
6 changes: 6 additions & 0 deletions rules/fnmatch/tgt_unsafe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2022-present INESC-ID.
// Distributed under the MIT license that can be found in the LICENSE file.

unsafe fn f1(a0: *const u8, a1: *const u8, a2: i32) -> i32 {
libc::fnmatch(a0 as *const i8, a1 as *const i8, a2)
}
10 changes: 10 additions & 0 deletions rules/ifaddrs/src.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <sys/types.h>
#include <ifaddrs.h>

int f1(struct ifaddrs **ifap) {
return getifaddrs(ifap);
}

void f2(struct ifaddrs *ifa) {
return freeifaddrs(ifa);
}
7 changes: 7 additions & 0 deletions rules/ifaddrs/tgt_unsafe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
unsafe fn f1(a0: *mut *mut libc::ifaddrs) -> i32 {
libc::getifaddrs(a0)
}

unsafe fn f2(a0: *mut libc::ifaddrs) {
libc::freeifaddrs(a0)
}
6 changes: 6 additions & 0 deletions rules/net_if/src.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2022-present INESC-ID.
// Distributed under the MIT license that can be found in the LICENSE file.

#include <net/if.h>

unsigned int f1(const char *ifname) { return if_nametoindex(ifname); }
6 changes: 6 additions & 0 deletions rules/net_if/tgt_unsafe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2022-present INESC-ID.
// Distributed under the MIT license that can be found in the LICENSE file.

unsafe fn f1(a0: *const u8) -> u32 {
libc::if_nametoindex(a0 as *const i8)
}
5 changes: 5 additions & 0 deletions rules/pwd/src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@
#include <pwd.h>

struct passwd *f1(uid_t uid) { return getpwuid(uid); }

int f2(uid_t uid, struct passwd *pwd, char *buf, size_t buflen,
struct passwd **result) {
return getpwuid_r(uid, pwd, buf, buflen, result);
}
10 changes: 10 additions & 0 deletions rules/pwd/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@
unsafe fn f1(a0: u32) -> *mut ::libc::passwd {
libc::getpwuid(a0)
}

unsafe fn f2(
a0: u32,
a1: *mut ::libc::passwd,
a2: *mut u8,
a3: u64,
a4: *mut *mut ::libc::passwd,
) -> i32 {
libc::getpwuid_r(a0, a1, a2 as *mut i8, a3 as usize, a4)
}
18 changes: 18 additions & 0 deletions rules/socket/src.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,21 @@ int f15(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) {
return accept4(sockfd, addr, addrlen, flags);
}
#endif

int f16(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
return bind(sockfd, addr, addrlen);
}

int f17(int sockfd, int backlog) {
return listen(sockfd, backlog);
}

ssize_t f18(int sockfd, void *buf, size_t len, int flags,
struct sockaddr *src_addr, socklen_t *addrlen) {
return recvfrom(sockfd, buf, len, flags, src_addr, addrlen);
}

ssize_t f19(int sockfd, const void *buf, size_t len, int flags,
const struct sockaddr *dest_addr, socklen_t addrlen) {
return sendto(sockfd, buf, len, flags, dest_addr, addrlen);
}
30 changes: 30 additions & 0 deletions rules/socket/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,33 @@ unsafe fn f14(a0: i32, a1: *mut ::libc::sockaddr, a2: *mut u32) -> i32 {
unsafe fn f15(a0: i32, a1: *mut ::libc::sockaddr, a2: *mut u32, a3: i32) -> i32 {
libc::accept4(a0, a1, a2, a3)
}

unsafe fn f16(a0: i32, a1: *const ::libc::sockaddr, a2: u32) -> i32 {
libc::bind(a0, a1, a2)
}

unsafe fn f17(a0: i32, a1: i32) -> i32 {
libc::listen(a0, a1)
}

unsafe fn f18(
a0: i32,
a1: *mut ::libc::c_void,
a2: u64,
a3: i32,
a4: *mut ::libc::sockaddr,
a5: *mut u32,
) -> i64 {
libc::recvfrom(a0, a1, a2 as usize, a3, a4, a5) as i64
}

unsafe fn f19(
a0: i32,
a1: *const ::libc::c_void,
a2: u64,
a3: i32,
a4: *const ::libc::sockaddr,
a5: u32,
) -> i64 {
libc::sendto(a0, a1, a2 as usize, a3, a4, a5) as i64
}
8 changes: 8 additions & 0 deletions rules/src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ pub mod cstring_tgt_unsafe;
pub mod deque_tgt_refcount;
#[path = r#"../deque/tgt_unsafe.rs"#]
pub mod deque_tgt_unsafe;
#[path = r#"../dirent/tgt_unsafe.rs"#]
pub mod dirent_tgt_unsafe;
#[path = r#"../errno/tgt_unsafe.rs"#]
pub mod errno_tgt_unsafe;
#[path = r#"../fnmatch/tgt_unsafe.rs"#]
pub mod fnmatch_tgt_unsafe;
#[path = r#"../fstream/tgt_refcount.rs"#]
pub mod fstream_tgt_refcount;
#[path = r#"../fstream/tgt_unsafe.rs"#]
pub mod fstream_tgt_unsafe;
#[path = r#"../ifaddrs/tgt_unsafe.rs"#]
pub mod ifaddrs_tgt_unsafe;
#[path = r#"../initializer_list/tgt_unsafe.rs"#]
pub mod initializer_list_tgt_unsafe;
#[path = r#"../iomanip/tgt_unsafe.rs"#]
Expand All @@ -62,6 +68,8 @@ pub mod map_tgt_refcount;
pub mod map_tgt_unsafe;
#[path = r#"../math/tgt_unsafe.rs"#]
pub mod math_tgt_unsafe;
#[path = r#"../net_if/tgt_unsafe.rs"#]
pub mod net_if_tgt_unsafe;
#[path = r#"../netdb/tgt_unsafe.rs"#]
pub mod netdb_tgt_unsafe;
#[path = r#"../pair/tgt_refcount.rs"#]
Expand Down
6 changes: 6 additions & 0 deletions rules/stdio/src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ int f19(FILE *stream, off_t offset, int whence) {
}

FILE *f20(int fd, const char *mode) { return fdopen(fd, mode); }

int f22(const char *a0, const char *a1) {
return rename(a0, a1);
}

int f23(FILE *stream) { return getc(stream); }
8 changes: 8 additions & 0 deletions rules/stdio/tgt_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,11 @@ unsafe fn f19(a0: *mut ::libc::FILE, a1: i64, a2: i32) -> i32 {
unsafe fn f20(a0: i32, a1: *const u8) -> *mut ::libc::FILE {
libc::fdopen(a0, a1 as *const i8)
}

unsafe fn f22(a0: *const i8, a1: *const i8) -> i32 {
libc::rename(a0 as *const i8, a1 as *const i8)
}

unsafe fn f23(a0: *mut ::libc::FILE) -> i32 {
libc::fgetc(a0)
}
Loading