input stringlengths 26 172k | output stringlengths 18 318k | repo_name stringclasses 23 values | decompiler stringclasses 5 values |
|---|---|---|---|
char *sh_quote_reusable(s, flags)
char *s;
int flags;
{
char *ret;
if (s == 0)
return s;
else if (*s == 0) {
ret = (char *)sh_xmalloc((3), "shquote.c", 371);
ret[0] = ret[1] = '\'';
ret[2] = '\0';
} else if (ansic_shouldquote(s))
ret = ansic_quote(s, 0, (int *)0);
else if (flags)
ret = sh_backslash_quote(s, 0, 1);
else
ret = sh_single_quote(s);
return ret;
} | char *sh_quote_reusable(char *param_1, int param_2)
{
int iVar1;
if (param_1 != (char *)0x0) {
if (*param_1 == '\0') {
param_1 = (char *)sh_xmalloc(3, "shquote.c", 0x173);
param_1[1] = '\'';
*param_1 = param_1[1];
param_1[2] = '\0';
} else {
iVar1 = ansic_shouldquote(param_1);
if (iVar1 == 0) {
if (param_2 == 0) {
param_1 = (char *)sh_single_quote(param_1);
} else {
param_1 = (char *)sh_backslash_quote(param_1, 0, 1);
}
} else {
param_1 = (char *)ansic_quote(param_1, 0, 0);
}
}
}
return param_1;
} | bash | ghidra |
int main(int argc, char **argv) {
char proc_dir_name[32];
char *target_str;
pid_t target;
int proc_dir_fd;
int ranges;
struct map_range *mappings;
struct stat st;
struct passwd *pw;
int written;
Prog = Basename(argv[0]);
log_set_progname(Prog);
log_set_logfd(stderr);
if (argc < 2)
usage();
target_str = argv[1];
if (!get_pid(target_str, &target))
usage();
written = snprintf(proc_dir_name, sizeof(proc_dir_name), "/proc/%u/", target);
if ((written <= 0) || (written >= sizeof(proc_dir_name))) {
fprintf(stderr, "%s: snprintf of proc path failed: %s\n", Prog,
strerror((*__errno_location())));
}
proc_dir_fd = open(proc_dir_name, 0200000);
if (proc_dir_fd < 0) {
fprintf(stderr,
gettext("%s: Could not open proc directory for target %u\n"), Prog,
target);
return 1;
}
pw = get_my_pwent();
if (((void *)0) == pw) {
fprintf(stderr, gettext("%s: Cannot determine your user name.\n"), Prog);
do {
char *old_locale = setlocale(6, ((void *)0));
char *saved_locale = ((void *)0);
if (((void *)0) != old_locale) {
saved_locale = strdup(old_locale);
}
if (((void *)0) != saved_locale) {
(void)setlocale(6, "C");
}
syslog(4, "Cannot determine the user name of the caller (UID %lu)",
(unsigned long)getuid());
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0);
return 1;
}
if (fstat(proc_dir_fd, &st) < 0) {
fprintf(stderr, gettext("%s: Could not stat directory for target %u\n"),
Prog, target);
return 1;
}
if ((getuid() != pw->pw_uid) ||
(!getdef_bool("GRANT_AUX_GROUP_SUBIDS") && (getgid() != pw->pw_gid)) ||
(pw->pw_uid != st.st_uid) || (getgid() != st.st_gid)) {
fprintf(
stderr,
gettext("%s: Target process %u is owned by a different user: uid:%lu "
"pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n"),
Prog, target, (unsigned long int)getuid(),
(unsigned long int)pw->pw_uid, (unsigned long int)st.st_uid,
(unsigned long int)getgid(), (unsigned long int)pw->pw_gid,
(unsigned long int)st.st_gid);
return 1;
}
if (!sub_uid_open(00)) {
return 1;
}
ranges = ((argc - 2) + 2) / 3;
mappings = get_map_ranges(ranges, argc - 2, argv + 2);
if (!mappings)
usage();
verify_ranges(pw, ranges, mappings);
write_mapping(proc_dir_fd, ranges, mappings, "uid_map", pw->pw_uid);
sub_uid_close();
return 0;
} | int main(unsigned long long a0, unsigned long long a1[2], unsigned int a2,
unsigned long a3, unsigned long long a4, unsigned long long a5) {
unsigned long v0;
unsigned long v1;
unsigned long v2;
unsigned long v3;
unsigned long v4;
unsigned long v5;
unsigned long v6;
char v7;
unsigned int v8;
unsigned int v9;
unsigned int v10;
void *v11;
unsigned long long v12;
unsigned int v13[6];
void *v14;
char *v15;
char v16;
char v17;
char v18;
char v19;
unsigned int v21;
unsigned long long v23;
Prog = Basename(a1[0]);
log_set_progname(0xf87d894810ec8348);
log_set_logfd(stderr);
if (a0 <= 1)
usage();
v12 = a1[1];
if (!get_pid(v12, &v7, &v7))
usage();
v8 = snprintf(&v19, 0x20, "/proc/%u/", *(&v7));
if (v8 <= 0 || v8 > 31)
fprintf(stderr, "%s: snprintf of proc path failed: %s\n", 283935560,
strerror(*(__errno_location())));
v9 = open(&v19, 0x10000, 0x8348);
if (v9 < 0) {
fprintf(stderr,
gettext("%s: Could not open proc directory for target %u\n"));
v21 = 1;
return v21;
}
*(&v13[0]) = get_my_pwent();
if (!v13) {
fprintf(stderr, gettext("%s: Cannot determine your user name.\n"));
v15 = setlocale(0x6, NULL);
v11 = 0;
if (v15)
v11 = strdup(v15);
if (v11)
setlocale(0x6, "C");
getuid();
syslog(0x4, "Cannot determine the user name of the caller (UID %lu)");
if (v11) {
setlocale(0x6, v11);
free(v11);
v21 = 1;
return v21;
}
v21 = 1;
return v21;
} else if (fstat(v9, &v16) < 0) {
fprintf(stderr, gettext("%s: Could not stat directory for target %u\n"));
v21 = 1;
return v21;
} else {
if (getuid() == v13[4] &&
(!(getdef_bool("GRANT_AUX_GROUP_SUBIDS") ^ 1) || getgid() == v13[5]) &&
v13[4] == *(&v17) && getgid() == *(&v18)) {
if (sub_uid_open(0x0)) {
v10 = (a0 * 1431655766 >> 32) - (a0 >> 31);
v14 = get_map_ranges(v10, a0 - 2, a1 + 1, a0 - 2);
if (v14) {
verify_ranges(v13, v10, v14);
write_mapping(v9, v10, v14, "uid_map", v13[4]);
sub_uid_close(a0, v10, 0x10ec8348, "uid_map", a4, a5);
v21 = 0;
return v21;
}
usage();
} else {
v21 = 1;
return v21;
}
}
v6 = *(&v18);
v23 = *(&v17);
v5 = v13[4];
v4 = getuid();
v3 = v6;
v2 = v13[5];
v1 = getgid();
v0 = v23;
fprintf(
stderr,
gettext("%s: Target process %u is owned by a different user: uid:%lu "
"pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n"));
v21 = 1;
return v21;
}
} | shadow | angr_sailr |
static void poly_hash(uhash_ctx_t hc, UINT32 data_in[]) {
int i;
UINT64 *data = (UINT64 *)data_in;
for (i = 0; i < (16 / 4); i++) {
if ((UINT32)(data[i] >> 32) == 0xfffffffful) {
hc->poly_accum[i] = poly64(hc->poly_accum[i], hc->poly_key_8[i],
((UINT64)0xFFFFFFFFFFFFFFC5ull) - 1);
hc->poly_accum[i] =
poly64(hc->poly_accum[i], hc->poly_key_8[i], (data[i] - 59));
} else {
hc->poly_accum[i] = poly64(hc->poly_accum[i], hc->poly_key_8[i], data[i]);
}
}
} | int poly_hash(long a1, long a2) {
int result;
unsigned long v3;
int i;
result = a2;
for (i = 0; i <= 3; ++i) {
if (HIDWORD(*(_QWORD *)(8LL * i + a2)) == -1) {
*(_QWORD *)(a1 + 8 * (i + 150LL) + 8) =
poly64(*(_QWORD *)(a1 + 8 * (i + 150LL) + 8),
*(_QWORD *)(a1 + 8 * (i + 146LL) + 8), 0xFFFFFFFFFFFFFFC4LL);
v3 = poly64(*(_QWORD *)(a1 + 8 * (i + 150LL) + 8),
*(_QWORD *)(a1 + 8 * (i + 146LL) + 8),
*(_QWORD *)(8LL * i + a2) - 59LL);
} else {
v3 = poly64(*(_QWORD *)(a1 + 8 * (i + 150LL) + 8),
*(_QWORD *)(a1 + 8 * (i + 146LL) + 8),
*(_QWORD *)(8LL * i + a2));
}
*(_QWORD *)(a1 + 8 * (i + 150LL) + 8) = v3;
result = i + 1;
}
return result;
} | openssh-portable | ida |
static const char *fmt_multistate_int(int val, const struct multistate *m) {
u_int i;
for (i = 0; m[i].key != ((void *)0); i++) {
if (m[i].value == val)
return m[i].key;
}
return "UNKNOWN";
} | void fmt_multistate_int(unsigned long a0, unsigned long long *a1) {
unsigned int v0;
unsigned long long v2;
unsigned long long v3;
v0 = 0;
while (true) {
if (!a1[2 * v0]) {
v2 = "UNKNOWN";
break;
} else if (a0 == a1[1 + 2 * v0]) {
v3 = a1[2 * v0];
break;
} else {
v0 += 1;
}
}
return;
} | openssh-portable | angr_dream |
void e2fsck_set_bitmap_type(ext2_filsys fs, unsigned int default_type,
const char *profile_name, unsigned int *old_type) {
unsigned type;
e2fsck_t ctx = (e2fsck_t)fs->priv_data;
if (old_type)
*old_type = fs->default_bitmap_type;
profile_get_uint(ctx->profile, "bitmaps", profile_name, 0, default_type,
&type);
profile_get_uint(ctx->profile, "bitmaps", "all", 0, type, &type);
fs->default_bitmap_type = type ? type : default_type;
} | unsigned long e2fsck_set_bitmap_type(long a1, unsigned int a2, long a3,
_DWORD *a4) {
short v4;
unsigned int v6;
long v7;
unsigned long v8;
v8 = __readfsqword(0x28u);
v7 = *(_QWORD *)(a1 + 224);
if (a4)
*a4 = *(unsigned short *)(a1 + 196);
profile_get_uint(*(_QWORD *)(v7 + 864), "bitmaps", a3, 0LL, a2, &v6);
profile_get_uint(*(_QWORD *)(v7 + 864), "bitmaps", "all", 0LL, v6, &v6);
if (v6)
v4 = v6;
else
v4 = a2;
*(_WORD *)(a1 + 196) = v4;
return __readfsqword(0x28u) ^ v8;
} | e2fsprogs-1.46.5 | ida |
static void channel_pre_listener(struct ssh *ssh, Channel *c) {
c->io_want = 0x10;
} | long long channel_pre_listener(unsigned long a0, struct_0 *a1) {
unsigned long v0;
v0 = a0;
a1->field_2c = 16;
return a1;
} | openssh-portable | angr_phoenix |
static int ipnetns_accept_msg(struct rtnl_ctrl_data *ctrl, struct nlmsghdr *n,
void *arg) {
struct nlmsgerr *err = (struct nlmsgerr *)((
void *)(((char *)n) +
((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1)))));
if (n->nlmsg_type == 0x2 && (err->error == -95 || err->error == -22))
have_rtnl_getnsid = 0;
else
have_rtnl_getnsid = 1;
return -1;
} | long long ipnetns_accept_msg(unsigned long a0, struct_0 *a1, unsigned long a2) {
unsigned long v0;
unsigned long v1;
unsigned int *v2;
v1 = a0;
v0 = a2;
v2 = &a1[2].field_4;
if (a1->field_4 != 2) {
have_rtnl_getnsid = 1;
return 4294967295;
}
switch (*(v2)) {
case 4294967201:
case 4294967274:
have_rtnl_getnsid = 0;
return 4294967295;
default:
have_rtnl_getnsid = 1;
return 4294967295;
}
} | iproute2-6.0.0 | angr_sailr |
static void ipstats_select_push(struct ipstats_sel *sel, const char *name) {
int i;
for (i = 0; i < IPSTATS_LEVELS_COUNT; i++)
if (sel->sel[i] == ((void *)0)) {
sel->sel[i] = name;
return;
}
((void)sizeof((0) ? 1 : 0), __extension__({
if (0)
;
else
__assert_fail("false", "ipstats.c", 929,
__extension__ __PRETTY_FUNCTION__);
}));
} | long ipstats_select_push(long a1, long a2) {
long result;
int i;
for (i = 0;; ++i) {
if (i > 2)
_assert_fail("false", "ipstats.c", 0x3A1u, "ipstats_select_push");
if (!*(_QWORD *)(a1 + 8LL * i))
break;
}
result = a1;
*(_QWORD *)(a1 + 8LL * i) = a2;
return result;
} | iproute2-6.0.0 | ida |
int maybe_unsave_line(void) { return rl_maybe_unsave_line(); } | long long maybe_unsave_line() { return rl_maybe_unsave_line(); } | bash | angr_sailr |
char **all_variables_matching_prefix(prefix) const char *prefix;
{
SHELL_VAR **varlist;
char **rlist;
int vind, rind, plen;
plen = (((prefix) && (prefix)[0])
? ((prefix)[1] ? ((prefix)[2] ? strlen(prefix) : 2) : 1)
: 0);
varlist = all_visible_variables();
for (vind = 0; varlist && varlist[vind]; vind++)
;
if (varlist == 0 || vind == 0)
return ((char **)((void *)0));
rlist = strvec_create(vind + 1);
for (vind = rind = 0; varlist[vind]; vind++) {
if (plen == 0 ||
((plen == 0) ? (1)
: ((prefix)[0] == (varlist[vind]->name)[0] &&
strncmp(prefix, varlist[vind]->name, plen) == 0)))
rlist[rind++] = (char *)strcpy(
sh_xmalloc((1 + strlen(varlist[vind]->name)), "variables.c", 4501),
(varlist[vind]->name));
}
rlist[rind] = (char *)0;
sh_xfree((varlist), "variables.c", 4504);
return rlist;
} | long long all_variables_matching_prefix(char a0[3]) {
unsigned int v0;
int tmp_11;
unsigned int v1;
unsigned int v2;
char ***v3;
void *v4;
unsigned int v6;
void *v9;
if (a0 && a0[0]) {
if (!a0[1]) {
v6 = 1;
} else if (a0[2]) {
v6 = strlen(a0);
} else {
v6 = 2;
}
}
if (!a0 || !a0[0])
v6 = 0;
v2 = v6;
v3 = all_visible_variables();
for (v0 = 0; v3; v0 += 1) {
if (!v3[v0])
break;
}
if (v3 && v0) {
v4 = strvec_create(v0 + 1);
v1 = 0;
for (v0 = v1; v3[v0]; v0 += 1) {
if (!v2 || !strncmp(a0, *(v3[v0]), v2) && a0[0] == *(*(v3[v0]))) {
tmp_11 = v1;
v1 += 1;
*((8 * tmp_11 + v4)) =
strcpy(sh_xmalloc(strlen(*(v3[v0])) + 1, "variables.c", 0x1195),
*(v3[v0]));
}
}
*((v4 + 8 * v1)) = 0;
sh_xfree(v3, "variables.c", 0x1198);
v9 = v4;
}
if (!v0 || !v3)
v9 = 0;
return v9;
} | bash | angr_dream |
int channel_setup_local_fwd_listener(struct ssh *ssh, struct Forward *fwd,
struct ForwardOptions *fwd_opts) {
if (fwd->listen_path != ((void *)0)) {
return channel_setup_fwd_listener_streamlocal(ssh, 18, fwd, fwd_opts);
} else {
return channel_setup_fwd_listener_tcpip(ssh, 2, fwd, ((void *)0), fwd_opts);
}
} | long long channel_setup_local_fwd_listener(void *a0, struct_0 *a1,
unsigned int *a2) {
unsigned long long v1;
if (!a1->field_10) {
v1 = channel_setup_fwd_listener_tcpip(a0, 0x2, a1, NULL, a2);
return v1;
}
v1 = channel_setup_fwd_listener_streamlocal(a0, 0x12, a1, a2);
return v1;
} | openssh-portable | angr_sailr |
const char *acl_error(int code) {
switch (code) {
case (0x1000):
return gettext("Multiple entries of same type");
case (0x2000):
return gettext("Duplicate entries");
case (0x3000):
return gettext("Missing or wrong entry");
case (0x4000):
return gettext("Invalid entry type");
default:
return ((void *)0);
}
} | char *acl_error(int a1) {
if (a1 == 0x4000)
return gettext("Invalid entry type");
if (a1 <= 0x4000) {
if (a1 == 12288)
return gettext("Missing or wrong entry");
if (a1 <= 12288) {
if (a1 == 4096)
return gettext("Multiple entries of same type");
if (a1 == 0x2000)
return gettext("Duplicate entries");
}
}
return 0LL;
} | acl-2.3.1 | ida |
static int userauth_hostbased(struct ssh *ssh, const char *method) {
Authctxt *authctxt = ssh->authctxt;
struct sshbuf *b;
struct sshkey *key = ((void *)0);
char *pkalg, *cuser, *chost;
u_char *pkblob, *sig;
size_t alen, blen, slen;
int r, pktype, authenticated = 0;
if ((r = sshpkt_get_cstring(ssh, &pkalg, &alen)) != 0 ||
(r = sshpkt_get_string(ssh, &pkblob, &blen)) != 0 ||
(r = sshpkt_get_cstring(ssh, &chost, ((void *)0))) != 0 ||
(r = sshpkt_get_cstring(ssh, &cuser, ((void *)0))) != 0 ||
(r = sshpkt_get_string(ssh, &sig, &slen)) != 0)
sshfatal("auth2-hostbased.c", __func__, 76, 1, SYSLOG_LEVEL_FATAL,
ssh_err(r), "parse packet");
sshlog("auth2-hostbased.c", __func__, 78, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0),
"cuser %s chost %s pkalg %s slen %zu", cuser, chost, pkalg, slen);
pktype = sshkey_type_from_name(pkalg);
if (pktype == KEY_UNSPEC) {
sshlog("auth2-hostbased.c", __func__, 87, 1, SYSLOG_LEVEL_INFO, ((void *)0),
"unsupported public key algorithm: %s", pkalg);
goto done;
}
if ((r = sshkey_from_blob(pkblob, blen, &key)) != 0) {
sshlog("auth2-hostbased.c", __func__, 92, 1, SYSLOG_LEVEL_ERROR, ssh_err(r),
"key_from_blob");
goto done;
}
if (key == ((void *)0)) {
sshlog("auth2-hostbased.c", __func__, 96, 1, SYSLOG_LEVEL_ERROR,
((void *)0), "cannot decode key: %s", pkalg);
goto done;
}
if (key->type != pktype) {
sshlog("auth2-hostbased.c", __func__, 100, 1, SYSLOG_LEVEL_ERROR,
((void *)0),
"type mismatch for decoded key "
"(received %d, expected %d)",
key->type, pktype);
goto done;
}
if (sshkey_type_plain(key->type) == KEY_RSA &&
(ssh->compat & 0x00002000) != 0) {
sshlog("auth2-hostbased.c", __func__, 106, 0, SYSLOG_LEVEL_ERROR,
((void *)0),
"Refusing RSA key because peer uses unsafe "
"signature format");
goto done;
}
if (match_pattern_list(pkalg, options.hostbased_accepted_algos, 0) != 1) {
sshlog("auth2-hostbased.c", __func__, 111, 1, SYSLOG_LEVEL_INFO,
((void *)0),
"signature algorithm %s not in "
"HostbasedAcceptedAlgorithms",
pkalg);
goto done;
}
if ((r = sshkey_check_cert_sigtype(key, options.ca_sign_algorithms)) != 0) {
sshlog(
"auth2-hostbased.c", __func__, 117, 1, SYSLOG_LEVEL_INFO, ssh_err(r),
"certificate signature algorithm %s",
(key->cert == ((void *)0) || key->cert->signature_type == ((void *)0))
? "(null)"
: key->cert->signature_type)
;
goto done;
}
if ((r = sshkey_check_rsa_length(key, options.required_rsa_size)) != 0) {
sshlog("auth2-hostbased.c", __func__, 124, 0, SYSLOG_LEVEL_INFO, ssh_err(r),
"refusing %s key", sshkey_type(key));
goto done;
}
if (!authctxt->valid || authctxt->user == ((void *)0)) {
sshlog("auth2-hostbased.c", __func__, 129, 1, SYSLOG_LEVEL_DEBUG2,
((void *)0), "disabled because of invalid user");
goto done;
}
if ((b = sshbuf_new()) == ((void *)0))
sshfatal("auth2-hostbased.c", __func__, 134, 1, SYSLOG_LEVEL_FATAL,
((void *)0), "sshbuf_new failed");
if ((r = sshbuf_put_stringb(b, ssh->kex->session_id)) != 0 ||
(r = sshbuf_put_u8(b, 50)) != 0 ||
(r = sshbuf_put_cstring(b, authctxt->user)) != 0 ||
(r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||
(r = sshbuf_put_cstring(b, method)) != 0 ||
(r = sshbuf_put_string(b, pkalg, alen)) != 0 ||
(r = sshbuf_put_string(b, pkblob, blen)) != 0 ||
(r = sshbuf_put_cstring(b, chost)) != 0 ||
(r = sshbuf_put_cstring(b, cuser)) != 0)
sshfatal("auth2-hostbased.c", __func__, 145, 1, SYSLOG_LEVEL_FATAL,
ssh_err(r), "reconstruct packet");
auth2_record_info(authctxt, "client user \"%.100s\", client host \"%.100s\"",
cuser, chost);
authenticated = 0;
if ((use_privsep
? mm_hostbased_key_allowed(ssh, authctxt->pw, cuser, chost, key)
: hostbased_key_allowed(ssh, authctxt->pw, cuser, chost, key)) &&
(use_privsep
? mm_sshkey_verify(key, sig, slen, sshbuf_ptr(b), sshbuf_len(b),
pkalg, ssh->compat, ((void *)0))
: sshkey_verify(key, sig, slen, sshbuf_ptr(b), sshbuf_len(b), pkalg,
ssh->compat, ((void *)0))) == 0)
authenticated = 1;
auth2_record_key(authctxt, authenticated, key);
sshbuf_free(b);
done:
sshlog("auth2-hostbased.c", __func__, 164, 1, SYSLOG_LEVEL_DEBUG2,
((void *)0), "authenticated %d", authenticated);
sshkey_free(key);
free(pkalg);
free(pkblob);
free(cuser);
free(chost);
free(sig);
return authenticated;
} | long long userauth_hostbased(struct_0 *a0, unsigned long long a1) {
unsigned long long v0;
unsigned int v1;
unsigned int v2;
unsigned int v3;
void *v4;
char v5;
char v6;
char v7;
char v8;
char v9;
char v10;
char v11;
char v12;
struct_2 *v13;
unsigned long long v14;
unsigned long long v15;
unsigned long long v16;
unsigned long long v17;
unsigned long v18;
unsigned long long v19;
unsigned long long v20;
char v21;
unsigned long long v22;
char v23;
char v24;
unsigned long long v25;
unsigned long long v27;
unsigned long long v28;
char v29;
v13 = a0->field_860;
v4 = 0;
v2 = 0;
v1 = sshpkt_get_cstring(a0, &v5, &v10, &v5);
if (v1) {
LABEL_400128:
v0 = "parse packet";
sshfatal("auth2-hostbased.c", "userauth_hostbased", 0x4c, 0x1, 0x1,
ssh_err(v1));
} else {
v1 = sshpkt_get_string(a0, &v8, &v11, &v8);
if (!(!v1) || !((v1 = sshpkt_get_cstring(a0, &v7, 0x0, &v7), !v1)))
goto LABEL_400128;
v1 = sshpkt_get_cstring(a0, &v6, 0x0, &v6);
if (v1 || (v1 = sshpkt_get_string(a0, &v9, &v12, &v9), v1))
goto LABEL_400128;
}
v19 = *(&v12);
v18 = *(&v5);
v17 = *(&v7);
v16 = *(&v6);
v15 = "cuser %s chost %s pkalg %s slen %zu";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0x4e, 0x1, 0x5, 0x0,
*(&v21), v22, *(&v23), *(&v24));
v3 = sshkey_type_from_name(*(&v5));
if (v3 == 14) {
v20 = *(&v5);
v19 = "unsupported public key algorithm: %s";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0x57, 0x1, 0x3, 0x0,
*(&v21), v22, *(&v23), *(&v24));
} else {
v1 = sshkey_from_blob(*(&v8), *(&v11), &v4, *(&v11));
if (v1) {
v19 = "key_from_blob";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0x5c, 0x1, 0x2,
ssh_err(v1), *(&v21), v22, *(&v23), *(&v24));
} else if (!v4) {
v20 = *(&v5);
v19 = "cannot decode key: %s";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0x60, 0x1, 0x2, 0x0,
*(&v21), v22, *(&v23), *(&v24));
} else if (v3 != *(v4)) {
v19 = v3;
v18 = *(v4);
v17 = "type mismatch for decoded key (received %d, expected %d)";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0x64, 0x1, 0x2, 0x0,
*(&v21), v22, *(&v23), *(&v24));
} else if (!(sshkey_type_plain(*(v4)) || !(a0->field_83c & 0x2000))) {
v19 = "Refusing RSA key because peer uses unsafe signature format";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0x6a, 0x0, 0x2, 0x0,
*(&v21), v22, *(&v23), *(&v24));
} else if (match_pattern_list(*(&v5), *(5244216), 0x0, *(5244216)) != 1) {
v20 = *(&v5);
v19 = "signature algorithm %s not in HostbasedAcceptedAlgorithms";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0x6f, 0x1, 0x3, 0x0,
*(&v21), v22, *(&v23), *(&v24));
} else {
v1 = sshkey_check_cert_sigtype(v4, *(5244232), *(5244232));
if (v1) {
if (!v4[128] || !*((v4[128] + 88)))
v25 = "(null)";
else
v25 = *((v4[128] + 88));
v20 = v25;
v19 = "certificate signature algorithm %s";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0x75, 0x1, 0x3,
ssh_err(v1), *(&v21), v22, *(&v23), *(&v24));
} else {
v1 = sshkey_check_rsa_length(v4, *(0x501f00), *(0x501f00));
if (v1) {
v20 = sshkey_type(v4);
v19 = "refusing %s key";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0x7c, 0x0, 0x3,
ssh_err(v1), *(&v21), v22, *(&v23), *(&v24));
} else if (!v13->field_c || !v13->field_20) {
v19 = "disabled because of invalid user";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0x81, 0x1, 0x6, 0x0,
*(&v21), v22, *(&v23), *(&v24));
} else {
v14 = sshbuf_new();
if (!v14) {
v19 = "sshbuf_new failed";
sshfatal("auth2-hostbased.c", "userauth_hostbased", 0x86, 0x1, 0x1,
0x0);
}
v1 = sshbuf_put_stringb(v14, a0->field_8->field_70,
a0->field_8->field_70);
if (v1) {
LABEL_40073c:
v19 = "reconstruct packet";
sshfatal("auth2-hostbased.c", "userauth_hostbased", 0x91, 0x1, 0x1,
ssh_err(v1));
} else {
v1 = sshbuf_put_u8(v14, 0x32);
if (!(!v1) ||
!((v1 = sshbuf_put_cstring(v14, v13->field_20, v13->field_20),
!v1)))
goto LABEL_40073c;
v1 = sshbuf_put_cstring(v14, v13->field_28, v13->field_28);
if (!(!v1) || !((v1 = sshbuf_put_cstring(v14, a1, a1), !v1)))
goto LABEL_40073c;
v1 = sshbuf_put_string(v14, *(&v5), *(&v10), *(&v5));
if (!(!v1) ||
!((v1 = sshbuf_put_string(v14, *(&v8), *(&v11), *(&v8)), !v1)))
goto LABEL_40073c;
v1 = sshbuf_put_cstring(v14, *(&v7), *(&v7));
if (v1 || (v1 = sshbuf_put_cstring(v14, *(&v6), *(&v6)), v1))
goto LABEL_40073c;
}
auth2_record_info(v13,
"client user \"%.100s\", client host \"%.100s\"",
*(&v6), *(&v7));
v2 = 0;
if ((!use_privsep ? mm_hostbased_key_allowed(a0, v13->field_30,
*(&v6), *(&v7), v4)
: hostbased_key_allowed(a0, v13->field_30, *(&v6),
*(&v7), v4))) {
if (!use_privsep) {
v27 = *(&v5);
v20 = 0;
v19 = a0->field_83c;
v29 = !sshkey_verify(v4, *(&v9), *(&v12), sshbuf_ptr(v14),
sshbuf_len(v14), v27, *(&v21));
} else {
v28 = *(&v5);
v20 = 0;
v19 = a0->field_83c;
v29 = !mm_sshkey_verify(v4, *(&v9), *(&v12), sshbuf_ptr(v14),
sshbuf_len(v14), v28, *(&v21));
}
if (v29)
v2 = 1;
}
auth2_record_key(v13, v2, v4, v2);
sshbuf_free(v14);
}
}
}
}
v20 = v2;
v19 = "authenticated %d";
sshlog("auth2-hostbased.c", "userauth_hostbased", 0xa4, 0x1, 0x6, 0x0,
*(&v21), v22, *(&v23), *(&v24));
sshkey_free(v4);
free(*(&v5));
free(*(&v8));
free(*(&v6));
free(*(&v7));
free(*(&v9));
return v2;
} | openssh-portable | angr_sailr |
static int cost_table_comparison(const void *p1, const void *p2) {
const struct pred_cost_lookup *pc1 = p1;
const struct pred_cost_lookup *pc2 = p2;
union {
PRED_FUNC pfn;
char mem[sizeof(PRED_FUNC)];
} u1, u2;
u1.pfn = pc1->fn;
u2.pfn = pc2->fn;
return memcmp(u1.mem, u2.mem, sizeof(u1.pfn));
} | long long cost_table_comparison(unsigned long long *a0,
unsigned long long *a1) {
unsigned long v0;
unsigned long v1;
v0 = *(a0);
v1 = *(a1);
return memcmp(&v0, &v1, 0x8);
} | findutils | angr_phoenix |
static void channel_pre_mux_client(struct ssh *ssh, Channel *c) {
c->io_want = 0;
if (c->istate == 0 && !c->mux_pause &&
sshbuf_check_reserve(c->input, (16 * 1024)) == 0)
c->io_want |= 0x01;
if (c->istate == 1) {
sshbuf_reset(c->input);
chan_ibuf_empty(ssh, c);
chan_rcvd_oclose(ssh, c);
}
if (c->ostate == 0 || c->ostate == 1) {
if (sshbuf_len(c->output) > 0)
c->io_want |= 0x02;
else if (c->ostate == 1)
chan_obuf_empty(ssh, c);
}
} | long long channel_pre_mux_client(unsigned long long a0, struct_0 *a1) {
struct_0 *v1;
a1->field_2c = 0;
if (!a1->field_10 && !a1->field_158 &&
!sshbuf_check_reserve(a1->field_68, 0x4000))
a1->field_2c = a1->field_2c | 1;
if (a1->field_10 == 1) {
sshbuf_reset(a1->field_68);
chan_ibuf_empty(a0, a1, a1);
chan_rcvd_oclose(a0, a1, a1);
}
if (a1->field_14) {
v1 = a1->field_14;
if (!(a1->field_14 == 1))
goto LABEL_403266;
}
if (sshbuf_len(a1->field_70)) {
v1 = a1;
a1->field_2c = a1->field_2c | 2;
} else {
v1 = a1->field_14;
if (a1->field_14 == 1)
v1 = chan_obuf_empty(a0, a1, a1);
}
LABEL_403266:
return v1;
} | openssh-portable | angr_phoenix |
void ssh_packet_get_bytes(struct ssh *ssh, u_int64_t *ibytes,
u_int64_t *obytes) {
if (ibytes)
*ibytes = ssh->state->p_read.bytes;
if (obytes)
*obytes = ssh->state->p_send.bytes;
} | _QWORD *ssh_packet_get_bytes(long a1, _QWORD *a2, _QWORD *a3) {
_QWORD *result;
if (a2) {
result = a2;
*a2 = *(_QWORD *)(*(_QWORD *)a1 + 376LL);
}
if (a3) {
result = a3;
*a3 = *(_QWORD *)(*(_QWORD *)a1 + 400LL);
}
return result;
} | openssh-portable | ida |
static inline void _rl_vi_backup(void) {
if ((__ctype_get_mb_cur_max()) > 1 && rl_byte_oriented == 0)
rl_point = _rl_find_prev_mbchar(rl_line_buffer, rl_point, 0x01);
else
rl_point--;
} | void _rl_vi_backup(void)
{
size_t sVar1;
sVar1 = __ctype_get_mb_cur_max();
if ((sVar1 < 2) || (rl_byte_oriented != 0)) {
rl_point = rl_point + -1;
} else {
rl_point = _rl_find_prev_mbchar(rl_line_buffer, rl_point, 1);
}
return;
} | bash | ghidra |
test_code_t test_rfc7507(gnutls_session_t session) {
int ret;
const char *pstr = ((void *)0);
if (tls1_2_ok && tls1_1_ok)
pstr = "-VERS-TLS-ALL:+VERS-TLS1.1:%FALLBACK_SCSV";
else if (tls1_1_ok && tls1_ok)
pstr = "-VERS-TLS-ALL:+VERS-TLS1.0:%FALLBACK_SCSV";
else
return TEST_IGNORE;
sprintf(prio_str,
"NONE:"
"+CIPHER-ALL:+ARCFOUR-128:+3DES-CBC"
":+GOST28147-TC26Z-CNT"
":"
"+COMP-NULL"
":%s:"
"+MAC-ALL:+MD5:+SHA1"
":+GOST28147-TC26Z-IMIT"
":"
"+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+ECDHE-RSA:+ECDHE-ECDSA:+ANON-ECDH"
":+VKO-GOST-12"
":%s",
pstr, rest);
{
int _ret;
if ((_ret = __gnutls_priority_set_direct(session, prio_str, 393)) !=
TEST_SUCCEED) {
return _ret;
}
};
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred);
ret = test_do_handshake(session);
if (ret < 0)
return TEST_IGNORE2;
if (handshake_output < 0)
return TEST_SUCCEED;
return TEST_FAILED;
} | int test_rfc7507(undefined8 param_1)
{
int iVar1;
char *local_10;
if ((tls1_2_ok == 0) || (tls1_1_ok == 0)) {
if ((tls1_1_ok == 0) || (tls1_ok == 0)) {
return 3;
}
local_10 = "-VERS-TLS-ALL:+VERS-TLS1.0:%FALLBACK_SCSV";
} else {
local_10 = "-VERS-TLS-ALL:+VERS-TLS1.1:%FALLBACK_SCSV";
}
sprintf(prio_str,
"NONE:+CIPHER-ALL:+ARCFOUR-128:+3DES-CBC:+GOST28147-TC26Z-CNT:+COMP-"
"NULL:%s:+MAC-ALL:+MD5:+SHA1:+GOST28147-TC26Z-IMIT:+RSA:+DHE-RSA:+"
"DHE-DSS:+ANON-DH:+ECDHE-RSA:+ECDHE-ECDSA:+ANON-ECDH:+VKO-GOST-12:%s",
local_10, rest);
iVar1 = __gnutls_priority_set_direct(param_1, prio_str, 0x189);
if (iVar1 == 0) {
gnutls_credentials_set(param_1, 1, xcred);
iVar1 = test_do_handshake(param_1);
if (iVar1 < 0) {
iVar1 = 4;
} else if (handshake_output < 0) {
iVar1 = 0;
} else {
iVar1 = 1;
}
}
return iVar1;
} | gnutls | ghidra |
static void usage(int status) {
FILE *usageout = (0 != status) ? stderr : stdout;
(void)fprintf(usageout,
gettext("Usage: %s [options] GROUP\n"
"\n"
"Options:\n")
,
Prog);
(void)fputs(gettext(" -f, --force exit successfully if "
"the group already exists,\n"
" and cancel -g if the "
"GID is already used\n"),
usageout);
(void)fputs(
gettext(" -g, --gid GID use GID for the new group\n"),
usageout);
(void)fputs(gettext(" -h, --help display this help "
"message and exit\n"),
usageout);
(void)fputs(gettext(" -K, --key KEY=VALUE override "
"/etc/login.defs defaults\n"),
usageout);
(void)fputs(gettext(" -o, --non-unique allow to create groups "
"with duplicate\n"
" (non-unique) GID\n"),
usageout);
(void)fputs(gettext(" -p, --password PASSWORD use this encrypted "
"password for the new group\n"),
usageout);
(void)fputs(
gettext(" -r, --system create a system account\n"),
usageout);
(void)fputs(
gettext(" -R, --root CHROOT_DIR directory to chroot into\n"),
usageout);
(void)fputs(gettext(" -P, --prefix PREFIX_DI directory prefix\n"),
usageout);
(void)fputs(gettext(" -U, --users USERS list of user members of "
"this group\n"),
usageout);
(void)fputs("\n", usageout);
exit(status);
} | void usage(int param_1)
{
undefined8 uVar1;
FILE *__stream;
char *pcVar2;
uVar1 = Prog;
__stream = stdout;
if (param_1 != 0) {
__stream = stderr;
}
pcVar2 = (char *)gettext("Usage: %s [options] GROUP\n\nOptions:\n");
fprintf(__stream, pcVar2, uVar1);
pcVar2 =
(char *)gettext(" -f, --force exit successfully if "
"the group already exists,\n "
" and cancel -g if the GID is already used\n");
fputs(pcVar2, __stream);
pcVar2 = (char *)gettext(
" -g, --gid GID use GID for the new group\n");
fputs(pcVar2, __stream);
pcVar2 = (char *)gettext(
" -h, --help display this help message and exit\n");
fputs(pcVar2, __stream);
pcVar2 = (char *)gettext(
" -K, --key KEY=VALUE override /etc/login.defs defaults\n");
fputs(pcVar2, __stream);
pcVar2 = (char *)gettext(
" -o, --non-unique allow to create groups with duplicate\n "
" (non-unique) GID\n");
fputs(pcVar2, __stream);
pcVar2 = (char *)gettext(" -p, --password PASSWORD use this encrypted "
"password for the new group\n");
fputs(pcVar2, __stream);
pcVar2 = (char *)gettext(
" -r, --system create a system account\n");
fputs(pcVar2, __stream);
pcVar2 = (char *)gettext(
" -R, --root CHROOT_DIR directory to chroot into\n");
fputs(pcVar2, __stream);
pcVar2 =
(char *)gettext(" -P, --prefix PREFIX_DI directory prefix\n");
fputs(pcVar2, __stream);
pcVar2 = (char *)gettext(
" -U, --users USERS list of user members of this group\n");
fputs(pcVar2, __stream);
fputs("\n", __stream);
exit(param_1);
} | shadow | ghidra |
int rl_fetch_history(int count, int c) {
int wanted, nhist;
if (rl_explicit_arg) {
nhist = history_base + where_history();
wanted = (count >= 0) ? nhist - count : -count;
if (wanted <= 0 || wanted >= nhist) {
if (rl_editing_mode == 0)
rl_ding();
else
rl_beginning_of_history(0, 0);
} else
rl_get_previous_history(wanted, c);
} else
rl_beginning_of_history(count, 0);
return (0);
} | long long rl_fetch_history(unsigned long a0, unsigned long a1) {
unsigned int v0;
unsigned int v1;
unsigned int v2;
unsigned int v5;
v0 = a0;
if (rl_explicit_arg) {
v1 = where_history() + history_base;
if (a0 >= 0)
v5 = v1 - a0;
else
v5 = -(v0);
v2 = v5;
if (v2 > 0 && v2 < v1)
rl_get_previous_history(v2, a1);
if (v2 <= 0 || v2 >= v1) {
if (!rl_editing_mode)
rl_ding();
else
rl_beginning_of_history(0x0, 0x0);
}
} else {
rl_beginning_of_history(a0, 0x0);
}
return 0;
} | bash | angr_dream |
void channel_send_open(struct ssh *ssh, int id) {
Channel *c = channel_lookup(ssh, id);
int r;
if (c == ((void *)0)) {
sshlog("channels.c", __func__, 971, 0, SYSLOG_LEVEL_INFO, ((void *)0),
"channel_send_open: %d: bad id", id);
return;
}
sshlog("channels.c", __func__, 974, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0),
"channel %d: send open", id);
open_preamble(ssh, __func__, c, c->ctype);
if ((r = sshpkt_send(ssh)) != 0)
sshfatal("channels.c", __func__, 977, 1, SYSLOG_LEVEL_FATAL, ssh_err(r),
"channel %i", c->self);
} | void channel_send_open(undefined8 param_1, undefined4 param_2)
{
undefined4 uVar1;
int iVar2;
long lVar3;
undefined8 uVar4;
lVar3 = channel_lookup(param_1, param_2);
if (lVar3 == 0) {
sshlog("channels.c", "channel_send_open", 0x3cb, 0, 3, 0,
"channel_send_open: %d: bad id", param_2);
} else {
sshlog("channels.c", "channel_send_open", 0x3ce, 0, 6, 0,
"channel %d: send open", param_2);
open_preamble(param_1, "channel_send_open", lVar3,
*(undefined8 *)(lVar3 + 200));
iVar2 = sshpkt_send(param_1);
if (iVar2 != 0) {
uVar1 = *(undefined4 *)(lVar3 + 4);
uVar4 = ssh_err(iVar2);
sshfatal("channels.c", "channel_send_open", 0x3d1, 1, 1, uVar4,
"channel %i", uVar1);
}
}
return;
} | openssh-portable | ghidra |
static void process_flags(int argc, char **argv) {
int c;
static struct option long_options[] = {
{"help", 0, ((void *)0), 'h'},
{"quiet", 0, ((void *)0), 'q'},
{"read-only", 0, ((void *)0), 'r'},
{"root", 1, ((void *)0), 'R'},
{"silence-warnings", 0, ((void *)0), 'S'},
{"sort", 0, ((void *)0), 's'},
{((void *)0), 0, ((void *)0), '\0'}};
while ((c = getopt_long(argc, argv, "hqrR:sS", long_options, ((void *)0))) !=
-1) {
switch (c) {
case 'h':
usage(0);
break;
case 'q':
break;
case 'r':
read_only = 1;
break;
case 'R':
break;
case 's':
sort_mode = 1;
break;
case 'S':
silence_warnings = 1;
break;
default:
usage(1);
}
}
if (sort_mode && read_only) {
fprintf(stderr, gettext("%s: -s and -r are incompatible\n"), Prog);
exit(1);
}
if (argc > (optind + 2))
{
usage(1);
}
if (optind != argc) {
grp_file = argv[optind];
gr_setdbname(grp_file);
use_system_grp_file = 0;
}
if ((optind + 2) == argc) {
sgr_file = argv[optind + 1];
sgr_setdbname(sgr_file);
is_shadow = 1;
use_system_sgr_file = 0;
} else if (optind == argc) {
is_shadow = sgr_file_present();
}
} | void process_flags(unsigned long a0, unsigned long long *a1) {
unsigned int v0;
unsigned long long v2;
unsigned long long v3;
while (true) {
v0 = getopt_long(a0, a1, "hqrR:sS", &long_options.5698, NULL);
if (v0 == -1)
break;
switch (v0) {
case 82:
case 113:
break;
case 83:
silence_warnings = 1;
break;
case 104:
usage(0x0);
case 114:
read_only = 1;
break;
case 115:
sort_mode = 1;
break;
default:
usage(0x1);
}
}
if (sort_mode && read_only) {
fprintf(stderr, gettext("%s: -s and -r are incompatible\n"));
exit(0x1);
}
if (a0 > optind + 2)
usage(0x1);
if (a0 != optind) {
grp_file = a1[optind];
gr_setdbname(grp_file);
use_system_grp_file = 0;
}
if (a0 == optind + 2) {
sgr_file = a1[1 + optind];
v3 = sgr_setdbname(sgr_file);
is_shadow = 1;
use_system_sgr_file = 0;
} else {
v2 = optind;
if (a0 == optind)
*(&is_shadow) = sgr_file_present();
}
return;
} | shadow | angr_phoenix |
void leave_raw_mode(int quiet) {
if (!_in_raw_mode)
return;
if (tcsetattr(fileno(stdin), 1, &_saved_tio) == -1) {
if (!quiet)
perror("tcsetattr");
} else
_in_raw_mode = 0;
} | long long leave_raw_mode(unsigned long a0) {
unsigned long long v1;
v1 = _in_raw_mode;
if (!_in_raw_mode)
return v1;
v1 = tcsetattr(fileno(stdin), 0x1, &_saved_tio);
if (v1 != -1) {
_in_raw_mode = 0;
return v1;
} else if (a0) {
return v1;
} else {
v1 = perror("tcsetattr");
return v1;
}
} | openssh-portable | angr_sailr |
static struct tblentry *cmdlookup(const char *name, int add) {
unsigned int hashval;
const char *p;
struct tblentry *cmdp;
struct tblentry **pp;
p = name;
hashval = (unsigned char)*p << 4;
while (*p)
hashval += (unsigned char)*p++;
hashval &= 0x7FFF;
pp = &cmdtable[hashval % 31];
for (cmdp = *pp; cmdp; cmdp = cmdp->next) {
if ((strcmp(cmdp->cmdname, name) == 0))
break;
pp = &cmdp->next;
}
if (add && cmdp == ((void *)0)) {
cmdp = *pp = ckmalloc(sizeof(struct tblentry) - 1 + strlen(name) + 1);
cmdp->next = ((void *)0);
cmdp->cmdtype = -1;
strcpy(cmdp->cmdname, name);
}
lastcmdentry = pp;
return cmdp;
} | undefined8 *cmdlookup(byte *param_1, int param_2)
{
int iVar1;
size_t sVar2;
undefined8 uVar3;
uint local_24;
byte *local_20;
undefined8 *local_18;
undefined8 *local_10;
local_24 = (uint)*param_1 << 4;
for (local_20 = param_1; *local_20 != 0; local_20 = local_20 + 1) {
local_24 = local_24 + *local_20;
}
local_10 = (undefined8 *)(cmdtable + (ulong)((local_24 & 0x7fff) % 0x1f) * 8);
local_18 = (undefined8 *)*local_10;
while ((local_18 != (undefined8 *)0x0 &&
(iVar1 = strcmp((char *)((long)local_18 + 0x13), (char *)param_1),
iVar1 != 0))) {
local_10 = local_18;
local_18 = (undefined8 *)*local_18;
}
if ((param_2 != 0) && (local_18 == (undefined8 *)0x0)) {
sVar2 = strlen((char *)param_1);
uVar3 = ckmalloc(sVar2 + 0x18);
*local_10 = uVar3;
local_18 = (undefined8 *)*local_10;
*local_18 = 0;
*(undefined2 *)(local_18 + 2) = 0xffff;
strcpy((char *)((long)local_18 + 0x13), (char *)param_1);
}
lastcmdentry = local_10;
return local_18;
} | dash-0.5.11+git20210903+057cd650a4ed | ghidra |
static int worst_cost(const struct predicate *p) {
if (p) {
unsigned int cost_r, cost_l, worst;
cost_l = worst_cost(p->pred_left);
cost_r = worst_cost(p->pred_right);
worst = (cost_l > cost_r) ? cost_l : cost_r;
if (worst < p->p_cost)
worst = p->p_cost;
return worst;
} else {
return 0;
}
} | int worst_cost(struct_0 *a0) {
unsigned int v0;
unsigned int v1;
unsigned int v2;
unsigned int v4;
unsigned int v5;
if (!a0) {
v4 = 0;
} else {
v1 = worst_cost(a0->field_110);
v2 = worst_cost(a0->field_118);
v5 = v1;
if (v1 <= v2)
v5 = v2;
v0 = v5;
if (v0 < a0->field_20)
v0 = a0->field_20;
v4 = v0;
}
return v4;
} | findutils | angr_phoenix |
static rsRetVal writePidFile(void) {
FILE *fp;
rsRetVal iRet = RS_RET_OK;
const char *tmpPidFile;
if (!strcmp(PidFile, "NONE")) {
goto finalize_it;
;
}
if (asprintf((char **)&tmpPidFile, "%s.tmp", PidFile) == -1) {
do {
iRet = RS_RET_OUT_OF_MEMORY;
goto finalize_it;
} while (0);
}
if (tmpPidFile == ((void *)0))
tmpPidFile = PidFile;
if (Debug) {
r_dbgprintf("rsyslogd.c", "rsyslogd: writing pidfile '%s'.\n", tmpPidFile);
};
if ((fp = fopen((char *)tmpPidFile, "w")) == ((void *)0)) {
perror("rsyslogd: error writing pid file (creation stage)\n");
do {
iRet = RS_RET_ERR;
goto finalize_it;
} while (0);
}
if (fprintf(fp, "%d", (int)glbl_ourpid) < 0) {
LogError((*__errno_location()), iRet, "rsyslog: error writing pid file");
}
fclose(fp);
if (tmpPidFile != PidFile) {
if (rename(tmpPidFile, PidFile) != 0) {
perror("rsyslogd: error writing pid file (rename stage)");
}
free((void *)tmpPidFile);
}
finalize_it:
return iRet;
} | int writePidFile() {
unsigned int v0;
void *v1;
void *v2;
v0 = 0;
if (strcmp(PidFile, "NONE")) {
if (asprintf(&v1, "%s.tmp", PidFile) == -1) {
v0 = -6;
} else {
if (!v1)
v1 = PidFile;
if (Debug)
r_dbgprintf("rsyslogd.c", "rsyslogd: writing pidfile '%s'.\n", v1);
v2 = fopen(v1, "w");
if (!v2) {
perror("rsyslogd: error writing pid file (creation stage)\n");
v0 = -3000;
} else {
if (fprintf(v2, "%d", glbl_ourpid) < 0)
LogError(*(__errno_location()), v0, "rsyslog: error writing pid file",
v0);
fclose(v2);
if (v1 != PidFile) {
if (rename(v1, PidFile))
perror("rsyslogd: error writing pid file (rename stage)");
free(v1);
}
}
}
}
return v0;
} | rsyslog-8.2210.0 | angr_dream |
static void dump_cfg_strarray(ServerOpCodes code, u_int count, char **vals) {
u_int i;
for (i = 0; i < count; i++)
printf("%s %s\n", lookup_opcode_name(code), vals[i]);
} | void dump_cfg_strarray(unsigned long a0, unsigned long a1,
unsigned long long *a2) {
unsigned int v0;
unsigned long long v2;
v0 = 0;
while (true) {
v2 = v0;
if (v0 >= a1)
break;
printf("%s %s\n", lookup_opcode_name(a0), a2[v0]);
v0 += 1;
}
return;
} | openssh-portable | angr_dream |
int main(int argc, char **argv) {
char proc_dir_name[32];
char *target_str;
pid_t target;
int proc_dir_fd;
int ranges;
struct map_range *mappings;
struct stat st;
struct passwd *pw;
int written;
_Bool allow_setgroups = 0;
Prog = Basename(argv[0]);
log_set_progname(Prog);
log_set_logfd(stderr);
if (argc < 2)
usage();
target_str = argv[1];
if (!get_pid(target_str, &target))
usage();
written = snprintf(proc_dir_name, sizeof(proc_dir_name), "/proc/%u/", target);
if ((written <= 0) || (written >= sizeof(proc_dir_name))) {
fprintf(stderr, "%s: snprintf of proc path failed: %s\n", Prog,
strerror((*__errno_location())));
}
proc_dir_fd = open(proc_dir_name, 0200000);
if (proc_dir_fd < 0) {
fprintf(stderr,
gettext("%s: Could not open proc directory for target %u\n"), Prog,
target);
return 1;
}
pw = get_my_pwent();
if (((void *)0) == pw) {
fprintf(stderr, gettext("%s: Cannot determine your user name.\n"), Prog);
do {
char *old_locale = setlocale(6, ((void *)0));
char *saved_locale = ((void *)0);
if (((void *)0) != old_locale) {
saved_locale = strdup(old_locale);
}
if (((void *)0) != saved_locale) {
(void)setlocale(6, "C");
}
syslog(4, "Cannot determine the user name of the caller (UID %lu)",
(unsigned long)getuid());
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0);
return 1;
}
if (fstat(proc_dir_fd, &st) < 0) {
fprintf(stderr, gettext("%s: Could not stat directory for target %u\n"),
Prog, target);
return 1;
}
if ((getuid() != pw->pw_uid) ||
(!getdef_bool("GRANT_AUX_GROUP_SUBIDS") && (getgid() != pw->pw_gid)) ||
(pw->pw_uid != st.st_uid) || (getgid() != st.st_gid)) {
fprintf(stderr,
gettext("%s: Target %u is owned by a different user: uid:%lu "
"pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n"),
Prog, target, (unsigned long int)getuid(),
(unsigned long int)pw->pw_uid, (unsigned long int)st.st_uid,
(unsigned long int)getgid(), (unsigned long int)pw->pw_gid,
(unsigned long int)st.st_gid);
return 1;
}
if (!sub_gid_open(00)) {
return 1;
}
ranges = ((argc - 2) + 2) / 3;
mappings = get_map_ranges(ranges, argc - 2, argv + 2);
if (!mappings)
usage();
verify_ranges(pw, ranges, mappings, &allow_setgroups);
write_setgroups(proc_dir_fd, allow_setgroups);
write_mapping(proc_dir_fd, ranges, mappings, "gid_map", pw->pw_uid);
sub_gid_close();
return 0;
} | int main(unsigned long a0, unsigned long long a1[2], unsigned int a2,
unsigned long a3, unsigned long long a4, unsigned long long a5) {
unsigned long v0;
unsigned long v1;
unsigned long v2;
unsigned long v3;
unsigned long v4;
unsigned long v5;
unsigned long v6;
char v7;
char v8;
unsigned int v9;
unsigned int v10;
unsigned int v11;
void *v12;
unsigned long long v13;
unsigned int v14[6];
void *v15;
char *v16;
char v17;
char v18;
char v19;
char v20;
unsigned int v22;
unsigned long long v24;
v7 = 0;
Prog = Basename(a1[0]);
log_set_progname(0xf87d894820ec8348);
log_set_logfd(stderr);
if (a0 <= 1)
usage();
v13 = a1[1];
if (!get_pid(v13, &v8, &v8))
usage();
v9 = snprintf(&v20, 0x20, "/proc/%u/", *(&v8));
if (v9 <= 0 || v9 > 31)
fprintf(stderr, "%s: snprintf of proc path failed: %s\n", 552371016,
strerror(*(__errno_location())));
v10 = open(&v20, 0x10000, 0x8348);
if (v10 < 0) {
fprintf(stderr,
gettext("%s: Could not open proc directory for target %u\n"));
v22 = 1;
return v22;
}
*(&v14[0]) = get_my_pwent();
if (!v14) {
fprintf(stderr, gettext("%s: Cannot determine your user name.\n"));
v16 = setlocale(0x6, NULL);
v12 = 0;
if (v16)
v12 = strdup(v16);
if (v12)
setlocale(0x6, "C");
getuid();
syslog(0x4, "Cannot determine the user name of the caller (UID %lu)");
if (v12) {
setlocale(0x6, v12);
free(v12);
v22 = 1;
return v22;
}
v22 = 1;
return v22;
} else if (fstat(v10, &v17) < 0) {
fprintf(stderr, gettext("%s: Could not stat directory for target %u\n"));
v22 = 1;
return v22;
} else {
if (getuid() == v14[4] &&
(!(getdef_bool("GRANT_AUX_GROUP_SUBIDS") ^ 1) || getgid() == v14[5]) &&
v14[4] == *(&v18) && getgid() == *(&v19)) {
if (sub_gid_open(0x0)) {
v11 = (a0 * 1431655766 >> 32) - (a0 >> 31);
v15 = get_map_ranges(v11, a0 - 2, a1 + 1, a0 - 2);
if (v15) {
verify_ranges(v14, v11, v15, &v7);
write_setgroups(v10, v7);
write_mapping(v10, v11, v15, "gid_map", v14[4]);
sub_gid_close(v10, v11, 0x20ec8348, "gid_map", a4, a5);
v22 = 0;
return v22;
}
usage();
} else {
v22 = 1;
return v22;
}
}
v6 = *(&v19);
v24 = *(&v18);
v5 = v14[4];
v4 = getuid();
v3 = v6;
v2 = v14[5];
v1 = getgid();
v0 = v24;
fprintf(stderr,
gettext("%s: Target %u is owned by a different user: uid:%lu "
"pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n"));
v22 = 1;
return v22;
}
} | shadow | angr_sailr |
void log_redirect_stderr_to(const char *logfile) {
int fd;
if (logfile == ((void *)0)) {
if (log_stderr_fd != 2) {
close(log_stderr_fd);
log_stderr_fd = 2;
}
return;
}
if ((fd = open(logfile, 01 | 0100 | 02000, 0600)) == -1) {
fprintf(stderr, "Couldn't open logfile %s: %s\n", logfile,
strerror((*__errno_location())));
exit(1);
}
log_stderr_fd = fd;
} | long long log_redirect_stderr_to(char *a0) {
unsigned int v0;
unsigned long long v2;
if (a0) {
v0 = open(a0, 0x441, 0x180);
if (v0 != -1) {
v2 = v0;
log_stderr_fd = v0;
return v2;
}
fprintf(stderr, "Couldn't open logfile %s: %s\n", a0,
strerror(*(__errno_location())));
exit(0x1);
} else {
v2 = log_stderr_fd;
if (log_stderr_fd != 2) {
v2 = close(log_stderr_fd);
log_stderr_fd = 2;
return v2;
}
return v2;
}
} | openssh-portable | angr_sailr |
int main(int argc, char **argv) {
const struct group *gr;
struct group grent;
const struct sgrp *sg;
struct sgrp sgent;
Prog = Basename(argv[0]);
log_set_progname(Prog);
log_set_logfd(stderr);
(void)setlocale(6, "");
(void)bindtextdomain("shadow", "/usr/share/locale");
(void)textdomain("shadow");
process_root_flag("-R", argc, argv);
openlog("grpconv", (0x01), (10 << 3));
process_flags(argc, argv);
if (gr_lock() == 0) {
fprintf(stderr, gettext("%s: cannot lock %s; try again later.\n"), Prog,
gr_dbname());
fail_exit(5);
}
gr_locked = 1;
if (gr_open(0100 | 02) == 0) {
fprintf(stderr, gettext("%s: cannot open %s\n"), Prog, gr_dbname());
fail_exit(1);
}
if (sgr_lock() == 0) {
fprintf(stderr, gettext("%s: cannot lock %s; try again later.\n"), Prog,
sgr_dbname());
fail_exit(5);
}
sgr_locked = 1;
if (sgr_open(0100 | 02) == 0) {
fprintf(stderr, gettext("%s: cannot open %s\n"), Prog, sgr_dbname());
fail_exit(1);
}
(void)sgr_rewind();
while ((sg = sgr_next()) != ((void *)0)) {
if (gr_locate(sg->sg_name) != ((void *)0)) {
continue;
}
if (sgr_remove(sg->sg_name) == 0) {
fprintf(stderr, gettext("%s: cannot remove entry '%s' from %s\n"), Prog,
sg->sg_name, sgr_dbname());
fail_exit(3);
}
(void)sgr_rewind();
}
(void)gr_rewind();
while ((gr = gr_next()) != ((void *)0)) {
sg = sgr_locate(gr->gr_name);
if (((void *)0) != sg) {
sgent = *sg;
if (strcmp(gr->gr_passwd, "x") != 0)
sgent.sg_passwd = gr->gr_passwd;
} else {
static char *empty = 0;
memset(&sgent, 0, sizeof sgent);
sgent.sg_name = gr->gr_name;
sgent.sg_passwd = gr->gr_passwd;
sgent.sg_adm = ∅
}
sgent.sg_mem = gr->gr_mem;
if (sgr_update(&sgent) == 0) {
fprintf(stderr, gettext("%s: failed to prepare the new %s entry '%s'\n"),
Prog, sgr_dbname(), sgent.sg_name);
fail_exit(3);
}
grent = *gr;
grent.gr_passwd = "x";
if (gr_update(&grent) == 0) {
fprintf(stderr, gettext("%s: failed to prepare the new %s entry '%s'\n"),
Prog, gr_dbname(), grent.gr_name);
fail_exit(3);
}
}
if (sgr_close() == 0) {
fprintf(stderr, gettext("%s: failure while writing changes to %s\n"), Prog,
sgr_dbname());
do {
char *old_locale = setlocale(6, ((void *)0));
char *saved_locale = ((void *)0);
if (((void *)0) != old_locale) {
saved_locale = strdup(old_locale);
}
if (((void *)0) != saved_locale) {
(void)setlocale(6, "C");
}
syslog(3, "failure while writing changes to %s", sgr_dbname());
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0);
fail_exit(3);
}
if (gr_close() == 0) {
fprintf(stderr, gettext("%s: failure while writing changes to %s\n"), Prog,
gr_dbname());
do {
char *old_locale = setlocale(6, ((void *)0));
char *saved_locale = ((void *)0);
if (((void *)0) != old_locale) {
saved_locale = strdup(old_locale);
}
if (((void *)0) != saved_locale) {
(void)setlocale(6, "C");
}
syslog(3, "failure while writing changes to %s", gr_dbname());
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0);
fail_exit(3);
}
if (sgr_unlock() == 0) {
fprintf(stderr, gettext("%s: failed to unlock %s\n"), Prog, sgr_dbname());
do {
char *old_locale = setlocale(6, ((void *)0));
char *saved_locale = ((void *)0);
if (((void *)0) != old_locale) {
saved_locale = strdup(old_locale);
}
if (((void *)0) != saved_locale) {
(void)setlocale(6, "C");
}
syslog(3, "failed to unlock %s", sgr_dbname());
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0);
}
if (gr_unlock() == 0) {
fprintf(stderr, gettext("%s: failed to unlock %s\n"), Prog, gr_dbname());
do {
char *old_locale = setlocale(6, ((void *)0));
char *saved_locale = ((void *)0);
if (((void *)0) != old_locale) {
saved_locale = strdup(old_locale);
}
if (((void *)0) != saved_locale) {
(void)setlocale(6, "C");
}
syslog(3, "failed to unlock %s", gr_dbname());
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0);
}
nscd_flush_cache("group");
sssd_flush_cache(0x002);
return 0;
} | int main(unsigned long a0, unsigned long long *a1, unsigned int a2,
unsigned long long a3, unsigned long long a4, unsigned long long a5) {
void *v0;
void *v1;
void *v2;
void *v3;
unsigned long long *v4;
unsigned long long v5[4];
char *v6;
char *v7;
char *v8;
char *v9;
unsigned long v10;
unsigned long v11;
unsigned long v12;
unsigned long v13;
unsigned long v14;
unsigned long v15;
unsigned long v16;
unsigned long v17;
unsigned long long v19;
unsigned long long v20;
unsigned long long v21;
unsigned long long v22;
unsigned long long v23;
unsigned long long v24;
unsigned long long v25;
unsigned long long v26;
unsigned long long v27;
unsigned long long v28;
unsigned long long v29;
unsigned long long v30;
Prog = Basename(*(a1));
log_set_progname(0x8930ec8348535441);
log_set_logfd(stderr);
setlocale(0x6, &g_400c78);
bindtextdomain("shadow", "/usr/share/locale");
textdomain("shadow");
process_root_flag("-R", a0, a1);
openlog("grpconv", 0x1, 0x50);
process_flags(a0, a1);
v19 = gr_lock(a0, a1, 0x50, a3, a4, a5);
if (!v19) {
v20 = gr_dbname();
fprintf(stderr, gettext("%s: cannot lock %s; try again later.\n"));
fail_exit(0x5);
}
gr_locked = 1;
if (!gr_open(0x42)) {
v21 = gr_dbname();
fprintf(stderr, gettext("%s: cannot open %s\n"));
fail_exit(0x1);
} else if (sgr_lock()) {
sgr_locked = 1;
if (!sgr_open(0x42)) {
v23 = sgr_dbname();
fprintf(stderr, gettext("%s: cannot open %s\n"));
fail_exit(0x1);
}
sgr_rewind();
while (true) {
v4 = sgr_next();
if (!v4)
break;
if (!gr_locate(*(v4))) {
if (sgr_remove(*(v4))) {
sgr_rewind();
} else {
v24 = sgr_dbname();
fprintf(stderr, gettext("%s: cannot remove entry '%s' from %s\n"));
fail_exit(0x3);
}
}
}
gr_rewind();
while (true) {
v5[0] = gr_next();
if (!v5)
break;
v4[0] = sgr_locate(v5[0]);
if (v4) {
v14 = v4[0];
v15 = v4[1];
v16 = v4[2];
v17 = v4[3];
if (strcmp(v5[1], "x"))
v15 = v5[1];
} else {
memset(&v14, 0x0, 0x20);
v14 = v5[0];
v15 = v5[1];
v16 = &empty.5668;
}
v17 = v5[3];
if (!sgr_update(&v14)) {
v25 = sgr_dbname();
fprintf(stderr,
gettext("%s: failed to prepare the new %s entry '%s'\n"));
fail_exit(0x3);
}
v10 = v5[0];
v11 = v5[1];
v12 = v5[2];
v13 = v5[3];
v11 = "x";
if (!gr_update(&v10)) {
v26 = gr_dbname();
fprintf(stderr,
gettext("%s: failed to prepare the new %s entry '%s'\n"));
fail_exit(0x3);
}
}
if (!sgr_close()) {
v27 = sgr_dbname();
fprintf(stderr, gettext("%s: failure while writing changes to %s\n"));
v6 = setlocale(0x6, NULL);
v0 = 0;
if (v6)
v0 = strdup(v6);
if (v0)
setlocale(0x6, "C");
sgr_dbname();
syslog(0x3, "failure while writing changes to %s");
if (v0) {
setlocale(0x6, v0);
free(v0);
}
fail_exit(0x3);
} else if (!gr_close()) {
v28 = gr_dbname();
fprintf(stderr, gettext("%s: failure while writing changes to %s\n"));
v7 = setlocale(0x6, NULL);
v1 = 0;
if (v7)
v1 = strdup(v7);
if (v1)
setlocale(0x6, "C");
gr_dbname();
syslog(0x3, "failure while writing changes to %s");
if (v1) {
setlocale(0x6, v1);
free(v1);
}
fail_exit(0x3);
} else if (!sgr_unlock()) {
v29 = sgr_dbname();
fprintf(stderr, gettext("%s: failed to un"));
v8 = setlocale(0x6, NULL);
v2 = 0;
if (v8)
v2 = strdup(v8);
if (v2)
setlocale(0x6, "C");
sgr_dbname();
syslog(0x3, "failed to unlock %s");
if (v2) {
setlocale(0x6, v2);
free(v2);
}
}
if (!gr_unlock()) {
v30 = gr_dbname();
fprintf(stderr, gettext("%s: failed to un"));
v9 = setlocale(0x6, NULL);
v3 = 0;
if (v9)
v3 = strdup(v9);
if (v3)
setlocale(0x6, "C");
gr_dbname();
syslog(0x3, "failed to unlock %s");
if (v3) {
setlocale(0x6, v3);
free(v3);
}
}
nscd_flush_cache("group");
sssd_flush_cache(0x2);
return 0;
} else {
v22 = sgr_dbname();
fprintf(stderr, gettext("%s: cannot lock %s; try again later.\n"));
fail_exit(0x5);
}
} | shadow | angr_sailr |
void usage(int status) {
if (status != 0)
do {
fprintf(stderr, gettext("Try '%s --help' for more information.\n"),
program_name);
} while (0);
else {
printf(gettext("Usage: %s [OPTION]... [FILE]...\n")
,
program_name);
fputs_unlocked(gettext("Convert tabs in each FILE to spaces, writing to "
"standard output.\n"),
stdout)
;
emit_stdin_note();
emit_mandatory_arg_note();
fputs_unlocked(
gettext(" -i, --initial do not convert tabs after non blanks\n "
"-t, --tabs=N have tabs N characters apart, not 8\n"),
stdout)
;
emit_tab_list_info();
fputs_unlocked(gettext(" --help display this help and exit\n"),
stdout);
fputs_unlocked(
gettext(" --version output version information and exit\n"),
stdout);
emit_ancillary_info("expand");
}
exit(status);
} | void usage(int a1) {
long v1;
char *v2;
char *v3;
FILE *v4;
char *v5;
FILE *v6;
char *v7;
FILE *v8;
char *v9;
FILE *v10;
char *v11;
v1 = program_name;
if (a1) {
v2 = gettext("Try '%s --help' for more information.\n");
fprintf(stderr, v2, v1);
} else {
v3 = gettext("Usage: %s [OPTION]... [FILE]...\n");
printf(v3, v1);
v4 = stdout;
v5 = gettext(
"Convert tabs in each FILE to spaces, writing to standard output.\n");
fputs_unlocked(v5, v4);
emit_stdin_note();
emit_mandatory_arg_note();
v6 = stdout;
v7 = gettext(" -i, --initial do not convert tabs after non blanks\n"
" -t, --tabs=N have tabs N characters apart, not 8\n");
fputs_unlocked(v7, v6);
emit_tab_list_info();
v8 = stdout;
v9 = gettext(" --help display this help and exit\n");
fputs_unlocked(v9, v8);
v10 = stdout;
v11 = gettext(" --version output version information and exit\n");
fputs_unlocked(v11, v10);
emit_ancillary_info("expand");
}
exit(a1);
} | coreutils | ida |
int sshpkt_put_stringb(struct ssh *ssh, const struct sshbuf *v) {
return sshbuf_put_stringb(ssh->state->outgoing_packet, v);
} | long sshpkt_put_stringb(long a1, long a2) {
return sshbuf_put_stringb(*(_QWORD *)(*(_QWORD *)a1 + 48LL), a2);
} | openssh-portable | ida |
static inline _Bool
field_sep(unsigned char ch) {
return ((*__ctype_b_loc())[(int)((ch))] & (unsigned short int)_ISblank) ||
ch == '\n';
} | int field_sep(unsigned long a0) {
unsigned int v2;
unsigned int v3;
unsigned int v4;
v2 = *((*(__ctype_b_loc()) + a0 * 2)) & 1;
if (v2 || a0 == 10)
v3 = 1;
else
v3 = 0;
v4 = v3 & 1;
return v4;
} | coreutils | angr_sailr |
static void add_user(const char *user, const struct group *grp) {
struct group *newgrp;
if (is_on_list(grp->gr_mem, user)) {
fprintf(stderr, gettext("%s: user '%s' is already a member of '%s'\n"),
Prog, user, grp->gr_name);
fail_exit(7);
}
newgrp = __gr_dup(grp);
if (((void *)0) == newgrp) {
fprintf(stderr, gettext("%s: Out of memory. Cannot update %s.\n"), Prog,
gr_dbname());
fail_exit(13);
}
newgrp->gr_mem = add_list(newgrp->gr_mem, user);
if (is_shadowgrp) {
const struct sgrp *sg = sgr_locate(newgrp->gr_name);
struct sgrp *newsg;
if (((void *)0) == sg) {
static struct sgrp sgrent;
sgrent.sg_name = xstrdup(newgrp->gr_name);
sgrent.sg_mem = dup_list(newgrp->gr_mem);
sgrent.sg_adm = (char **)xmalloc(sizeof(char *));
{
sgrent.sg_adm[0] = ((void *)0);
}
sgrent.sg_passwd = newgrp->gr_passwd;
newgrp->gr_passwd = "x";
newsg = &sgrent;
} else {
newsg = __sgr_dup(sg);
if (((void *)0) == newsg) {
fprintf(stderr, gettext("%s: Out of memory. Cannot update %s.\n"), Prog,
sgr_dbname());
fail_exit(13);
}
newsg->sg_mem = add_list(newsg->sg_mem, user);
}
if (sgr_update(newsg) == 0) {
fprintf(stderr, gettext("%s: failed to prepare the new %s entry '%s'\n"),
Prog, sgr_dbname(), newsg->sg_name);
fail_exit(13);
}
}
if (gr_update(newgrp) == 0) {
fprintf(stderr, gettext("%s: failed to prepare the new %s entry '%s'\n"),
Prog, gr_dbname(), newgrp->gr_name);
fail_exit(13);
}
} | void add_user(unsigned long long a0, struct_0 *a1) {
unsigned long long v0;
unsigned long long v1[4];
unsigned long long v2;
unsigned long long v4;
unsigned long long v5;
unsigned long long v7;
unsigned long long v8;
if (is_on_list(a1->field_18, a0, a0)) {
fprintf(*(&stderr), gettext("%s: user '%s' is already a member of '%s'\n"));
fail_exit(0x7);
}
v1[0] = __gr_dup(a1);
if (!v1) {
v4 = gr_dbname();
fprintf(*(&stderr), gettext("%s: Out of memory. Cannot update %s.\n"));
fail_exit(0xd);
}
v1[3] = add_list(v1[3], a0, a0);
if (is_shadowgrp) {
v2 = sgr_locate(v1[0]);
if (!v2) {
sgrent.5662 = xstrdup(v1[0]);
g_4016b8 = dup_list(v1[3]);
g_4016b0 = xmalloc(0x8);
*(g_4016b0) = 0;
g_4016a8 = v1[1];
v1[1] = "x";
v0 = &sgrent.5662;
} else {
v0 = __sgr_dup(v2);
if (!v0) {
v5 = sgr_dbname();
fprintf(*(&stderr), gettext("%s: Out of memory. Cannot update %s.\n"));
fail_exit(0xd);
}
*((v0 + 24)) = add_list(*((v0 + 24)), a0, a0);
}
if (!sgr_update(v0)) {
v7 = sgr_dbname();
fprintf(*(&stderr),
gettext("%s: failed to prepare the new %s entry '%s'\n"));
fail_exit(0xd);
}
}
if (!gr_update(v1)) {
v8 = gr_dbname();
fprintf(*(&stderr),
gettext("%s: failed to prepare the new %s entry '%s'\n"));
fail_exit(0xd);
}
return;
} | shadow | angr_sailr |
_Bool
_rl_print_prefix_color (void)
{
struct bin_str *s;
s = _rl_custom_readline_prefix();
if (s == 0)
s = &_rl_color_indicator[C_SOCK];
if (s->string != ((void *)0)) {
if (is_colored(C_NORM))
restore_default_color();
_rl_put_indicator(&_rl_color_indicator[C_LEFT]);
_rl_put_indicator(s);
_rl_put_indicator(&_rl_color_indicator[C_RIGHT]);
return 0;
} else
return 1;
} | undefined8 _rl_print_prefix_color(void)
{
char cVar1;
undefined8 uVar2;
long local_10;
local_10 = _rl_custom_readline_prefix();
if (local_10 == 0) {
local_10 = 0x1010a0;
}
if (*(long *)(local_10 + 8) == 0) {
uVar2 = 1;
} else {
cVar1 = is_colored(4);
if (cVar1 != '\0') {
restore_default_color();
}
_rl_put_indicator(&_rl_color_indicator);
_rl_put_indicator(local_10);
_rl_put_indicator(strlen);
uVar2 = 0;
}
return uVar2;
} | bash | ghidra |
static void delete_cmd_entry(void) {
struct tblentry *cmdp;
({
suppressint++;
({ __asm__ __volatile__("" : : : "memory"); });
0;
});
cmdp = *lastcmdentry;
*lastcmdentry = cmdp->next;
if (cmdp->cmdtype == 1)
freefunc(cmdp->param.func);
free((pointer)(cmdp));
({
({ __asm__ __volatile__("" : : : "memory"); });
if (--suppressint == 0 && intpending)
onint();
0;
});
} | void delete_cmd_entry() {
struct_0 *v0;
unsigned long long v2;
unsigned long long v3;
unsigned long long v4;
suppressint = suppressint + 1;
v0 = g_f0758948f87d8948;
g_f0758948f87d8948 = v0->field_0;
if (v0->field_10 == 1)
freefunc(v0->field_8);
free(v0);
suppressint = suppressint - 1;
v2 = suppressint;
if (!suppressint) {
v3 = intpending;
if (intpending)
v4 = onint();
}
return;
} | dash-0.5.11+git20210903+057cd650a4ed | angr_dream |
int ttnoecho() {
struct termios tt;
if (ttsaved == 0)
return -1;
tt = ttin;
return (ttfd_noecho(0, &tt));
} | long long ttnoecho() {
unsigned long v0;
unsigned long v1;
unsigned long v2;
unsigned long v3;
unsigned long v4;
unsigned long v5;
unsigned long v6;
unsigned int v7;
unsigned long long v9;
if (!ttsaved) {
v9 = 4294967295;
} else {
v0 = ttin;
v1 = g_400748;
v2 = g_400750;
v3 = g_400758;
v4 = g_400760;
v5 = g_400768;
v6 = g_400770;
v7 = g_400778;
v9 = ttfd_noecho(0x0, &v0);
}
return v9;
} | bash | angr_phoenix |
static int set_saved_history() {
int absolute_offset, count;
if (saved_history_logical_offset >= 0) {
absolute_offset = saved_history_logical_offset - history_base;
count = where_history() - absolute_offset;
rl_get_previous_history(count, 0);
}
saved_history_logical_offset = -1;
_rl_internal_startup_hook = _rl_saved_internal_startup_hook;
return (0);
} | undefined8 set_saved_history(void)
{
int iVar1;
int iVar2;
if (-1 < saved_history_logical_offset) {
iVar2 = saved_history_logical_offset - history_base;
iVar1 = where_history();
rl_get_previous_history(iVar1 - iVar2, 0);
}
saved_history_logical_offset = 0xffffffff;
_rl_internal_startup_hook = _rl_saved_internal_startup_hook;
return 0;
} | bash | ghidra |
static int terminal_putc(int c) {
if (terminal_outfile == ((void *)0))
return -1;
return fputc(c, terminal_outfile);
} | int terminal_putc(int a1) {
if (terminal_outfile)
return fputc(a1, terminal_outfile);
else
return -1;
} | libedit | ida |
static int clone_file_block(ext2_filsys fs, blk64_t *block_nr,
e2_blkcnt_t blockcnt,
blk64_t ref_block __attribute__((unused)),
int ref_offset __attribute__((unused)),
void *priv_data) {
struct dup_cluster *p = ((void *)0);
blk64_t new_block;
errcode_t retval;
struct clone_struct *cs = (struct clone_struct *)priv_data;
dnode_t *n;
e2fsck_t ctx;
blk64_t c;
int is_meta = 0;
int should_write = 1;
ctx = cs->ctx;
deferred_dec_badcount(cs);
if (*block_nr == 0)
return 0;
if (ext2fs_has_feature_shared_blocks(ctx->fs->super) &&
(ctx->options & 0x40000) && (ctx->options & 0x0008))
should_write = 0;
c = ((blockcnt) >> (fs)->cluster_ratio_bits);
if (check_if_fs_cluster(ctx, ((*block_nr) >> (fs)->cluster_ratio_bits)))
is_meta = 1;
if (c == cs->dup_cluster && cs->alloc_block) {
new_block = cs->alloc_block;
goto got_block;
}
if (ext2fs_test_block_bitmap2(ctx->block_dup_map, *block_nr)) {
n = dict_lookup(
&clstr_dict,
((void *)(intptr_t)(((*block_nr) >> (fs)->cluster_ratio_bits))));
if (!n) {
com_err("clone_file_block", 0,
(gettext("internal error: can't find dup_blk for %llu\n")),
(unsigned long long)*block_nr);
return 0;
}
p = (struct dup_cluster *)((n)->dict_data);
cs->dup_cluster = c;
new_block = 0;
retval = ext2fs_map_cluster_block(fs, cs->ino, EXT2_INODE(cs->inode),
blockcnt, &new_block);
if (retval == 0 && new_block != 0 &&
((new_block) >> (ctx->fs)->cluster_ratio_bits) !=
((*block_nr) >> (ctx->fs)->cluster_ratio_bits))
goto cluster_alloc_ok;
retval = ext2fs_new_block2(fs, 0, ctx->block_found_map, &new_block);
if (retval) {
cs->errcode = retval;
return 2;
}
if (ext2fs_has_feature_shared_blocks(fs->super)) {
ext2fs_block_alloc_stats2(fs, new_block, +1);
}
cluster_alloc_ok:
cs->alloc_block = new_block;
got_block:
new_block &= ~((1 << (fs)->cluster_ratio_bits) - 1);
new_block += ((1 << (fs)->cluster_ratio_bits) - 1) & blockcnt;
if (cs->dir && (blockcnt >= 0)) {
retval = ext2fs_set_dir_block2(fs->dblist, cs->dir, new_block, blockcnt);
if (retval) {
cs->errcode = retval;
return 2;
}
}
retval = io_channel_read_blk64(fs->io, *block_nr, 1, cs->buf);
if (retval) {
cs->errcode = retval;
return 2;
}
if (should_write) {
retval = io_channel_write_blk64(fs->io, new_block, 1, cs->buf);
if (retval) {
cs->errcode = retval;
return 2;
}
}
cs->save_dup_cluster = (is_meta ? ((void *)0) : p);
cs->save_blocknr = *block_nr;
*block_nr = new_block;
ext2fs_mark_block_bitmap2(ctx->block_found_map, new_block);
ext2fs_mark_block_bitmap2(fs->block_map, new_block);
if (!should_write) {
return 0;
}
return 1;
}
return 0;
} | undefined8 clone_file_block(long param_1, ulong *param_2, ulong param_3,
undefined8 param_4, undefined8 param_5,
long *param_6)
{
ulong uVar1;
bool bVar2;
int iVar3;
int iVar4;
undefined8 uVar5;
long lVar6;
long in_FS_OFFSET;
ulong local_58;
long local_50;
long *local_48;
long *local_40;
long local_38;
long local_30;
long local_28;
long local_20;
local_20 = *(long *)(in_FS_OFFSET + 0x28);
local_50 = 0;
bVar2 = true;
local_40 = (long *)param_6[5];
local_48 = param_6;
deferred_dec_badcount(param_6);
if (*param_2 == 0) {
uVar5 = 0;
goto LAB_00102303;
}
iVar3 = ext2fs_has_feature_shared_blocks(*(undefined8 *)(*local_40 + 0x20));
if (((iVar3 != 0) && ((*(uint *)((long)local_40 + 0x4c) & 0x40000) != 0)) &&
((*(uint *)((long)local_40 + 0x4c) & 8) != 0)) {
bVar2 = false;
}
local_38 = (long)param_3 >> ((byte) * (undefined4 *)(param_1 + 0xc0) & 0x3f);
iVar3 = check_if_fs_cluster(
local_40, *param_2 >> ((byte) * (undefined4 *)(param_1 + 0xc0) & 0x3f));
if ((local_38 == local_48[1]) && (local_48[2] != 0)) {
local_58 = local_48[2];
} else {
iVar4 = ext2fs_test_block_bitmap2(local_40[0x35], *param_2);
if (iVar4 == 0) {
uVar5 = 0;
goto LAB_00102303;
}
local_30 = dict_lookup(
clstr_dict,
*param_2 >> ((byte) * (undefined4 *)(param_1 + 0xc0) & 0x3f));
if (local_30 == 0) {
uVar1 = *param_2;
uVar5 = gettext("internal error: can\'t find dup_blk for %llu\n");
com_err("clone_file_block", 0, uVar5, uVar1);
uVar5 = 0;
goto LAB_00102303;
}
local_50 = *(long *)(local_30 + 0x28);
local_48[1] = local_38;
local_58 = 0;
uVar5 = EXT2_INODE(local_48[6]);
local_28 = ext2fs_map_cluster_block(param_1,
*(undefined4 *)((long)local_48 + 0x1c),
uVar5, param_3, &local_58);
if (((local_28 != 0) || (local_58 == 0)) ||
(local_58 >> ((byte) * (undefined4 *)(*local_40 + 0xc0) & 0x3f) ==
*param_2 >> ((byte) * (undefined4 *)(*local_40 + 0xc0) & 0x3f))) {
local_28 = ext2fs_new_block2(param_1, 0, local_40[0x34]);
if (local_28 != 0) {
*local_48 = local_28;
uVar5 = 2;
goto LAB_00102303;
}
iVar4 = ext2fs_has_feature_shared_blocks(*(undefined8 *)(param_1 + 0x20));
if (iVar4 != 0) {
ext2fs_block_alloc_stats2(param_1, local_58, 1);
}
}
local_48[2] = local_58;
}
local_58 =
(local_58 &
(long)-(1 << ((byte) * (undefined4 *)(param_1 + 0xc0) & 0x1f))) +
((long)((1 << ((byte) * (undefined4 *)(param_1 + 0xc0) & 0x1f)) + -1) &
param_3);
if (((*(int *)(local_48 + 3) == 0) || ((long)param_3 < 0)) ||
(local_28 = ext2fs_set_dir_block2(*(undefined8 *)(param_1 + 0x90),
*(undefined4 *)(local_48 + 3), local_58,
param_3),
local_28 == 0)) {
local_28 = io_channel_read_blk64(*(undefined8 *)(param_1 + 8), *param_2, 1,
local_48[4]);
if (local_28 == 0) {
if ((bVar2) &&
(local_28 = io_channel_write_blk64(*(undefined8 *)(param_1 + 8),
local_58, 1, local_48[4]),
local_28 != 0)) {
*local_48 = local_28;
uVar5 = 2;
} else {
lVar6 = local_50;
if (iVar3 != 0) {
lVar6 = 0;
}
local_48[7] = lVar6;
local_48[8] = *param_2;
*param_2 = local_58;
ext2fs_mark_block_bitmap2(local_40[0x34], local_58);
ext2fs_mark_block_bitmap2(*(undefined8 *)(param_1 + 0x58), local_58);
if (bVar2) {
uVar5 = 1;
} else {
uVar5 = 0;
}
}
} else {
*local_48 = local_28;
uVar5 = 2;
}
} else {
*local_48 = local_28;
uVar5 = 2;
}
LAB_00102303:
if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) {
__stack_chk_fail();
}
return uVar5;
} | e2fsprogs-1.46.5 | ghidra |
static struct dns_response *parse_dns_response(const u_char *answer, int size) {
struct dns_response *resp;
const u_char *cp;
resp = calloc(1, sizeof(*resp));
if (resp == ((void *)0))
return (((void *)0));
cp = answer;
memcpy(&resp->header, cp, 12);
cp += 12;
resp->header.qdcount = ntohs(resp->header.qdcount);
resp->header.ancount = ntohs(resp->header.ancount);
resp->header.nscount = ntohs(resp->header.nscount);
resp->header.arcount = ntohs(resp->header.arcount);
if (resp->header.qdcount < 1) {
free_dns_response(resp);
return (((void *)0));
}
resp->query = parse_dns_qsection(answer, size, &cp, resp->header.qdcount);
if (resp->header.qdcount && resp->query == ((void *)0)) {
free_dns_response(resp);
return (((void *)0));
}
resp->answer = parse_dns_rrsection(answer, size, &cp, resp->header.ancount);
if (resp->header.ancount && resp->answer == ((void *)0)) {
free_dns_response(resp);
return (((void *)0));
}
resp->authority =
parse_dns_rrsection(answer, size, &cp, resp->header.nscount);
if (resp->header.nscount && resp->authority == ((void *)0)) {
free_dns_response(resp);
return (((void *)0));
}
resp->additional =
parse_dns_rrsection(answer, size, &cp, resp->header.arcount);
if (resp->header.arcount && resp->additional == ((void *)0)) {
free_dns_response(resp);
return (((void *)0));
}
return (resp);
} | int parse_dns_response(void *a0, unsigned long a1) {
void *v0;
struct_0 *v1;
unsigned int v3;
v1 = calloc(0x1, 0x30);
if (!v1) {
v3 = 0;
} else {
v0 = a0;
memcpy(v1, v0, 0xc);
v0 += 12;
v1->field_4 = ntohs(v1->field_4);
v1->field_6 = ntohs(v1->field_6);
v1->field_8 = ntohs(v1->field_8);
v1->field_a = ntohs(v1->field_a);
if (!v1->field_4) {
free_dns_response(v1);
v3 = 0;
} else {
v1->field_10 = parse_dns_qsection(a0, a1, &v0, v1->field_4);
if (v1->field_4 && !v1->field_10) {
free_dns_response(v1);
v3 = 0;
}
if (!v1->field_4 || v1->field_10) {
v1->field_18 = parse_dns_rrsection(a0, a1, &v0, v1->field_6);
if (v1->field_6 && !v1->field_18) {
free_dns_response(v1);
v3 = 0;
}
if (!v1->field_6 || v1->field_18) {
v1->field_20 = parse_dns_rrsection(a0, a1, &v0, v1->field_8);
if (v1->field_8 && !v1->field_20) {
free_dns_response(v1);
v3 = 0;
}
if (!v1->field_8 || v1->field_20) {
v1->field_28 = parse_dns_rrsection(a0, a1, &v0, v1->field_a);
if (v1->field_a && !v1->field_28) {
free_dns_response(v1);
v3 = 0;
}
if (!v1->field_a || v1->field_28)
v3 = v1;
}
}
}
}
}
return v3;
} | openssh-portable | angr_dream |
static struct deferred_unlink *dunlink_alloc(void) {
struct deferred_unlink *p;
if (dunlink_avail) {
p = dunlink_avail;
dunlink_avail = p->next;
p->next = ((void *)0);
} else
p = xmalloc(sizeof(*p));
return p;
} | int dunlink_alloc() {
unsigned long long *v0;
if (dunlink_avail) {
v0 = dunlink_avail;
dunlink_avail = *(v0);
*(v0) = 0;
} else {
v0 = xmalloc(0x28);
}
return v0;
} | tar | angr_phoenix |
static void usage(int status) {
FILE *usageout = (0 != status) ? stderr : stdout;
(void)fprintf(usageout,
gettext("Usage: %s [options] LOGIN\n"
"\n"
"Options:\n")
,
Prog);
(void)fputs(gettext(" -d, --lastday LAST_DAY set date of last "
"password change to LAST_DAY\n"),
usageout);
(void)fputs(gettext(" -E, --expiredate EXPIRE_DATE set account expiration "
"date to EXPIRE_DATE\n"),
usageout);
(void)fputs(gettext(" -h, --help display this help "
"message and exit\n"),
usageout);
(void)fputs(gettext(" -i, --iso8601 use YYYY-MM-DD when "
"printing dates\n"),
usageout);
(void)fputs(gettext(" -I, --inactive INACTIVE set password inactive "
"after expiration\n"
" to INACTIVE\n"),
usageout);
(void)fputs(
gettext(
" -l, --list show account aging information\n"),
usageout);
(void)fputs(gettext(" -m, --mindays MIN_DAYS set minimum number of "
"days before password\n"
" change to MIN_DAYS\n"),
usageout);
(void)fputs(gettext(" -M, --maxdays MAX_DAYS set maximum number of "
"days before password\n"
" change to MAX_DAYS\n"),
usageout);
(void)fputs(
gettext(" -R, --root CHROOT_DIR directory to chroot into\n"),
usageout);
(void)fputs(gettext(" -W, --warndays WARN_DAYS set expiration warning "
"days to WARN_DAYS\n"),
usageout);
(void)fputs("\n", usageout);
exit(status);
} | void usage(unsigned long a0) {
void *v0;
unsigned long v1;
unsigned long v3;
void *v4;
v1 = v3;
if (a0)
v4 = stderr;
else
v4 = stdout;
v0 = v4;
fprintf(v0, gettext("Usage: %s [options] LOGIN\n\nOptions:\n"));
fputs(gettext(" -d, --lastday LAST_DAY set date of last password "
"change to LAST_DAY\n"),
v0);
fputs(gettext(" -E, --expiredate EXPIRE_DATE set account expiration date "
"to EXPIRE_DATE\n"),
v0);
fputs(gettext(" -h, --help display this help message and "
"exit\n"),
v0);
fputs(gettext(" -i, --iso8601 use YYYY-MM-DD when printing "
"dates\n"),
v0);
fputs(gettext(" -I, --inactive INACTIVE set password inactive after "
"expiration\n to INACTIVE\n"),
v0);
fputs(gettext(
" -l, --list show account aging information\n"),
v0);
fputs(gettext(
" -m, --mindays MIN_DAYS set minimum number of days before "
"password\n change to MIN_DAYS\n"),
v0);
fputs(gettext(
" -M, --maxdays MAX_DAYS set maximum number of days before "
"password\n change to MAX_DAYS\n"),
v0);
fputs(gettext(" -R, --root CHROOT_DIR directory to chroot into\n"),
v0);
fputs(gettext(" -W, --warndays WARN_DAYS set expiration warning days "
"to WARN_DAYS\n"),
v0);
fputs("\n", v0);
exit(a0);
} | shadow | angr_phoenix |
inline static int is_ip(const char *hostname) {
int len = strlen(hostname);
if (strchr(hostname, ':') != 0)
return 1;
else if (len > 2 && c_isdigit(hostname[0]) && c_isdigit(hostname[len - 1]))
return 1;
return 0;
} | _BOOL8 is_ip(const char *a1) {
int v2;
v2 = strlen(a1);
if (strchr(a1, 58))
return 1LL;
return v2 > 2 && (unsigned char)c_isdigit((unsigned int)*a1) &&
(unsigned char)c_isdigit((unsigned int)a1[v2 - 1]);
} | gnutls | ida |
static void do_exit(exitcode) int exitcode;
{
static int in_exit = 0;
if (in_exit)
exit(exitcode);
in_exit = 1;
free(env);
env = ((void *)0);
;
;
;
;
;
exit(exitcode);
} | void do_exit(int param_1)
{
if (in_exit_5606 != 0) {
exit(param_1);
}
in_exit_5606 = 1;
free(env);
env = (void *)0x0;
exit(param_1);
} | gzip-1.12 | ghidra |
static void print_secy_stats(const char *prefix, struct rtattr *attr) {
struct rtattr *stats[MACSEC_SECY_STATS_ATTR_MAX + 1];
if (!attr || show_stats == 0)
return;
(parse_rtattr_flags(
(stats), (MACSEC_SECY_STATS_ATTR_MAX),
((void *)(((char *)(attr)) +
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))),
((int)((attr)->rta_len) -
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))),
(1 << 15)));
print_stats(prefix, secy_stats_names, NUM_MACSEC_SECY_STATS_ATTR, stats);
} | void print_secy_stats(unsigned int a0, unsigned short *a1, unsigned long a2,
unsigned long a3, unsigned long a4,
unsigned long long a5) {
char v0;
char v1;
unsigned long long *v3;
unsigned long long v4;
if (a1 && show_stats) {
parse_rtattr_flags(&v0, 0x9, a1 + 2, *(a1)-4, 0x8000);
print_stats(a0, &secy_stats_names, 0xa, &v0, 0x8000, a5);
}
v4 = *(&v1) ^ v3[5];
return;
} | iproute2-6.0.0 | angr_phoenix |
int _rl_dispatch_callback(_rl_keyseq_cxt *cxt) {
int nkey, r;
if ((cxt->flags & 0x01) == 0) {
nkey = _rl_subseq_getchar(cxt->okey);
if (nkey < 0) {
_rl_abort_internal();
return -1;
}
r = _rl_dispatch_subseq(nkey, cxt->dmap, cxt->subseq_arg);
cxt->flags |= 0x01;
} else
r = cxt->childval;
if (r != -3)
r = _rl_subseq_result(r, cxt->oldmap, cxt->okey, (cxt->flags & 0x02));
do {
if (_rl_caught_signal)
_rl_signal_handler(_rl_caught_signal);
} while (0);
if (r >= 0 || (r == -1 && (cxt->flags & 0x02) == 0)) {
_rl_keyseq_chain_dispose();
(rl_readline_state &= ~(0x0200000));
return r;
}
if (r != -3)
_rl_kscxt = cxt->ocxt;
if (_rl_kscxt)
_rl_kscxt->childval = r;
if (r != -3)
_rl_keyseq_cxt_dispose(cxt);
return r;
} | long long _rl_dispatch_callback(struct_0 *a0) {
struct_0 *v0;
unsigned int v1;
unsigned int v2;
unsigned long long v4;
v0 = a0;
if (!(a0->field_0 & 1)) {
v2 = _rl_subseq_getchar(a0->field_c);
if (v2 < 0) {
_rl_abort_internal();
v4 = 4294967295;
} else {
v1 = _rl_dispatch_subseq(v2, a0->field_10, a0->field_4);
a0->field_0 = a0->field_0 | 1;
}
} else {
v1 = a0->field_28;
}
if (v2 >= 0 || (a0->field_0 & 1)) {
if (v1 != -3)
v1 = _rl_subseq_result(v1, a0->field_18, a0->field_c, a0->field_0 & 2);
if (_rl_caught_signal)
_rl_signal_handler(_rl_caught_signal);
if (v1 < 0 && (v1 != -1 || (a0->field_0 & 2))) {
if (v1 != -3)
_rl_kscxt = a0->field_20;
if (_rl_kscxt)
*((_rl_kscxt + 40)) = v1;
if (v1 != -3)
_rl_keyseq_cxt_dispose(a0);
v4 = v1;
}
if (v1 >= 0 || v1 == -1 && !(a0->field_0 & 2)) {
_rl_keyseq_chain_dispose();
rl_readline_state = rl_readline_state & -2097153;
v4 = v1;
}
}
return v4;
} | bash | angr_dream |
int parse_forward(struct Forward *fwd, const char *fwdspec, int dynamicfwd,
int remotefwd) {
struct fwdarg fwdargs[4];
char *p, *cp;
int i, err;
memset(fwd, 0, sizeof(*fwd));
memset(fwdargs, 0, sizeof(fwdargs));
cp = p = dollar_expand(&err, fwdspec);
if (p == ((void *)0) || err)
return 0;
while (
((*__ctype_b_loc())[(int)(((u_char)*cp))] & (unsigned short int)_ISspace))
cp++;
for (i = 0; i < 4; ++i) {
if (parse_fwd_field(&cp, &fwdargs[i]) != 0)
break;
}
if (cp != ((void *)0) && *cp != '\0') {
i = 0;
}
switch (i) {
case 1:
if (fwdargs[0].ispath) {
fwd->listen_path = xstrdup(fwdargs[0].arg);
fwd->listen_port = -2;
} else {
fwd->listen_host = ((void *)0);
fwd->listen_port = a2port(fwdargs[0].arg);
}
fwd->connect_host = xstrdup("socks");
break;
case 2:
if (fwdargs[0].ispath && fwdargs[1].ispath) {
fwd->listen_path = xstrdup(fwdargs[0].arg);
fwd->listen_port = -2;
fwd->connect_path = xstrdup(fwdargs[1].arg);
fwd->connect_port = -2;
} else if (fwdargs[1].ispath) {
fwd->listen_host = ((void *)0);
fwd->listen_port = a2port(fwdargs[0].arg);
fwd->connect_path = xstrdup(fwdargs[1].arg);
fwd->connect_port = -2;
} else {
fwd->listen_host = xstrdup(fwdargs[0].arg);
fwd->listen_port = a2port(fwdargs[1].arg);
fwd->connect_host = xstrdup("socks");
}
break;
case 3:
if (fwdargs[0].ispath) {
fwd->listen_path = xstrdup(fwdargs[0].arg);
fwd->listen_port = -2;
fwd->connect_host = xstrdup(fwdargs[1].arg);
fwd->connect_port = a2port(fwdargs[2].arg);
} else if (fwdargs[2].ispath) {
fwd->listen_host = xstrdup(fwdargs[0].arg);
fwd->listen_port = a2port(fwdargs[1].arg);
fwd->connect_path = xstrdup(fwdargs[2].arg);
fwd->connect_port = -2;
} else {
fwd->listen_host = ((void *)0);
fwd->listen_port = a2port(fwdargs[0].arg);
fwd->connect_host = xstrdup(fwdargs[1].arg);
fwd->connect_port = a2port(fwdargs[2].arg);
}
break;
case 4:
fwd->listen_host = xstrdup(fwdargs[0].arg);
fwd->listen_port = a2port(fwdargs[1].arg);
fwd->connect_host = xstrdup(fwdargs[2].arg);
fwd->connect_port = a2port(fwdargs[3].arg);
break;
default:
i = 0;
}
free(p);
if (dynamicfwd) {
if (!(i == 1 || i == 2))
goto fail_free;
} else {
if (!(i == 3 || i == 4)) {
if (fwd->connect_path == ((void *)0) && fwd->listen_path == ((void *)0))
goto fail_free;
}
if (fwd->connect_port <= 0 && fwd->connect_path == ((void *)0))
goto fail_free;
}
if ((fwd->listen_port < 0 && fwd->listen_path == ((void *)0)) ||
(!remotefwd && fwd->listen_port == 0))
goto fail_free;
if (fwd->connect_host != ((void *)0) && strlen(fwd->connect_host) >= 1025)
goto fail_free;
if (fwd->connect_path != ((void *)0) &&
strlen(fwd->connect_path) >= (sizeof((struct sockaddr_un *)0)->sun_path))
goto fail_free;
if (fwd->listen_host != ((void *)0) && strlen(fwd->listen_host) >= 1025)
goto fail_free;
if (fwd->listen_path != ((void *)0) &&
strlen(fwd->listen_path) >= (sizeof((struct sockaddr_un *)0)->sun_path))
goto fail_free;
return (i);
fail_free:
free(fwd->connect_host);
fwd->connect_host = ((void *)0);
free(fwd->connect_path);
fwd->connect_path = ((void *)0);
free(fwd->listen_host);
fwd->listen_host = ((void *)0);
free(fwd->listen_path);
fwd->listen_path = ((void *)0);
return (0);
} | long parse_forward(const char **a1, _OWORD *a2, int a3, int a4) {
int v7;
int i;
char *v9;
void *ptr;
_OWORD v11[4];
unsigned long v12;
v12 = __readfsqword(0x28u);
memset(a1, 0, 0x38uLL);
memset(v11, 0, sizeof(v11));
ptr = (void *)dollar_expand(&v7, a2);
v9 = (char *)ptr;
if (!ptr || v7)
return 0LL;
while (((*_ctype_b_loc())[(unsigned char)*v9] & 0x2000) != 0)
++v9;
for (i = 0; i <= 3; ++i) {
a2 = &v11[i];
if ((unsigned int)parse_fwd_field(&v9, (long)a2))
break;
HIDWORD(a2) = 0;
}
if (v9 && *v9)
i = 0;
if (i == 4) {
*a1 = (const char *)xstrdup(*(_QWORD *)&v11[0], a2);
*((_DWORD *)a1 + 2) = a2port(*(_QWORD *)&v11[1]);
a1[3] = (const char *)xstrdup(*(_QWORD *)&v11[2], a2);
*((_DWORD *)a1 + 8) = a2port(*(_QWORD *)&v11[3]);
goto LABEL_36;
}
if (i > 4)
goto LABEL_35;
switch (i) {
case 3:
if (DWORD2(v11[0])) {
a1[2] = (const char *)xstrdup(*(_QWORD *)&v11[0], a2);
*((_DWORD *)a1 + 2) = -2;
a1[3] = (const char *)xstrdup(*(_QWORD *)&v11[1], a2);
*((_DWORD *)a1 + 8) = a2port(*(_QWORD *)&v11[2]);
} else if (DWORD2(v11[2])) {
*a1 = (const char *)xstrdup(*(_QWORD *)&v11[0], a2);
*((_DWORD *)a1 + 2) = a2port(*(_QWORD *)&v11[1]);
a1[5] = (const char *)xstrdup(*(_QWORD *)&v11[2], a2);
*((_DWORD *)a1 + 8) = -2;
} else {
*a1 = 0LL;
*((_DWORD *)a1 + 2) = a2port(*(_QWORD *)&v11[0]);
a1[3] = (const char *)xstrdup(*(_QWORD *)&v11[1], a2);
*((_DWORD *)a1 + 8) = a2port(*(_QWORD *)&v11[2]);
}
break;
case 1:
if (DWORD2(v11[0])) {
a1[2] = (const char *)xstrdup(*(_QWORD *)&v11[0], a2);
*((_DWORD *)a1 + 2) = -2;
} else {
*a1 = 0LL;
*((_DWORD *)a1 + 2) = a2port(*(_QWORD *)&v11[0]);
}
a1[3] = (const char *)xstrdup("socks", a2);
break;
case 2:
if (DWORD2(v11[0]) && DWORD2(v11[1])) {
a1[2] = (const char *)xstrdup(*(_QWORD *)&v11[0], a2);
*((_DWORD *)a1 + 2) = -2;
a1[5] = (const char *)xstrdup(*(_QWORD *)&v11[1], a2);
*((_DWORD *)a1 + 8) = -2;
} else if (DWORD2(v11[1])) {
*a1 = 0LL;
*((_DWORD *)a1 + 2) = a2port(*(_QWORD *)&v11[0]);
a1[5] = (const char *)xstrdup(*(_QWORD *)&v11[1], a2);
*((_DWORD *)a1 + 8) = -2;
} else {
*a1 = (const char *)xstrdup(*(_QWORD *)&v11[0], a2);
*((_DWORD *)a1 + 2) = a2port(*(_QWORD *)&v11[1]);
a1[3] = (const char *)xstrdup("socks", a2);
}
break;
default:
LABEL_35:
i = 0;
break;
}
LABEL_36:
free(ptr);
if (a3) {
if (i != 1 && i != 2)
goto LABEL_59;
} else if (i != 3 && i != 4 && !a1[5] && !a1[2] ||
*((int *)a1 + 8) <= 0 && !a1[5]) {
goto LABEL_59;
}
if ((*((int *)a1 + 2) >= 0 || a1[2]) && (a4 || *((_DWORD *)a1 + 2)) &&
(!a1[3] || strlen(a1[3]) <= 0x400) && (!a1[5] || strlen(a1[5]) <= 0x6B) &&
(!*a1 || strlen(*a1) <= 0x400) && (!a1[2] || strlen(a1[2]) <= 0x6B)) {
return (unsigned int)i;
}
LABEL_59:
free((void *)a1[3]);
a1[3] = 0LL;
free((void *)a1[5]);
a1[5] = 0LL;
free((void *)*a1);
*a1 = 0LL;
free((void *)a1[2]);
a1[2] = 0LL;
return 0LL;
} | openssh-portable | ida |
static _Bool
parse_obsolete_option(int argc, char *const *argv, uintmax_t *n_units) {
char const *p;
char const *n_string;
char const *n_string_end;
int default_count = 10;
_Bool t_from_start;
_Bool t_count_lines = 1;
_Bool t_forever = 0;
if (!(argc == 2 || (argc == 3 && !(argv[2][0] == '-' && argv[2][1])) ||
(3 <= argc && argc <= 4 && (strcmp(argv[2], "--") == 0))))
return 0;
int posix_ver = posix2_version();
_Bool obsolete_usage = posix_ver < 200112;
_Bool traditional_usage = obsolete_usage || 200809 <= posix_ver;
p = argv[1];
switch (*p++) {
default:
return 0;
case '+':
if (!traditional_usage)
return 0;
t_from_start = 1;
break;
case '-':
if (!obsolete_usage && !p[p[0] == 'c'])
return 0;
t_from_start = 0;
break;
}
n_string = p;
while (((unsigned int)(*p) - '0' <= 9))
p++;
n_string_end = p;
switch (*p) {
case 'b':
default_count *= 512;
__attribute__((__fallthrough__));
case 'c':
t_count_lines = 0;
__attribute__((__fallthrough__));
case 'l':
p++;
break;
}
if (*p == 'f') {
t_forever = 1;
++p;
}
if (*p)
return 0;
if (n_string == n_string_end)
*n_units = default_count;
else if ((xstrtoumax(n_string, ((void *)0), 10, n_units, "b") &
~LONGINT_INVALID_SUFFIX_CHAR) != LONGINT_OK) {
((!!sizeof(struct {
_Static_assert(1,
"verify_expr ("
"1"
", "
"(error (1, (*__errno_location ()), \"%s: %s\", gettext "
"(\"invalid number\"), quote (argv[1])), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, (*__errno_location()), "%s: %s",
gettext("invalid number"), quote(argv[1])),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, (*__errno_location()), "%s: %s",
gettext("invalid number"), quote(argv[1])),
((0) ? (void)0 : __builtin_unreachable()))));
}
from_start = t_from_start;
count_lines = t_count_lines;
forever = t_forever;
return 1;
} | int parse_obsolete_option(unsigned long a0, struct_0 *a1,
unsigned long long *a2) {
int tmp_32;
char v0;
char v1;
char v2;
char v3;
char v4;
unsigned int v5;
unsigned int v6;
char *v7;
char *v8;
char *v9;
unsigned int v11;
char v12;
unsigned long long v13;
unsigned long long v14;
v5 = 10;
v1 = 1;
v2 = 0;
if (a0 != 2) {
if (a0 != 3) {
LABEL_4065e1:
if (a0 > 2 && a0 <= 4 && !strcmp(a1->field_10, "--"))
goto LABEL_406615;
v11 = 0;
goto LABEL_406801;
} else if (a1->field_10->field_0 == 45) {
if (!a1->field_10->field_1)
goto LABEL_406615;
goto LABEL_4065e1;
}
}
LABEL_406615:
v6 = posix2_version();
v3 = v6 <= 200111;
if (v3) {
LABEL_406639:
v12 = 1;
} else {
if (!(v6 <= 200808))
goto LABEL_406639;
v12 = 0;
}
v4 = v12;
v4 &= 1;
v7 = a1->field_8;
tmp_32 = v7;
v7 += 1;
v11 = *(tmp_32);
if (v11 != 43) {
if (v11 != 45) {
v11 = 0;
goto LABEL_406801;
}
if ((v3 ^ 1) && !v7[*(v7) == 99]) {
v11 = 0;
goto LABEL_406801;
}
v0 = 0;
} else if (!(v4 ^ 1)) {
v0 = 1;
} else {
v11 = 0;
goto LABEL_406801;
}
for (v8 = v7; *(v7)-48 <= 9; v7 += 1)
;
v9 = v7;
if (*(v7) != 108) {
if (!(*(v7) <= 108))
goto LABEL_406727;
if (*(v7) == 98) {
v5 *= 0x200;
} else if (!(*(v7) == 99)) {
goto LABEL_406727;
}
v1 = 0;
}
v7 += 1;
LABEL_406727:
if (*(v7) == 102) {
v2 = 1;
v7 += 1;
}
if (*(v7)) {
v11 = 0;
} else {
if (v8 == v9) {
*(a2) = v5;
} else {
v11 = xstrtoumax(v8, 0x0, 0xa, a2, "b") & -3;
if (v11) {
v13 = quote(a1->field_8);
v14 = gettext("invalid number");
error(0x1, *(__errno_location()), "%s: %s");
}
}
from_start = v0;
count_lines = v1;
forever = v2;
v11 = 1;
}
LABEL_406801:
return v11;
} | coreutils | angr_phoenix |
_Bool
transform_name (char **pinput, int type)
{
return transform_name_fp(pinput, type, ((void *)0), ((void *)0));
} | long long transform_name(unsigned long long *a0, unsigned long a1) {
return transform_name_fp(a0, a1, 0x0, 0x0);
} | tar | angr_sailr |
int confirm(const char *message_action, const char *message_name) {
static FILE *confirm_file;
static int confirm_file_EOF;
_Bool status = 0;
if (!confirm_file) {
if (archive == 0 || stdin_used_by) {
confirm_file = fopen("/dev/tty", "r");
if (!confirm_file)
open_fatal("/dev/tty");
} else {
request_stdin("-w");
confirm_file = stdin;
}
}
fprintf(stdlis, "%s %s?", message_action, quote(message_name));
fflush_unlocked(stdlis);
if (!confirm_file_EOF) {
char *response = ((void *)0);
size_t response_size = 0;
if (getline(&response, &response_size, confirm_file) < 0)
confirm_file_EOF = 1;
else
status = rpmatch(response) > 0;
free(response);
}
if (confirm_file_EOF) {
fputc_unlocked('\n', stdlis);
fflush_unlocked(stdlis);
}
return status;
} | bool confirm(undefined8 param_1, undefined8 param_2)
{
int iVar1;
undefined8 uVar2;
__ssize_t _Var3;
long in_FS_OFFSET;
bool local_21;
char *local_20;
size_t local_18;
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
local_21 = false;
if (confirm_file_7386 == (FILE *)0x0) {
if ((archive == 0) || (stdin_used_by != 0)) {
confirm_file_7386 = fopen("/dev/tty", "r");
if (confirm_file_7386 != (FILE *)0x0)
goto LAB_00100129;
open_fatal("/dev/tty");
}
request_stdin(&DAT_0010539a);
confirm_file_7386 = stdin;
}
LAB_00100129:
uVar2 = quote(param_2);
fprintf(stdlis, "%s %s?", param_1, uVar2);
fflush_unlocked(stdlis);
if (confirm_file_EOF_7387 == 0) {
local_20 = (char *)0x0;
local_18 = 0;
_Var3 = getline(&local_20, &local_18, confirm_file_7386);
if (_Var3 < 0) {
confirm_file_EOF_7387 = 1;
} else {
iVar1 = rpmatch(local_20);
local_21 = 0 < iVar1;
}
free(local_20);
}
if (confirm_file_EOF_7387 != 0) {
fputc_unlocked(10, stdlis);
fflush_unlocked(stdlis);
}
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
__stack_chk_fail();
}
return local_21;
} | tar | ghidra |
static wchar_t *do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc,
int iswextra) {
if (flags & 0x0002) {
switch (c) {
case L'\n':
*dst++ = L'\\';
*dst++ = L'n';
return dst;
case L'\r':
*dst++ = L'\\';
*dst++ = L'r';
return dst;
case L'\b':
*dst++ = L'\\';
*dst++ = L'b';
return dst;
case L'\a':
*dst++ = L'\\';
*dst++ = L'a';
return dst;
case L'\v':
*dst++ = L'\\';
*dst++ = L'v';
return dst;
case L'\t':
*dst++ = L'\\';
*dst++ = L't';
return dst;
case L'\f':
*dst++ = L'\\';
*dst++ = L'f';
return dst;
case L' ':
*dst++ = L'\\';
*dst++ = L's';
return dst;
case L'\0':
*dst++ = L'\\';
*dst++ = L'0';
if ((((unsigned char)(nextc)) >= L'0' &&
((unsigned char)(nextc)) <= L'7')) {
*dst++ = L'0';
*dst++ = L'0';
}
return dst;
case L'n':
case L'r':
case L'b':
case L'a':
case L'v':
case L't':
case L'f':
case L's':
case L'0':
case L'M':
case L'^':
case L'$':
break;
default:
if ((((flags) & 0x4000)
? ((*__ctype_b_loc())[(int)((c))] & (unsigned short int)_ISgraph)
: iswgraph(c)) &&
!(((unsigned char)(c)) >= L'0' && ((unsigned char)(c)) <= L'7')) {
*dst++ = L'\\';
*dst++ = c;
return dst;
}
}
}
if (iswextra || ((c & 0177) == L' ') || (flags & 0x0001)) {
*dst++ = L'\\';
*dst++ = (unsigned char)(((uint32_t)(unsigned char)c >> 6) & 03) + L'0';
*dst++ = (unsigned char)(((uint32_t)(unsigned char)c >> 3) & 07) + L'0';
*dst++ = (c & 07) + L'0';
} else {
if ((flags & 0x0040) == 0)
*dst++ = L'\\';
if (c & 0200) {
c &= 0177;
*dst++ = L'M';
}
if (iswcntrl(c)) {
*dst++ = L'^';
if (c == 0177)
*dst++ = L'?';
else
*dst++ = c + L'@';
} else {
*dst++ = L'-';
*dst++ = c;
}
}
return dst;
} | int do_mbyte(unsigned long long a0, unsigned long a1, unsigned long a2,
unsigned long a3, unsigned long a4) {
unsigned int v0;
int tmp_14;
int tmp_22;
int tmp_10;
int tmp_18;
int tmp_11;
int tmp_19;
int tmp_12;
int tmp_20;
int tmp_44;
int tmp_70;
int tmp_109;
int tmp_135;
unsigned int *v1;
unsigned int v3;
unsigned int *v5;
v1 = a0;
v0 = a1;
if ((a2 & 2)) {
switch (v0) {
case 0:
tmp_14 = v1;
v1 = v1 + 1;
*(tmp_14) = 92;
tmp_22 = v1;
v1 = v1 + 1;
*(tmp_22) = 48;
if (a3 > 47 && a3 <= 55) {
tmp_10 = v1;
v1 = v1 + 1;
*(tmp_10) = 48;
tmp_18 = v1;
v1 = v1 + 1;
*(tmp_18) = 48;
}
v3 = v1;
return v3;
case 7:
tmp_11 = v1;
v1 = v1 + 1;
*(tmp_11) = 92;
tmp_19 = v1;
v1 = v1 + 1;
*(tmp_19) = 97;
v3 = v1;
return v3;
case 8:
tmp_11 = v1;
v1 = v1 + 1;
*(tmp_11) = 92;
tmp_19 = v1;
v1 = v1 + 1;
*(tmp_19) = 98;
v3 = v1;
return v3;
case 9:
tmp_11 = v1;
v1 = v1 + 1;
*(tmp_11) = 92;
tmp_19 = v1;
v1 = v1 + 1;
*(tmp_19) = 116;
v3 = v1;
return v3;
case 10:
tmp_11 = v1;
v1 = v1 + 1;
*(tmp_11) = 92;
tmp_19 = v1;
v1 = v1 + 1;
*(tmp_19) = 110;
v3 = v1;
return v3;
case 11:
tmp_11 = v1;
v1 = v1 + 1;
*(tmp_11) = 92;
tmp_19 = v1;
v1 = v1 + 1;
*(tmp_19) = 118;
v3 = v1;
return v3;
case 12:
tmp_11 = v1;
v1 = v1 + 1;
*(tmp_11) = 92;
tmp_19 = v1;
v1 = v1 + 1;
*(tmp_19) = 102;
v3 = v1;
return v3;
case 13:
tmp_11 = v1;
v1 = v1 + 1;
*(tmp_11) = 92;
tmp_19 = v1;
v1 = v1 + 1;
*(tmp_19) = 114;
v3 = v1;
return v3;
case 32:
tmp_11 = v1;
v1 = v1 + 1;
*(tmp_11) = 92;
tmp_19 = v1;
v1 = v1 + 1;
*(tmp_19) = 115;
v3 = v1;
return v3;
case 36:
case 48:
case 77:
case 94:
case 97:
case 98:
case 102:
case 110:
case 114:
case 115:
case 116:
case 118:
goto LABEL_4004a3;
default:
if (!(a2 & 0x4000)) {
v3 = iswgraph(v0);
break;
} else {
v3 = *((*(__ctype_b_loc()) + v0 * 2));
*(&v3) = v3 >> 15;
break;
}
if (v3 && (!(v0 > 47) || !(v0 <= 55))) {
tmp_12 = v1;
v1 = v1 + 1;
*(tmp_12) = 92;
tmp_20 = v1;
v1 = v1 + 1;
*(tmp_20) = v0;
*(&v3) = v1;
return v3;
}
}
}
LABEL_4004a3:
if (a4 || (v0 & 127) == 32 || (a2 & 1)) {
tmp_44 = v1;
v1 = v1 + 1;
*(tmp_44) = 92;
tmp_70 = v1;
v1 += 1;
*(tmp_70) = (v0 >> 6) + 48;
tmp_109 = v1;
v1 += 1;
*(tmp_109) = ((v0 >> 3) & 7) + 48;
tmp_135 = v1;
v1 += 1;
*(tmp_135) = (v0 & 7) + 48;
} else {
if (!(a2 & 64)) {
v3 = v1;
v1 = v1 + 1;
*(v3) = 92;
}
if ((v0 & 128)) {
v0 &= 127;
v3 = v1;
v1 = v1 + 1;
*(v3) = 77;
}
if (!iswcntrl(v0)) {
tmp_11 = v1;
v1 = v1 + 1;
*(tmp_11) = 45;
tmp_19 = v1;
v1 = v1 + 1;
*(tmp_19) = v0;
} else {
v5 = v1;
v1 = v1 + 1;
*(v5) = 94;
if (v0 == 127) {
v3 = v1;
v1 = v1 + 1;
*(v3) = 63;
} else {
v3 = v1;
v1 = v1 + 1;
*(v3) = v0 + 64;
}
}
}
*(&v3) = v1;
return v3;
} | libbsd-0.11.7 | angr_sailr |
static char *fingerprint_hex(const char *alg, u_char *dgst_raw,
size_t dgst_raw_len) {
char *retval, hex[5];
size_t i, rlen = dgst_raw_len * 3 + strlen(alg) + 2;
if (dgst_raw_len > 65536 || (retval = calloc(1, rlen)) == ((void *)0))
return ((void *)0);
strlcpy(retval, alg, rlen);
strlcat(retval, ":", rlen);
for (i = 0; i < dgst_raw_len; i++) {
snprintf(hex, sizeof(hex), "%s%02x", i > 0 ? ":" : "", dgst_raw[i]);
strlcat(retval, hex, rlen);
}
return retval;
} | void *fingerprint_hex(const char *a1, long a2, unsigned long a3) {
const char *v4;
unsigned long i;
unsigned long size;
void *v8;
char v9[5];
unsigned long v10;
v10 = __readfsqword(0x28u);
size = 3 * a3 + strlen(a1) + 2;
if (a3 > 0x10000)
return 0LL;
v8 = calloc(1uLL, size);
if (!v8)
return 0LL;
strlcpy(v8, a1, size);
strlcat(v8, &unk_C0D0, size);
for (i = 0LL; i < a3; ++i) {
if (i)
v4 = (const char *)&unk_C0D0;
else
v4 = &s2;
snprintf(v9, 5uLL, "%s%02x", v4, *(unsigned char *)(a2 + i));
strlcat(v8, v9, size);
}
return v8;
} | openssh-portable | ida |
void usage(FILE *out, int status) {
const char str[] =
"p11tool - GnuTLS PKCS #11 tool\n"
"Usage: p11tool [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [url]\n"
"\n"
"None:\n"
"\n"
"\n"
"Tokens:\n"
"\n"
" --list-tokens List all available tokens\n"
" --list-token-urls List the URLs available tokens\n"
" --list-mechanisms List all available mechanisms in a token\n"
" --initialize Initializes a PKCS #11 token\n"
" --initialize-pin Initializes/Resets a PKCS #11 token user "
"PIN\n"
" --initialize-so-pin Initializes/Resets a PKCS #11 token "
"security officer PIN\n"
" --set-pin=str Specify the PIN to use on token "
"operations\n"
" --set-so-pin=str Specify the Security Officer's PIN to use "
"on token initialization\n"
"\n"
"Object listing:\n"
"\n"
" --list-all List all available objects in a token\n"
" --list-all-certs List all available certificates in a "
"token\n"
" --list-certs List all certificates that have an "
"associated private key\n"
" --list-all-privkeys List all available private keys in a "
"token\n"
" --list-privkeys an alias for the 'list-all-privkeys' "
"option\n"
" --list-keys an alias for the 'list-all-privkeys' "
"option\n"
" --list-all-trusted List all available certificates marked as "
"trusted\n"
" --export Export the object specified by the URL\n"
" - prohibits these options:\n"
" export-stapled\n"
" export-chain\n"
" export-pubkey\n"
" --export-stapled Export the certificate object specified "
"by the URL\n"
" - prohibits these options:\n"
" export\n"
" export-chain\n"
" export-pubkey\n"
" --export-chain Export the certificate specified by the "
"URL and its chain of trust\n"
" - prohibits these options:\n"
" export-stapled\n"
" export\n"
" export-pubkey\n"
" --export-pubkey Export the public key for a private key\n"
" - prohibits these options:\n"
" export-stapled\n"
" export\n"
" export-chain\n"
" --info List information on an available object "
"in a token\n"
" --trusted an alias for the 'mark-trusted' option\n"
" --distrusted an alias for the 'mark-distrusted' "
"option\n"
"\n"
"Key generation:\n"
"\n"
" --generate-privkey=str Generate private-public key pair of given "
"type\n"
" --bits=num Specify the number of bits for the key "
"generate\n"
" --curve=str Specify the curve used for EC key "
"generation\n"
" --sec-param=str Specify the security level\n"
"\n"
"Writing objects:\n"
"\n"
" --set-id=str Set the CKA_ID (in hex) for the specified "
"by the URL object\n"
" - prohibits the option 'write'\n"
" --set-label=str Set the CKA_LABEL for the specified by "
"the URL object\n"
" - prohibits these options:\n"
" write\n"
" set-id\n"
" --write Writes the loaded objects to a PKCS #11 "
"token\n"
" --delete Deletes the objects matching the given "
"PKCS #11 URL\n"
" --label=str Sets a label for the write operation\n"
" --id=str Sets an ID for the write operation\n"
" --mark-wrap Marks the generated key to be a wrapping "
"key\n"
" --mark-trusted Marks the object to be written as "
"trusted\n"
" - prohibits the option 'mark-distrusted'\n"
" --mark-distrusted When retrieving objects, it requires the "
"objects to be distrusted (blacklisted)\n"
" - prohibits the option 'mark-trusted'\n"
" --mark-decrypt Marks the object to be written for "
"decryption\n"
" --mark-sign Marks the object to be written for "
"signature generation\n"
" --mark-ca Marks the object to be written as a CA\n"
" --mark-private Marks the object to be written as "
"private\n"
" --ca an alias for the 'mark-ca' option\n"
" --private an alias for the 'mark-private' option\n"
" --mark-always-authenticate Marks the object to be written as "
"always authenticate\n"
" --secret-key=str Provide a hex encoded secret key\n"
" --load-privkey=file Private key file to use\n"
" - file must pre-exist\n"
" --load-pubkey=file Public key file to use\n"
" - file must pre-exist\n"
" --load-certificate=file Certificate file to use\n"
" - file must pre-exist\n"
"\n"
"Other options:\n"
"\n"
" -d, --debug=num Enable debugging\n"
" - it must be in the range:\n"
" 0 to 9999\n"
" --outfile=str Output file\n"
" --login Force (user) login to token\n"
" --so-login Force security officer login to token\n"
" --admin-login an alias for the 'so-login' option\n"
" --test-sign Tests the signature operation of the "
"provided object\n"
" --sign-params=str Sign with a specific signature algorithm\n"
" --hash=str Hash algorithm to use for signing\n"
" --generate-random=num Generate random data\n"
" -8, --pkcs8 Use PKCS #8 format for private keys\n"
" --inder Use DER/RAW format for input\n"
" --inraw an alias for the 'inder' option\n"
" --outder Use DER format for output certificates, "
"private keys, and DH parameters\n"
" --outraw an alias for the 'outder' option\n"
" --provider=file Specify the PKCS #11 provider library\n"
" --detailed-url Print detailed URLs\n"
" --only-urls Print a compact listing using only the "
"URLs\n"
" --batch Disable all interaction with the tool\n"
"\n"
"Version, usage and configuration options:\n"
"\n"
" -v, --version[=arg] output version information and exit\n"
" -h, --help display extended usage information and "
"exit\n"
" -!, --more-help extended usage information passed thru "
"pager\n"
"\n"
"Options are specified by doubled hyphens and their name or by a single\n"
"hyphen and the flag character.\n"
"Operands and options may be intermixed. They will be reordered.\n"
"\n"
"Program that allows operations on PKCS #11 smart cards\n"
"and security modules. \n"
"\n"
"To use PKCS #11 tokens with GnuTLS the p11-kit configuration files need "
"to be setup.\n"
"That is create a .module file in /etc/pkcs11/modules with the contents "
"'module: /path/to/pkcs11.so'.\n"
"Alternatively the configuration file /etc/gnutls/pkcs11.conf has to "
"exist and contain a number\n"
"of lines of the form 'load=/usr/lib/opensc-pkcs11.so'.\n"
"\n"
"You can provide the PIN to be used for the PKCS #11 operations with the "
"environment variables\n"
"GNUTLS_PIN and GNUTLS_SO_PIN.\n"
"\n"
"\n"
"Please send bug reports to: <bugs@gnutls.org>\n"
"\n";
fprintf(out, "%s", str);
exit(status);
} | void usage(FILE *param_1, int param_2)
{
long lVar1;
undefined8 *puVar2;
undefined8 *puVar3;
long in_FS_OFFSET;
undefined8 local_1908[799];
undefined8 local_10;
local_10 = *(undefined8 *)(in_FS_OFFSET + 0x28);
puVar2 =
(undefined8
*)"p11tool - GnuTLS PKCS #11 tool\nUsage: p11tool [ -<flag> "
"[<val>] | --<name>[{=| }<val>] ]... "
"[url]\n\nNone:\n\n\nTokens:\n\n --list-tokens "
"List all available tokens\n --list-token-urls List "
"the URLs available tokens\n --list-mechanisms List "
"all available mechanisms in a token\n --initialize "
" Initializes a PKCS #11 token\n --initialize-pin "
"Initializes/Resets a PKCS #11 token user PIN\n "
"--initialize-so-pin Initializes/Resets a PKCS #11 token "
"security officer PIN\n --set-pin=str Specify the "
"PIN to use on token operations\n --set-so-pin=str "
"Specify the Security Officer\'s PIN to use on token "
"initialization\n\nObject listing:\n\n --list-all "
" List all available objects in a token\n --list-all-certs "
" List all available certificates in a token\n "
"--list-certs List all certificates that have an "
"associated private key\n --list-all-privkeys List all "
"available private keys in a token\n --list-privkeys "
"an alias for the \'list-all-privkeys\' option\n "
"--list-keys an alias for the \'list-all-privkeys\' "
"option\n --list-all-trusted List all available "
"certificates marked as trusted\n --export "
"Export the object specified by the URL\n\t\t\t\t- prohibits "
"these "
"options:\n\t\t\t\texport-stapled\n\t\t\t\texport-"
"chain\n\t\t\t\texport-pubkey\n --export-stapled "
"Export the certificate object specified by the URL\n\t\t\t\t- "
"prohibits these "
"options:\n\t\t\t\texport\n\t\t\t\texport-chain\n\t\t\t\texport-"
"pubkey\n --export-chain Export the certificate "
"specified by the URL and its chain of trust\n\t\t\t\t- prohibits "
"these "
"options:\n\t\t\t\texport-stapled\n\t\t\t\texport\n\t\t\t\texport-"
"pubkey\n --export-pubkey Export the public key for "
"a private key\n\t\t\t\t- prohibits these "
"options:\n\t\t\t\texport-stapled\n\t\t\t\texport\n\t\t\t\texport-"
"chain\n --info List information on an "
"available object in a token\n --trusted an "
"alias for the \'mark-trusted\' option\n --distrusted...";
puVar3 = local_1908;
for (lVar1 = 799; lVar1 != 0; lVar1 = lVar1 + -1) {
*puVar3 = *puVar2;
puVar2 = puVar2 + 1;
puVar3 = puVar3 + 1;
}
fprintf(param_1, "%s", local_1908);
exit(param_2);
} | gnutls | ghidra |
) {
fprintf(stderr, "Not enough information: \"prefix\" argument is "
"required.\n");
return -1;
} | int fprintf(FILE *__stream, char *__format, ...)
{
halt_baddata();
} | iproute2-6.0.0 | ghidra |
static unsigned read_buf(strm, buf, size)
z_streamp strm;
Bytef *buf;
unsigned size;
{
unsigned len = strm->avail_in;
if (len > size)
len = size;
if (len == 0)
return 0;
strm->avail_in -= len;
memcpy(buf, strm->next_in, len);
if (strm->state->wrap == 1) {
strm->adler = adler32(strm->adler, buf, len);
}
else if (strm->state->wrap == 2) {
strm->adler = crc32(strm->adler, buf, len);
}
strm->next_in += len;
strm->total_in += len;
return len;
} | int read_buf(struct_0 *a0, void *a1, unsigned long a2) {
struct_2 *v0;
unsigned int v1;
unsigned int v3;
v0 = &a0->field_0;
v1 = a0->field_8;
if (v1 > a2)
v1 = a2;
if (!v1) {
v3 = 0;
} else {
a0->field_8 = a0->field_8 - v1;
memcpy(a1, a0->field_0, v1);
if (a0->field_38->field_30 == 1) {
a0->field_60 = adler32(a0->field_60, a1, v1, a1);
} else if (a0->field_38->field_30 == 2) {
a0->field_60 = crc32(a0->field_60, a1, v1);
}
a0->field_0 = a0->field_0 + v1;
a0->field_10 = a0->field_10 + v1;
v3 = v1;
}
return v3;
} | zlib | angr_phoenix |
static void get_term_capabilities(char **bp) {
register int i;
for (i = 0; i < (sizeof(tc_strings) / sizeof(struct _tc_string)); i++)
*(tc_strings[i].tc_value) = tgetstr((char *)tc_strings[i].tc_var, bp);
tcap_initialized = 1;
} | void get_term_capabilities(unsigned long long a0) {
void *v1;
void *v2;
v1 = 0;
while (true) {
v2 = v1;
if (v1 > 33)
break;
*(*((0x10 * v1 + &g_401328))) =
tgetstr(*((0x10 * v1 + &tc_strings)), a0, a0, v1 * 16);
v1 = v1 + 1;
}
tcap_initialized = 1;
return;
} | bash | angr_dream |
static void channel_handler_init(struct ssh_channels *sc) {
chan_fn **pre, **post;
if ((pre = calloc(23, sizeof(*pre))) == ((void *)0) ||
(post = calloc(23, sizeof(*post))) == ((void *)0))
sshfatal("channels.c", __func__, 2354, 1, SYSLOG_LEVEL_FATAL, ((void *)0),
"allocation failed");
pre[4] = &channel_pre_open;
pre[7] = &channel_pre_x11_open;
pre[2] = &channel_pre_listener;
pre[11] = &channel_pre_listener;
pre[18] = &channel_pre_listener;
pre[19] = &channel_pre_listener;
pre[1] = &channel_pre_listener;
pre[6] = &channel_pre_listener;
pre[12] = &channel_pre_connecting;
pre[13] = &channel_pre_dynamic;
pre[22] = &channel_pre_connecting;
pre[15] = &channel_pre_listener;
pre[16] = &channel_pre_mux_client;
post[4] = &channel_post_open;
post[2] = &channel_post_port_listener;
post[11] = &channel_post_port_listener;
post[18] = &channel_post_port_listener;
post[19] = &channel_post_port_listener;
post[1] = &channel_post_x11_listener;
post[6] = &channel_post_auth_listener;
post[12] = &channel_post_connecting;
post[13] = &channel_post_open;
post[22] = &channel_post_connecting;
post[15] = &channel_post_mux_listener;
post[16] = &channel_post_mux_client;
sc->channel_pre = pre;
sc->channel_post = post;
} | long channel_handler_init(long a1) {
long result;
_QWORD *v2;
_QWORD *v3;
v2 = calloc(0x17uLL, 8uLL);
if (!v2 || (v3 = calloc(0x17uLL, 8uLL)) == 0LL)
sshfatal("channels.c", "channel_handler_init", 2354LL, 1LL, 1LL, 0LL,
"allocation failed");
v2[4] = channel_pre_open;
v2[7] = channel_pre_x11_open;
v2[2] = channel_pre_listener;
v2[11] = channel_pre_listener;
v2[18] = channel_pre_listener;
v2[19] = channel_pre_listener;
v2[1] = channel_pre_listener;
v2[6] = channel_pre_listener;
v2[12] = channel_pre_connecting;
v2[13] = channel_pre_dynamic;
v2[22] = channel_pre_connecting;
v2[15] = channel_pre_listener;
v2[16] = channel_pre_mux_client;
v3[4] = channel_post_open;
v3[2] = channel_post_port_listener;
v3[11] = channel_post_port_listener;
v3[18] = channel_post_port_listener;
v3[19] = channel_post_port_listener;
v3[1] = channel_post_x11_listener;
v3[6] = channel_post_auth_listener;
v3[12] = channel_post_connecting;
v3[13] = channel_post_open;
v3[22] = channel_post_connecting;
v3[15] = channel_post_mux_listener;
v3[16] = channel_post_mux_client;
*(_QWORD *)(a1 + 16) = v2;
result = a1;
*(_QWORD *)(a1 + 24) = v3;
return result;
} | openssh-portable | ida |
(r = sshpkt_send(ssh)) != 0)
sshpkt_fatal(ssh, r, "%s: exit reply", __func__);
}
else { | void sshpkt_send(void)
{
halt_baddata();
} | openssh-portable | ghidra |
static void huf_decode_start() {
init_getbits();
blocksize = 0;
} | long huf_decode_start() {
long result;
result = init_getbits();
blocksize = 0;
return result;
} | gzip-1.12 | ida |
void ssh_packet_disconnect(struct ssh *ssh, const char *fmt, ...) {
char buf[1024], remote_id[512];
va_list args;
static int disconnecting = 0;
int r;
if (disconnecting)
sshfatal("packet.c", __func__, 1941, 0, SYSLOG_LEVEL_FATAL, ((void *)0),
"packet_disconnect called recursively.");
disconnecting = 1;
sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id));
__builtin_va_start(args, fmt);
vsnprintf(buf, sizeof(buf), fmt, args);
__builtin_va_end(args);
sshlog("packet.c", __func__, 1954, 0, SYSLOG_LEVEL_INFO, ((void *)0),
"Disconnecting %s: %.100s", remote_id, buf);
if ((r = sshpkt_disconnect(ssh, "%s", buf)) != 0)
sshpkt_fatal(ssh, r, "%s", __func__);
if ((r = ssh_packet_write_wait(ssh)) != 0)
sshpkt_fatal(ssh, r, "%s", __func__);
ssh_packet_close(ssh);
cleanup_exit(255);
} | long long ssh_packet_disconnect() {
unsigned long long v0;
unsigned int v1;
unsigned int v2;
unsigned int v3;
unsigned long v4;
unsigned long v5;
char v6;
char v7;
unsigned long v8;
char v9;
unsigned long v10;
unsigned long v11;
unsigned long v12;
unsigned long v13;
int v14;
int v15;
int v16;
int v17;
int v18;
int v19;
int v20;
unsigned long long v21;
unsigned long v22;
unsigned long v23;
unsigned long v24;
unsigned long v25;
unsigned long v26;
unsigned long v27;
unsigned long v28;
char v29;
int v30;
int v31;
int v32;
int v33;
int v34;
int v35;
int v36;
int v37;
unsigned long long *v38;
void *v39;
char *v40;
v10 = v25;
v11 = v26;
v12 = v27;
v13 = v28;
if (v29) {
v14 = v30;
v15 = v31;
v16 = v32;
v17 = v33;
v18 = v34;
v19 = v35;
v20 = v36;
v22 = v37;
}
v8 = v38[5];
if (disconnecting.20275) {
v0 = "packet_disconnect called recursively.";
sshfatal("packet.c", "ssh_packet_disconnect", 0x795, 0x0, 0x1, 0x0);
}
disconnecting.20275 = 1;
sshpkt_fmt_connection_id(v39, &v6, 0x200);
v2 = 16;
v3 = 48;
v4 = &v24;
v5 = &v9;
vsnprintf(&v7, 0x400, v40, &v2);
v23 = &v7;
v22 = &v6;
v21 = "Disconnecting %s: %.100s";
sshlog("packet.c", "ssh_packet_disconnect", 0x7a2, 0x0, 0x3, 0x0);
v1 = sshpkt_disconnect();
if (v1)
sshpkt_fatal(v39, v1);
v1 = ssh_packet_write_wait(v39);
if (v1)
sshpkt_fatal(v39, v1);
ssh_packet_close(v39);
cleanup_exit(0xff);
} | openssh-portable | angr_dream |
static void install_signal_handlers(void) {
static int const sig[] = {
20,
14, 1, 2, 13, 3, 15,
29,
27,
26,
24,
25,
};
enum { nsigs = sizeof(sig) / sizeof *(sig) };
{
int j;
struct sigaction act;
sigemptyset(&caught_signals);
for (j = 0; j < nsigs; j++) {
sigaction(sig[j], ((void *)0), &act);
if (act.__sigaction_handler.sa_handler != ((__sighandler_t)1))
sigaddset(&caught_signals, sig[j]);
}
act.sa_mask = caught_signals;
act.sa_flags = 0x10000000;
for (j = 0; j < nsigs; j++)
if (sigismember(&caught_signals, sig[j])) {
act.__sigaction_handler.sa_handler =
sig[j] == 20 ? stophandler : sighandler;
sigaction(sig[j], &act, ((void *)0));
}
}
} | void install_signal_handlers() {
unsigned int v0;
char v1;
unsigned long v2;
unsigned long v3;
unsigned long v4;
unsigned long v5;
unsigned long v6;
unsigned long v7;
unsigned long v8;
unsigned long v9;
unsigned long v10;
unsigned long v11;
unsigned long v12;
unsigned long v13;
unsigned long v14;
unsigned long v15;
unsigned long v16;
unsigned long v17;
unsigned int v18;
char v19;
unsigned long long *v22;
unsigned long long v23;
sigemptyset(&caught_signals);
for (v0 = 0; v0 <= 11; v0 += 1) {
sigaction(sig.5610 [v0], 0x0, &v1);
if (*(&v1) != 1)
sigaddset(&caught_signals, sig.5610 [v0]);
}
v2 = caught_signals;
v3 = g_402808;
v4 = g_402810;
v5 = g_402818;
v6 = g_402820;
v7 = g_402828;
v8 = g_402830;
v9 = g_402838;
v10 = g_402840;
v11 = g_402848;
v12 = g_402850;
v13 = g_402858;
v14 = g_402860;
v15 = g_402868;
v16 = g_402870;
v17 = g_402878;
v18 = 0x10000000;
for (v0 = 0; v0 <= 11; v0 += 1) {
if (sigismember(&caught_signals, sig.5610 [v0])) {
*(&v1) = (sig.5610 [v0] == 20 ? sighandler : stophandler);
sigaction(sig.5610 [v0], &v1, 0x0);
}
}
v23 = *(&v19) ^ v22[5];
return;
} | diffutils | angr_sailr |
void client_stop_mux(void) {
if (options.control_path != ((void *)0) && muxserver_sock != -1)
unlink(options.control_path);
if (options.control_persist || options.session_type == 0) {
session_closed = 1;
setproctitle("[stopped mux]");
}
} | void client_stop_mux(void)
{
if ((_DAT_0010d3a0 != (char *)0x0) && (muxserver_sock != -1)) {
unlink(_DAT_0010d3a0);
}
if ((_DAT_0010d3ac != 0) || (_DAT_0010d3e8 == 0)) {
session_closed = 1;
setproctitle("[stopped mux]");
}
return;
} | openssh-portable | ghidra |
static void error_prolog(print_lineno) int print_lineno;
{
char *ename;
int line;
ename = get_name_for_error();
line =
(print_lineno && interactive_shell == 0) ? executing_line_number() : -1;
if (line > 0)
fprintf(stderr, "%s:%s%d: ", ename,
gnu_error_format ? "" : gettext(" line "), line);
else
fprintf(stderr, "%s: ", ename);
} | void error_prolog(unsigned long a0) {
unsigned int v0;
unsigned long v1;
unsigned int v3;
unsigned long long v4;
unsigned long long v5;
v1 = get_name_for_error();
if (a0 && !interactive_shell) {
v3 = executing_line_number();
goto LABEL_400034;
}
v3 = -1;
LABEL_400034:
v0 = v3;
if (v0 <= 0) {
v4 = fprintf(*(&stderr), "%s: ", v1);
} else {
if (gnu_error_format)
v3 = &g_400df8;
else
v3 = gettext(" line ");
v5 = fprintf(*(&stderr), "%s:%s%d: ", v1, v3, v0);
}
return;
} | bash | angr_phoenix |
static int rsa_hash_id_from_keyname(const char *alg) {
int r;
if ((r = rsa_hash_id_from_ident(alg)) != -1)
return r;
if (strcmp(alg, "ssh-rsa-cert-v01@openssh.com") == 0)
return 1;
if (strcmp(alg, "rsa-sha2-256-cert-v01@openssh.com") == 0)
return 2;
if (strcmp(alg, "rsa-sha2-512-cert-v01@openssh.com") == 0)
return 4;
return -1;
} | long rsa_hash_id_from_keyname(const char *a1) {
unsigned int v2;
v2 = rsa_hash_id_from_ident(a1);
if (v2 != -1)
return v2;
if (!strcmp(a1, "ssh-rsa-cert-v01@openssh.com"))
return 1LL;
if (!strcmp(a1, "rsa-sha2-256-cert-v01@openssh.com"))
return 2LL;
if (!strcmp(a1, "rsa-sha2-512-cert-v01@openssh.com"))
return 4LL;
return 0xFFFFFFFFLL;
} | openssh-portable | ida |
static void mp_factor_using_pollard_rho(mpz_t n, unsigned long int a,
struct mp_factors *factors) {
mpz_t x, z, y, P;
mpz_t t, t2;
do {
if (dev_debug)
fprintf(stderr, "[pollard-rho (%lu)] ", a);
} while (0);
__gmpz_inits(t, t2, ((void *)0));
__gmpz_init_set_si(y, 2);
__gmpz_init_set_si(x, 2);
__gmpz_init_set_si(z, 2);
__gmpz_init_set_ui(P, 1);
unsigned long long int k = 1;
unsigned long long int l = 1;
while ((__builtin_constant_p(1) && (1) == 0
? ((n)->_mp_size < 0 ? -1 : (n)->_mp_size > 0)
: __gmpz_cmp_ui(n, 1)) != 0) {
for (;;) {
do {
__gmpz_mul(t, x, x);
__gmpz_mod(x, t, n);
__gmpz_add_ui(x, x, a);
__gmpz_sub(t, z, x);
__gmpz_mul(t2, P, t);
__gmpz_mod(P, t2, n);
if (k % 32 == 1) {
__gmpz_gcd(t, P, n);
if ((__builtin_constant_p(1) && (1) == 0
? ((t)->_mp_size < 0 ? -1 : (t)->_mp_size > 0)
: __gmpz_cmp_ui(t, 1)) != 0)
goto factor_found;
__gmpz_set(y, x);
}
} while (--k != 0);
__gmpz_set(z, x);
k = l;
l = 2 * l;
for (unsigned long long int i = 0; i < k; i++) {
__gmpz_mul(t, x, x);
__gmpz_mod(x, t, n);
__gmpz_add_ui(x, x, a);
}
__gmpz_set(y, x);
}
factor_found:
do {
__gmpz_mul(t, y, y);
__gmpz_mod(y, t, n);
__gmpz_add_ui(y, y, a);
__gmpz_sub(t, z, y);
__gmpz_gcd(t, t, n);
} while ((__builtin_constant_p(1) && (1) == 0
? ((t)->_mp_size < 0 ? -1 : (t)->_mp_size > 0)
: __gmpz_cmp_ui(t, 1)) == 0);
__gmpz_divexact(n, n, t);
if (!mp_prime_p(t)) {
do {
if (dev_debug)
fprintf(stderr, "[composite factor--restarting pollard-rho] ");
} while (0);
mp_factor_using_pollard_rho(t, a + 1, factors);
} else {
mp_factor_insert(factors, t);
}
if (mp_prime_p(n)) {
mp_factor_insert(factors, n);
break;
}
__gmpz_mod(x, x, n);
__gmpz_mod(z, z, n);
__gmpz_mod(y, y, n);
}
__gmpz_clears(P, t2, t, z, x, y, ((void *)0));
} | void mp_factor_using_pollard_rho(undefined8 param_1, long param_2,
undefined8 param_3)
{
char cVar1;
int iVar2;
long in_FS_OFFSET;
undefined8 uVar3;
ulong local_90;
ulong local_88;
ulong local_80;
undefined local_78[16];
undefined local_68[16];
undefined local_58[16];
undefined local_48[16];
undefined local_38[16];
undefined local_28[24];
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
if (dev_debug != '\0') {
fprintf(stderr, "[pollard-rho (%lu)] ", param_2);
}
__gmpz_inits(local_38, local_28, 0);
__gmpz_init_set_si(local_58, 2);
__gmpz_init_set_si(local_78, 2);
__gmpz_init_set_si(local_68, 2);
__gmpz_init_set_ui(local_48, 1);
local_90 = 1;
local_88 = 1;
LAB_00104447:
uVar3 = 0x10445b;
iVar2 = __gmpz_cmp_ui(param_1, 1);
if (iVar2 != 0) {
LAB_00104105:
__gmpz_mul(local_38, local_78, local_78);
__gmpz_mod(local_78, local_38, param_1);
__gmpz_add_ui(local_78, local_78, param_2);
__gmpz_sub(local_38, local_68, local_78);
__gmpz_mul(local_28, local_48, local_38);
__gmpz_mod(local_48, local_28, param_1);
if (((uint)local_90 & 0x1f) == 1) {
__gmpz_gcd(local_38, local_48, param_1);
iVar2 = __gmpz_cmp_ui(local_38, 1);
if (iVar2 != 0)
goto LAB_001042a7;
__gmpz_set(local_58, local_78);
}
local_90 = local_90 - 1;
if (local_90 == 0) {
__gmpz_set(local_68, local_78);
local_90 = local_88;
for (local_80 = 0; local_80 < local_88; local_80 = local_80 + 1) {
__gmpz_mul(local_38, local_78, local_78);
__gmpz_mod(local_78, local_38, param_1);
__gmpz_add_ui(local_78, local_78, param_2);
}
__gmpz_set(local_58, local_78);
local_88 = local_88 << 1;
}
goto LAB_00104105;
}
LAB_00104463:
__gmpz_clears(local_48, local_28, local_38, local_68, local_78, local_58, 0,
uVar3);
if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) {
return;
}
__stack_chk_fail();
LAB_001042a7:
do {
__gmpz_mul(local_38, local_58, local_58);
__gmpz_mod(local_58, local_38, param_1);
__gmpz_add_ui(local_58, local_58, param_2);
__gmpz_sub(local_38, local_68, local_58);
__gmpz_gcd(local_38, local_38, param_1);
iVar2 = __gmpz_cmp_ui(local_38, 1);
} while (iVar2 == 0);
__gmpz_divexact(param_1, param_1, local_38);
cVar1 = mp_prime_p(local_38);
if (cVar1 == '\x01') {
mp_factor_insert(param_3, local_38);
} else {
if (dev_debug != '\0') {
fprintf(stderr, "[composite factor--restarting pollard-rho] ");
}
mp_factor_using_pollard_rho(local_38, param_2 + 1, param_3);
}
cVar1 = mp_prime_p(param_1);
if (cVar1 != '\0') {
uVar3 = 0x1043f7;
mp_factor_insert(param_3, param_1);
goto LAB_00104463;
}
__gmpz_mod(local_78, local_78, param_1);
__gmpz_mod(local_68, local_68, param_1);
__gmpz_mod(local_58, local_58, param_1);
goto LAB_00104447;
} | coreutils | ghidra |
COMMAND *make_subshell_command(command)
COMMAND *command;
{
SUBSHELL_COM *temp;
temp = (SUBSHELL_COM *)sh_xmalloc((sizeof(SUBSHELL_COM)), "make_cmd.c", 821);
temp->command = command;
temp->flags = 0x01;
temp->line = line_number;
return (make_command(cm_subshell, (SIMPLE_COM *)temp));
} | long long make_subshell_command(unsigned long a0) {
struct_0 *v0;
v0 = sh_xmalloc(0x10, "make_cmd.c", 0x335);
v0->field_8 = a0;
v0->field_0 = 1;
v0->field_4 = line_number;
return make_command(0xd, v0);
} | bash | angr_dream |
int setlogin(const char *name) { return (0); } | long long setlogin(unsigned long a0) {
unsigned long v0;
v0 = a0;
return 0;
} | openssh-portable | angr_dream |
static int extmatch_wc(xc, s, se, p, pe, flags)
wint_t xc;
wchar_t *s, *se;
wchar_t *p, *pe;
int flags;
{
wchar_t *prest;
wchar_t *psub;
wchar_t *pnext;
wchar_t *srest;
int m1, m2, xflags;
prest = glob_patscan_wc(p + (*p == L'('), pe, 0);
if (prest == 0)
return (wscompare(p - 1, pe, s, se));
switch (xc) {
case L'+':
case L'*':
if (xc == L'*' && (gmatch_wc(s, se, prest, pe, ((void *)0), flags) == 0))
return 0;
for (psub = p + 1;; psub = pnext) {
pnext = glob_patscan_wc(psub, pe, L'|');
for (srest = s; srest <= se; srest++) {
m1 = gmatch_wc(s, srest, psub, pnext - 1, ((void *)0), flags) == 0;
if (m1) {
xflags = (srest > s) ? (flags & ~((1 << 2) | (1 << 7))) : flags;
m2 = (gmatch_wc(srest, se, prest, pe, ((void *)0), xflags) == 0) ||
(s != srest &&
gmatch_wc(srest, se, p - 1, pe, ((void *)0), xflags) == 0);
}
if (m1 && m2)
return (0);
}
if (pnext == prest)
break;
}
return (1);
case L'?':
case L'@':
if (xc == L'?' && (gmatch_wc(s, se, prest, pe, ((void *)0), flags) == 0))
return 0;
for (psub = p + 1;; psub = pnext) {
pnext = glob_patscan_wc(psub, pe, L'|');
srest = (prest == pe) ? se : s;
for (; srest <= se; srest++) {
xflags = (srest > s) ? (flags & ~((1 << 2) | (1 << 7))) : flags;
if (gmatch_wc(s, srest, psub, pnext - 1, ((void *)0), flags) == 0 &&
gmatch_wc(srest, se, prest, pe, ((void *)0), xflags) == 0)
return (0);
}
if (pnext == prest)
break;
}
return (1);
case '!':
for (srest = s; srest <= se; srest++) {
m1 = 0;
for (psub = p + 1;; psub = pnext) {
pnext = glob_patscan_wc(psub, pe, L'|');
if (m1 =
(gmatch_wc(s, srest, psub, pnext - 1, ((void *)0), flags) == 0))
break;
if (pnext == prest)
break;
}
if (m1 == 0 && (flags & (1 << 2)) && *s == '.')
return (1);
if (m1 == 0 && (flags & (1 << 7)) &&
((s[0] == L'.' &&
(s[1] == L'\0' || (s[1] == L'.' && s[2] == L'\0'))) ||
((flags & (1 << 0)) && s[-1] == L'/' &&
(s[0] == L'.' &&
((((s[1]) == L'/') || (s[1]) == L'\0') ||
(s[1] == L'.' && (((s[2]) == L'/') || (s[2]) == L'\0')))))))
return (1);
xflags = (srest > s) ? (flags & ~((1 << 2) | (1 << 7))) : flags;
if (m1 == 0 && gmatch_wc(srest, se, prest, pe, ((void *)0), xflags) == 0)
return (0);
}
return (1);
}
return (1);
} | undefined8 extmatch_wc(uint param_1, int *param_2, int *param_3, int *param_4,
int *param_5, uint param_6)
{
int iVar1;
uint uVar2;
int iVar3;
int *piVar4;
undefined8 uVar5;
int *piVar6;
long lVar7;
bool bVar8;
int local_34;
int *local_28;
int *local_20;
if (*param_4 == 0x28) {
lVar7 = 4;
} else {
lVar7 = 0;
}
piVar4 = (int *)glob_patscan_wc(lVar7 + (long)param_4, param_5, 0);
if (piVar4 == (int *)0x0) {
uVar5 = wscompare(param_4 + -1, param_5, param_2, param_3);
return uVar5;
}
if (param_1 < 0x41) {
if (0x3e < param_1) {
if ((param_1 == 0x3f) &&
(iVar1 = gmatch_wc(param_2, param_3, piVar4, param_5, 0, param_6),
iVar1 == 0)) {
return 0;
}
local_28 = param_4 + 1;
do {
piVar6 = (int *)glob_patscan_wc(local_28, param_5, 0x7c);
local_20 = param_2;
if (piVar4 == param_5) {
local_20 = param_3;
}
for (; local_20 <= param_3; local_20 = local_20 + 1) {
uVar2 = param_6;
if (param_2 < local_20) {
uVar2 = param_6 & 0xffffff7b;
}
iVar1 =
gmatch_wc(param_2, local_20, local_28, piVar6 + -1, 0, param_6);
if ((iVar1 == 0) &&
(iVar1 = gmatch_wc(local_20, param_3, piVar4, param_5, 0, uVar2),
iVar1 == 0)) {
return 0;
}
}
local_28 = piVar6;
if (piVar6 == piVar4) {
return 1;
}
} while (true);
}
local_20 = param_2;
if (param_1 == 0x21) {
do {
if (param_3 < local_20) {
return 1;
}
local_28 = param_4 + 1;
do {
piVar6 = (int *)glob_patscan_wc(local_28, param_5, 0x7c);
iVar1 =
gmatch_wc(param_2, local_20, local_28, piVar6 + -1, 0, param_6);
bVar8 = iVar1 == 0;
if (bVar8)
break;
local_28 = piVar6;
} while (piVar6 != piVar4);
if (((!bVar8) && ((param_6 & 4) != 0)) && (*param_2 == 0x2e)) {
return 1;
}
if (((!bVar8) && ((param_6 & 0x80) != 0)) &&
(((*param_2 == 0x2e &&
((param_2[1] == 0 ||
((param_2[1] == 0x2e && (param_2[2] == 0)))))) ||
((((param_6 & 1) != 0 &&
((param_2[-1] == 0x2f && (*param_2 == 0x2e)))) &&
(((param_2[1] == 0x2f || (param_2[1] == 0)) ||
((param_2[1] == 0x2e &&
((param_2[2] == 0x2f || (param_2[2] == 0)))))))))))) {
return 1;
}
uVar2 = param_6;
if (param_2 < local_20) {
uVar2 = param_6 & 0xffffff7b;
}
if ((!bVar8) &&
(iVar1 = gmatch_wc(local_20, param_3, piVar4, param_5, 0, uVar2),
iVar1 == 0)) {
return 0;
}
local_20 = local_20 + 1;
} while (true);
}
if ((0x20 < param_1) && (param_1 - 0x2a < 2)) {
if ((param_1 == 0x2a) &&
(iVar1 = gmatch_wc(param_2, param_3, piVar4, param_5, 0, param_6),
iVar1 == 0)) {
return 0;
}
local_28 = param_4 + 1;
do {
piVar6 = (int *)glob_patscan_wc(local_28, param_5, 0x7c);
for (local_20 = param_2; local_20 <= param_3; local_20 = local_20 + 1) {
iVar1 =
gmatch_wc(param_2, local_20, local_28, piVar6 + -1, 0, param_6);
if (iVar1 == 0) {
uVar2 = param_6;
if (param_2 < local_20) {
uVar2 = param_6 & 0xffffff7b;
}
iVar3 = gmatch_wc(local_20, param_3, piVar4, param_5, 0, uVar2);
if ((iVar3 == 0) ||
((param_2 != local_20 &&
(iVar3 = gmatch_wc(local_20, param_3, param_4 + -1, param_5,
0, uVar2),
iVar3 == 0)))) {
local_34 = 1;
} else {
local_34 = 0;
}
}
if ((iVar1 == 0) && (local_34 != 0)) {
return 0;
}
}
local_28 = piVar6;
if (piVar6 == piVar4) {
return 1;
}
} while (true);
}
}
return 1;
} | bash | ghidra |
static _Bool
print_color_indicator(const struct bin_str *ind) {
if (ind) {
if (is_colored(C_NORM))
restore_default_color();
put_indicator(&color_indicator[C_LEFT]);
put_indicator(ind);
put_indicator(&color_indicator[C_RIGHT]);
}
return ind != ((void *)0);
} | void print_color_indicator(void *a0) {
unsigned long long v1;
if (a0) {
if (is_colored(0x4))
restore_default_color();
put_indicator(&color_indicator);
put_indicator(a0);
v1 = put_indicator(&g_410710);
}
*(&v1) = a0;
return;
} | coreutils | angr_sailr |
static void ipnh_cache_link_entry(struct nh_entry *nhe) {
struct hlist_head *head = ipnh_cache_head(nhe->nh_id);
hlist_add_head(&nhe->nh_hash, head);
} | void ipnh_cache_link_entry(long param_1)
{
undefined8 uVar1;
uVar1 = ipnh_cache_head(*(undefined4 *)(param_1 + 0x10));
hlist_add_head(param_1, uVar1);
return;
} | iproute2-6.0.0 | ghidra |
static void xheader_set_keyword_equal(char *kw, char *eq) {
_Bool global = 1;
char *p = eq;
if (eq == kw)
do {
if (error_hook)
error_hook();
error(0, 0, gettext("Malformed pax option: %s"), quote(kw));
usage(2);
} while (0);
if (eq[-1] == ':') {
p--;
global = 0;
}
while (p > kw && ((*__ctype_b_loc())[(int)(((unsigned char)*p))] &
(unsigned short int)_ISspace))
p--;
*p = 0;
for (p = eq + 1; *p && ((*__ctype_b_loc())[(int)(((unsigned char)*p))] &
(unsigned short int)_ISspace);
p++)
;
if (strcmp(kw, "delete") == 0) {
if (xheader_protected_pattern_p(p))
do {
if (error_hook)
error_hook();
error(0, 0, gettext("Pattern %s cannot be used"), quote(p));
usage(2);
} while (0);
xheader_list_append(&keyword_pattern_list, p, ((void *)0));
} else if (strcmp(kw, "exthdr.name") == 0)
assign_string(&exthdr_name, p);
else if (strcmp(kw, "globexthdr.name") == 0)
assign_string(&globexthdr_name, p);
else if (strcmp(kw, "exthdr.mtime") == 0)
assign_time_option(&exthdr_mtime_option, &exthdr_mtime, p);
else if (strcmp(kw, "globexthdr.mtime") == 0)
assign_time_option(&globexthdr_mtime_option, &globexthdr_mtime, p);
else {
if (xheader_protected_keyword_p(kw))
do {
if (error_hook)
error_hook();
error(0, 0, gettext("Keyword %s cannot be overridden"), kw);
usage(2);
} while (0);
if (global)
xheader_list_append(&keyword_global_override_list, kw, p);
else
xheader_list_append(&keyword_override_list, kw, p);
}
} | _QWORD *xheader_set_keyword_equal(const char *a1, const char *a2) {
long v2;
char *v3;
long v4;
char *v5;
char *v7;
char v8;
const char *v9;
const char *i;
v8 = 1;
v9 = a2;
if (a2 == a1) {
if (error_hook)
error_hook(a1);
v2 = quote(a1);
v3 = gettext("Malformed pax option: %s");
error(0, 0, v3, v2);
usage(2LL);
}
if (*(a2 - 1) == 58) {
v9 = a2 - 1;
v8 = 0;
}
while (v9 > a1 && ((*_ctype_b_loc())[*(unsigned char *)v9] & 0x2000) != 0)
--v9;
*v9 = 0;
for (i = a2 + 1; *i && ((*_ctype_b_loc())[*(unsigned char *)i] & 0x2000) != 0;
++i)
;
if (!strcmp(a1, "delete")) {
if ((unsigned char)xheader_protected_pattern_p(i)) {
if (error_hook)
error_hook(i);
v4 = quote(i);
v5 = gettext("Pattern %s cannot be used");
error(0, 0, v5, v4);
usage(2LL);
}
return xheader_list_append(&keyword_pattern_list, (long)i, 0LL);
} else if (!strcmp(a1, "exthdr.name")) {
return (_QWORD *)assign_string(&exthdr_name, i);
} else if (!strcmp(a1, "globexthdr.name")) {
return (_QWORD *)assign_string(&globexthdr_name, i);
} else if (!strcmp(a1, "exthdr.mtime")) {
return (_QWORD *)assign_time_option((long)&exthdr_mtime_option,
&exthdr_mtime, (long)i);
} else if (!strcmp(a1, "globexthdr.mtime")) {
return (_QWORD *)assign_time_option((long)&globexthdr_mtime_option,
&globexthdr_mtime, (long)i);
} else {
if ((unsigned char)xheader_protected_keyword_p(a1)) {
if (error_hook)
error_hook(a1);
v7 = gettext("Keyword %s cannot be overridden");
error(0, 0, v7, a1);
usage(2LL);
}
if (v8)
return xheader_list_append(&keyword_global_override_list, (long)a1,
(long)i);
else
return xheader_list_append(&keyword_override_list, (long)a1, (long)i);
}
} | tar | ida |
char *quote_string_for_globbing(pathname, qflags) const char *pathname;
int qflags;
{
char *temp;
register int i, j;
int cclass, collsym, equiv, c, last_was_backslash;
int savei, savej;
temp = (char *)sh_xmalloc((2 * strlen(pathname) + 1), "pathexp.c", 215);
if ((qflags & 0x01) && ((pathname)[0] == '\177' && (pathname)[1] == '\0')) {
temp[0] = '\0';
return temp;
}
cclass = collsym = equiv = last_was_backslash = 0;
for (i = j = 0; pathname[i]; i++) {
if (pathname[i] == '\001' && pathname[i + 1] == '\0') {
temp[j++] = pathname[i++];
break;
}
else if ((qflags & (0x04 | 0x08)) && pathname[i] == '\001' &&
(pathname[i + 1] == '\001' || pathname[i + 1] == '\177')) {
i++;
temp[j++] = pathname[i];
continue;
} else if (pathname[i] == '\001') {
convert_to_backslash:
if ((qflags & 0x02) && pathname[i + 1] == '/')
continue;
if (pathname[i + 1] != '\001' && (qflags & 0x04) &&
ere_char(pathname[i + 1]) == 0)
continue;
temp[j++] = '\\';
i++;
if (pathname[i] == '\0')
break;
} else if ((qflags & 0x04) && (i == 0 || pathname[i - 1] != '\001') &&
pathname[i] == '[') {
temp[j++] = pathname[i++];
savej = j;
savei = i;
c = pathname[i++];
if (c == '^') {
temp[j++] = c;
c = pathname[i++];
}
if (c == ']') {
temp[j++] = c;
c = pathname[i++];
}
do {
if (c == 0)
goto endpat;
else if (c == '\001') {
if (pathname[i] == 0)
goto endpat;
temp[j++] = pathname[i++];
} else if (c == '[' && pathname[i] == ':') {
temp[j++] = c;
temp[j++] = pathname[i++];
cclass = 1;
} else if (cclass && c == ':' && pathname[i] == ']') {
temp[j++] = c;
temp[j++] = pathname[i++];
cclass = 0;
} else if (c == '[' && pathname[i] == '=') {
temp[j++] = c;
temp[j++] = pathname[i++];
if (pathname[i] == ']')
temp[j++] = pathname[i++];
equiv = 1;
} else if (equiv && c == '=' && pathname[i] == ']') {
temp[j++] = c;
temp[j++] = pathname[i++];
equiv = 0;
} else if (c == '[' && pathname[i] == '.') {
temp[j++] = c;
temp[j++] = pathname[i++];
if (pathname[i] == ']')
temp[j++] = pathname[i++];
collsym = 1;
} else if (collsym && c == '.' && pathname[i] == ']') {
temp[j++] = c;
temp[j++] = pathname[i++];
collsym = 0;
} else
temp[j++] = c;
} while (((c = pathname[i++]) != ']') && c != 0);
if (c == 0) {
i = savei - 1;
j = savej;
continue;
}
temp[j++] = c;
i--;
continue;
} else if (pathname[i] == '\\' && (qflags & 0x04) == 0) {
temp[j++] = '\\';
i++;
if (pathname[i] == '\0')
break;
if ((qflags & 0x08) && pathname[i] == '\001' &&
(pathname[i + 1] == '\001' || pathname[i + 1] == '\177'))
i++;
else if ((qflags & 0x08) && pathname[i] == '\001')
goto convert_to_backslash;
} else if (pathname[i] == '\\' && (qflags & 0x04))
last_was_backslash = 1;
temp[j++] = pathname[i];
}
endpat:
temp[j] = '\0';
return (temp);
} | int quote_string_for_globbing(void *a0, unsigned long a1) {
unsigned int v0;
int tmp_27;
int tmp_17;
int tmp_40;
int tmp_65;
int tmp_14;
int tmp_32;
int tmp_10;
int tmp_36;
int tmp_53;
int tmp_43;
int tmp_60;
int tmp_7;
int tmp_11;
int tmp_19;
unsigned int v1;
unsigned int v2;
unsigned int v3;
unsigned int v4;
unsigned int v5;
unsigned int v6;
void *v7;
void *v9;
void *v10;
unsigned int v11;
unsigned int v12;
void *v13;
v7 = sh_xmalloc(strlen(a0) * 2 + 1, "pathexp.c", 0xd7);
if ((a1 & 1) && *(a0) == 127 && !a0[1]) {
*(v7) = 0;
v11 = v7;
goto LABEL_400b04;
}
v4 = 0;
v2 = v4;
v1 = v2;
v0 = v1;
v9 = 0;
v10 = 0;
while (true) {
if (!*((a0 + v10)))
break;
if (*((a0 + v10)) == 1 && !*((a0 + v10 + 1))) {
tmp_27 = v9;
v9 += 1;
*(tmp_27 + v7) = *((v10 + a0));
break;
}
if ((a1 & 12) && *((a0 + v10)) == 1) {
if (*((a0 + v10 + 1)) != 1 && !(*((a0 + v10 + 1)) == 127))
goto LABEL_4004b2;
v10 = v10 + 1;
tmp_27 = v9;
v9 += 1;
*(tmp_27 + v7) = *((v10 + a0));
goto LABEL_400ad2;
}
LABEL_4004b2:
if (*((a0 + v10)) == 1) {
LABEL_4004c8:
if ((a1 & 2) && *((a0 + v10 + 1)) == 47)
goto LABEL_400ad2;
if (*((a0 + v10 + 1)) != 1 && (a1 & 4) && !ere_char(*((a0 + v10 + 1))))
goto LABEL_400ad2;
tmp_17 = v9;
v9 += 1;
*(v7 + tmp_17) = 92;
v10 = v10 + 1;
if (!*((a0 + v10)))
break;
}
if ((a1 & 4)) {
if (v10 && *((a0 + v10 - 1)) == 1)
goto LABEL_4009cd;
if (*((a0 + v10)) == 91) {
tmp_40 = v9;
v9 += 1;
*(tmp_40 + v7) = *((v10 + a0));
v5 = v9;
v6 = v10 + 1;
tmp_65 = v10 + 1;
v10 += 2;
v12 = *(a0 + tmp_65);
v3 = v12;
if (v3 == 94) {
tmp_14 = v9;
v9 += 1;
*(v7 + tmp_14) = v3;
tmp_32 = v10;
v10 += 1;
v12 = *(a0 + tmp_32);
v3 = v12;
}
if (v3 == 93) {
tmp_14 = v9;
v9 += 1;
*(v7 + tmp_14) = v3;
tmp_32 = v10;
v10 += 1;
v12 = *(a0 + tmp_32);
v3 = v12;
}
while (true) {
if (!v3)
break;
if (v3 == 1) {
if (!*((a0 + v10)))
break;
tmp_10 = v10;
v10 += 1;
tmp_27 = v9;
v13 = v9 + 1;
*(&v12) = *(tmp_10 + a0);
*(tmp_27 + v7) = v12;
goto LABEL_400972;
}
if (v3 == 91 && *((a0 + v10)) == 58) {
*((v7 + v9)) = v3;
tmp_36 = v10;
v10 += 1;
tmp_53 = v9 + 1;
v13 = v9 + 2;
*(&v12) = *(tmp_36 + a0);
*(tmp_53 + v7) = v12;
v0 = 1;
goto LABEL_400972;
}
if (v0 && v3 == 58 && *((a0 + v10)) == 93) {
*((v7 + v9)) = v3;
tmp_36 = v10;
v10 += 1;
tmp_53 = v9 + 1;
v13 = v9 + 2;
*(&v12) = *(tmp_36 + a0);
*(tmp_53 + v7) = v12;
v0 = 0;
goto LABEL_400972;
}
if (v3 == 91 && *((a0 + v10)) == 61) {
*((v7 + v9)) = v3;
tmp_43 = v10;
v10 += 1;
tmp_60 = v9 + 1;
v13 = v9 + 2;
*(&v12) = *(tmp_43 + a0);
*(tmp_60 + v7) = v12;
if (*((a0 + v10)) == 93) {
tmp_10 = v10;
v10 += 1;
tmp_27 = v13;
v13 += 1;
*(&v12) = *(tmp_10 + a0);
*(tmp_27 + v7) = v12;
}
v2 = 1;
goto LABEL_400972;
}
if (v2 && v3 == 61 && *((a0 + v10)) == 93) {
*((v7 + v9)) = v3;
tmp_36 = v10;
v10 += 1;
tmp_53 = v9 + 1;
v13 = v9 + 2;
*(&v12) = *(tmp_36 + a0);
*(tmp_53 + v7) = v12;
v2 = 0;
goto LABEL_400972;
}
if (v3 == 91 && *((a0 + v10)) == 46) {
*((v7 + v9)) = v3;
tmp_43 = v10;
v10 += 1;
tmp_60 = v9 + 1;
v13 = v9 + 2;
*(&v12) = *(tmp_43 + a0);
*(tmp_60 + v7) = v12;
if (*((a0 + v10)) == 93) {
tmp_10 = v10;
v10 += 1;
tmp_27 = v13;
v13 += 1;
*(&v12) = *(tmp_10 + a0);
*(tmp_27 + v7) = v12;
}
v1 = 1;
goto LABEL_400972;
}
if (v1 && v3 == 46 && *((a0 + v10)) == 93) {
*((v7 + v9)) = v3;
tmp_36 = v10;
v10 += 1;
tmp_53 = v9 + 1;
v13 = v9 + 2;
*(&v12) = *(tmp_36 + a0);
*(tmp_53 + v7) = v12;
v1 = 0;
goto LABEL_400972;
}
tmp_7 = v9;
v13 = v9 + 1;
*(v7 + tmp_7) = v3;
LABEL_400972:
tmp_11 = v10;
v10 += 1;
v12 = *(a0 + tmp_11);
v3 = v12;
if (v3 == 93) {
LABEL_40099a:
if (!v3) {
v10 = v6 - 1;
v9 = v5;
goto LABEL_400ad2;
} else {
tmp_10 = v13;
v9 = v13 + 1;
*(v7 + tmp_10) = v3;
*(&v10) = v10 - 1;
goto LABEL_400ad2;
}
} else if (!v3) {
goto LABEL_40099a;
}
}
}
}
LABEL_4009cd:
if (*((a0 + v10)) != 92) {
LABEL_400a86:
if (*((a0 + v10)) == 92 && (a1 & 4)) {
v4 = 1;
goto LABEL_400aaa;
}
} else {
if (!(!(a1 & 4)))
goto LABEL_400a86;
tmp_17 = v9;
v9 += 1;
*(v7 + tmp_17) = 92;
v10 = v10 + 1;
if (!*((a0 + v10)))
break;
if ((a1 & 8) && *((a0 + v10)) == 1) {
if (*((a0 + v10 + 1)) != 1 && !(*((a0 + v10 + 1)) == 127))
goto LABEL_400a66;
v10 = v10 + 1;
goto LABEL_400aaa;
}
LABEL_400a66:
if ((a1 & 8)) {
if (!(*((a0 + v10)) == 1))
goto LABEL_400aaa;
goto LABEL_4004c8;
}
LABEL_400aaa:
tmp_19 = v9;
v9 += 1;
*(tmp_19 + v7) = *((v10 + a0));
LABEL_400ad2:
v10 = v10 + 1;
}
}
*((v7 + v9)) = 0;
v11 = v7;
LABEL_400b04:
return v11;
} | bash | angr_phoenix |
static unsigned getbits(n)
int n;
{
unsigned x;
x = bitbuf >> ((8 * 2 * sizeof(char)) - n);
fillbuf(n);
return x;
} | int getbits(unsigned long a0) {
unsigned int v0;
v0 = bitbuf >> ((16 - a0) & 31);
fillbuf(a0);
return v0;
} | gzip-1.12 | angr_phoenix |
static int uidtb_start(void) {
static int fail = 0;
if (uidtb != ((void *)0))
return 0;
if (fail)
return -1;
if ((uidtb = calloc(317, sizeof(UIDC *))) == ((void *)0)) {
++fail;
return -1;
}
return 0;
} | undefined8 uidtb_start(void)
{
undefined8 uVar1;
if (uidtb == (void *)0x0) {
if (fail_4010 == 0) {
uidtb = calloc(0x13d, 8);
if (uidtb == (void *)0x0) {
fail_4010 = fail_4010 + 1;
uVar1 = 0xffffffff;
} else {
uVar1 = 0;
}
} else {
uVar1 = 0xffffffff;
}
} else {
uVar1 = 0;
}
return uVar1;
} | libbsd-0.11.7 | ghidra |
WORD_DESC *alloc_word_desc() {
WORD_DESC *temp;
do {
if ((wdcache).nc > 0) {
(temp) = (WORD_DESC *)((WORD_DESC **)((wdcache).data))[--(wdcache).nc];
} else
(temp) = (WORD_DESC *)sh_xmalloc((sizeof(WORD_DESC)), "make_cmd.c", 76);
} while (0);
temp->flags = 0;
temp->word = 0;
return temp;
} | long alloc_word_desc() {
long v0;
long v2;
if (*((int *)&wdcache + 3) <= 0) {
v2 = sh_xmalloc(16LL, "make_cmd.c", 76LL);
} else {
v0 = wdcache;
v2 = *(_QWORD *)(8LL * (int)--*((_DWORD *)&wdcache + 3) + v0);
}
*(_DWORD *)(v2 + 8) = 0;
*(_QWORD *)v2 = 0LL;
return v2;
} | bash | ida |
static void load_data(common_info_st *cinfo, gnutls_datum_t *data) {
FILE *fp;
size_t size;
fp = fopen(cinfo->data_file, "r");
if (fp == ((void *)0)) {
fprintf(stderr, "Could not open %s\n", cinfo->data_file);
app_exit(1);
}
data->data = (void *)_gnutls_fread_file(fp, 0, &size);
if (data->data == ((void *)0)) {
fprintf(stderr, "Error reading data file");
app_exit(1);
}
data->size = size;
fclose(fp);
} | void load_data(struct_0 *a0, struct_1 *a1) {
char v0;
void *v1;
char v2;
unsigned long long *v4;
unsigned long long v5;
v1 = fopen(a0->field_48, "r");
if (!v1) {
fprintf(*(&stderr), "Could not open %s\n", a0->field_48);
app_exit(0x1);
}
a1->field_0 = _gnutls_fread_file(v1, 0x0, &v0);
if (!a1->field_0) {
fprintf(*(&stderr), "Error reading data file");
app_exit(0x1);
}
a1->field_8 = *(&v0);
fclose(v1);
v5 = *(&v2) ^ v4[5];
return;
} | gnutls | angr_phoenix |
static Bool uncompressStream(FILE *zStream, FILE *stream) {
BZFILE *bzf = ((void *)0);
Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i;
UChar obuf[5000];
UChar unused[5000];
Int32 nUnused;
void *unusedTmpV;
UChar *unusedTmp;
nUnused = 0;
streamNo = 0;
;
;
if (ferror(stream))
goto errhandler_io;
if (ferror(zStream))
goto errhandler_io;
while (((Bool)1)) {
bzf = BZ2_bzReadOpen(&bzerr, zStream, verbosity, (int)smallMode, unused,
nUnused);
if (bzf == ((void *)0) || bzerr != 0)
goto errhandler;
streamNo++;
while (bzerr == 0) {
nread = BZ2_bzRead(&bzerr, bzf, obuf, 5000);
if (bzerr == (-5))
goto trycat;
if ((bzerr == 0 || bzerr == 4) && nread > 0)
fwrite(obuf, sizeof(UChar), nread, stream);
if (ferror(stream))
goto errhandler_io;
}
if (bzerr != 4)
goto errhandler;
BZ2_bzReadGetUnused(&bzerr, bzf, &unusedTmpV, &nUnused);
if (bzerr != 0)
panic("decompress:bzReadGetUnused");
unusedTmp = (UChar *)unusedTmpV;
for (i = 0; i < nUnused; i++)
unused[i] = unusedTmp[i];
BZ2_bzReadClose(&bzerr, bzf);
if (bzerr != 0)
panic("decompress:bzReadGetUnused");
if (nUnused == 0 && myfeof(zStream))
break;
}
closeok:
if (ferror(zStream))
goto errhandler_io;
if (stream != stdout) {
Int32 fd = fileno(stream);
if (fd < 0)
goto errhandler_io;
applySavedFileAttrToOutputFile(fd);
}
ret = fclose(zStream);
if (ret == (-1))
goto errhandler_io;
if (ferror(stream))
goto errhandler_io;
ret = fflush(stream);
if (ret != 0)
goto errhandler_io;
if (stream != stdout) {
ret = fclose(stream);
outputHandleJustInCase = ((void *)0);
if (ret == (-1))
goto errhandler_io;
}
outputHandleJustInCase = ((void *)0);
if (verbosity >= 2)
fprintf(stderr, "\n ");
return ((Bool)1);
trycat:
if (forceOverwrite) {
rewind(zStream);
while (((Bool)1)) {
if (myfeof(zStream))
break;
nread = fread(obuf, sizeof(UChar), 5000, zStream);
if (ferror(zStream))
goto errhandler_io;
if (nread > 0)
fwrite(obuf, sizeof(UChar), nread, stream);
if (ferror(stream))
goto errhandler_io;
}
goto closeok;
}
errhandler:
BZ2_bzReadClose(&bzerr_dummy, bzf);
switch (bzerr) {
case (-9):
configError();
break;
case (-6):
errhandler_io:
ioError();
break;
case (-4):
crcError();
case (-3):
outOfMemory();
case (-7):
compressedStreamEOF();
case (-5):
if (zStream != stdin)
fclose(zStream);
if (stream != stdout)
fclose(stream);
if (streamNo == 1) {
return ((Bool)0);
} else {
if (noisy)
fprintf(stderr, "\n%s: %s: trailing garbage after EOF ignored\n",
progName, inName);
return ((Bool)1);
}
default:
panic("decompress:unexpected error");
}
panic("decompress:end");
return ((Bool)1);
} | int uncompressStream(void *a0, void *a1) {
char v0;
char v1;
unsigned int v2;
unsigned int v3;
unsigned int v4;
unsigned int v5;
unsigned int v6;
unsigned int v7;
char v8;
void *v9;
unsigned long long v10;
char v11;
unsigned long long v12;
char v13;
unsigned long long v14;
unsigned long long v18;
unsigned long long v21;
unsigned long long v22;
unsigned long long v23;
unsigned int v24;
unsigned long long v25;
v14 = *(&v14);
v12 = *(&v12);
v9 = 0;
v2 = 0;
v3 = 0;
if (!ferror(a1) && !ferror(a0)) {
while (true) {
v9 = BZ2_bzReadOpen(&v0, a0, verbosity, smallMode, &v13, v2);
if (v9 && !*(&v0)) {
v3 += 1;
while (true) {
if (!*(&v0)) {
v5 = BZ2_bzRead(&v0, v9, &v11, 0x1388);
if ((!*(&v0) || *(&v0) == 4) && v5 > 0)
fwrite(&v11, 0x1, v5, a1);
v18 = ferror(a1);
if (v18)
break;
} else {
if (*(&v0) != 4)
break;
}
if (*(&v0) == 4) {
BZ2_bzReadGetUnused(&v0, v9, &v8, &v2);
panic("decompress:bzReadGetUnused");
}
if (false) {
if (!forceOverwrite)
break;
if (forceOverwrite) {
rewind(a0);
while (true) {
v21 = myfeof(a0);
if (v21)
break;
v5 = fread(&v11, 0x1, 0x1388, a0);
v22 = ferror(a0);
if (v22)
break;
if (!v22 && v5 > 0)
fwrite(&v11, 0x1, v5, a1);
v23 = ferror(a1);
if (v23)
break;
}
if (!v21 && (v23 || v22))
break;
}
v10 = *(&v8);
for (v4 = 0; v4 < v2; v4 += 1) {
(&v13)[v4] = *((v10 + v4));
}
BZ2_bzReadClose(&v0, v9, v9);
panic("decompress:bzReadGetUnused");
if (v2)
break;
if (!v2) {
if (!myfeof(a0))
break;
}
v25 = ferror(a0);
if (v25)
break;
if (!v25) {
if (a1 != *(&stdout)) {
v6 = fileno(a1);
if (v6 < 0)
break;
if (v6 >= 0)
applySavedFileAttrToOutputFile(v6);
}
v7 = fclose(a0);
if (v7 == -1)
break;
if (v7 != -1) {
v24 = ferror(a1);
if (v24)
break;
if (!v24) {
v7 = fflush(a1);
if (v7)
break;
if (!v7) {
if (a1 != *(&stdout)) {
v7 = fclose(a1);
outputHandleJustInCase = 0;
if (v7 == -1)
break;
}
if (v7 != -1) {
outputHandleJustInCase = 0;
if (verbosity > 1)
fprintf(*(&stderr), "\n ");
v24 = 1;
break;
}
}
}
}
}
}
}
if (v18)
break;
if (v18)
continue;
}
if (!v9 || *(&v0)) {
BZ2_bzReadClose(&v1, v9, v9);
switch (*(&v0) + 9) {
case 0:
configError();
case 2:
compressedStreamEOF();
case 4:
if (a0 != stdin)
fclose(a0);
if (a1 != *(&stdout))
fclose(a1);
if (v3 == 1) {
v24 = 0;
break;
} else {
if (noisy)
fprintf(*(&stderr),
"\n%s: %s: trailing garbage after EOF ignored\n",
progName, &inName);
v24 = 1;
break;
}
case 5:
crcError();
case 6:
outOfMemory();
default:
panic("decompress:unexpected error");
}
if (*(&v0) + 9 <= 6)
v24 = (*((36 + 4 * *(&v0) + &g_4053ec)) + &g_4053ec);
}
if ((v24 == 4197594 || !*(&v0)) && (!*(&v0) || *(&v0) + 9 <= 6) &&
(v24 == 4197594 || v9) && (*(&v0) + 9 <= 6 || v9))
return v24;
}
}
ioError();
} | bzip2 | angr_dream |
static void print_login(const STRUCT_UTMP *utmp_ent) {
char *comment = make_id_equals_comment(utmp_ent);
char pidstr[(((((sizeof(utmp_ent->ut_pid) * 8) -
(!((__typeof__(utmp_ent->ut_pid))0 <
(__typeof__(utmp_ent->ut_pid))-1))) *
146 +
484) /
485) +
(!((__typeof__(utmp_ent->ut_pid))0 <
(__typeof__(utmp_ent->ut_pid))-1))) +
1];
sprintf(pidstr, "%ld", (long int)(utmp_ent->ut_pid));
print_line(-1, gettext("LOGIN"), ' ', sizeof utmp_ent->ut_line,
utmp_ent->ut_line, time_string(utmp_ent), "", pidstr, comment, "");
free(comment);
} | unsigned long print_login(long a1) {
char *v1;
char *v2;
char *ptr;
char s[12];
unsigned long v6;
v6 = __readfsqword(0x28u);
ptr = make_id_equals_comment(a1);
sprintf(s, "%ld", *(int *)(a1 + 4));
v1 = time_string(a1);
v2 = gettext("LOGIN");
print_line(-1, v2, 32, 32, (const char *)(a1 + 8), v1, locale, s, ptr,
locale);
free(ptr);
return __readfsqword(0x28u) ^ v6;
} | coreutils | ida |
int find_string_in_alist(string, alist, flags)
char *string;
STRING_INT_ALIST *alist;
int flags;
{
register int i;
int r;
for (i = r = 0; alist[i].word; i++) {
if (flags)
r = strmatch(alist[i].word, string, (1 << 5)) != 1;
else
r = ((string)[0] == (alist[i].word)[0] &&
strcmp(string, alist[i].word) == 0);
if (r)
return (alist[i].token);
}
return -1;
} | long long find_string_in_alist(char *a0, char **a1, unsigned long a2) {
unsigned int v0;
char **v2;
unsigned int v3;
unsigned int v4;
unsigned long long v5;
v0 = 0;
v2 = v0;
while (true) {
if (*((a1 + 0x10 * v2))) {
if (a2) {
v4 = strmatch(*((a1 + 0x10 * v2)), a0, 0x20, a0) != 1;
v0 = v4;
} else {
if (*(a0) == *(*((a1 + 0x10 * v2)))) {
v3 = strcmp(a0, *((a1 + 0x10 * v2)));
if (!v3)
v3 = 1;
}
if (*(a0) != *(*((a1 + 0x10 * v2))) || v3)
v3 = 0;
v0 = v3;
}
if (v0) {
v5 = *((8 + a1 + 0x10 * v2));
break;
} else {
v2 = v2 + 1;
}
} else {
v5 = 4294967295;
break;
}
}
return v5;
} | bash | angr_dream |
map_init_vi(EditLine *el) {
int i;
el_action_t *key = el->el_map.key;
el_action_t *alt = el->el_map.alt;
const el_action_t *vii = el->el_map.vii;
const el_action_t *vic = el->el_map.vic;
el->el_map.type = 1;
el->el_map.current = el->el_map.key;
keymacro_reset(el);
for (i = 0; i < 256; i++) {
key[i] = vii[i];
alt[i] = vic[i];
}
map_init_meta(el);
map_init_nls(el);
tty_bind_char(el, 1);
terminal_bind_arrow(el);
} | long map_init_vi(long a1) {
int i;
long v3;
long v4;
long v5;
long v6;
v3 = *(_QWORD *)(a1 + 1016);
v4 = *(_QWORD *)(a1 + 1008);
v5 = *(_QWORD *)(a1 + 1048);
v6 = *(_QWORD *)(a1 + 1040);
*(_DWORD *)(a1 + 1056) = 1;
*(_QWORD *)(a1 + 1024) = *(_QWORD *)(a1 + 1016);
keymacro_reset(a1);
for (i = 0; i <= 255; ++i) {
*(_BYTE *)(i + v3) = *(_BYTE *)(i + v5);
*(_BYTE *)(i + v4) = *(_BYTE *)(i + v6);
}
map_init_meta(a1);
map_init_nls(a1);
tty_bind_char(a1, 1LL);
return terminal_bind_arrow(a1);
} | libedit | ida |
void reset_completer_word_break_chars() {
rl_completer_word_break_characters =
perform_hostname_completion
? (char *)strcpy(
sh_xmalloc((1 + strlen(bash_completer_word_break_characters)),
"bashline.c", 369),
(bash_completer_word_break_characters))
: (char *)strcpy(
sh_xmalloc((1 + strlen(bash_nohostname_word_break_characters)),
"bashline.c", 369),
(bash_nohostname_word_break_characters));
} | long long reset_completer_word_break_chars() {
unsigned long long v1;
if (!perform_hostname_completion)
v1 = strcpy(sh_xmalloc(strlen(bash_nohostname_word_break_characters) + 1,
"bashline.c", 0x171),
bash_nohostname_word_break_characters);
else
v1 = strcpy(sh_xmalloc(strlen(bash_completer_word_break_characters) + 1,
"bashline.c", 0x171),
bash_completer_word_break_characters);
rl_completer_word_break_characters = v1;
return v1;
} | bash | angr_phoenix |
_Bool
string_ascii_p (char const *p)
{
for (; *p; p++)
if (*p & ~0x7f)
return 0;
return 1;
} | undefined8 string_ascii_p(char *param_1)
{
char *local_10;
local_10 = param_1;
while (true) {
if (*local_10 == '\0') {
return 1;
}
if (*local_10 < '\0')
break;
local_10 = local_10 + 1;
}
return 0;
} | tar | ghidra |
static void transitional_interest_callback_ro(const char *trig,
struct pkginfo *pkg,
struct pkgbin *pkgbin,
enum trig_options opts) {
struct pkginfo *pend = pkg;
struct pkgbin *pendbin = pkgbin;
debug(dbg_triggersdetail,
"trig_transitional_interest_callback trig=%s pend=%s", trig,
pkgbin_name(pend, pendbin, pnaw_always));
if (pend->status >= PKG_STAT_TRIGGERSAWAITED)
trig_note_pend(pend, nfstrsave(trig));
} | void transitional_interest_callback_ro(undefined8 param_1, long param_2,
undefined8 param_3)
{
undefined8 uVar1;
uVar1 = pkgbin_name(param_2, param_3, 3);
debug(0x2000, "trig_transitional_interest_callback trig=%s pend=%s", param_1,
uVar1);
if (4 < *(uint *)(param_2 + 0x18)) {
uVar1 = nfstrsave(param_1);
trig_note_pend(param_2, uVar1);
}
return;
} | dpkg | ghidra |
mode_t getmode(const void *bbox, mode_t omode) {
const BITCMD *set;
mode_t clrval, newmode, value;
set = (const BITCMD *)bbox;
newmode = omode;
for (value = 0;; set++)
switch (set->cmd) {
case 'u':
value = (newmode & (0400 | 0200 | 0100)) >> 6;
goto common;
case 'g':
value = (newmode & ((0400 | 0200 | 0100) >> 3)) >> 3;
goto common;
case 'o':
value = newmode & (((0400 | 0200 | 0100) >> 3) >> 3);
common:
if (set->cmd2 & 0x01) {
clrval =
(set->cmd2 & 0x02) ? (((0400 | 0200 | 0100) >> 3) >> 3) : value;
if (set->cmd2 & 0x10)
newmode &= ~((clrval << 6) & set->bits);
if (set->cmd2 & 0x04)
newmode &= ~((clrval << 3) & set->bits);
if (set->cmd2 & 0x08)
newmode &= ~(clrval & set->bits);
}
if (set->cmd2 & 0x02) {
if (set->cmd2 & 0x10)
newmode |= (value << 6) & set->bits;
if (set->cmd2 & 0x04)
newmode |= (value << 3) & set->bits;
if (set->cmd2 & 0x08)
newmode |= value & set->bits;
}
break;
case '+':
newmode |= set->bits;
break;
case '-':
newmode &= ~set->bits;
break;
case 'X':
if (omode & (0040000 | 0100 | (0100 >> 3) | ((0100 >> 3) >> 3)))
newmode |= set->bits;
break;
case '\0':
default:
return (newmode);
}
} | long long getmode(unsigned long a0, unsigned long a1) {
unsigned int v0;
unsigned int v1;
unsigned int v2;
struct_0 *v3;
unsigned int v5;
v3 = a0;
v0 = a1;
v1 = 0;
while (true) {
if (v3->field_0 == 117) {
v1 = (v0 >> 6) & 7;
} else {
if (v3->field_0 > 117)
break;
if (v3->field_0 == 111) {
v1 = v0 & 7;
} else {
if (v3->field_0 > 111)
break;
if (v3->field_0 == 103) {
v1 = (v0 >> 3) & 7;
} else {
if (v3->field_0 > 103)
break;
if (v3->field_0 == 88) {
if ((a1 & 16457))
v0 = v0 | v3->field_4;
goto LABEL_40020a;
} else {
if (v3->field_0 > 88)
break;
if (v3->field_0 == 43) {
v0 = v0 | v3->field_4;
goto LABEL_40020a;
} else {
if (v3->field_0 != 45)
break;
v0 = v0 & !(v3->field_4);
goto LABEL_40020a;
}
}
}
}
}
if ((v3->field_1 & 1)) {
if (!(v3->field_1 & 2))
v5 = v1;
else
v5 = 7;
v2 = v5;
if ((v3->field_1 & 16))
v0 &= !(v3->field_4 & (v2 * 64));
if ((v3->field_1 & 4))
v0 = v0 & !(v3->field_4 & (v2 * 8));
if ((v3->field_1 & 8))
v0 = v0 & !(v3->field_4 & v2);
}
if ((v3->field_1 & 2)) {
if ((v3->field_1 & 16))
v0 = v0 | v3->field_4 & (v1 * 64);
if ((v3->field_1 & 4))
v0 = v0 | v3->field_4 & (v1 * 8);
if ((v3->field_1 & 8))
v0 = v0 | v3->field_4 & v1;
}
LABEL_40020a:
v3 += 1;
}
return v0;
} | libbsd-0.11.7 | angr_phoenix |
void rl_free(void *mem) {
if (mem)
free(mem);
} | void rl_free(void *param_1)
{
if (param_1 != (void *)0x0) {
free(param_1);
}
return;
} | bash | ghidra |
static int _verify_passwd_int(const char *username, const char *passwd,
char *verifier, const char *salt,
const gnutls_datum_t *g,
const gnutls_datum_t *n) {
char _salt[1024];
gnutls_datum_t tmp, raw_salt, new_verifier;
size_t salt_size;
char *pos;
if (salt == ((void *)0) || verifier == ((void *)0))
return -1;
if (strlen(salt) >= sizeof(_salt)) {
fprintf(stderr, "Too long salt.\n");
return -1;
}
strcpy(_salt, salt);
pos = strchr(_salt, ':');
if (pos != ((void *)0))
*pos = 0;
tmp.data = (void *)_salt;
tmp.size = strlen(_salt);
if (gnutls_srp_base64_decode2(&tmp, &raw_salt) < 0) {
fprintf(stderr, "Could not decode salt.\n");
return -1;
}
if (gnutls_srp_verifier(username, passwd, &raw_salt, g, n, &new_verifier) <
0) {
fprintf(stderr, "Could not make the verifier\n");
return -1;
}
free(raw_salt.data);
salt_size = sizeof(_salt);
memset(_salt, 0, salt_size);
if (gnutls_srp_base64_encode(&new_verifier, _salt, &salt_size) < 0) {
fprintf(stderr, "Encoding error\n");
return -1;
}
free(new_verifier.data);
if (strncmp(verifier, _salt, strlen(_salt)) == 0) {
fprintf(stderr, "Password verified\n");
return 0;
} else {
fprintf(stderr, "Password does NOT match\n");
}
return -1;
} | void _verify_passwd_int(unsigned long long a0, unsigned long long a1, char *a2,
char *a3, unsigned long long a4,
unsigned long long a5) {
unsigned long long v0;
char *v1;
unsigned long v2;
unsigned int v3;
char v4;
char v5;
char v6;
unsigned long long v8;
unsigned long long v10;
unsigned long long v13;
unsigned long long v14;
unsigned long long v16;
void *v18;
unsigned long long v19;
if (a3 && a2) {
if (strlen(a3) > 1023) {
fprintf(*(&stderr), "Too long salt.\n");
v10 = 4294967295;
} else {
strcpy(&v6, a3);
v1 = strchr(&v6, 0x3a);
if (v1)
*(v1) = 0;
v2 = &v6;
v3 = strlen(&v6);
if (gnutls_srp_base64_decode2(&v2, &v4, &v4) < 0) {
fprintf(*(&stderr), "Could not decode salt.\n");
v13 = 4294967295;
} else if (gnutls_srp_verifier(a0, a1, &v4, a4, a5, &v5) < 0) {
fprintf(*(&stderr), "Could not make the verifier\n");
v14 = 4294967295;
} else {
free(*(&v4));
v0 = 0x400;
memset(&v6, 0x0, v0);
if (gnutls_srp_base64_encode(&v5, &v6, &v0, &v6) < 0) {
fprintf(*(&stderr), "Encoding error\n");
v16 = 4294967295;
} else {
free(*(&v5));
if (!strncmp(a2, &v6, strlen(&v6))) {
fprintf(*(&stderr), "Password verified\n");
v18 = 0;
} else {
fprintf(*(&stderr), "Password does NOT match\n");
v19 = 4294967295;
}
}
}
}
}
if (!a3 || !a2)
v8 = 4294967295;
return;
} | gnutls | angr_dream |
void cipher_free(struct sshcipher_ctx *cc) {
if (cc == ((void *)0))
return;
if ((cc->cipher->flags & (1 << 1)) != 0) {
chachapoly_free(cc->cp_ctx);
cc->cp_ctx = ((void *)0);
} else if ((cc->cipher->flags & (1 << 2)) != 0)
explicit_bzero(&cc->ac_ctx, sizeof(cc->ac_ctx));
EVP_CIPHER_CTX_free(cc->evp);
cc->evp = ((void *)0);
freezero(cc, sizeof(*cc));
} | long long cipher_free(struct_0 *a0) {
unsigned long long v1;
if (!a0)
return v1;
if ((a0->field_120->field_18 & 2)) {
chachapoly_free(a0->field_10);
a0->field_10 = 0;
} else if ((a0->field_120->field_18 & 4)) {
explicit_bzero(&a0->padding_18, 0x104);
}
EVP_CIPHER_CTX_free(a0->field_8);
a0->field_8 = 0;
v1 = freezero(a0, 0x128);
return v1;
} | openssh-portable | angr_sailr |
static int mux_client_forward(int fd, int cancel_flag, u_int ftype,
struct Forward *fwd) {
struct sshbuf *m;
char *e, *fwd_desc;
const char *lhost, *chost;
u_int type, rid;
int r;
fwd_desc = format_forward(ftype, fwd);
sshlog("mux.c", __func__, 1752, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0),
"Requesting %s %s", cancel_flag ? "cancellation of" : "forwarding of",
fwd_desc);
free(fwd_desc);
type = cancel_flag ? 0x10000007 : 0x10000006;
if (fwd->listen_path != ((void *)0))
lhost = fwd->listen_path;
else if (fwd->listen_host == ((void *)0))
lhost = "";
else if (*fwd->listen_host == '\0')
lhost = "*";
else
lhost = fwd->listen_host;
if (fwd->connect_path != ((void *)0))
chost = fwd->connect_path;
else if (fwd->connect_host == ((void *)0))
chost = "";
else
chost = fwd->connect_host;
if ((m = sshbuf_new()) == ((void *)0))
sshfatal("mux.c", __func__, 1774, 1, SYSLOG_LEVEL_FATAL, ((void *)0),
"sshbuf_new");
if ((r = sshbuf_put_u32(m, type)) != 0 ||
(r = sshbuf_put_u32(m, muxclient_request_id)) != 0 ||
(r = sshbuf_put_u32(m, ftype)) != 0 ||
(r = sshbuf_put_cstring(m, lhost)) != 0 ||
(r = sshbuf_put_u32(m, fwd->listen_port)) != 0 ||
(r = sshbuf_put_cstring(m, chost)) != 0 ||
(r = sshbuf_put_u32(m, fwd->connect_port)) != 0)
sshfatal("mux.c", __func__, 1782, 1, SYSLOG_LEVEL_FATAL, ssh_err(r),
"request");
if (mux_client_write_packet(fd, m) != 0)
sshfatal("mux.c", __func__, 1785, 1, SYSLOG_LEVEL_FATAL, ((void *)0),
"write packet: %s", strerror((*__errno_location())));
sshbuf_reset(m);
if (mux_client_read_packet(fd, m) != 0) {
sshbuf_free(m);
return -1;
}
if ((r = sshbuf_get_u32(m, &type)) != 0 || (r = sshbuf_get_u32(m, &rid)) != 0)
sshfatal("mux.c", __func__, 1797, 1, SYSLOG_LEVEL_FATAL, ssh_err(r),
"parse");
if (rid != muxclient_request_id)
sshfatal("mux.c", __func__, 1799, 1, SYSLOG_LEVEL_FATAL, ((void *)0),
"out of sequence reply: my id %u theirs %u", muxclient_request_id,
rid);
switch (type) {
case 0x80000001:
break;
case 0x80000007:
if (cancel_flag)
sshfatal("mux.c", __func__, 1807, 1, SYSLOG_LEVEL_FATAL, ((void *)0),
"got MUX_S_REMOTE_PORT for cancel");
if ((r = sshbuf_get_u32(m, &fwd->allocated_port)) != 0)
sshfatal("mux.c", __func__, 1809, 1, SYSLOG_LEVEL_FATAL, ssh_err(r),
"parse port");
sshlog("mux.c", __func__, 1810, 0, SYSLOG_LEVEL_VERBOSE, ((void *)0),
"Allocated port %u for remote forward to %s:%d", fwd->allocated_port,
fwd->connect_host ? fwd->connect_host : "", fwd->connect_port)
;
if (muxclient_command == 5)
fprintf(stdout, "%i\n", fwd->allocated_port);
break;
case 0x80000002:
if ((r = sshbuf_get_cstring(m, &e, ((void *)0))) != 0)
sshfatal("mux.c", __func__, 1819, 1, SYSLOG_LEVEL_FATAL, ssh_err(r),
"parse error message");
sshbuf_free(m);
sshlog("mux.c", __func__, 1821, 0, SYSLOG_LEVEL_ERROR, ((void *)0),
"Master refused forwarding request: %s", e);
return -1;
case 0x80000003:
if ((r = sshbuf_get_cstring(m, &e, ((void *)0))) != 0)
sshfatal("mux.c", __func__, 1825, 1, SYSLOG_LEVEL_FATAL, ssh_err(r),
"parse error message");
sshbuf_free(m);
sshlog("mux.c", __func__, 1827, 1, SYSLOG_LEVEL_ERROR, ((void *)0),
"forwarding request failed: %s", e);
return -1;
default:
sshfatal("mux.c", __func__, 1830, 1, SYSLOG_LEVEL_FATAL, ((void *)0),
"unexpected response from master 0x%08x", type);
}
sshbuf_free(m);
muxclient_request_id++;
return 0;
} | int mux_client_forward(unsigned long long a0, unsigned long a1,
unsigned long a2, struct_0 *a3) {
unsigned long v0;
unsigned int v1;
char v2;
unsigned int v3;
char v4;
unsigned long long v5;
unsigned long long v6;
unsigned long long v7;
unsigned long long v8;
unsigned long long v9;
unsigned long v10;
char v11;
unsigned long v13;
unsigned long long v14;
unsigned long long v15;
v7 = format_forward(a2, a3);
if (a1)
v13 = "cancellation of";
else
v13 = "forwarding of";
v0 = v13;
sshlog("mux.c", "mux_client_forward", 0x6d8, 0x0, 0x5, 0x0,
"Requesting %s %s");
free(v7);
if (!a1)
*(&v13) = 268435462;
else
*(&v13) = 268435463;
v1 = v13;
if (a3->field_10) {
v5 = a3->field_10;
} else if (!a3->field_0) {
v5 = &g_409d86;
} else if (!*(a3->field_0)) {
v5 = "*";
} else {
v5 = a3->field_0;
}
if (a3->field_28) {
v6 = a3->field_28;
} else if (!a3->field_18) {
v6 = &g_409d86;
} else {
v6 = a3->field_18;
}
v8 = sshbuf_new(a0, "mux_client_forward", 0x6d8, 0x0, 0x5, 0x0);
if (!v8)
sshfatal("mux.c", "mux_client_forward", 0x6ee, 0x1, 0x1, 0x0, "sshbuf_new");
v3 = sshbuf_put_u32(v8, v1);
if (!v3) {
v3 = sshbuf_put_u32(v8, muxclient_request_id);
if (!v3) {
v3 = sshbuf_put_u32(v8, a2);
if (!v3) {
v3 = sshbuf_put_cstring(v8, v5, v5);
if (!v3) {
v3 = sshbuf_put_u32(v8, a3->field_8);
if (!v3) {
v3 = sshbuf_put_cstring(v8, v6, v6);
if (!v3) {
v3 = sshbuf_put_u32(v8, a3->field_20);
if (!v3)
goto LABEL_406166;
}
}
}
}
}
}
v9 = "request";
sshfatal("mux.c", "mux_client_forward", 0x6f6, 0x1, 0x1, ssh_err(v3),
*(&v11));
LABEL_406166:
if (mux_client_write_packet(a0, v8, v8, a3, v14, v15)) {
v10 = strerror(*(__errno_location()));
v9 = "write packet: %s";
sshfatal("mux.c", "mux_client_forward", 0x6f9, 0x1, 0x1, 0x0, *(&v11));
}
sshbuf_reset(v8);
if (mux_client_read_packet(a0, v8, v8, a3, v14, v15)) {
sshbuf_free(v8);
*(&v13) = -1;
} else {
v3 = sshbuf_get_u32(v8, &v1, &v1);
if (!v3) {
v3 = sshbuf_get_u32(v8, &v2, &v2);
if (!v3)
goto LABEL_406270;
}
v9 = "parse";
sshfatal("mux.c", "mux_client_forward", 0x705, 0x1, 0x1, ssh_err(v3),
*(&v11));
LABEL_406270:
if (*(&v2) != muxclient_request_id) {
v9 = *(&v2);
v8 = muxclient_request_id;
v7 = "out of sequence reply: my id %u theirs %u";
sshfatal("mux.c", "mux_client_forward", 0x707, 0x1, 0x1, 0x0, *(&v11));
}
if (v1 == 2147483655) {
if (a1) {
v9 = "got MUX_S_REMOTE_PORT for cancel";
sshfatal("mux.c", "mux_client_forward", 0x70f, 0x1, 0x1, 0x0, *(&v11));
}
v3 = sshbuf_get_u32(v8, &a3->field_30, &a3->field_30);
if (v3) {
v9 = "parse port";
sshfatal("mux.c", "mux_client_forward", 0x711, 0x1, 0x1, ssh_err(v3),
*(&v11));
}
if (!a3->field_18)
v13 = &g_409d86;
else
v13 = a3->field_18;
v10 = a3->field_20;
v9 = v13;
v8 = a3->field_30;
v7 = "Allocated port %u for remote forward to %s:%d";
sshlog("mux.c", "mux_client_forward", 0x712, 0x0, 0x4, 0x0, *(&v11));
if (muxclient_command == 5)
fprintf(stdout, "%i\n", a3->field_30);
goto LABEL_4065f1;
}
if (v1 <= 2147483655) {
if (v1 == 2147483651) {
v3 = sshbuf_get_cstring(v8, &v4, 0x0, &v4);
if (v3) {
v9 = "parse error message";
sshfatal("mux.c", "mux_client_forward", 0x721, 0x1, 0x1, ssh_err(v3),
*(&v11));
}
sshbuf_free(v8);
v10 = *(&v4);
v9 = "forwarding request failed: %s";
sshlog("mux.c", "mux_client_forward", 0x723, 0x1, 0x2, 0x0, *(&v11));
*(&v13) = -1;
goto LABEL_406611;
}
if (v1 <= 2147483651) {
if (v1 == 2147483649)
goto LABEL_4065ed;
if (v1 == 2147483650) {
v3 = sshbuf_get_cstring(v8, &v4, 0x0, &v4);
if (v3) {
v9 = "parse error message";
sshfatal("mux.c", "mux_client_forward", 0x71b, 0x1, 0x1,
ssh_err(v3), *(&v11));
}
sshbuf_free(v8);
v10 = *(&v4);
v9 = "Master refused forwarding request: %s";
sshlog("mux.c", "mux_client_forward", 0x71d, 0x0, 0x2, 0x0, *(&v11));
*(&v13) = -1;
goto LABEL_406611;
}
}
}
v10 = v1;
v9 = "unexpected response from master 0x%08x";
sshfatal("mux.c", "mux_client_forward", 0x726, 0x1, 0x1, 0x0, *(&v11));
LABEL_4065ed:
LABEL_4065f1:
sshbuf_free(v8);
muxclient_request_id = muxclient_request_id + 1;
*(&v13) = 0;
}
LABEL_406611:
return v13;
} | openssh-portable | angr_phoenix |
int bind_builtin(list)
WORD_LIST *list;
{
int return_code;
Keymap kmap, saved_keymap;
int flags, opt;
char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq, *t;
if (no_line_editing) {
builtin_warning(gettext("line editing not enabled"));
}
kmap = saved_keymap = (Keymap)((void *)0);
flags = 0;
initfile = map_name = fun_name = unbind_name = remove_seq = cmd_seq =
(char *)((void *)0);
return_code = 0;
if (bash_readline_initialized == 0)
initialize_readline();
begin_unwind_frame("bind_builtin");
unwind_protect_mem((char *)&(rl_outstream), sizeof(rl_outstream));
rl_outstream = stdout;
reset_internal_getopt();
while ((opt = internal_getopt(list, "lvpVPsSXf:q:u:m:r:x:")) != -1) {
switch (opt) {
case 'l':
flags |= 0x0001;
break;
case 'v':
flags |= 0x0008;
break;
case 'p':
flags |= 0x0002;
break;
case 'f':
flags |= 0x0004;
initfile = list_optarg;
break;
case 'm':
flags |= 0x0020;
map_name = list_optarg;
break;
case 'q':
flags |= 0x0010;
fun_name = list_optarg;
break;
case 'u':
flags |= 0x0800;
unbind_name = list_optarg;
break;
case 'r':
flags |= 0x0040;
remove_seq = list_optarg;
break;
case 'V':
flags |= 0x0100;
break;
case 'P':
flags |= 0x0080;
break;
case 's':
flags |= 0x0200;
break;
case 'S':
flags |= 0x0400;
break;
case 'x':
flags |= 0x1000;
cmd_seq = list_optarg;
break;
case 'X':
flags |= 0x2000;
break;
case -99:
default:
builtin_usage();
do {
return_code = 258;
goto bind_exit;
} while (0);
}
}
list = loptend;
if ((flags & 0x0020) && map_name) {
kmap = rl_get_keymap_by_name(map_name);
if (kmap == 0) {
builtin_error(gettext("`%s': invalid keymap name"), map_name);
do {
return_code = 1;
goto bind_exit;
} while (0);
}
}
if (kmap) {
saved_keymap = rl_get_keymap();
rl_set_keymap(kmap);
}
if (flags & 0x0001)
rl_list_funmap_names();
if (flags & 0x0002)
rl_function_dumper(1);
if (flags & 0x0080)
rl_function_dumper(0);
if (flags & 0x0200)
rl_macro_dumper(1);
if (flags & 0x0400)
rl_macro_dumper(0);
if (flags & 0x0008)
rl_variable_dumper(1);
if (flags & 0x0100)
rl_variable_dumper(0);
if ((flags & 0x0004) && initfile) {
if (rl_read_init_file(initfile) != 0) {
t = printable_filename(initfile, 0);
builtin_error(gettext("%s: cannot read: %s"), t,
strerror((*__errno_location())));
if (t != initfile)
sh_xfree((t), "./bind.def", 254);
do {
return_code = 1;
goto bind_exit;
} while (0);
}
}
if ((flags & 0x0010) && fun_name)
return_code = query_bindings(fun_name);
if ((flags & 0x0800) && unbind_name)
return_code = unbind_command(unbind_name);
if ((flags & 0x0040) && remove_seq) {
opt = unbind_keyseq(remove_seq);
do {
return_code = opt;
goto bind_exit;
} while (0);
}
if (flags & 0x1000)
return_code = bind_keyseq_to_unix_command(cmd_seq);
if (flags & 0x2000)
return_code = print_unix_command_map();
while (list) {
int olen, nlen, d, i;
char **obindings, **nbindings;
obindings = rl_invoking_keyseqs(bash_execute_unix_command);
olen = obindings ? strvec_len(obindings) : 0;
rl_parse_and_bind(list->word->word);
nbindings = rl_invoking_keyseqs(bash_execute_unix_command);
nlen = nbindings ? strvec_len(nbindings) : 0;
if (nlen < olen)
for (d = olen - nlen, i = 0; i < olen && d > 0; i++)
if (nlen == 0 || strvec_search(nbindings, obindings[i]) < 0) {
unbind_unix_command(obindings[i]);
d--;
}
strvec_dispose(obindings);
strvec_dispose(nbindings);
list = list->next;
}
bind_exit:
if (saved_keymap)
rl_set_keymap(saved_keymap);
run_unwind_frame("bind_builtin");
if (return_code < 0)
return_code = 1;
return (sh_chkwrite(return_code));
} | long long bind_builtin(unsigned long long a0, unsigned long a1,
unsigned long long a2, unsigned long long a3,
unsigned long long a4, unsigned long long a5) {
struct_0 *v0;
unsigned int v1;
unsigned int v2;
unsigned int v3;
unsigned int v4;
unsigned int v5;
unsigned int v6;
unsigned int v7;
void *v8;
void *v9;
void *v10;
void *v11;
void *v12;
void *v13;
void *v14;
void *v15;
unsigned long long v16;
unsigned long long *v17;
unsigned long long v18;
unsigned long long v20;
unsigned int v21;
v0 = a0;
if (no_line_editing)
builtin_warning(gettext("line editing not enabled"));
v9 = 0;
v8 = v9;
v2 = 0;
v15 = 0;
v14 = v15;
v13 = v14;
v12 = v13;
v11 = v12;
v10 = v11;
v1 = 0;
if (!bash_readline_initialized)
initialize_readline();
begin_unwind_frame("bind_builtin");
unwind_protect_mem(0x500030, 0x8);
rl_outstream = stdout;
reset_internal_getopt(0x500030, 0x8, a2, a3, a4, a5);
while (true) {
v5 = internal_getopt(v0, "lvpVPsSXf:q:u:m:r:x:");
if (v5 != -1) {
switch (v5) {
case 80:
v2 |= 128;
break;
case 83:
v2 |= 0x400;
break;
case 86:
v2 |= 0x100;
break;
case 88:
v2 |= 0x2000;
break;
case 102:
v2 |= 4;
v10 = *(&list_optarg);
break;
case 108:
v2 |= 1;
break;
case 109:
v2 |= 32;
v11 = *(&list_optarg);
break;
case 112:
v2 |= 2;
break;
case 113:
v2 |= 16;
v12 = *(&list_optarg);
break;
case 114:
v2 |= 64;
v14 = *(&list_optarg);
break;
case 115:
v2 |= 0x200;
break;
case 117:
v2 |= 0x800;
v13 = *(&list_optarg);
break;
case 118:
v2 |= 8;
break;
case 120:
v2 |= 0x1000;
v15 = *(&list_optarg);
break;
default:
builtin_usage();
v1 = 258;
}
} else {
v0 = loptend;
if ((v2 & 32) && v11) {
v8 = rl_get_keymap_by_name(v11);
if (!v8) {
v20 = gettext("`%s': invalid keymap name");
builtin_error(v20, v11, v20);
v1 = 1;
break;
}
}
if (!(v2 & 32) || !v11 || v8) {
if (v8) {
v9 = rl_get_keymap();
rl_set_keymap(v8);
}
if ((v2 & 1))
rl_list_funmap_names();
if ((v2 & 2))
rl_function_dumper(0x1);
if ((v2 & 128))
rl_function_dumper(0x0);
if ((v2 & 0x200))
rl_macro_dumper(0x1);
if ((v2 & 0x400))
rl_macro_dumper(0x0);
if ((v2 & 8))
rl_variable_dumper(0x1);
if ((v2 & 0x100))
rl_variable_dumper(0x0);
if ((v2 & 4) && v10) {
v21 = rl_read_init_file(v10);
if (v21) {
v16 = printable_filename(v10, 0x0);
builtin_error(gettext("%s: cannot read: %s"), v16,
strerror(*(__errno_location())));
if (v16 != v10)
sh_xfree(v16, "./bind.def", 0xfe);
v1 = 1;
break;
}
}
if (!(v2 & 4) || !v10 || !v21) {
if ((v2 & 16) && v12)
v1 = query_bindings(v12);
if ((v2 & 0x800) && v13)
v1 = unbind_command(v13);
if ((v2 & 64) && v14) {
v5 = unbind_keyseq(v14);
v1 = v5;
break;
}
if (!v14 || !(v2 & 64)) {
if ((v2 & 0x1000))
v1 = bind_keyseq_to_unix_command(v15);
if ((v2 & 0x2000))
v1 = print_unix_command_map();
for (; v0; v0 = v0->field_0) {
v17 = rl_invoking_keyseqs(got.bash_execute_unix_command);
if (v17)
v21 = strvec_len(v17);
else
v21 = 0;
v6 = v21;
rl_parse_and_bind(v0->field_8->field_0);
v18 = rl_invoking_keyseqs(got.bash_execute_unix_command);
if (v18)
v21 = strvec_len(v18);
else
v21 = 0;
v7 = v21;
if (v7 < v6) {
v3 = v6 - v7;
for (v4 = 0; v4 < v6; v4 += 1) {
if (v3 <= 0)
break;
if (v3 > 0 &&
(!v7 || strvec_search(v18, v17[v4], v17[v4]) < 0)) {
unbind_unix_command(v17[v4]);
v3 -= 1;
}
}
}
strvec_dispose(v17);
strvec_dispose(v18);
}
}
}
}
}
}
if (v9)
rl_set_keymap(v9);
run_unwind_frame("bind_builtin");
if (v1 < 0)
v1 = 1;
return sh_chkwrite(v1);
} | bash | angr_dream |
void uid_to_uname(uid_t uid, char **uname) {
struct passwd *passwd;
if (uid != 0 && uid == cached_no_such_uid) {
*uname = xstrdup("");
return;
}
if (!cached_uname || uid != cached_uid) {
passwd = getpwuid(uid);
if (passwd) {
cached_uid = uid;
assign_string(&cached_uname, passwd->pw_name);
} else {
cached_no_such_uid = uid;
*uname = xstrdup("");
return;
}
}
*uname = xstrdup(cached_uname);
} | long long uid_to_uname(unsigned long a0, unsigned long long *a1) {
unsigned long long *v0;
unsigned long long *v2;
if (a0 && a0 == cached_no_such_uid) {
v2 = a1;
*(a1) = xstrdup(&g_404344);
return v2;
}
if (!cached_uname || a0 != cached_uid) {
v0 = &getpwuid(a0)->pw_name;
if (!v0) {
cached_no_such_uid = a0;
v2 = a1;
*(a1) = xstrdup(&g_404344);
return v2;
}
cached_uid = a0;
assign_string(&cached_uname, *(v0));
}
v2 = a1;
*(a1) = xstrdup(cached_uname);
return v2;
} | tar | angr_sailr |
(ext2fs_bg_flags_test(fs, group, 0x0001)))
skip_group++;
for (i = 1; i <= fs->super->s_inodes_count && i > 0; i++) {
bitmap = 0;
if (skip_group && i % fs->super->s_inodes_per_group == 1) {
if (ext2fs_test_inode_bitmap_range(ctx->inode_used_map, i,
fs->super->s_inodes_per_group)) {
first_free = 1;
inodes = fs->super->s_inodes_per_group - 1;
group_free = inodes;
free_inodes += inodes;
i += inodes;
skip_group = 0;
goto do_counts;
}
}
actual = ext2fs_fast_test_inode_bitmap2(ctx->inode_used_map, i);
if (redo_flag)
bitmap = actual;
else if (!skip_group)
bitmap = ext2fs_fast_test_inode_bitmap2(fs->inode_map, i);
if (!actual == !bitmap)
goto do_counts;
if (!actual && bitmap) {
problem = 0x050008;
} else {
problem = 0x050009;
if (skip_group) {
struct problem_context pctx2;
pctx2.blk = i;
pctx2.group = group;
if (fix_problem(ctx, 0x050019, &pctx2)) {
ext2fs_bg_flags_clear(fs, group, 0x0001);
skip_group = 0;
}
}
}
if (pctx.ino == 0) {
pctx.ino = pctx.ino2 = i;
save_problem = problem;
} else {
if ((problem == save_problem) && (pctx.ino2 == i - 1))
pctx.ino2++;
else {
print_bitmap_problem(ctx, save_problem, &pctx);
pctx.ino = pctx.ino2 = i;
save_problem = problem;
}
}
ctx->flags |= 0x0040;
had_problem++;
ctx->options &= ~0x2000;
do_counts:
inodes++;
if (bitmap) {
if (ext2fs_test_inode_bitmap2(ctx->inode_dir_map, i))
dirs_count++;
if (inodes > first_free) {
e2fsck_discard_inodes(ctx, group, first_free, inodes - first_free);
first_free = fs->super->s_inodes_per_group + 1;
}
} else {
group_free++;
free_inodes++;
if (first_free > inodes)
first_free = inodes;
}
if ((inodes == fs->super->s_inodes_per_group) ||
(i == fs->super->s_inodes_count)) {
if (!bitmap && inodes >= first_free)
e2fsck_discard_inodes(ctx, group, first_free,
inodes - first_free + 1);
if ((ctx->options & 0x2000) && (fs->io->flags & 0x02) &&
!(ext2fs_bg_flags_test(fs, group, 0x0004))) {
ext2fs_bg_flags_set(fs, group, 0x0004);
ext2fs_group_desc_csum_set(fs, group);
}
first_free = fs->super->s_inodes_per_group + 1;
free_array[group] = group_free;
dir_array[group] = dirs_count;
group++;
inodes = 0;
skip_group = 0;
group_free = 0;
dirs_count = 0;
if (ctx->progress)
if ((ctx->progress)(ctx, 5, group + fs->group_desc_count,
fs->group_desc_count * 2))
goto errout;
if (csum_flag && (i != fs->super->s_inodes_count) &&
(ext2fs_bg_flags_test(fs, group, 0x0001)))
skip_group++;
}
} | void ext2fs_bg_flags_test(void)
{
halt_baddata();
} | e2fsprogs-1.46.5 | ghidra |
static _Bool
set_extend_size(uintmax_t tabval) {
_Bool ok = 1;
if (extend_size) {
error(0, 0,
gettext("'/' specifier only allowed"
" with the last value"));
ok = 0;
}
extend_size = tabval;
return ok;
} | int set_extend_size(unsigned long long a0) {
char v0;
v0 = 1;
if (extend_size) {
error(0x0, 0x0, gettext("'/' specifier only allowed with the last value"));
v0 = 0;
}
extend_size = a0;
return v0;
} | coreutils | angr_dream |
int _rl_find_prev_mbchar(char *string, int seed, int flags) {
return _rl_find_prev_mbchar_internal(string, seed, flags);
} | long long _rl_find_prev_mbchar(char *a0, unsigned long a1, unsigned long a2) {
return _rl_find_prev_mbchar_internal(a0, a1, a2);
} | bash | angr_sailr |
static int connect_next(struct channel_connect *cctx) {
int sock, saved_errno;
struct sockaddr_un *sunaddr;
char ntop[1025];
char strport[(((32) > (sizeof(sunaddr->sun_path)))
? (32)
: (sizeof(sunaddr->sun_path)))];
for (; cctx->ai; cctx->ai = cctx->ai->ai_next) {
switch (cctx->ai->ai_family) {
case 1:
sunaddr = (struct sockaddr_un *)cctx->ai->ai_addr;
strlcpy(ntop, "unix", sizeof(ntop));
strlcpy(strport, sunaddr->sun_path, sizeof(strport));
break;
case 2:
case 10:
if (getnameinfo(cctx->ai->ai_addr, cctx->ai->ai_addrlen, ntop,
sizeof(ntop), strport, sizeof(strport),
1 | 2) != 0) {
sshlog("channels.c", __func__, 4406, 1, SYSLOG_LEVEL_ERROR, ((void *)0),
"getnameinfo failed");
continue;
}
break;
default:
continue;
}
sshlog("channels.c", __func__, 4413, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0),
"start for host %.100s ([%.100s]:%s)", cctx->host, ntop, strport);
if ((sock = socket(cctx->ai->ai_family, cctx->ai->ai_socktype,
cctx->ai->ai_protocol)) == -1) {
if (cctx->ai->ai_next == ((void *)0))
sshlog("channels.c", __func__, 4418, 0, SYSLOG_LEVEL_ERROR, ((void *)0),
"socket: %.100s", strerror((*__errno_location())));
else
sshlog("channels.c", __func__, 4420, 0, SYSLOG_LEVEL_VERBOSE,
((void *)0), "socket: %.100s", strerror((*__errno_location())));
continue;
}
if (set_nonblock(sock) == -1)
sshfatal("channels.c", __func__, 4424, 1, SYSLOG_LEVEL_FATAL, ((void *)0),
"set_nonblock(%d)", sock);
if (connect(sock, cctx->ai->ai_addr, cctx->ai->ai_addrlen) == -1 &&
(*__errno_location()) != 115) {
sshlog("channels.c", __func__, 4427, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0),
"host %.100s ([%.100s]:%s): %.100s", cctx->host, ntop, strport,
strerror((*__errno_location())));
saved_errno = (*__errno_location());
close(sock);
(*__errno_location()) = saved_errno;
continue;
}
if (cctx->ai->ai_family != 1)
set_nodelay(sock);
sshlog("channels.c", __func__, 4436, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0),
"connect host %.100s ([%.100s]:%s) in progress, fd=%d", cctx->host,
ntop, strport, sock);
cctx->ai = cctx->ai->ai_next;
return sock;
}
return -1;
} | int connect_next(struct_0 *a0, unsigned long a1, unsigned long a2,
unsigned long long a3) {
unsigned int v0;
unsigned int v1;
unsigned long v2;
char v3;
char v4;
unsigned long long v5;
unsigned long v6;
unsigned long v7;
unsigned long v8;
unsigned long long v9;
unsigned long v10;
char v11;
unsigned int v13;
while (true) {
if (a0->field_10) {
if (a0->field_10->field_4 != 10 && a0->field_10->field_4 <= 10 &&
a0->field_10->field_4 == 1) {
v2 = a0->field_10->field_18;
strlcpy(&v4, "unix", 0x401, a3);
strlcpy(&v3, v2 + 2, 0x6c, v2 + 2);
}
if (a0->field_10->field_4 == 10 || a0->field_10->field_4 == 2 &&
a0->field_10->field_4 <= 10 &&
a0->field_10->field_4 != 1) {
v9 = 3;
v13 = getnameinfo(a0->field_10->field_18, a0->field_10->field_10, &v4,
0x401, &v3, 0x6c);
}
if ((!v13 || a0->field_10->field_4 == 1) &&
(a0->field_10->field_4 == 10 || a0->field_10->field_4 <= 10) &&
(!v13 || a0->field_10->field_4 != 10) &&
(a0->field_10->field_4 == 1 || a0->field_10->field_4 == 10 ||
a0->field_10->field_4 == 2)) {
v10 = &v3;
v9 = &v4;
v8 = a0->field_0;
v7 = "start for host %.100s ([%.100s]:%s)";
sshlog("channels.c", "connect_next", 0x113d, 0x1, 0x5, 0x0, *(&v11));
v0 = socket(a0->field_10->field_4, a0->field_10->field_8,
a0->field_10->field_c);
if (v0 != -1) {
if (set_nonblock(v0) == -1) {
v10 = v0;
v9 = "set_nonblock(%d)";
sshfatal("channels.c", "connect_next", 0x1148, 0x1, 0x1, 0x0);
}
v13 = connect(v0, a0->field_10->field_18, a0->field_10->field_10);
if (v13 == -1) {
v13 = *(__errno_location());
v9 = strerror(*(__errno_location()));
v8 = &v3;
v7 = &v4;
v6 = a0->field_0;
v5 = "host %.100s ([%.100s]:%s): %.100s";
sshlog("channels.c", "connect_next", 0x114b, 0x1, 0x5, 0x0,
*(&v11));
v1 = *(__errno_location());
close(v0);
*(__errno_location()) = v1;
}
if (v13 == 115 || v13 != -1) {
if (a0->field_10->field_4 != 1)
set_nodelay(v0);
v9 = v0;
v8 = &v3;
v7 = &v4;
v6 = a0->field_0;
v5 = "connect host %.100s ([%.100s]:%s) in progress, fd=%d";
sshlog("channels.c", "connect_next", 0x1154, 0x1, 0x5, 0x0,
*(&v11));
a0->field_10 = a0->field_10->field_28;
v13 = v0;
break;
}
} else if (!a0->field_10->field_28) {
v10 = strerror(*(__errno_location()));
v9 = "socket: %.100s";
sshlog("channels.c", "connect_next", 0x1142, 0x0, 0x2, 0x0, *(&v11));
} else {
v10 = strerror(*(__errno_location()));
v9 = "socket: %.100s";
sshlog("channels.c", "connect_next", 0x1144, 0x0, 0x4, 0x0, *(&v11));
}
}
if (v13 && (a0->field_10->field_4 == 10 || a0->field_10->field_4 == 2) &&
(a0->field_10->field_4 == 10 || a0->field_10->field_4 <= 10) &&
(a0->field_10->field_4 == 10 || a0->field_10->field_4 != 1)) {
v9 = "getnameinfo failed";
sshlog("channels.c", "connect_next", 0x1136, 0x1, 0x2, 0x0, *(&v11));
}
if (v0 == -1 || v13 == -1 || a0->field_10->field_4 == 10 && v13 ||
v13 && a0->field_10->field_4 != 1 ||
a0->field_10->field_4 != 10 && a0->field_10->field_4 > 10 ||
a0->field_10->field_4 != 1 && a0->field_10->field_4 != 10 &&
a0->field_10->field_4 != 2)
a0->field_10 = a0->field_10->field_28;
} else {
v13 = -1;
break;
}
}
return v13;
} | openssh-portable | angr_dream |
static Bool testStream(FILE *zStream) {
BZFILE *bzf = ((void *)0);
Int32 bzerr, bzerr_dummy, ret, streamNo, i;
UChar obuf[5000];
UChar unused[5000];
Int32 nUnused;
void *unusedTmpV;
UChar *unusedTmp;
nUnused = 0;
streamNo = 0;
;
if (ferror(zStream))
goto errhandler_io;
while (((Bool)1)) {
bzf = BZ2_bzReadOpen(&bzerr, zStream, verbosity, (int)smallMode, unused,
nUnused);
if (bzf == ((void *)0) || bzerr != 0)
goto errhandler;
streamNo++;
while (bzerr == 0) {
BZ2_bzRead(&bzerr, bzf, obuf, 5000);
if (bzerr == (-5))
goto errhandler;
}
if (bzerr != 4)
goto errhandler;
BZ2_bzReadGetUnused(&bzerr, bzf, &unusedTmpV, &nUnused);
if (bzerr != 0)
panic("test:bzReadGetUnused");
unusedTmp = (UChar *)unusedTmpV;
for (i = 0; i < nUnused; i++)
unused[i] = unusedTmp[i];
BZ2_bzReadClose(&bzerr, bzf);
if (bzerr != 0)
panic("test:bzReadGetUnused");
if (nUnused == 0 && myfeof(zStream))
break;
}
if (ferror(zStream))
goto errhandler_io;
ret = fclose(zStream);
if (ret == (-1))
goto errhandler_io;
if (verbosity >= 2)
fprintf(stderr, "\n ");
return ((Bool)1);
errhandler:
BZ2_bzReadClose(&bzerr_dummy, bzf);
if (verbosity == 0)
fprintf(stderr, "%s: %s: ", progName, inName);
switch (bzerr) {
case (-9):
configError();
break;
case (-6):
errhandler_io:
ioError();
break;
case (-4):
fprintf(stderr, "data integrity (CRC) error in data\n");
return ((Bool)0);
case (-3):
outOfMemory();
case (-7):
fprintf(stderr, "file ends unexpectedly\n");
return ((Bool)0);
case (-5):
if (zStream != stdin)
fclose(zStream);
if (streamNo == 1) {
fprintf(stderr, "bad magic number (file not created by bzip2)\n");
return ((Bool)0);
} else {
if (noisy)
fprintf(stderr, "trailing garbage after EOF ignored\n");
return ((Bool)1);
}
default:
panic("test:unexpected error");
}
panic("test:end");
return ((Bool)1);
} | long testStream(FILE *a1) {
int v2;
char v3[4];
unsigned int v4;
int v5;
int i;
int v7;
long v8;
long v9;
long v10;
char v11[1824];
char v12[912];
unsigned long v13;
v13 = __readfsqword(0x28u);
v9 = 0LL;
v4 = 0;
v5 = 0;
if (ferror(a1))
goto LABEL_26;
do {
v9 = BZ2_bzReadOpen(&v2, a1, (unsigned int)verbosity,
(unsigned char)smallMode, v12, v4);
if (!v9 || v2)
goto LABEL_22;
++v5;
while (!v2) {
BZ2_bzRead(&v2, v9, v11, 5000LL);
if (v2 == -5)
goto LABEL_22;
}
if (v2 != 4) {
LABEL_22:
BZ2_bzReadClose(v3, v9);
if (!verbosity)
fprintf(stderr, "%s: %s: ", progName, inName);
switch (v2) {
case -9:
configError();
case -7:
fprintf(stderr, "file ends unexpectedly\n");
return 0LL;
case -6:
goto LABEL_26;
case -5:
if (a1 != stdin)
fclose(a1);
if (v5 == 1) {
fprintf(stderr, "bad magic number (file not created by bzip2)\n");
return 0LL;
} else {
if (noisy)
fprintf(stderr, "trailing garbage after EOF ignored\n");
return 1LL;
}
case -4:
fprintf(stderr, "data integrity (CRC) error in data\n");
return 0LL;
case -3:
outOfMemory();
default:
panic("test:unexpected error");
}
}
BZ2_bzReadGetUnused(&v2, v9, &v8, &v4);
if (v2)
panic("test:bzReadGetUnused");
v10 = v8;
for (i = 0; i < (int)v4; ++i)
v12[i] = *(_BYTE *)(i + v10);
BZ2_bzReadClose(&v2, v9);
if (v2)
panic("test:bzReadGetUnused");
} while (v4 || !(unsigned char)myfeof(a1));
if (ferror(a1) || (v7 = fclose(a1), v7 == -1))
LABEL_26:
ioError();
if (verbosity > 1)
fprintf(stderr, "\n ");
return 1LL;
} | bzip2 | ida |
static inline __u8 rta_getattr_u8(const struct rtattr *rta) {
return *(__u8 *)((
void *)(((char *)(rta)) +
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))));
} | undefined rta_getattr_u8(long param_1)
{
return *(undefined *)(param_1 + 4);
} | iproute2-6.0.0 | ghidra |
_Bool
check_nofollow (void)
{
struct utsname uts;
float release;
if (0 == 0400000) {
return 0;
}
if (0 == uname(&uts)) {
double (*conversion)(const char *) = atof;
release = conversion(uts.release);
if (0 == strcmp("Linux", uts.sysname)) {
return release >= 2.2f;
} else if (0 == strcmp("FreeBSD", uts.sysname)) {
return release >= 3.1f;
}
}
return 1;
} | int check_nofollow() {
unsigned long v0;
char v1;
char v2;
unsigned int v4;
if (!uname(&v1)) {
v0 = got.atof;
(stack_base)[416](&v2);
v4 = strcmp("Linux", &v1);
if (!v4) {
*(&v4) = [D] amd64g_calculate_condition(
0x3 < 64 >, 0x0 < 64 >,
Conv(32->64, ((Conv(32->64, ymm0<4>) CmpF 0x40466666400ccccd < 64 >) &
0x45 < 32 >)),
0x0 < 64 >, cc_ndep<8>);
goto LABEL_400696;
}
v4 = strcmp("FreeBSD", &v1);
if (!v4) {
*(&v4) = [D] amd64g_calculate_condition(
0x3 < 64 >, 0x0 < 64 >,
Conv(32->64, ((Conv(32->64, ymm0<4>) CmpF Conv(
32->64, Load(addr = 0x4029a4 < 64 >, size = 4,
endness = Iend_LE))) &
0x45 < 32 >)),
0x0 < 64 >, cc_ndep<8>);
goto LABEL_400696;
}
}
v4 = 1;
LABEL_400696:
return v4;
} | findutils | angr_phoenix |
long get_clk_tck() {
static long retval = 0;
if (retval != 0)
return (retval);
retval = sysconf(_SC_CLK_TCK);
return (retval);
} | long long get_clk_tck() {
unsigned long long v1;
if (retval.3359) {
v1 = retval.3359;
} else {
retval.3359 = sysconf(0x2);
v1 = retval.3359;
}
return v1;
} | bash | angr_dream |
void readline_internal_setup(void) {
char *nprompt;
_rl_in_stream = rl_instream;
_rl_out_stream = rl_outstream;
if (_rl_enable_meta & (rl_readline_state & (0x0000004)))
_rl_enable_meta_key();
run_startup_hooks();
rl_deactivate_mark();
if (rl_editing_mode == 0)
rl_vi_insertion_mode(1, 'i');
else
if (_rl_show_mode_in_prompt)
_rl_reset_prompt();
if (_rl_echoing_p == 0 && rl_redisplay_function == rl_redisplay) {
if (rl_prompt && rl_already_prompted == 0) {
nprompt = _rl_strip_prompt(rl_prompt);
fprintf(_rl_out_stream, "%s", nprompt);
fflush(_rl_out_stream);
xfree(nprompt);
}
} else {
if (rl_prompt && rl_already_prompted)
rl_on_new_line_with_prompt();
else
rl_on_new_line();
(*rl_redisplay_function)();
}
if (rl_pre_input_hook)
(*rl_pre_input_hook)();
do {
if (_rl_caught_signal)
_rl_signal_handler(_rl_caught_signal);
} while (0);
} | long long readline_internal_setup(unsigned long long a0, unsigned long long a1,
unsigned long long a2, unsigned long long a3,
unsigned long long a4,
unsigned long long a5) {
unsigned long long v0;
unsigned long long v2;
_rl_dispatching_keymap = rl_instream;
_rl_dispatching_keymap = rl_outstream;
if (((rl_readline_state & _rl_enable_meta) & 4))
_rl_enable_meta_key();
run_startup_hooks();
rl_deactivate_mark(a0, a1, _rl_enable_meta, a3, a4, a5);
if (!rl_editing_mode) {
rl_vi_insertion_mode(0x1, 0x69);
} else if (_rl_show_mode_in_prompt) {
_rl_reset_prompt();
}
if (!_rl_echoing_p && rl_redisplay_function == got.rl_redisplay &&
*(&rl_prompt) && !*(&rl_already_prompted)) {
v0 = _rl_strip_prompt(*(&rl_prompt));
fprintf(0xf87d894810ec8348, "%s", v0);
fflush(0xf87d894810ec8348);
xfree(v0);
}
if (_rl_echoing_p || rl_redisplay_function != got.rl_redisplay) {
if (*(&rl_prompt) && *(&rl_already_prompted))
rl_on_new_line_with_prompt();
if (!*(&rl_already_prompted) || !*(&rl_prompt))
rl_on_new_line();
*(5243008)(1, 105, a2, a3, a4, a5);
}
if (rl_pre_input_hook)
*(4202880)();
v2 = _rl_caught_signal;
if (_rl_caught_signal)
v2 = _rl_signal_handler(_rl_caught_signal);
return v2;
} | bash | angr_dream |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.