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
40 changes: 40 additions & 0 deletions rules/locale/ir_unsafe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"f1": {
"body": [
{
"text": "libc::setlocale("
},
{
"placeholder": {
"arg": 0,
"access": "read"
}
},
{
"text": ", "
},
{
"placeholder": {
"arg": 1,
"access": "read"
}
},
{
"text": " as *const i8) as *mut u8"
}
],
"params": {
"a0": {
"type": "i32"
},
"a1": {
"type": "*const u8",
"is_unsafe_pointer": true
}
},
"return_type": {
"type": "*mut u8",
"is_unsafe_pointer": true
}
}
}
8 changes: 8 additions & 0 deletions rules/locale/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 <locale.h>

char *f1(int category, const char *locale) {
return setlocale(category, locale);
}
6 changes: 6 additions & 0 deletions rules/locale/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: i32, a1: *const u8) -> *mut u8 {
libc::setlocale(a0, a1 as *const i8) as *mut u8
}
88 changes: 88 additions & 0 deletions rules/netdb/ir_unsafe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"f1": {
"body": [
{
"text": "libc::getaddrinfo("
},
{
"placeholder": {
"arg": 0,
"access": "read"
}
},
{
"text": " as *const i8, "
},
{
"placeholder": {
"arg": 1,
"access": "read"
}
},
{
"text": " as *const i8, "
},
{
"placeholder": {
"arg": 2,
"access": "read"
}
},
{
"text": ", "
},
{
"placeholder": {
"arg": 3,
"access": "read"
}
},
{
"text": ")"
}
],
"params": {
"a0": {
"type": "*const u8",
"is_unsafe_pointer": true
},
"a1": {
"type": "*const u8",
"is_unsafe_pointer": true
},
"a2": {
"type": "*const ::libc::addrinfo",
"is_unsafe_pointer": true
},
"a3": {
"type": "*mut *mut ::libc::addrinfo",
"is_unsafe_pointer": true
}
},
"return_type": {
"type": "i32"
}
},
"f2": {
"body": [
{
"text": "libc::freeaddrinfo("
},
{
"placeholder": {
"arg": 0,
"access": "read"
}
},
{
"text": ")"
}
],
"params": {
"a0": {
"type": "*mut ::libc::addrinfo",
"is_unsafe_pointer": true
}
}
}
}
11 changes: 11 additions & 0 deletions rules/netdb/src.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2022-present INESC-ID.
// Distributed under the MIT license that can be found in the LICENSE file.

#include <netdb.h>

int f1(const char *node, const char *service, const struct addrinfo *hints,
struct addrinfo **res) {
return getaddrinfo(node, service, hints, res);
}

void f2(struct addrinfo *res) { return freeaddrinfo(res); }
15 changes: 15 additions & 0 deletions rules/netdb/tgt_unsafe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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: *const ::libc::addrinfo,
a3: *mut *mut ::libc::addrinfo,
) -> i32 {
libc::getaddrinfo(a0 as *const i8, a1 as *const i8, a2, a3)
}

unsafe fn f2(a0: *mut ::libc::addrinfo) {
libc::freeaddrinfo(a0)
}
27 changes: 27 additions & 0 deletions rules/pwd/ir_unsafe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"f1": {
"body": [
{
"text": "libc::getpwuid("
},
{
"placeholder": {
"arg": 0,
"access": "read"
}
},
{
"text": ")"
}
],
"params": {
"a0": {
"type": "u32"
}
},
"return_type": {
"type": "*mut ::libc::passwd",
"is_unsafe_pointer": true
}
}
}
6 changes: 6 additions & 0 deletions rules/pwd/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 <pwd.h>

struct passwd *f1(uid_t uid) { return getpwuid(uid); }
6 changes: 6 additions & 0 deletions rules/pwd/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: u32) -> *mut ::libc::passwd {
libc::getpwuid(a0)
}
52 changes: 52 additions & 0 deletions rules/signal/ir_unsafe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"f1": {
"body": [
{
"text": "libc::sigaction("
},
{
"placeholder": {
"arg": 0,
"access": "read"
}
},
{
"text": ", "
},
{
"placeholder": {
"arg": 1,
"access": "read"
}
},
{
"text": ", "
},
{
"placeholder": {
"arg": 2,
"access": "read"
}
},
{
"text": ")"
}
],
"params": {
"a0": {
"type": "i32"
},
"a1": {
"type": "*const ::libc::sigaction",
"is_unsafe_pointer": true
},
"a2": {
"type": "*mut ::libc::sigaction",
"is_unsafe_pointer": true
}
},
"return_type": {
"type": "i32"
}
}
}
8 changes: 8 additions & 0 deletions rules/signal/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 <signal.h>

int f1(int signum, const struct sigaction *act, struct sigaction *oldact) {
return sigaction(signum, act, oldact);
}
6 changes: 6 additions & 0 deletions rules/signal/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: i32, a1: *const ::libc::sigaction, a2: *mut ::libc::sigaction) -> i32 {
libc::sigaction(a0, a1, a2)
}
10 changes: 10 additions & 0 deletions rules/src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,28 @@ pub mod iostream_tgt_unsafe;
pub mod ip_tgt_unsafe;
#[path = r#"../limits/tgt_unsafe.rs"#]
pub mod limits_tgt_unsafe;
#[path = r#"../locale/tgt_unsafe.rs"#]
pub mod locale_tgt_unsafe;
#[path = r#"../map/tgt_refcount.rs"#]
pub mod map_tgt_refcount;
#[path = r#"../map/tgt_unsafe.rs"#]
pub mod map_tgt_unsafe;
#[path = r#"../math/tgt_unsafe.rs"#]
pub mod math_tgt_unsafe;
#[path = r#"../netdb/tgt_unsafe.rs"#]
pub mod netdb_tgt_unsafe;
#[path = r#"../pair/tgt_refcount.rs"#]
pub mod pair_tgt_refcount;
#[path = r#"../pair/tgt_unsafe.rs"#]
pub mod pair_tgt_unsafe;
#[path = r#"../poll/tgt_unsafe.rs"#]
pub mod poll_tgt_unsafe;
#[path = r#"../pwd/tgt_unsafe.rs"#]
pub mod pwd_tgt_unsafe;
#[path = r#"../select/tgt_unsafe.rs"#]
pub mod select_tgt_unsafe;
#[path = r#"../signal/tgt_unsafe.rs"#]
pub mod signal_tgt_unsafe;
#[path = r#"../socket/tgt_unsafe.rs"#]
pub mod socket_tgt_unsafe;
#[path = r#"../stat/tgt_unsafe.rs"#]
Expand All @@ -78,6 +86,8 @@ pub mod stdio_tgt_unsafe;
pub mod string_tgt_refcount;
#[path = r#"../string/tgt_unsafe.rs"#]
pub mod string_tgt_unsafe;
#[path = r#"../termios/tgt_unsafe.rs"#]
pub mod termios_tgt_unsafe;
#[path = r#"../unique_ptr/tgt_refcount.rs"#]
pub mod unique_ptr_tgt_refcount;
#[path = r#"../unique_ptr/tgt_unsafe.rs"#]
Expand Down
Loading
Loading