input stringlengths 26 172k | output stringlengths 18 318k | repo_name stringclasses 23 values | decompiler stringclasses 5 values |
|---|---|---|---|
int main(int argc, char *argv[]) {
struct sigaction sact;
cron_db database;
int fd;
char *cs;
pid_t pid = getpid();
long oldGMToff;
struct timeval tv;
struct timezone tz;
char buf[256];
if ((ProgramName = strrchr(argv[0], '/')) == ((void *)0)) {
ProgramName = argv[0];
} else {
++ProgramName;
}
MailCmd[0] = '\0';
cron_default_mail_charset[0] = '\0';
setlocale(6, "");
SyslogOutput = 0;
NoFork = 0;
ChangePath = 1;
parse_args(argc, argv);
memset((char *)&sact, 0, sizeof sact);
sigemptyset(&sact.sa_mask);
sact.sa_flags = 0;
sact.sa_flags |= 0x10000000;
sact.__sigaction_handler.sa_handler = sigchld_handler;
(void)sigaction(17, &sact, ((void *)0));
sact.__sigaction_handler.sa_handler = sighup_handler;
(void)sigaction(1, &sact, ((void *)0));
sact.__sigaction_handler.sa_handler = sigintterm_handler;
(void)sigaction(2, &sact, ((void *)0));
(void)sigaction(15, &sact, ((void *)0));
acquire_daemonlock(0);
set_cron_uid();
check_spool_dir();
if (ChangePath) {
if (setenv("PATH", "/usr/bin:/bin", 1) < 0) {
log_it("CRON", pid, "DEATH", "can't setenv PATH",
(*__errno_location()));
exit(1);
}
}
setlocale(6, "");
if ((cs = nl_langinfo(CODESET)) != ((void *)0))
strncpy(cron_default_mail_charset, cs, 131072 - 1);
else
strcpy(cron_default_mail_charset, "US-ASCII");
if (DebugFlags) {
(void)fprintf(stderr, "[%ld] cron started\n", (long)getpid());
} else if (NoFork == 0) {
switch (fork()) {
case -1:
log_it("CRON", pid, "DEATH", "can't fork", (*__errno_location()));
exit(0);
break;
case 0:
(void)setsid();
if ((fd = open("/dev/null", 02, 0)) >= 0) {
(void)dup2(fd, 0);
(void)dup2(fd, 1);
(void)dup2(fd, 2);
if (fd != 2)
(void)close(fd);
}
break;
default:
_exit(0);
}
}
log_it("CRON", getpid(), "STARTUP", "1.6.1", 0);
if (!SyslogOutput && MailCmd[0] == '\0' &&
access("/usr/sbin/sendmail", 1) != 0) {
SyslogOutput = 1;
log_it("CRON", pid, "INFO", "Syslog will be used instead of sendmail.", 0);
}
pid = getpid();
if (gettimeofday(&tv, &tz) != 0)
tv.tv_usec = 0;
srandom((unsigned int)(pid + tv.tv_usec));
RandomScale = (double)random() / (double)(1lu << 31);
snprintf(buf, sizeof(buf),
"RANDOM_DELAY will be scaled with factor %d%% if used.",
(int)(RandomScale * 100));
log_it("CRON", pid, "INFO", buf, 0);
acquire_daemonlock(0);
fd = -1;
database.head = ((void *)0);
database.tail = ((void *)0);
database.mtime = (time_t)0;
load_database(&database);
set_time(1);
run_reboot_jobs(&database);
timeRunning = virtualTime = clockTime;
oldGMToff = GMToff;
while (!got_sigintterm) {
int timeDiff;
enum timejump wakeupKind;
do {
cron_sleep(timeRunning + 1, &database);
set_time(0);
} while (!got_sigintterm && clockTime == timeRunning);
if (got_sigintterm)
break;
timeRunning = clockTime;
timeDiff = timeRunning - virtualTime;
check_orphans(&database);
load_database(&database);
if (timeDiff == 1) {
virtualTime = timeRunning;
oldGMToff = GMToff;
find_jobs(virtualTime, &database, 1, 1, oldGMToff);
} else {
if (timeDiff > (3 * (59 - 0 + 1)) || timeDiff < -(3 * (59 - 0 + 1)))
wakeupKind = large;
else if (timeDiff > 5)
wakeupKind = medium;
else if (timeDiff > 0)
wakeupKind = small;
else
wakeupKind = negative;
switch (wakeupKind) {
case small:
if ((DebugFlags & (0x0002)) != 0)
printf("[%ld], normal case %d minutes to go\n", (long)pid, timeDiff);
do {
if (job_runqueue())
sleep(10);
virtualTime++;
if (virtualTime >= timeRunning)
oldGMToff = GMToff;
find_jobs(virtualTime, &database, 1, 1, oldGMToff);
} while (virtualTime < timeRunning);
break;
case medium:
if ((DebugFlags & (0x0002)) != 0)
printf("[%ld], DST begins %d minutes to go\n", (long)pid, timeDiff);
find_jobs(timeRunning, &database, 1, 0, GMToff);
do {
if (job_runqueue())
sleep(10);
virtualTime++;
if (virtualTime >= timeRunning)
oldGMToff = GMToff;
find_jobs(virtualTime, &database, 0, 1, oldGMToff);
set_time(0);
} while (virtualTime < timeRunning && clockTime == timeRunning);
break;
case negative:
if ((DebugFlags & (0x0002)) != 0)
printf("[%ld], DST ends %d minutes to go\n", (long)pid, timeDiff);
find_jobs(timeRunning, &database, 1, 0, GMToff);
break;
default:
if ((DebugFlags & (0x0002)) != 0)
printf("[%ld], clock jumped\n", (long)pid);
virtualTime = timeRunning;
oldGMToff = GMToff;
find_jobs(timeRunning, &database, 1, 1, GMToff);
}
}
job_runqueue();
handle_signals(&database);
}
log_it("CRON", pid, "INFO", "Shutting down", 0);
(void)unlink("/usr/local/var/run"
"/"
"crond.pid");
return 0;
} | int main(unsigned long a0, unsigned long long *a1, unsigned long a2,
unsigned long long a3, unsigned long long a4, unsigned long long a5) {
unsigned int v0;
unsigned int v1;
unsigned int v2;
unsigned int v3;
unsigned int v4;
char *v5;
char v6;
char v7;
void *v8;
void *v9;
void *v10;
void *v11;
unsigned long long v12;
char v13;
unsigned int v14;
char v15;
unsigned long long v18;
unsigned long long v22;
v1 = getpid();
RandomScale = strrchr(*(a1), 0x2f);
RandomScale = -541125437600005303;
if (false)
RandomScale = *(a1);
cron_default_mail_charset = 0;
cron_default_mail_charset = 0;
setlocale(0x6, &g_40197a);
ChangePath = 0;
ChangePath = 0;
ChangePath = 1;
parse_args(a0, a1);
memset(&v12, 0x0, 0x98);
sigemptyset(&v13);
v14 = 0;
v14 |= 0x10000000;
v12 = sigchld_handler;
sigaction(0x11, &v12, 0x0);
v12 = sighup_handler;
sigaction(0x1, &v12, 0x0);
v12 = sigintterm_handler;
sigaction(0x2, &v12, 0x0);
sigaction(0xf, &v12, 0x0);
acquire_daemonlock(0x0);
set_cron_uid(0x0, &v12, 0x0, a3, a4, a5);
check_spool_dir(0x0, &v12, 0x0, a3, a4, a5);
if (setenv("PATH", "/usr/bin:/bin", 0x1) < 0) {
log_it("CRON", v1, "DEATH", "can't setenv PATH", *(__errno_location()));
exit(0x1);
}
setlocale(0x6, &g_40197a);
v5 = nl_langinfo(0xe);
if (v5)
strncpy(&cron_default_mail_charset, v5, 0x1ffff);
else
strcpy(&cron_default_mail_charset, "US-ASCII");
if (DebugFlags)
fprintf(stderr, "[%ld] cron started\n", getpid());
if (false) {
v18 = fork();
log_it("CRON", v1, "DEATH", "can't fork", *(__errno_location()));
exit(0x0);
_exit(0x0);
setsid();
v2 = open("/dev/null", 0x2, 0x0);
if (v2 >= 0) {
dup2(v2, 0x0);
dup2(v2, 0x1);
dup2(v2, 0x2);
if (v2 != 2)
close(v2);
}
}
log_it("CRON", getpid(), "STARTUP", "1.6.1", 0x0);
if (false && access("/usr/sbin/sendmail", 0x1)) {
ChangePath = 1;
log_it("CRON", v1, "INFO", "Syslog will be used instead of sendmail.", 0x0);
}
v1 = getpid();
if (gettimeofday(&v7, &v6))
v8 = 0;
srandom(v1 + v8);
v22 = random() / 0x41e0000000000000;
RandomScale = v22;
snprintf(&v15, 0x100, "RANDOM_DELAY will be scaled with factor %d%% if used.",
(0x4059000000000000 * 17905618636109546312));
log_it("CRON", v1, "INFO", &v15, 0x0);
acquire_daemonlock(0x0);
v2 = -1;
v9 = 0;
v10 = 0;
v11 = 0;
load_database(&v9);
set_time(0x1);
run_reboot_jobs(&v9);
virtualTime = clockTime;
timeRunning = virtualTime;
*(&v4) = GMToff;
while (!got_sigintterm) {
do {
cron_sleep(timeRunning + 1, &v9);
set_time(0x0);
if (got_sigintterm)
break;
} while (clockTime == timeRunning);
if (got_sigintterm)
break;
if (!got_sigintterm) {
timeRunning = clockTime;
v3 = timeRunning - virtualTime;
check_orphans(&v9);
load_database(&v9);
if (v3 == 1) {
virtualTime = timeRunning;
*(&v4) = GMToff;
find_jobs(virtualTime, &v9, 0x1, 0x1, *(&v4));
} else {
if (v3 <= 180 && v3 >= -180) {
if (v3 > 5) {
v0 = 2;
} else if (v3 > 0) {
v0 = 1;
} else {
v0 = 0;
}
}
if (v3 < -180 || v3 > 180)
v0 = 3;
if (v0 != 2) {
if (v0 <= 2) {
if (!v0) {
if ((DebugFlags & 2))
printf("[%ld], DST ends %d minutes to go\n", v1, v3);
find_jobs(timeRunning, &v9, 0x1, 0x0, GMToff);
}
if (v0 == 1) {
if ((DebugFlags & 2))
printf("[%ld], normal case %d minutes to go\n", v1, v3);
while (true) {
if (job_runqueue())
sleep(0xa);
virtualTime = virtualTime + 1;
if (virtualTime >= timeRunning)
*(&v4) = GMToff;
find_jobs(virtualTime, &v9, 0x1, 0x1, *(&v4));
if (virtualTime >= timeRunning)
break;
}
}
}
if (v0 > 2 || v0 != 1 && v0) {
if ((DebugFlags & 2))
printf("[%ld], clock jumped\n", v1);
virtualTime = timeRunning;
v4 = GMToff;
find_jobs(timeRunning, &v9, 0x1, 0x1, GMToff);
}
} else {
if ((DebugFlags & 2))
printf("[%ld], DST begins %d minutes to go\n", v1, v3);
find_jobs(timeRunning, &v9, 0x1, 0x0, GMToff);
do {
if (job_runqueue())
sleep(0xa);
virtualTime = virtualTime + 1;
if (virtualTime >= timeRunning)
*(&v4) = GMToff;
find_jobs(virtualTime, &v9, 0x0, 0x1, *(&v4));
set_time(0x0);
if (virtualTime >= timeRunning)
break;
} while (clockTime == timeRunning);
}
}
}
job_runqueue();
handle_signals(&v9);
}
log_it("CRON", v1, "INFO", "Shutting down", 0x0);
unlink("/usr/local/var/run/crond.pid");
return 0;
} | cronie | angr_dream |
static inline struct ext2_inode *
EXT2_INODE(struct ext2_inode_large *large_inode) {
return (struct ext2_inode *)large_inode;
} | int EXT2_INODE(unsigned long a0) { return a0; } | e2fsprogs-1.46.5 | angr_dream |
void gid_to_gname(gid_t gid, char **gname) {
struct group *group;
if (gid != 0 && gid == cached_no_such_gid) {
*gname = xstrdup("");
return;
}
if (!cached_gname || gid != cached_gid) {
group = getgrgid(gid);
if (group) {
cached_gid = gid;
assign_string(&cached_gname, group->gr_name);
} else {
cached_no_such_gid = gid;
*gname = xstrdup("");
return;
}
}
*gname = xstrdup(cached_gname);
} | void gid_to_gname(__gid_t param_1, undefined8 *param_2)
{
undefined8 uVar1;
group *pgVar2;
if ((param_1 == 0) || (param_1 != cached_no_such_gid)) {
if ((cached_gname == 0) || (param_1 != cached_gid)) {
pgVar2 = getgrgid(param_1);
if (pgVar2 == (group *)0x0) {
cached_no_such_gid = param_1;
uVar1 = xstrdup(&DAT_00104344);
*param_2 = uVar1;
return;
}
cached_gid = param_1;
assign_string(&cached_gname, pgVar2->gr_name);
}
uVar1 = xstrdup(cached_gname);
*param_2 = uVar1;
} else {
uVar1 = xstrdup(&DAT_00104344);
*param_2 = uVar1;
}
return;
} | tar | ghidra |
static int vti6_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n) {
struct ifinfomsg *ifi =
((void *)(((char *)n) +
((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1)))));
struct {
struct nlmsghdr n;
struct ifinfomsg i;
} req = {
.n.nlmsg_len =
((sizeof(*ifi)) +
((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1)))),
.n.nlmsg_flags = 0x01,
.n.nlmsg_type = RTM_GETLINK,
.i.ifi_family = preferred_family,
.i.ifi_index = ifi->ifi_index,
};
struct nlmsghdr *answer;
struct rtattr *tb[(__IFLA_MAX - 1) + 1];
struct rtattr *linkinfo[(__IFLA_INFO_MAX - 1) + 1];
struct rtattr *vtiinfo[(__IFLA_VTI_MAX - 1) + 1];
__be32 ikey = 0;
__be32 okey = 0;
inet_prefix saddr, daddr;
unsigned int link = 0;
__u32 fwmark = 0;
int len;
inet_prefix_reset(&saddr);
inet_prefix_reset(&daddr);
if (!(n->nlmsg_flags & 0x400)) {
const struct rtattr *rta;
if (rtnl_talk(&rth, &req.n, &answer) < 0) {
get_failed:
fprintf(stderr, "Failed to get existing tunnel info.\n");
return -1;
}
len = answer->nlmsg_len;
len -= ((sizeof(*ifi)) +
((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))));
if (len < 0)
goto get_failed;
parse_rtattr(
tb, (__IFLA_MAX - 1),
((struct rtattr
*)(((char *)((
(void *)(((char *)answer) +
((int)(((sizeof(struct nlmsghdr)) + 4U - 1) &
~(4U - 1))))))) +
(((sizeof(struct ifinfomsg)) + 4U - 1) & ~(4U - 1)))),
len);
if (!tb[IFLA_LINKINFO])
goto get_failed;
(parse_rtattr_flags(
(linkinfo), ((__IFLA_INFO_MAX - 1)),
((void *)(((char *)(tb[IFLA_LINKINFO])) +
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))),
((int)((tb[IFLA_LINKINFO])->rta_len) -
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))),
(1 << 15)));
if (!linkinfo[IFLA_INFO_DATA])
goto get_failed;
(parse_rtattr_flags(
(vtiinfo), ((__IFLA_VTI_MAX - 1)),
((void *)(((char *)(linkinfo[IFLA_INFO_DATA])) +
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))),
((int)((linkinfo[IFLA_INFO_DATA])->rta_len) -
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))),
(1 << 15)));
rta = vtiinfo[IFLA_VTI_LOCAL];
if (rta && get_addr_rta(&saddr, rta, 10))
goto get_failed;
rta = vtiinfo[IFLA_VTI_REMOTE];
if (rta && get_addr_rta(&daddr, rta, 10))
goto get_failed;
if (vtiinfo[IFLA_VTI_IKEY])
ikey = rta_getattr_u32(vtiinfo[IFLA_VTI_IKEY]);
if (vtiinfo[IFLA_VTI_OKEY])
okey = rta_getattr_u32(vtiinfo[IFLA_VTI_OKEY]);
if (vtiinfo[IFLA_VTI_LINK])
link = rta_getattr_u8(vtiinfo[IFLA_VTI_LINK]);
if (vtiinfo[IFLA_VTI_FWMARK])
fwmark = rta_getattr_u32(vtiinfo[IFLA_VTI_FWMARK]);
free(answer);
}
while (argc > 0) {
if (!matches(*argv, "key")) {
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
ikey = okey = tnl_parse_key("key", *argv);
} else if (!matches(*argv, "ikey")) {
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
ikey = tnl_parse_key("ikey", *argv);
} else if (!matches(*argv, "okey")) {
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
okey = tnl_parse_key("okey", *argv);
} else if (!matches(*argv, "remote")) {
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
get_addr(&daddr, *argv, 10);
} else if (!matches(*argv, "local")) {
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
get_addr(&saddr, *argv, 10);
} else if (!matches(*argv, "dev")) {
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
link = ll_name_to_index(*argv);
if (!link)
exit(nodev(*argv));
} else if (strcmp(*argv, "fwmark") == 0) {
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u32(&fwmark, *argv, 0))
invarg("invalid fwmark\n", *argv);
} else {
vti6_print_help(lu, argc, argv, stderr);
return -1;
}
argc--;
argv++;
}
addattr32(n, 1024, IFLA_VTI_IKEY, ikey);
addattr32(n, 1024, IFLA_VTI_OKEY, okey);
if (is_addrtype_inet_not_unspec(&saddr))
addattr_l(n, 1024, IFLA_VTI_LOCAL, saddr.data, saddr.bytelen);
if (is_addrtype_inet_not_unspec(&daddr))
addattr_l(n, 1024, IFLA_VTI_REMOTE, daddr.data, daddr.bytelen);
addattr32(n, 1024, IFLA_VTI_FWMARK, fwmark);
if (link)
addattr32(n, 1024, IFLA_VTI_LINK, link);
return 0;
} | long long vti6_parse_opt(unsigned int a0, unsigned long a1, unsigned int a2,
struct_0 *a3) {
unsigned long long *v0;
unsigned int v1;
unsigned int v2;
unsigned int v3;
unsigned int v4;
unsigned int v5;
unsigned int v6;
char v7;
struct_1 *v8;
unsigned long long v9;
unsigned int v10;
unsigned short v11;
unsigned short v12;
void *v13;
char v14;
unsigned int v15;
void *v16;
char v17;
char v18;
char v19;
char v20;
char v21;
char v22;
char v23;
char v24;
char v25;
char v26;
char v27;
char v28;
char v29;
char v30;
char v31;
char v32;
char v33;
unsigned long long v35;
unsigned long long v36;
unsigned long long v37;
unsigned long long v40;
v1 = a1;
*(&v0) = a2;
v8 = &a3[2].padding_0;
v10 = 0;
v13 = 0;
v14 = 0;
v16 = 0;
v10 = 32;
v11 = 18;
v12 = 1;
v14 = preferred_family;
v15 = v8->field_4;
v3 = 0;
v4 = 0;
v5 = 0;
v2 = 0;
inet_prefix_reset(&v26);
inet_prefix_reset(&v29);
if (!(a3->field_6 & 0x400)) {
v35 = rtnl_talk(0x500020, &v10, &v7);
if (v35 >= 0) {
v6 = *(*(&v7));
v6 -= 32;
if (v6 >= 0) {
parse_rtattr(&v32, 0x3c, *(&v7) + 32, v6);
if (*(&v33)) {
parse_rtattr_flags(&v17, 0x5, *(&v33) + 4, *(*(&v33)) - 4, 0x8000);
if (*(&v18)) {
parse_rtattr_flags(&v19, 0x6, *(&v18) + 4, *(*(&v18)) - 4, 0x8000);
v9 = *(&v23);
if (v9)
v35 = get_addr_rta(&v26, v9, 0xa, v9);
if (!v9 || !v35) {
v9 = *(&v24);
if (v9)
v35 = get_addr_rta(&v29, v9, 0xa, v9);
}
}
}
}
}
}
if (!(a3->field_6 & 0x400) && *(&v18) && v9 && *(&v33) && v35 >= 0 &&
v6 >= 0 && (!v9 || !v35) && v35 ||
!(a3->field_6 & 0x400) && *(&v18) && v9 && *(&v33) && v35 >= 0 &&
v6 >= 0 && v35 ||
!(a3->field_6 & 0x400) && *(&v33) && v35 >= 0 && v6 >= 0 && !*(&v18) ||
!(a3->field_6 & 0x400) && v35 >= 0 && v6 >= 0 && !*(&v33) ||
!(a3->field_6 & 0x400) && v35 >= 0 && v6 < 0 ||
!(a3->field_6 & 0x400) && v35 < 0) {
fprintf(*(&stderr), "Failed to get existing tunnel info.\n");
v40 = 4294967295;
}
if (!(a3->field_6 & 0x400) && *(&v18) && v9 && *(&v33) && v35 >= 0 &&
v6 >= 0 && (!v9 || !v35) && !v35 ||
!(a3->field_6 & 0x400) && *(&v18) && *(&v33) && v35 >= 0 && v6 >= 0 &&
(!v9 || !v35) && !v9) {
if (*(&v21))
v3 = rta_getattr_u32(*(&v21));
if (*(&v22))
v4 = rta_getattr_u32(*(&v22));
if (*(&v20))
v5 = rta_getattr_u8(*(&v20));
if (*(&v25))
v2 = rta_getattr_u32(*(&v25));
free(*(&v7));
}
if (!(a3->field_6 & 0x400) && *(&v18) && v9 && *(&v33) && v35 >= 0 &&
v6 >= 0 && (!v9 || !v35) && !v35 ||
!(a3->field_6 & 0x400) && *(&v18) && *(&v33) && v35 >= 0 && v6 >= 0 &&
(!v9 || !v35) && !v9 ||
(a3->field_6 & 0x400)) {
while (true) {
if (v1 > 0) {
*(&v35) = matches(*(v0), "key") ^ 1;
if (v35) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
v4 = tnl_parse_key("key", *(v0));
v3 = v4;
} else {
*(&v35) = matches(*(v0), "ikey") ^ 1;
*(&v35) = matches(*(v0), "okey") ^ 1;
*(&v35) = matches(*(v0), "remote") ^ 1;
*(&v35) = matches(*(v0), "local") ^ 1;
*(&v35) = matches(*(v0), "dev") ^ 1;
v36 = strcmp(*(v0), "fwmark");
if (!v36) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
v37 = get_u32(&v2, *(v0), 0x0, *(v0));
if (v37)
invarg("invalid fwmark\n", *(v0));
}
if (v36 || v37) {
vti6_print_help(a0, v1, v0, *(&stderr));
v40 = 4294967295;
break;
}
}
if (false) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
v3 = tnl_parse_key("ikey", *(v0));
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
v4 = tnl_parse_key("okey", *(v0));
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
get_addr(&v29, *(v0), 0xa, *(v0));
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
get_addr(&v26, *(v0), 0xa, *(v0));
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
v5 = ll_name_to_index(*(v0));
exit(nodev(*(v0)));
}
if (v35 || !v36 && !v37) {
v1 -= 1;
v0 += 1;
}
} else {
addattr32(a3, 0x400, 0x2, v3);
addattr32(a3, 0x400, 0x3, v4);
if (is_addrtype_inet_not_unspec(&v26))
addattr_l(a3, 0x400, 0x4, &v28, *(&v27));
if (is_addrtype_inet_not_unspec(&v29))
addattr_l(a3, 0x400, 0x5, &v31, *(&v30));
addattr32(a3, 0x400, 0x6, v2);
if (v5)
addattr32(a3, 0x400, 0x1, v5);
v40 = 0;
break;
}
}
}
return v40;
} | iproute2-6.0.0 | angr_dream |
int mbscmp(mbs1, mbs2) const char *mbs1;
const char *mbs2;
{
int len1, len2, mb_cur_max;
wchar_t c1, c2;
len1 = len2 = 0;
(void)mblen((char *)((void *)0), 0);
mb_cur_max = (__ctype_get_mb_cur_max());
do {
len1 = mbtowc(&c1, mbs1, mb_cur_max);
len2 = mbtowc(&c2, mbs2, mb_cur_max);
if (len1 == 0)
return len2 == 0 ? 0 : -1;
else if (len2 == 0)
return 1;
else if (len1 > 0 && len2 < 0)
return -1;
else if (len1 < 0 && len2 > 0)
return 1;
else if (len1 < 0 && len2 < 0) {
len1 = strlen(mbs1);
len2 = strlen(mbs2);
return (len1 == len2
? memcmp(mbs1, mbs2, len1)
: ((len1 < len2) ? (memcmp(mbs1, mbs2, len1) > 0 ? 1 : -1)
: (memcmp(mbs1, mbs2, len2) >= 0 ? 1 : -1)));
}
mbs1 += len1;
mbs2 += len2;
} while (c1 == c2);
return c1 - c2;
} | int mbscmp(char *param_1, char *param_2)
{
int iVar1;
size_t sVar2;
long in_FS_OFFSET;
char *local_38;
char *local_30;
wchar_t local_24;
wchar_t local_20;
int local_1c;
int local_18;
int local_14;
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
local_1c = 0;
local_18 = 0;
mblen((char *)0x0, 0);
sVar2 = __ctype_get_mb_cur_max();
local_14 = (int)sVar2;
local_38 = param_2;
local_30 = param_1;
while (true) {
local_18 = mbtowc(&local_24, local_30, (long)local_14);
local_1c = mbtowc(&local_20, local_38, (long)local_14);
if (local_18 == 0) {
if (local_1c == 0) {
iVar1 = 0;
} else {
iVar1 = -1;
}
goto LAB_001001bb;
}
if (local_1c == 0) {
iVar1 = 1;
goto LAB_001001bb;
}
if ((0 < local_18) && (local_1c < 0)) {
iVar1 = -1;
goto LAB_001001bb;
}
if ((local_18 < 0) && (0 < local_1c)) {
iVar1 = 1;
goto LAB_001001bb;
}
if ((local_18 < 0) && (local_1c < 0))
break;
local_30 = local_30 + local_18;
local_38 = local_38 + local_1c;
if (local_24 != local_20) {
iVar1 = local_24 - local_20;
LAB_001001bb:
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
__stack_chk_fail();
}
return iVar1;
}
}
sVar2 = strlen(local_30);
local_18 = (int)sVar2;
sVar2 = strlen(local_38);
local_1c = (int)sVar2;
if (local_18 == local_1c) {
iVar1 = memcmp(local_30, local_38, (long)local_18);
} else if (local_18 < local_1c) {
iVar1 = memcmp(local_30, local_38, (long)local_18);
if (iVar1 < 1) {
iVar1 = -1;
} else {
iVar1 = 1;
}
} else {
iVar1 = memcmp(local_30, local_38, (long)local_1c);
if (iVar1 < 0) {
iVar1 = -1;
} else {
iVar1 = 1;
}
}
goto LAB_001001bb;
} | bash | ghidra |
int nextopt(const char *optstring) {
char *p;
const char *q;
char c;
if ((p = optptr) == ((void *)0) || *p == '\0') {
p = *argptr;
if (p == ((void *)0) || *p != '-' || *++p == '\0')
return '\0';
argptr++;
if (p[0] == '-' && p[1] == '\0')
return '\0';
}
c = *p++;
for (q = optstring; *q != c;) {
if (*q == '\0')
sh_error("Illegal option -%c", c);
if (*++q == ':')
q++;
}
if (*++q == ':') {
if (*p == '\0' && (p = *argptr++) == ((void *)0))
sh_error("No arg for -%c option", c);
optionarg = p;
p = ((void *)0);
}
optptr = p;
return c;
} | int nextopt(char *param_1)
{
char **ppcVar1;
char cVar2;
char *pcVar3;
char *pcVar4;
char *local_18;
char *local_10;
local_18 = optptr;
if ((optptr == (char *)0x0) || (*optptr == '\0')) {
pcVar3 = *argptr;
if ((pcVar3 == (char *)0x0) ||
((*pcVar3 != '-' || (local_18 = pcVar3 + 1, *local_18 == '\0')))) {
return 0;
}
argptr = argptr + 1;
if ((*local_18 == '-') && (pcVar3[2] == '\0')) {
return 0;
}
}
pcVar3 = local_18 + 1;
cVar2 = *local_18;
pcVar4 = param_1;
while (local_10 = pcVar4, cVar2 != *local_10) {
if (*local_10 == '\0') {
sh_error("Illegal option -%c", (int)cVar2);
}
pcVar4 = local_10 + 1;
if (local_10[1] == ':') {
pcVar4 = local_10 + 2;
}
}
local_18 = pcVar3;
if (local_10[1] == ':') {
if (*pcVar3 == '\0') {
ppcVar1 = argptr + 1;
local_18 = *argptr;
argptr = ppcVar1;
if (local_18 == (char *)0x0) {
sh_error("No arg for -%c option", (int)cVar2);
}
}
optionarg = local_18;
local_18 = (char *)0x0;
}
optptr = local_18;
return (int)cVar2;
} | dash-0.5.11+git20210903+057cd650a4ed | ghidra |
static inline __u8 rta_getattr_u8(const struct rtattr *rta) {
return *(__u8 *)((
void *)(((char *)(rta)) +
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))));
} | int rta_getattr_u8(struct_0 *a0) { return a0->field_4; } | iproute2-6.0.0 | angr_sailr |
char *compat_cipher_proposal(struct ssh *ssh, char *cipher_prop) {
if (!(ssh->compat & 0x00001000))
return xstrdup(cipher_prop);
sshlog("compat.c", __func__, 165, 1, SYSLOG_LEVEL_DEBUG2, ((void *)0),
"original cipher proposal: %s", cipher_prop);
if ((cipher_prop = match_filter_denylist(cipher_prop, "aes*")) == ((void *)0))
sshfatal("compat.c", __func__, 167, 0, SYSLOG_LEVEL_FATAL, ((void *)0),
"match_filter_denylist failed");
sshlog("compat.c", __func__, 168, 1, SYSLOG_LEVEL_DEBUG2, ((void *)0),
"compat cipher proposal: %s", cipher_prop);
if (*cipher_prop == '\0')
sshfatal("compat.c", __func__, 170, 0, SYSLOG_LEVEL_FATAL, ((void *)0),
"No supported ciphers found");
return cipher_prop;
} | char *compat_cipher_proposal(long param_1, char *param_2)
{
char **ppcVar1;
char *pcStack40;
char *pcStack32;
char *local_18;
long local_10;
local_18 = param_2;
local_10 = param_1;
if ((*(uint *)(param_1 + 0x83c) & 0x1000) == 0) {
pcStack32 = (char *)0x100192;
local_18 = (char *)xstrdup(param_2);
} else {
pcStack40 = "original cipher proposal: %s";
pcStack32 = param_2;
sshlog("compat.c", "compat_cipher_proposal", 0xa5, 1, 6, 0);
ppcVar1 = &local_18;
pcStack32 = (char *)0x1001e7;
local_18 = (char *)match_filter_denylist(local_18, &DAT_00100659);
if (local_18 == (char *)0x0) {
ppcVar1 = &pcStack40;
pcStack40 = "match_filter_denylist failed";
sshfatal("compat.c", "compat_cipher_proposal", 0xa7, 0, 1, 0);
}
*(char **)((long)ppcVar1 + -8) = local_18;
*(char **)((long)ppcVar1 + -0x10) = "compat cipher proposal: %s";
*(undefined8 *)((long)ppcVar1 + -0x18) = 0x100265;
sshlog("compat.c", "compat_cipher_proposal", 0xa8, 1, 6, 0);
if (*local_18 == '\0') {
*(char **)((long)ppcVar1 + -0x10) = "No supported ciphers found";
*(undefined8 *)((long)ppcVar1 + -0x18) = 0x1002ae;
sshfatal("compat.c", "compat_cipher_proposal", 0xaa, 0, 1, 0);
}
}
return local_18;
} | openssh-portable | ghidra |
static struct latch_descr *find_latch(int code) {
int i;
for (i = 0; pr_latch_info[i].latch_code >= 0; i++) {
if (pr_latch_info[i].latch_code == code)
return &pr_latch_info[i];
}
return 0;
} | int find_latch(unsigned long a0) {
unsigned int v0;
unsigned int v2;
v0 = 0;
while (true) {
if (pr_latch_info[4 * v0] < 0) {
v2 = 0;
break;
} else if (a0 != pr_latch_info[4 * v0]) {
v0 += 1;
} else {
v2 = &pr_latch_info[4 * v0];
break;
}
}
return v2;
} | e2fsprogs-1.46.5 | angr_phoenix |
static const struct kexalg *kex_alg_by_name(const char *name) {
const struct kexalg *k;
for (k = kexalgs; k->name != ((void *)0); k++) {
if (strcmp(k->name, name) == 0)
return k;
}
return ((void *)0);
} | const char **kex_alg_by_name(const char *a1) {
const char **i;
for (i = (const char **)&kexalgs; *i; i += 3) {
if (!strcmp(*i, a1))
return i;
}
return 0LL;
} | openssh-portable | ida |
static inline void emit_ancillary_info(char const *program) {
struct infomap {
char const *program;
char const *node;
} const infomap[] = {
{"[", "test invocation"}, {"coreutils", "Multi-call invocation"},
{"sha224sum", "sha2 utilities"}, {"sha256sum", "sha2 utilities"},
{"sha384sum", "sha2 utilities"}, {"sha512sum", "sha2 utilities"},
{((void *)0), ((void *)0)}};
char const *node = program;
struct infomap const *map_prog = infomap;
while (map_prog->program && !(strcmp(program, map_prog->program) == 0))
map_prog++;
if (map_prog->node)
node = map_prog->node;
printf (gettext ("\n%s online help: <%s>\n"), "GNU coreutils", "https:
char const *lc_messages = setlocale (
5
,
((void *)0)
);
if (lc_messages && strncmp (lc_messages, "" "en_" "", sizeof ("en_") - 1))
{
fputs_unlocked (gettext ("Report any translation bugs to " "<https:
stdout
)
;
}
char const *url_program = (strcmp (program, "[") == 0) ? "test" : program;
printf (gettext ("Full documentation <%s%s>\n"),
"https:
printf (gettext ("or available locally via: info '(coreutils) %s%s'\n"),
node, node == program ? " invocation" : "");
} | unsigned long emit_ancillary_info(const char *a1) {
char *v1;
FILE *v2;
char *v3;
const char *v4;
char *v5;
const char *v6;
char *v7;
const char *v9;
long *i;
const char *v11;
const char *v12;
long v13[15];
unsigned long v14;
v14 = __readfsqword(0x28u);
v13[0] = (long)"[";
v13[1] = (long)"test invocation";
v13[2] = (long)"coreutils";
v13[3] = (long)"Multi-call invocation";
v13[4] = (long)"sha224sum";
v13[5] = (long)"sha2 utilities";
v13[6] = (long)"sha256sum";
v13[7] = (long)"sha2 utilities";
v13[8] = (long)"sha384sum";
v13[9] = (long)"sha2 utilities";
v13[10] = (long)"sha512sum";
v13[11] = (long)"sha2 utilities";
v13[12] = 0LL;
v13[13] = 0LL;
v9 = a1;
for (i = v13; *i && strcmp(a1, (const char *)*i); i += 2)
;
if (i[1])
v9 = (const char *)i[1];
v1 = gettext("\n%s online help: <%s>\n");
printf(v1, "GNU coreutils", "https:
v11 = setlocale(5, 0LL);
if ( v11 && strncmp(v11, "en_", 3uLL) )
{
v2 = stdout;
v3 = gettext("Report any translation bugs to <https:
fputs_unlocked(v3, v2);
}
if ( !strcmp(a1, "[") )
v4 = "test";
else
v4 = a1;
v12 = v4;
v5 = gettext("Full documentation <%s%s>\n");
printf(v5, "https:
if ( v9 == a1 )
v6 = " invocation";
else
v6 = locale;
v7 = gettext("or available locally via: info '(coreutils) %s%s'\n");
printf(v7, v9, v6);
return __readfsqword(0x28u) ^ v14;
} | coreutils | ida |
static inline _Bool is_addrtype_inet_not_unspec(const inet_prefix *p) {
return (p->flags & ADDRTYPE_INET_UNSPEC) == ADDRTYPE_INET;
} | int is_addrtype_inet_not_unspec(unsigned short *a0) {
unsigned int v1;
v1 = *(a0) & 6;
*(&v1) = (*(a0) & 6) == 2;
return v1;
} | iproute2-6.0.0 | angr_dream |
static SIMPLE_COM *copy_simple_command(com)
SIMPLE_COM *com;
{
SIMPLE_COM *new_simple;
new_simple =
(SIMPLE_COM *)sh_xmalloc((sizeof(SIMPLE_COM)), "copy_cmd.c", 331);
new_simple->flags = com->flags;
new_simple->words = copy_word_list(com->words);
new_simple->redirects =
com->redirects ? copy_redirects(com->redirects) : (REDIRECT *)((void *)0);
new_simple->line = com->line;
return (new_simple);
} | int copy_simple_command(struct_0 *a0) {
struct_0 *v0;
void *v2;
v0 = sh_xmalloc(0x18, "copy_cmd.c", 0x14b);
v0->field_0 = a0->field_0;
v0->field_8 = copy_word_list(a0->field_8, "copy_cmd.c", a0->field_0);
if (!a0->field_10)
v2 = 0;
else
v2 = copy_redirects(a0->field_10);
v0->field_10 = v2;
v0->field_4 = a0->field_4;
return v0;
} | bash | angr_phoenix |
static char const *find_int(char const *string) {
char const *p;
char const *number_start;
for (p = string; ((*__ctype_b_loc())[(int)((to_uchar(*p)))] &
(unsigned short int)_ISblank);
p++)
continue;
if (*p == '+') {
p++;
number_start = p;
} else {
number_start = p;
p += (*p == '-');
}
if (((unsigned int)(*p++) - '0' <= 9)) {
while (((unsigned int)(*p) - '0' <= 9))
p++;
while (((*__ctype_b_loc())[(int)((to_uchar(*p)))] &
(unsigned short int)_ISblank))
p++;
if (!*p)
return number_start;
}
test_syntax_error(gettext("invalid integer %s"), quote(string));
} | int find_int(unsigned long long a0) {
char *v0;
int tmp_12;
char *v1;
unsigned short v4;
unsigned int v5;
unsigned int v6;
unsigned int v8;
v0 = a0;
while (true) {
v4 = *((to_uchar(*(v0)) * 2 + *(__ctype_b_loc())));
v5 = v4 & 1;
if (!v5)
break;
v0 += 1;
}
if (*(v0) == 43) {
v0 += 1;
v1 = v0;
} else {
v1 = v0;
v0 = &v0[*(v0) == 45];
}
tmp_12 = v0;
v0 += 1;
*(&v5) = *(tmp_12);
if (v6 <= 9) {
for (v6 = v5 - 48; *(v0)-48 <= 9; v0 += 1)
;
while (true) {
*(&v6) = *((to_uchar(*(v0)) * 2 + *(__ctype_b_loc())));
v8 = v6 & 1;
if (!v8)
break;
v0 += 1;
}
if (!*(v0))
return v1;
}
test_syntax_error(gettext("invalid integer %s"), quote(a0));
} | coreutils | angr_phoenix |
static __inline__ int isnetfs(const char *type) {
static const char *netfs[] = {"nfs", "nfs4", "smbfs", "cifs",
"afs", "ncpfs", (char *)0};
int n;
for (n = 0; netfs[n]; n++) {
if (!strcasecmp(netfs[n], type))
return 1;
}
return 0;
} | int isnetfs(char *a0) {
unsigned int v0;
unsigned int v2;
v0 = 0;
while (true) {
if (netfs.4428 [v0]) {
v2 = strcasecmp(netfs.4428 [v0], a0);
if (!v2) {
v2 = 1;
break;
} else {
v0 += 1;
}
} else {
v2 = 0;
break;
}
}
return v2;
} | sysvinit | angr_dream |
static _Bool
file_ignored(char const *name) {
return (
(ignore_mode != IGNORE_MINIMAL && name[0] == '.' &&
(ignore_mode == IGNORE_DEFAULT || !name[1 + (name[1] == '.')])) ||
(ignore_mode == IGNORE_DEFAULT && patterns_match(hide_patterns, name)) ||
patterns_match(ignore_patterns, name));
} | undefined4 file_ignored(char *param_1)
{
char cVar1;
long lVar2;
if ((ignore_mode != 2) && (*param_1 == '.')) {
if (ignore_mode == 0) {
return 1;
}
if (param_1[1] == '.') {
lVar2 = 2;
} else {
lVar2 = 1;
}
if (param_1[lVar2] == '\0') {
return 1;
}
}
if (((ignore_mode != 0) ||
(cVar1 = patterns_match(hide_patterns, param_1), cVar1 == '\0')) &&
(cVar1 = patterns_match(ignore_patterns, param_1), cVar1 == '\0')) {
return 0;
}
return 1;
} | coreutils | ghidra |
static int build_actions(list, flagp, actp, optp)
WORD_LIST *list;
struct _optflags *flagp;
unsigned long *actp, *optp;
{
int opt, ind, opt_given;
unsigned long acts, copts;
WORD_DESC w;
acts = copts = (unsigned long)0L;
opt_given = 0;
reset_internal_getopt();
while ((opt = internal_getopt(list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI")) !=
-1) {
opt_given = 1;
switch (opt) {
case 'r':
if (flagp) {
flagp->rflag = 1;
break;
} else {
sh_invalidopt("-r");
builtin_usage();
return (258);
}
case 'p':
if (flagp) {
flagp->pflag = 1;
break;
} else {
sh_invalidopt("-p");
builtin_usage();
return (258);
}
case 'a':
acts |= (1 << 0);
break;
case 'b':
acts |= (1 << 3);
break;
case 'c':
acts |= (1 << 4);
break;
case 'd':
acts |= (1 << 5);
break;
case 'e':
acts |= (1 << 8);
break;
case 'f':
acts |= (1 << 9);
break;
case 'g':
acts |= (1 << 11);
break;
case 'j':
acts |= (1 << 14);
break;
case 'k':
acts |= (1 << 15);
break;
case 's':
acts |= (1 << 17);
break;
case 'u':
acts |= (1 << 22);
break;
case 'v':
acts |= (1 << 23);
break;
case 'o':
ind = find_compopt(list_optarg);
if (ind < 0) {
sh_invalidoptname(list_optarg);
return (258);
}
copts |= compopts[ind].optflag;
break;
case 'A':
ind = find_compact(list_optarg);
if (ind < 0) {
builtin_error(gettext("%s: invalid action name"), list_optarg);
return (258);
}
acts |= compacts[ind].actflag;
break;
case 'C':
Carg = list_optarg;
break;
case 'D':
if (flagp) {
flagp->Dflag = 1;
break;
} else {
sh_invalidopt("-D");
builtin_usage();
return (258);
}
case 'E':
if (flagp) {
flagp->Eflag = 1;
break;
} else {
sh_invalidopt("-E");
builtin_usage();
return (258);
}
case 'I':
if (flagp) {
flagp->Iflag = 1;
break;
} else {
sh_invalidopt("-I");
builtin_usage();
return (258);
}
case 'F':
w.word = Farg = list_optarg;
w.flags = 0;
if (check_identifier(&w, posixly_correct) == 0 ||
strpbrk(Farg, "()<>;&| \t\n") != 0) {
sh_invalidid(Farg);
return (258);
}
break;
case 'G':
Garg = list_optarg;
break;
case 'P':
Parg = list_optarg;
break;
case 'S':
Sarg = list_optarg;
break;
case 'W':
Warg = list_optarg;
break;
case 'X':
Xarg = list_optarg;
break;
case -99:
builtin_help();
return (258);
default:
builtin_usage();
return (258);
}
}
*actp = acts;
*optp = copts;
return (opt_given ? 0 : 1);
} | int build_actions(unsigned long long a0, unsigned int a1[5],
unsigned long long *a2, unsigned long long a3,
unsigned long long a4, unsigned long long a5) {
unsigned int v0;
unsigned int v1;
unsigned int v2;
void *v3;
void *v4;
unsigned long v5;
unsigned int v6;
unsigned int v8;
v4 = 0;
v3 = v4;
v0 = 0;
reset_internal_getopt();
while (true) {
v1 = internal_getopt(a0, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI");
if (v1 != -1) {
v0 = 1;
if (v1 == -99) {
builtin_help();
v8 = 258;
break;
} else if (v1 >= -99 && v1 <= 118 && v1 >= 65) {
switch (v1) {
case 65:
v2 = find_compact(*(&list_optarg));
if (v2 < 0) {
builtin_error(gettext("%s: invalid action name"), *(&list_optarg));
v8 = 258;
} else {
v3 |= (&g_401e48)[3 * v2];
break;
}
case 67:
Carg = *(&list_optarg);
break;
case 68:
if (a1) {
a1[2] = 1;
break;
} else {
sh_invalidopt("-D");
builtin_usage("-D", "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI",
&g_401bfc, a3, a4, a5);
v8 = 258;
}
case 69:
if (a1) {
a1[3] = 1;
break;
} else {
sh_invalidopt("-E");
builtin_usage("-E", "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI",
&g_401bfc, a3, a4, a5);
v8 = 258;
}
case 70:
Farg = *(&list_optarg);
v5 = Farg;
v6 = 0;
v8 = check_identifier(&v5, posixly_correct, posixly_correct);
if (v8) {
v8 = strpbrk(Farg, "()<>;&| \t\n");
continue;
}
sh_invalidid(Farg);
v8 = 258;
case 71:
Garg = *(&list_optarg);
break;
case 73:
if (a1) {
a1[4] = 1;
break;
} else {
sh_invalidopt("-I");
builtin_usage("-I", "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI",
&g_401bfc, a3, a4, a5);
v8 = 258;
}
case 80:
Parg = *(&list_optarg);
break;
case 83:
Sarg = *(&list_optarg);
break;
case 87:
Warg = *(&list_optarg);
break;
case 88:
Xarg = *(&list_optarg);
break;
case 97:
v3 |= 1;
break;
case 98:
v3 |= 8;
break;
case 99:
v3 |= 16;
break;
case 100:
v3 |= 32;
break;
case 101:
v3 |= 0x100;
break;
case 102:
v3 |= 0x200;
break;
case 103:
v3 |= 0x800;
break;
case 106:
v3 |= 0x4000;
break;
case 107:
v3 |= 0x8000;
break;
case 111:
v2 = find_compopt(*(&list_optarg));
if (v2 < 0) {
sh_invalidoptname(*(&list_optarg));
v8 = 258;
} else {
v4 |= *((4202664 + 16 * v2));
break;
}
case 112:
if (a1) {
a1[0] = 1;
break;
} else {
sh_invalidopt("-p");
builtin_usage("-p", "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI",
&g_401bfc, a3, a4, a5);
v8 = 258;
}
case 114:
if (a1) {
a1[1] = 1;
break;
} else {
sh_invalidopt("-r");
builtin_usage("-r", "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI",
&g_401bfc, a3, a4, a5);
v8 = 258;
}
case 115:
v3 |= 0x20000;
break;
case 117:
v3 |= find_compact;
break;
case 118:
v3 |= &g_800000;
break;
default:
builtin_usage(a0, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI", &g_401bfc,
a3, a4, a5);
v8 = 258;
}
}
} else {
*(a2) = v3;
*(a3) = v4;
v8 = !v0;
break;
}
}
return v8;
} | bash | angr_dream |
static int prepare_poll(struct pollfd **pfdp, size_t *npfdp, int *timeoutp,
u_int maxfds) {
struct pollfd *pfd = *pfdp;
size_t i, j, npfd = 0;
time_t deadline;
int r;
for (i = 0; i < sockets_alloc; i++) {
switch (sockets[i].type) {
case AUTH_SOCKET:
case AUTH_CONNECTION:
npfd++;
break;
case AUTH_UNUSED:
break;
default:
sshfatal("ssh-agent.c", __func__, 1886, 0, SYSLOG_LEVEL_FATAL,
((void *)0), "Unknown socket type %d", sockets[i].type);
break;
}
}
if (npfd != *npfdp &&
(pfd = recallocarray(pfd, *npfdp, npfd, sizeof(*pfd))) == ((void *)0))
sshfatal("ssh-agent.c", __func__, 1892, 1, SYSLOG_LEVEL_FATAL, ((void *)0),
"recallocarray failed");
*pfdp = pfd;
*npfdp = npfd;
for (i = j = 0; i < sockets_alloc; i++) {
switch (sockets[i].type) {
case AUTH_SOCKET:
if (npfd > maxfds) {
sshlog("ssh-agent.c", __func__, 1900, 0, SYSLOG_LEVEL_DEBUG3,
((void *)0),
"out of fds (active %zu >= limit %u); "
"skipping arming listener",
npfd, maxfds);
break;
}
pfd[j].fd = sockets[i].fd;
pfd[j].revents = 0;
pfd[j].events = 0x001;
j++;
break;
case AUTH_CONNECTION:
pfd[j].fd = sockets[i].fd;
pfd[j].revents = 0;
if ((r = sshbuf_check_reserve(sockets[i].input, (4096))) == 0 &&
(r = sshbuf_check_reserve(sockets[i].output, (256 * 1024))) == 0)
pfd[j].events = 0x001;
else if (r != -9)
sshfatal("ssh-agent.c", __func__, 1922, 1, SYSLOG_LEVEL_FATAL,
ssh_err(r), "reserve");
if (sshbuf_len(sockets[i].output) > 0)
pfd[j].events |= 0x004;
j++;
break;
default:
break;
}
}
deadline = reaper();
if (parent_alive_interval != 0)
deadline = (deadline == 0) ? parent_alive_interval
: (((deadline) < (parent_alive_interval))
? (deadline)
: (parent_alive_interval));
if (deadline == 0) {
*timeoutp = -1;
} else {
if (deadline > 0x7fffffff / 1000)
*timeoutp = 0x7fffffff / 1000;
else
*timeoutp = deadline * 1000;
}
return (1);
} | long prepare_poll(long *a1, unsigned long *a2, _DWORD *a3, unsigned int a4) {
int v4;
int v5;
long v6;
long v7;
unsigned int v11;
long v12;
unsigned long i;
unsigned long j;
long v15;
unsigned long v16;
long v17;
v12 = *a1;
v16 = 0LL;
for (i = 0LL; i < (unsigned int)sockets_alloc; ++i) {
v4 = *(_DWORD *)(sockets + 48 * i + 4);
if (v4) {
if ((unsigned int)(v4 - 1) > 1)
sshfatal("ssh-agent.c", "prepare_poll", 1886LL, 0LL, 1LL, 0LL,
"Unknown socket type %d",
*(unsigned int *)(sockets + 48 * i + 4));
else
++v16;
}
}
if (v16 != *a2) {
v12 = recallocarray(v12, *a2, v16, 8LL);
if (!v12)
sshfatal("ssh-agent.c", "prepare_poll", 1892LL, 1LL, 1LL, 0LL,
"recallocarray failed");
}
*a1 = v12;
*a2 = v16;
v15 = 0LL;
for (j = 0LL; j < (unsigned int)sockets_alloc; ++j) {
v5 = *(_DWORD *)(sockets + 48 * j + 4);
if (v5 == 1) {
if (v16 <= a4) {
*(_DWORD *)(8 * v15 + v12) = *(_DWORD *)(sockets + 48 * j);
*(_WORD *)(8 * v15 + v12 + 6) = 0;
*(_WORD *)(8 * v15++ + v12 + 4) = 1;
} else {
sshlog("ssh-agent.c", "prepare_poll", 1900LL, 0LL, 7LL, 0LL,
"out of fds (active %zu >= limit %u); skipping arming listener",
v16, a4);
}
} else if (v5 == 2) {
*(_DWORD *)(8 * v15 + v12) = *(_DWORD *)(sockets + 48 * j);
*(_WORD *)(8 * v15 + v12 + 6) = 0;
v11 = sshbuf_check_reserve(*(_QWORD *)(sockets + 48 * j + 8), 4096LL);
if (v11 || (v11 = sshbuf_check_reserve(*(_QWORD *)(sockets + 48 * j + 16),
0x40000LL)) != 0) {
if (v11 != -9) {
v6 = ssh_err(v11);
sshfatal("ssh-agent.c", "prepare_poll", 1922LL, 1LL, 1LL, v6,
"reserve");
}
} else {
*(_WORD *)(8 * v15 + v12 + 4) = 1;
}
if (sshbuf_len(*(_QWORD *)(sockets + 48 * j + 16)))
*(_WORD *)(8 * v15 + v12 + 4) |= 4u;
++v15;
}
}
v17 = reaper();
if (parent_alive_interval) {
if (v17) {
v7 = parent_alive_interval;
if (v17 <= parent_alive_interval)
v7 = v17;
} else {
v7 = parent_alive_interval;
}
v17 = v7;
}
if (v17) {
if (v17 <= 2147483)
*a3 = 1000 * v17;
else
*a3 = 2147483;
} else {
*a3 = -1;
}
return 1LL;
} | openssh-portable | ida |
static SHELL_VAR *find_nameref_at_context(v, vc)
SHELL_VAR *v;
VAR_CONTEXT *vc;
{
SHELL_VAR *nv, *nv2;
char *newname;
int level;
nv = v;
level = 1;
while (nv && ((((nv)->attributes) & (0x0000800)))) {
level++;
if (level > 8)
return (&nameref_maxloop_value);
newname = ((nv)->value);
if (newname == 0 || *newname == '\0')
return ((SHELL_VAR *)((void *)0));
nv2 = hash_lookup(newname, vc->table);
if (nv2 == 0)
break;
nv = nv2;
}
return nv;
} | int find_nameref_at_context(unsigned long a0, struct_0 *a1) {
unsigned int v0;
struct_1 *v1;
char *v2;
unsigned long v3;
unsigned int v5;
v1 = a0;
v0 = 1;
while (true) {
if (v1 && (v1->field_28 & 0x800)) {
v0 += 1;
if (v0 > 8) {
v5 = &nameref_maxloop_value;
break;
} else {
v2 = v1->field_8;
if (v2 && *(v2)) {
v3 = hash_lookup(v2, a1->field_20);
if (v3) {
v1 = v3;
continue;
}
}
if (!v2 || !*(v2)) {
v5 = 0;
break;
}
}
}
if (!v1 || !(v1->field_28 & 0x800) || !v3 && v0 <= 8 && v2 && *(v2)) {
v5 = v1;
break;
}
}
return v5;
} | bash | angr_dream |
static void load_x509_keys(void) {
unsigned int crt_num;
int ret;
unsigned int i;
gnutls_datum_t data = {((void *)0), 0};
gnutls_x509_crt_t crt_list[6];
if (x509_certfile != ((void *)0) && x509_keyfile != ((void *)0)) {
if (strncmp(x509_certfile, "pkcs11:", 7) == 0) {
crt_num = 1;
ret = gnutls_x509_crt_init(&crt_list[0]);
if (ret < 0) {
fprintf(stderr, "Memory error\n");
exit(1);
}
gnutls_x509_crt_set_pin_function(crt_list[0], pin_callback,
((void *)0));
ret = gnutls_x509_crt_import_url(crt_list[0], x509_certfile, 0);
if (ret == -56)
ret = gnutls_x509_crt_import_url(crt_list[0], x509_certfile,
GNUTLS_PKCS11_OBJ_FLAG_LOGIN);
if (ret < 0) {
fprintf(stderr, "*** Error loading cert file.\n");
exit(1);
}
x509_crt_size = 1;
} else
{
ret = gnutls_load_file(x509_certfile, &data);
if (ret < 0) {
fprintf(stderr, "*** Error loading cert file.\n");
exit(1);
}
crt_num = 6;
ret = gnutls_x509_crt_list_import(
crt_list, &crt_num, &data, x509ctype,
GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED);
if (ret < 0) {
if (ret == -51) {
fprintf(stderr, "*** Error loading cert file: Too many certs %d\n",
crt_num);
} else {
fprintf(stderr, "*** Error loading cert file: %s\n",
gnutls_strerror(ret));
}
exit(1);
}
x509_crt_size = ret;
}
for (i = 0; i < x509_crt_size; i++) {
ret = gnutls_pcert_import_x509(&x509_crt[i], crt_list[i], 0);
if (ret < 0) {
fprintf(stderr, "*** Error importing crt to pcert: %s\n",
gnutls_strerror(ret));
exit(1);
}
gnutls_x509_crt_deinit(crt_list[i]);
}
gnutls_free((void *)(data.data)), data.data = ((void *)0);
load_priv_key(&x509_key, x509_keyfile);
log_msg(stdout, "Processed %d client X.509 certificates...\n",
x509_crt_size);
}
} | unsigned long load_x509_keys() {
const char *v0;
const char *v1;
unsigned int v3;
int v4;
unsigned int i;
long v6;
int v7;
long v8[7];
unsigned long v9;
v9 = __readfsqword(0x28u);
v6 = 0LL;
v7 = 0;
if (x509_certfile && x509_keyfile) {
if (!strncmp(x509_certfile, "pkcs11:", 7uLL)) {
v3 = 1;
if ((int)gnutls_x509_crt_init(v8) < 0) {
fprintf(stderr, "Memory error\n");
exit(1);
}
gnutls_x509_crt_set_pin_function(v8[0], &pin_callback, 0LL);
v4 = gnutls_x509_crt_import_url(v8[0], x509_certfile, 0LL);
if (v4 == -56)
v4 = gnutls_x509_crt_import_url(v8[0], x509_certfile, 1LL);
if (v4 < 0) {
fprintf(stderr, "*** Error loading cert file.\n");
exit(1);
}
x509_crt_size = 1;
} else {
v4 = gnutls_load_file(x509_certfile, &v6);
if (v4 < 0) {
fprintf(stderr, "*** Error loading cert file.\n");
exit(1);
}
v3 = 6;
v4 = gnutls_x509_crt_list_import(v8, &v3, &v6, (unsigned int)x509ctype,
1LL);
if (v4 < 0) {
if (v4 == -51) {
fprintf(stderr, "*** Error loading cert file: Too many certs %d\n",
v3);
} else {
v0 = (const char *)gnutls_strerror((unsigned int)v4);
fprintf(stderr, "*** Error loading cert file: %s\n", v0);
}
exit(1);
}
x509_crt_size = v4;
}
for (i = 0; i < x509_crt_size; ++i) {
v4 = gnutls_pcert_import_x509((char *)&x509_crt + 32 * i, v8[i], 0LL);
if (v4 < 0) {
v1 = (const char *)gnutls_strerror((unsigned int)v4);
fprintf(stderr, "*** Error importing crt to pcert: %s\n", v1);
exit(1);
}
gnutls_x509_crt_deinit(v8[i]);
}
gnutls_free(v6);
v6 = 0LL;
load_priv_key(&x509_key, x509_keyfile);
log_msg(stdout, "Processed %d client X.509 certificates...\n",
(unsigned int)x509_crt_size);
}
return __readfsqword(0x28u) ^ v9;
} | gnutls | ida |
int _rl_reset_region_color(int which, const char *value) {
int len;
if (which == 0) {
xfree(_rl_active_region_start_color);
if (value && *value) {
_rl_active_region_start_color = (char *)xmalloc(2 * strlen(value) + 1);
rl_translate_keyseq(value, _rl_active_region_start_color, &len);
_rl_active_region_start_color[len] = '\0';
} else
_rl_active_region_start_color = ((void *)0);
} else {
xfree(_rl_active_region_end_color);
if (value && *value) {
_rl_active_region_end_color = (char *)xmalloc(2 * strlen(value) + 1);
rl_translate_keyseq(value, _rl_active_region_end_color, &len);
_rl_active_region_end_color[len] = '\0';
} else
_rl_active_region_end_color = ((void *)0);
}
return 0;
} | void _rl_reset_region_color(unsigned long a0, char *a1) {
char v0;
void *v2;
if (a0) {
xfree(_rl_active_region_end_color);
if (a1 && *(a1)) {
_rl_active_region_end_color = xmalloc(strlen(a1) * 2 + 1);
rl_translate_keyseq(a1, _rl_active_region_end_color, &v0,
_rl_active_region_end_color);
*(*(&v0) + _rl_active_region_end_color) = 0;
goto LABEL_400f6e;
}
_rl_active_region_end_color = 0;
} else {
xfree(_rl_active_region_start_color);
if (a1 && *(a1)) {
_rl_active_region_start_color = xmalloc(strlen(a1) * 2 + 1);
rl_translate_keyseq(a1, _rl_active_region_start_color, &v0,
_rl_active_region_start_color);
*(*(&v0) + _rl_active_region_start_color) = 0;
goto LABEL_400f6e;
}
_rl_active_region_start_color = 0;
}
LABEL_400f6e:
v2 = 0;
return;
} | bash | angr_phoenix |
static _Bool
decode_num(uintmax_t *num, char const *arg, uintmax_t maxval) {
uintmax_t u;
char *arg_lim;
if (!((unsigned)(*arg) - '0' <= 9))
return 0;
(*__errno_location()) = 0;
u = strtoumax(arg, &arg_lim, 10);
if (!(u <= maxval && (*__errno_location()) != 34) || *arg_lim)
return 0;
*num = u;
return 1;
} | undefined8 decode_num(uintmax_t *param_1, char *param_2, ulong param_3)
{
undefined8 uVar1;
int *piVar2;
long in_FS_OFFSET;
char *local_20;
uintmax_t local_18;
long local_10;
local_10 = *(long *)(in_FS_OFFSET + 0x28);
if ((int)*param_2 - 0x30U < 10) {
piVar2 = __errno_location();
*piVar2 = 0;
local_18 = strtoumax(param_2, &local_20, 10);
if (local_18 <= param_3) {
piVar2 = __errno_location();
if ((*piVar2 != 0x22) && (*local_20 == '\0')) {
*param_1 = local_18;
uVar1 = 1;
goto LAB_00103056;
}
}
uVar1 = 0;
} else {
uVar1 = 0;
}
LAB_00103056:
if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
__stack_chk_fail();
}
return uVar1;
} | tar | ghidra |
static inline const char *rta_getattr_str(const struct rtattr *rta) {
return (const char *)((
void *)(((char *)(rta)) +
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))));
} | long rta_getattr_str(long a1) { return a1 + 4; } | iproute2-6.0.0 | ida |
static inline void emit_mandatory_arg_note(void) {
fputs_unlocked(gettext("\nMandatory arguments to long options are mandatory "
"for short options too.\n"),
stdout)
;
} | void emit_mandatory_arg_note() {
unsigned long long v1;
v1 = fputs_unlocked(gettext("\nMandatory arguments to long options are "
"mandatory for short options too.\n"),
stdout);
return;
} | coreutils | angr_phoenix |
static void ipstats_show_group(const struct ipstats_sel *sel) {
int i;
for (i = 0; i < IPSTATS_LEVELS_COUNT; i++) {
if (sel->sel[i] == ((void *)0))
break;
print_string(PRINT_JSON, ipstats_levels[i], ((void *)0), sel->sel[i]);
print_string(PRINT_FP, ((void *)0), " %s ", ipstats_levels[i]);
print_string(PRINT_FP, ((void *)0), "%s", sel->sel[i]);
}
} | long ipstats_show_group(long a1) {
long result;
int i;
for (i = 0; i <= 2; ++i) {
result = *(_QWORD *)(a1 + 8LL * i);
if (!result)
break;
print_string(2u, (long)ipstats_levels[i], 0LL, *(_QWORD *)(a1 + 8LL * i));
print_string(1u, 0LL, " %s ", (long)ipstats_levels[i]);
result = print_string(1u, 0LL, "%s", *(_QWORD *)(a1 + 8LL * i));
}
return result;
} | iproute2-6.0.0 | ida |
vi_yank_end(EditLine *el, wint_t c __attribute__((__unused__))) {
cv_yank(el, el->el_line.cursor,
(int)(el->el_line.lastchar - el->el_line.cursor));
return 4;
} | long vi_yank_end(long a1) {
cv_yank(
a1, *(_QWORD *)(a1 + 88),
(unsigned int)((long)(*(_QWORD *)(a1 + 96) - *(_QWORD *)(a1 + 88)) >> 2));
return 4LL;
} | libedit | ida |
static inline __u32 rta_getattr_u32(const struct rtattr *rta) {
return *(__u32 *)((
void *)(((char *)(rta)) +
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))));
} | int rta_getattr_u32(struct_0 *a0) { return a0->field_4; } | iproute2-6.0.0 | angr_sailr |
static void fix_assignment_words(words) WORD_LIST *words;
{
WORD_LIST *w, *wcmd;
struct builtin *b;
int assoc, global, array, integer;
if (words == 0)
return;
b = 0;
assoc = global = array = integer = 0;
wcmd = words;
for (wcmd = words; wcmd; wcmd = wcmd->next)
if ((wcmd->word->flags & (1 << 2)) == 0)
break;
while (posixly_correct && wcmd && wcmd->word && wcmd->word->word &&
((wcmd->word->word)[0] == ("command")[0] &&
strcmp(wcmd->word->word, "command") == 0))
wcmd = wcmd->next;
for (w = wcmd; w; w = w->next)
if (w->word->flags & (1 << 2)) {
if (b == 0) {
b = builtin_address_internal(wcmd->word->word, 0);
if (b == 0 || (b->flags & 0x10) == 0)
return;
else if (b && (b->flags & 0x10))
wcmd->word->flags |= (1 << 16);
}
w->word->flags |= ((1 << 4) | (1 << 5) | (1 << 7) | (1 << 17));
if (assoc)
w->word->flags |= (1 << 22);
if (array)
w->word->flags |= (1 << 23);
if (global)
w->word->flags |= (1 << 25);
if (b && ((b->flags & (0x10 | 0x40)) == 0x10))
w->word->flags |= (1 << 25) | (1 << 28);
else if (b && (b->flags & 0x10) && (b->flags & 0x40) && variable_context)
w->word->flags |= (1 << 29);
}
else if (w->word->word[0] == '-' &&
(strpbrk(w->word->word + 1, "Aag") != 0))
{
if (b == 0) {
b = builtin_address_internal(wcmd->word->word, 0);
if (b == 0 || (b->flags & 0x10) == 0)
return;
else if (b && (b->flags & 0x10))
wcmd->word->flags |= (1 << 16);
}
if ((wcmd->word->flags & (1 << 16)) && strchr(w->word->word + 1, 'A'))
assoc = 1;
else if ((wcmd->word->flags & (1 << 16)) &&
strchr(w->word->word + 1, 'a'))
array = 1;
if ((wcmd->word->flags & (1 << 16)) && strchr(w->word->word + 1, 'g'))
global = 1;
}
} | void fix_assignment_words(undefined8 *param_1)
{
bool bVar1;
bool bVar2;
bool bVar3;
int iVar4;
char *pcVar5;
undefined8 *local_20;
undefined8 *local_18;
long local_10;
if (param_1 != (undefined8 *)0x0) {
local_10 = 0;
bVar2 = false;
bVar3 = false;
bVar1 = false;
local_18 = param_1;
while ((local_18 != (undefined8 *)0x0 &&
((*(uint *)(local_18[1] + 8) & 4) != 0))) {
local_18 = (undefined8 *)*local_18;
}
while (
(((posixly_correct != 0 && (local_18 != (undefined8 *)0x0)) &&
(local_18[1] != 0)) &&
(((*(long *)local_18[1] != 0 && (**(char **)local_18[1] == 'c')) &&
(iVar4 = strcmp(*(char **)local_18[1], "command"), iVar4 == 0))))) {
local_18 = (undefined8 *)*local_18;
}
for (local_20 = local_18; local_20 != (undefined8 *)0x0;
local_20 = (undefined8 *)*local_20) {
if ((*(uint *)(local_20[1] + 8) & 4) == 0) {
if ((**(char **)local_20[1] == '-') &&
(pcVar5 = strpbrk((char *)(*(long *)local_20[1] + 1), "Aag"),
pcVar5 != (char *)0x0)) {
if (local_10 == 0) {
local_10 = builtin_address_internal(*(undefined8 *)local_18[1], 0);
if (local_10 == 0) {
return;
}
if ((*(uint *)(local_10 + 0x10) & 0x10) == 0) {
return;
}
if ((local_10 != 0) && ((*(uint *)(local_10 + 0x10) & 0x10) != 0)) {
*(uint *)(local_18[1] + 8) = *(uint *)(local_18[1] + 8) | 0x10000;
}
}
if (((*(uint *)(local_18[1] + 8) & 0x10000) == 0) ||
(pcVar5 = strchr((char *)(*(long *)local_20[1] + 1), 0x41),
pcVar5 == (char *)0x0)) {
if (((*(uint *)(local_18[1] + 8) & 0x10000) != 0) &&
(pcVar5 = strchr((char *)(*(long *)local_20[1] + 1), 0x61),
pcVar5 != (char *)0x0)) {
bVar2 = true;
}
} else {
bVar1 = true;
}
if (((*(uint *)(local_18[1] + 8) & 0x10000) != 0) &&
(pcVar5 = strchr((char *)(*(long *)local_20[1] + 1), 0x67),
pcVar5 != (char *)0x0)) {
bVar3 = true;
}
}
} else {
if (local_10 == 0) {
local_10 = builtin_address_internal(*(undefined8 *)local_18[1], 0);
if (local_10 == 0) {
return;
}
if ((*(uint *)(local_10 + 0x10) & 0x10) == 0) {
return;
}
if ((local_10 != 0) && ((*(uint *)(local_10 + 0x10) & 0x10) != 0)) {
*(uint *)(local_18[1] + 8) = *(uint *)(local_18[1] + 8) | 0x10000;
}
}
*(uint *)(local_20[1] + 8) = *(uint *)(local_20[1] + 8) | 0x200b0;
if (bVar1) {
*(uint *)(local_20[1] + 8) = *(uint *)(local_20[1] + 8) | 0x400000;
}
if (bVar2) {
*(uint *)(local_20[1] + 8) = *(uint *)(local_20[1] + 8) | 0x800000;
}
if (bVar3) {
*(uint *)(local_20[1] + 8) = *(uint *)(local_20[1] + 8) | 0x2000000;
}
if ((local_10 == 0) || ((*(uint *)(local_10 + 0x10) & 0x50) != 0x10)) {
if ((local_10 != 0) &&
((((*(uint *)(local_10 + 0x10) & 0x10) != 0 &&
((*(uint *)(local_10 + 0x10) & 0x40) != 0)) &&
(variable_context != 0)))) {
*(uint *)(local_20[1] + 8) =
*(uint *)(local_20[1] + 8) | 0x20000000;
}
} else {
*(uint *)(local_20[1] + 8) = *(uint *)(local_20[1] + 8) | 0x12000000;
}
}
}
}
return;
} | bash | ghidra |
static Bool unRLE_obuf_to_output_FAST(DState *s) {
UChar k1;
if (s->blockRandomised) {
while (((Bool)1)) {
while (((Bool)1)) {
if (s->strm->avail_out == 0)
return ((Bool)0);
if (s->state_out_len == 0)
break;
*((UChar *)(s->strm->next_out)) = s->state_out_ch;
{
s->calculatedBlockCRC = (s->calculatedBlockCRC << 8) ^
BZ2_crc32Table[(s->calculatedBlockCRC >> 24) ^
((UChar)s->state_out_ch)];
};
s->state_out_len--;
s->strm->next_out++;
s->strm->avail_out--;
s->strm->total_out_lo32++;
if (s->strm->total_out_lo32 == 0)
s->strm->total_out_hi32++;
}
if (s->nblock_used == s->save_nblock + 1)
return ((Bool)0);
if (s->nblock_used > s->save_nblock + 1)
return ((Bool)1);
s->state_out_len = 1;
s->state_out_ch = s->k0;
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k)
return ((Bool)1);
s->tPos = s->tt[s->tPos];
k1 = (UChar)(s->tPos & 0xff);
s->tPos >>= 8;
;
if (s->rNToGo == 0) {
s->rNToGo = BZ2_rNums[s->rTPos];
s->rTPos++;
if (s->rTPos == 512)
s->rTPos = 0;
}
s->rNToGo--;
;
k1 ^= ((s->rNToGo == 1) ? 1 : 0);
s->nblock_used++;
if (s->nblock_used == s->save_nblock + 1)
continue;
if (k1 != s->k0) {
s->k0 = k1;
continue;
};
s->state_out_len = 2;
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k)
return ((Bool)1);
s->tPos = s->tt[s->tPos];
k1 = (UChar)(s->tPos & 0xff);
s->tPos >>= 8;
;
if (s->rNToGo == 0) {
s->rNToGo = BZ2_rNums[s->rTPos];
s->rTPos++;
if (s->rTPos == 512)
s->rTPos = 0;
}
s->rNToGo--;
;
k1 ^= ((s->rNToGo == 1) ? 1 : 0);
s->nblock_used++;
if (s->nblock_used == s->save_nblock + 1)
continue;
if (k1 != s->k0) {
s->k0 = k1;
continue;
};
s->state_out_len = 3;
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k)
return ((Bool)1);
s->tPos = s->tt[s->tPos];
k1 = (UChar)(s->tPos & 0xff);
s->tPos >>= 8;
;
if (s->rNToGo == 0) {
s->rNToGo = BZ2_rNums[s->rTPos];
s->rTPos++;
if (s->rTPos == 512)
s->rTPos = 0;
}
s->rNToGo--;
;
k1 ^= ((s->rNToGo == 1) ? 1 : 0);
s->nblock_used++;
if (s->nblock_used == s->save_nblock + 1)
continue;
if (k1 != s->k0) {
s->k0 = k1;
continue;
};
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k)
return ((Bool)1);
s->tPos = s->tt[s->tPos];
k1 = (UChar)(s->tPos & 0xff);
s->tPos >>= 8;
;
if (s->rNToGo == 0) {
s->rNToGo = BZ2_rNums[s->rTPos];
s->rTPos++;
if (s->rTPos == 512)
s->rTPos = 0;
}
s->rNToGo--;
;
k1 ^= ((s->rNToGo == 1) ? 1 : 0);
s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4;
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k)
return ((Bool)1);
s->tPos = s->tt[s->tPos];
s->k0 = (UChar)(s->tPos & 0xff);
s->tPos >>= 8;
;
if (s->rNToGo == 0) {
s->rNToGo = BZ2_rNums[s->rTPos];
s->rTPos++;
if (s->rTPos == 512)
s->rTPos = 0;
}
s->rNToGo--;
;
s->k0 ^= ((s->rNToGo == 1) ? 1 : 0);
s->nblock_used++;
}
} else {
UInt32 c_calculatedBlockCRC = s->calculatedBlockCRC;
UChar c_state_out_ch = s->state_out_ch;
Int32 c_state_out_len = s->state_out_len;
Int32 c_nblock_used = s->nblock_used;
Int32 c_k0 = s->k0;
UInt32 *c_tt = s->tt;
UInt32 c_tPos = s->tPos;
char *cs_next_out = s->strm->next_out;
unsigned int cs_avail_out = s->strm->avail_out;
Int32 ro_blockSize100k = s->blockSize100k;
UInt32 avail_out_INIT = cs_avail_out;
Int32 s_save_nblockPP = s->save_nblock + 1;
unsigned int total_out_lo32_old;
while (((Bool)1)) {
if (c_state_out_len > 0) {
while (((Bool)1)) {
if (cs_avail_out == 0)
goto return_notr;
if (c_state_out_len == 1)
break;
*((UChar *)(cs_next_out)) = c_state_out_ch;
{
c_calculatedBlockCRC = (c_calculatedBlockCRC << 8) ^
BZ2_crc32Table[(c_calculatedBlockCRC >> 24) ^
((UChar)c_state_out_ch)];
};
c_state_out_len--;
cs_next_out++;
cs_avail_out--;
}
s_state_out_len_eq_one: {
if (cs_avail_out == 0) {
c_state_out_len = 1;
goto return_notr;
};
*((UChar *)(cs_next_out)) = c_state_out_ch;
{
c_calculatedBlockCRC = (c_calculatedBlockCRC << 8) ^
BZ2_crc32Table[(c_calculatedBlockCRC >> 24) ^
((UChar)c_state_out_ch)];
};
cs_next_out++;
cs_avail_out--;
}
}
if (c_nblock_used > s_save_nblockPP)
return ((Bool)1);
if (c_nblock_used == s_save_nblockPP) {
c_state_out_len = 0;
goto return_notr;
};
c_state_out_ch = c_k0;
if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k)
return ((Bool)1);
c_tPos = c_tt[c_tPos];
k1 = (UChar)(c_tPos & 0xff);
c_tPos >>= 8;
;
c_nblock_used++;
if (k1 != c_k0) {
c_k0 = k1;
goto s_state_out_len_eq_one;
};
if (c_nblock_used == s_save_nblockPP)
goto s_state_out_len_eq_one;
c_state_out_len = 2;
if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k)
return ((Bool)1);
c_tPos = c_tt[c_tPos];
k1 = (UChar)(c_tPos & 0xff);
c_tPos >>= 8;
;
c_nblock_used++;
if (c_nblock_used == s_save_nblockPP)
continue;
if (k1 != c_k0) {
c_k0 = k1;
continue;
};
c_state_out_len = 3;
if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k)
return ((Bool)1);
c_tPos = c_tt[c_tPos];
k1 = (UChar)(c_tPos & 0xff);
c_tPos >>= 8;
;
c_nblock_used++;
if (c_nblock_used == s_save_nblockPP)
continue;
if (k1 != c_k0) {
c_k0 = k1;
continue;
};
if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k)
return ((Bool)1);
c_tPos = c_tt[c_tPos];
k1 = (UChar)(c_tPos & 0xff);
c_tPos >>= 8;
;
c_nblock_used++;
c_state_out_len = ((Int32)k1) + 4;
if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k)
return ((Bool)1);
c_tPos = c_tt[c_tPos];
c_k0 = (UChar)(c_tPos & 0xff);
c_tPos >>= 8;
;
c_nblock_used++;
}
return_notr:
total_out_lo32_old = s->strm->total_out_lo32;
s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out);
if (s->strm->total_out_lo32 < total_out_lo32_old)
s->strm->total_out_hi32++;
s->calculatedBlockCRC = c_calculatedBlockCRC;
s->state_out_ch = c_state_out_ch;
s->state_out_len = c_state_out_len;
s->nblock_used = c_nblock_used;
s->k0 = c_k0;
s->tt = c_tt;
s->tPos = c_tPos;
s->strm->next_out = cs_next_out;
s->strm->avail_out = cs_avail_out;
}
return ((Bool)0);
} | int unRLE_obuf_to_output_FAST(struct_0 *a0) {
char v0;
char v1;
unsigned int v2;
unsigned int v3;
unsigned int v4;
unsigned int v5;
unsigned int v6;
unsigned int v7;
unsigned int v8;
unsigned int v9;
unsigned int v10;
unsigned int v11;
char *v12;
unsigned int *v13;
unsigned int v15;
unsigned int v16;
unsigned int v17;
unsigned int v18;
unsigned int v19;
unsigned int v20;
if (a0->field_14) {
while (true) {
if (!a0->field_0->field_20) {
v20 = 0;
break;
} else if (a0->field_10) {
*(a0->field_0->field_18) = a0->field_c;
a0->field_c70 =
(a0->field_c70 * 0x100) ^
*(&(&BZ2_crc32Table)[4 * (a0->field_c ^ (a0->field_c70 >> 24))]);
a0->field_10 = a0->field_10 - 1;
a0->field_0->field_18 = a0->field_0->field_18 + 1;
a0->field_0->field_20 = a0->field_0->field_20 - 1;
a0->field_0->field_24 = a0->field_0->field_24 + 1;
if (a0->field_0->field_24)
continue;
a0->field_0->field_28 = a0->field_0->field_28 + 1;
} else if (a0->field_444 == a0->field_fa50 + 1) {
v20 = 0;
break;
} else if (a0->field_444 > a0->field_fa50 + 1) {
v20 = 1;
break;
} else {
a0->field_10 = 1;
a0->field_c = a0->field_40;
if (a0->field_3c >= a0->field_28 * 100000) {
v20 = 1;
break;
} else {
a0->field_3c = *((a0->field_3c * 4 + a0->field_c50));
v1 = a0->field_3c;
a0->field_3c = a0->field_3c >> 8;
if (!a0->field_18) {
a0->field_18 = *((4 * a0->field_1c + &BZ2_rNums));
a0->field_1c = a0->field_1c + 1;
if (a0->field_1c == 0x200)
a0->field_1c = 0;
}
a0->field_18 = a0->field_18 - 1;
v15 = a0->field_18;
*(&v15) = a0->field_18 == 1;
*(&v15) = v1 ^ v15;
v1 = v15;
a0->field_444 = a0->field_444 + 1;
if (a0->field_444 == a0->field_fa50 + 1)
continue;
if (v1 != a0->field_40) {
a0->field_40 = v1;
} else {
a0->field_10 = 2;
if (a0->field_3c >= a0->field_28 * 100000) {
v20 = 1;
break;
} else {
a0->field_3c = *((a0->field_3c * 4 + a0->field_c50));
v1 = a0->field_3c;
a0->field_3c = a0->field_3c >> 8;
if (!a0->field_18) {
a0->field_18 = *((4 * a0->field_1c + &BZ2_rNums));
a0->field_1c = a0->field_1c + 1;
if (a0->field_1c == 0x200)
a0->field_1c = 0;
}
a0->field_18 = a0->field_18 - 1;
v16 = a0->field_18;
*(&v16) = a0->field_18 == 1;
*(&v16) = v1 ^ v16;
v1 = v16;
a0->field_444 = a0->field_444 + 1;
if (a0->field_444 == a0->field_fa50 + 1)
continue;
if (a0->field_444 != a0->field_fa50 + 1) {
if (v1 != a0->field_40) {
a0->field_40 = v1;
} else {
a0->field_10 = 3;
if (a0->field_3c >= a0->field_28 * 100000) {
v20 = 1;
break;
} else {
a0->field_3c = *((a0->field_3c * 4 + a0->field_c50));
v1 = a0->field_3c;
a0->field_3c = a0->field_3c >> 8;
if (!a0->field_18) {
a0->field_18 = *((4 * a0->field_1c + &BZ2_rNums));
a0->field_1c = a0->field_1c + 1;
if (a0->field_1c == 0x200)
a0->field_1c = 0;
}
a0->field_18 = a0->field_18 - 1;
v17 = a0->field_18;
*(&v17) = a0->field_18 == 1;
*(&v17) = v1 ^ v17;
v1 = v17;
a0->field_444 = a0->field_444 + 1;
if (a0->field_444 != a0->field_fa50 + 1) {
if (v1 != a0->field_40) {
a0->field_40 = v1;
} else if (a0->field_3c >= a0->field_28 * 100000) {
v20 = 1;
break;
} else {
a0->field_3c = *((a0->field_3c * 4 + a0->field_c50));
v1 = a0->field_3c;
a0->field_3c = a0->field_3c >> 8;
if (!a0->field_18) {
a0->field_18 = *((4 * a0->field_1c + &BZ2_rNums));
a0->field_1c = a0->field_1c + 1;
if (a0->field_1c == 0x200)
a0->field_1c = 0;
}
a0->field_18 = a0->field_18 - 1;
v18 = a0->field_18;
*(&v18) = a0->field_18 == 1;
*(&v18) = v1 ^ v18;
v1 = v18;
a0->field_444 = a0->field_444 + 1;
a0->field_10 = v1 + 4;
if (a0->field_3c >= a0->field_28 * 100000) {
v20 = 1;
break;
} else {
a0->field_3c = *((a0->field_3c * 4 + a0->field_c50));
v19 = a0->field_3c;
a0->field_40 = a0->field_3c;
a0->field_3c = v19 / 0x100;
if (!a0->field_18) {
a0->field_18 = *((4 * a0->field_1c + &BZ2_rNums));
a0->field_1c = a0->field_1c + 1;
if (a0->field_1c == 0x200)
a0->field_1c = 0;
}
a0->field_18 = a0->field_18 - 1;
a0->field_40 = a0->field_40 ^ a0->field_18 == 1;
a0->field_444 = a0->field_444 + 1;
continue;
}
}
}
}
}
}
}
}
}
}
}
} else {
v2 = a0->field_c70;
v0 = a0->field_c;
v3 = a0->field_10;
v4 = a0->field_444;
v5 = a0->field_40;
v13 = a0->field_c50;
v6 = a0->field_3c;
v12 = a0->field_0->field_18;
v7 = a0->field_0->field_20;
v8 = a0->field_28;
v9 = v7;
while (true) {
if (v3 > 0) {
for (v10 = a0->field_fa50 + 1; v7; v7 -= 1) {
if (v3 == 1)
break;
*(v12) = v0;
v2 = *(&(&BZ2_crc32Table)[4 * (v0 ^ (v2 >> 24))]) ^ (v2 * 0x100);
v3 -= 1;
v12 += 1;
}
}
if (v3 <= 0 || v7) {
if (v4 > v10) {
v20 = 1;
break;
} else if (v4 == v10) {
v3 = 0;
} else {
v0 = v5;
if (v6 >= v8 * 100000) {
v20 = 1;
break;
} else {
v6 = v13[v6];
v1 = v6;
v6 >>= 8;
v4 += 1;
if (v5 != v1) {
v5 = v1;
} else if (v4 != v10) {
v3 = 2;
if (v6 >= v8 * 100000) {
v20 = 1;
break;
} else {
v6 = v13[v6];
v1 = v6;
v6 >>= 8;
v4 += 1;
if (v4 == v10)
continue;
if (v5 != v1) {
v5 = v1;
} else {
v3 = 3;
if (v6 >= v8 * 100000) {
v20 = 1;
break;
} else {
v6 = v13[v6];
v1 = v6;
v6 >>= 8;
v4 += 1;
if (v4 != v10) {
if (v5 != v1) {
v5 = v1;
} else if (v6 >= v8 * 100000) {
v20 = 1;
break;
} else {
v6 = v13[v6];
v1 = v6;
v6 >>= 8;
v4 += 1;
v3 = v1 + 4;
if (v6 >= v8 * 100000) {
v20 = 1;
break;
} else {
v6 = v13[v6];
v5 = v6;
v6 >>= 8;
v4 += 1;
continue;
}
}
}
}
}
if (v5 != v1 || v6 < v8 * 100000 && v4 == v10 ||
v6 < v8 * 100000 && v5 != v1)
continue;
}
}
}
}
}
if (!v7) {
v3 = 1;
} else {
*(v12) = v0;
v2 = *(&(&BZ2_crc32Table)[4 * (v0 ^ (v2 >> 24))]) ^ (v2 * 0x100);
v12 += 1;
v7 -= 1;
}
if (!v7 || v4 == v10 && v4 <= v10 || !v7 && v3 > 0) {
v11 = a0->field_0->field_24;
a0->field_0->field_24 = v9 - v7 + a0->field_0->field_24;
if (v11 > a0->field_0->field_24)
a0->field_0->field_28 = a0->field_0->field_28 + 1;
a0->field_c70 = v2;
a0->field_c = v0;
a0->field_10 = v3;
a0->field_444 = v4;
a0->field_40 = v5;
a0->field_c50 = v13;
a0->field_3c = v6;
a0->field_0->field_18 = v12;
a0->field_0->field_20 = v7;
v20 = 0;
break;
}
}
}
return v20;
} | bzip2 | angr_dream |
static void Round(Fq *out, const Fq *a) {
int i;
for (i = 0; i < 761; ++i)
out[i] = a[i] - F3_freeze(a[i]);
} | void Round(unsigned short *a0, unsigned short *a1) {
unsigned int v0;
unsigned long long v2;
unsigned long long v3;
for (v0 = 0; v0 <= 760; v0 = __addvsi3(v0, 0x1, v3)) {
v2 = F3_freeze(a1[v0], 0x1, v0 * 2);
*(&v2) = v2;
v3 = a1[v0] - v2;
a0[v0] = a1[v0] - v2;
}
return;
} | openssh-portable | angr_sailr |
static _Bool
advance_seq(FILE *fp, struct seq *seq, _Bool first, int whichfile) {
if (first)
seq->count = 0;
return getseq(fp, seq, whichfile);
} | void advance_seq(void *a0, unsigned long long *a1, unsigned long a2,
unsigned long a3) {
unsigned long long v1;
if (a2)
*(a1) = 0;
v1 = getseq(a0, a1, a3);
return;
} | coreutils | angr_dream |
int phash_remove(filename) const char *filename;
{
register BUCKET_CONTENTS *item;
if (hashing_enabled == 0 || hashed_filenames == 0)
return 0;
item = hash_remove(filename, hashed_filenames, 0);
if (item) {
if (item->data)
phash_freedata(item->data);
sh_xfree((item->key), "hashcmd.c", 79);
sh_xfree((item), "hashcmd.c", 80);
return 0;
}
return 1;
} | long long phash_remove(unsigned long long a0) {
unsigned long long v1;
unsigned long long v2[3];
if (hashing_enabled && hashed_filenames) {
v2 = hash_remove(a0, hashed_filenames, 0x0, hashed_filenames);
if (v2) {
if (v2[2])
phash_freedata(v2[2]);
sh_xfree(v2[1], "hashcmd.c", 0x4f);
sh_xfree(v2, "hashcmd.c", 0x50);
v1 = 0;
} else {
v1 = 1;
}
}
if (!hashed_filenames || !hashing_enabled)
v1 = 0;
return v1;
} | bash | angr_dream |
static void bufmap_reset(struct bufmap *map, ssize_t fixup) {
bufmap_free(map);
if (map) {
for (; map; map = map->next) {
map->start += fixup;
map->nblocks = 0;
}
}
} | void bufmap_reset(unsigned int a0, unsigned long a1) {
unsigned long long v0[6];
unsigned long long v2;
unsigned long long v3;
*(&v0[0]) = a0;
v2 = bufmap_free(v0);
if (v0) {
for (; v0; v0[0] = v0[0]) {
v0[1] = v0[1] + a1;
v0[5] = 0;
v3 = v0[0];
}
}
return;
} | tar | angr_phoenix |
char *string_rest_of_args(dollar_star)
int dollar_star;
{
register WORD_LIST *list;
char *string;
list = list_rest_of_args();
string =
dollar_star ? string_list_dollar_star(list, 0, 0) : string_list(list);
dispose_words(list);
return (string);
} | long long string_rest_of_args(unsigned long a0, unsigned long a1,
unsigned long a2, unsigned long long a3,
unsigned long long a4, unsigned long long a5) {
unsigned long v0;
void *v2;
unsigned long long v3;
v2 = list_rest_of_args();
if (a0)
v3 = string_list_dollar_star(v2, 0x0, 0x0, a3, a4, a5);
else
v3 = string_list(v2);
v0 = v3;
dispose_words(v2);
return v0;
} | bash | angr_dream |
static void run_checkpoint_actions(_Bool do_write) {
struct checkpoint_action *p;
for (p = checkpoint_action; p; p = p->next) {
switch (p->opcode) {
case cop_dot:
fputc_unlocked('.', stdlis);
fflush_unlocked(stdlis);
break;
case cop_bell:
if (!tty)
tty = fopen("/dev/tty", "w");
if (tty) {
fputc_unlocked('\a', tty);
fflush_unlocked(tty);
}
break;
case cop_echo: {
int n = fprintf(stderr, "%s: ", program_name);
format_checkpoint_string(stderr, n, p->v.command, do_write, checkpoint);
fputc_unlocked('\n', stderr);
} break;
case cop_ttyout:
if (!tty)
tty = fopen("/dev/tty", "w");
if (tty)
format_checkpoint_string(tty, 0, p->v.command, do_write, checkpoint);
break;
case cop_sleep:
sleep(p->v.time);
break;
case cop_exec:
sys_exec_checkpoint_script(p->v.command, archive_name_cursor[0],
checkpoint);
break;
case cop_totals:
compute_duration();
print_total_stats();
break;
case cop_wait: {
int n;
sigwait(&sigs, &n);
}
}
}
} | void run_checkpoint_actions(unsigned long long a0, unsigned long long a1,
unsigned long long a2, unsigned long long a3,
unsigned long long a4, unsigned long long a5) {
char v0;
unsigned int v1;
struct_0 *v2;
char v3;
unsigned long long *v5;
unsigned long long v6;
for (v2 = checkpoint_action; v2; v2 = v2->field_0) {
switch (v2->field_8) {
case 0:
fputc_unlocked(0x2e, stdlis);
fflush_unlocked(stdlis);
break;
case 1:
if (!tty)
tty = fopen("/dev/tty", "w");
if (tty) {
fputc_unlocked(0x7, tty);
fflush_unlocked(tty);
}
break;
case 2:
v1 = fprintf(stderr, "%s: ", program_name);
format_checkpoint_string(stderr, v1, v2->field_10, a0, *(&checkpoint));
*(&a0) = 10;
fputc_unlocked(0xa, stderr);
break;
case 3:
if (!tty)
tty = fopen("/dev/tty", "w");
if (tty)
format_checkpoint_string(tty, 0x0, v2->field_10, a0, *(&checkpoint));
break;
case 4:
*(&a0) = v2->field_10;
sleep(v2->field_10);
break;
case 5:
sys_exec_checkpoint_script(v2->field_10, *(archive_name_cursor),
*(&checkpoint), *(archive_name_cursor));
break;
case 6:
compute_duration();
print_total_stats(a0, a1, a2, a3, a4, a5);
break;
case 7:
sigwait(&sigs, &v0);
break;
}
}
v6 = *(&v3) ^ v5[5];
return;
} | tar | angr_phoenix |
static void dump_cfg_fmtint(OpCodes code, int val) {
printf("%s %s\n", lookup_opcode_name(code), fmt_intarg(code, val));
} | void dump_cfg_fmtint(unsigned long a0, unsigned long a1) {
unsigned long long v1;
v1 = printf("%s %s\n", lookup_opcode_name(a0), fmt_intarg(a0, a1));
return;
} | openssh-portable | angr_sailr |
struct cond_com *make_cond_node(type, op, left, right)
int type;
WORD_DESC *op;
struct cond_com *left, *right;
{
COND_COM *temp;
temp = (COND_COM *)sh_xmalloc((sizeof(COND_COM)), "make_cmd.c", 461);
temp->flags = 0;
temp->line = line_number;
temp->type = type;
temp->op = op;
temp->left = left;
temp->right = right;
return (temp);
} | long make_cond_node(int a1, long a2, long a3, long a4) {
long result;
result = sh_xmalloc(40LL, "make_cmd.c", 461LL);
*(_DWORD *)result = 0;
*(_DWORD *)(result + 4) = line_number;
*(_DWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
*(_QWORD *)(result + 24) = a3;
*(_QWORD *)(result + 32) = a4;
return result;
} | bash | ida |
xsum(size_t size1, size_t size2) {
size_t sum = size1 + size2;
return (sum >= size1 ? sum : (18446744073709551615UL));
} | void xsum(void)
{
halt_baddata();
} | gzip-1.12 | ghidra |
int ssh_digest_update_buffer(struct ssh_digest_ctx *ctx,
const struct sshbuf *b) {
return ssh_digest_update(ctx, sshbuf_ptr(b), sshbuf_len(b));
} | void ssh_digest_update_buffer(undefined8 param_1, undefined8 param_2)
{
undefined8 uVar1;
undefined8 uVar2;
uVar1 = sshbuf_len(param_2);
uVar2 = sshbuf_ptr(param_2);
ssh_digest_update(param_1, uVar2, uVar1);
return;
} | openssh-portable | ghidra |
static void genpattern(int *dest, size_t num, struct randint_source *s) {
size_t randpasses;
int const *p;
int *d;
size_t n;
size_t accum, top, swap;
int k;
if (!num)
return;
p = patterns;
randpasses = 0;
d = dest;
n = num;
while (1) {
k = *p++;
if (!k) {
p = patterns;
} else if (k < 0) {
k = -k;
if ((size_t)k >= n) {
randpasses += n;
break;
}
randpasses += k;
n -= k;
} else if ((size_t)k <= n) {
memcpy(d, p, k * sizeof(int));
p += k;
d += k;
n -= k;
} else if (n < 2 || 3 * n < (size_t)k) {
randpasses += n;
break;
} else {
do {
if (n == (size_t)k || randint_choose(s, k) < n) {
*d++ = *p;
n--;
}
p++;
k--;
} while (n);
break;
}
}
top = num - randpasses;
randpasses--;
accum = randpasses;
for (n = 0; n < num; n++) {
if (accum <= randpasses) {
accum += num - 1;
dest[top++] = dest[n];
dest[n] = -1;
} else {
swap = n + randint_choose(s, top - n);
k = dest[n];
dest[n] = dest[swap];
dest[swap] = k;
}
accum -= randpasses;
}
} | void genpattern(void *a0, unsigned long a1, unsigned long long a2) {
int tmp_11;
unsigned int v0;
int tmp_54;
void *v1;
unsigned long long v2;
void *v3;
unsigned long v4;
unsigned long v5;
void *v6;
void *v7;
void *v10;
void *v11;
if (a1) {
v2 = &patterns;
v1 = 0;
v3 = a0;
v4 = a1;
while (true) {
tmp_11 = v2;
v2 += 4;
v0 = *(tmp_11);
if (!v0) {
v2 = &patterns;
} else if (v0 < 0) {
v0 = -(v0);
if (v4 <= v0) {
v1 += v4;
break;
} else {
v1 += v0;
v4 -= v0;
}
} else if (v4 >= v0) {
memcpy(v3, v2, v0 * 4);
v2 += v0 * 4;
v3 += v0 * 4;
v4 -= v0;
} else {
if (v4 > 1 && v4 + (v4 << 1) >= v0) {
do {
if (v4 == v0 || v4 > randint_choose(a2, v0)) {
v10 = v3;
v3 += 4;
*(v10) = *(v2);
v4 -= 1;
}
v2 += 4;
v0 -= 1;
} while (v4);
}
if (v4 + (v4 << 1) < v0 || v4 <= 1) {
v1 += v4;
break;
}
}
}
v6 = a1 - v1;
v1 -= 1;
v5 = v1;
v4 = 0;
while (true) {
v11 = v4;
if (v4 >= a1)
break;
if (v5 <= v1) {
v5 = v5 + a1 - 1;
tmp_54 = v6;
v6 += 1;
*((4 * tmp_54 + a0)) = *((0x4 * v4 + a0));
*((a0 + 0x4 * v4)) = -1;
} else {
v7 = randint_choose(a2, v6 - v4) + v4;
v0 = *((a0 + 0x4 * v4));
*((a0 + 0x4 * v4)) = *((a0 + 0x4 * v7));
*((0x4 * v7 + a0)) = v0;
}
v5 -= v1;
v4 += 1;
}
}
return;
} | coreutils | angr_dream |
static inline _Bool
is_smack_enabled(void) {
return 0;
} | int is_smack_enabled() { return 0; } | coreutils | angr_sailr |
static int compare_names(struct name const *n1, struct name const *n2) {
return strcmp(n1->name, n2->name);
} | long long compare_names(struct_0 *a0, struct_0 *a1) {
return strcmp(a0->field_10, a1->field_10);
} | tar | angr_dream |
static _Bool
subtree_has_side_effects(const struct predicate *p) {
if (p) {
return p->side_effects || subtree_has_side_effects(p->pred_left) ||
subtree_has_side_effects(p->pred_right);
} else {
return 0;
}
} | int subtree_has_side_effects(struct_0 *a0) {
unsigned int v1;
if (a0) {
if (!a0->field_18) {
v1 = subtree_has_side_effects(a0->field_110);
if (!v1) {
v1 = subtree_has_side_effects(a0->field_118);
if (!v1)
v1 = 0;
}
}
if (a0->field_18 || v1 || v1)
v1 = 1;
v1 &= 1;
} else {
v1 = 0;
}
return v1;
} | findutils | angr_dream |
void print_utline(struct utmp ut) {
char addr_buf[46 + 1];
const char *addr_string, *time_string;
void *in_addr = &ut.ut_addr_v6;
size_t addr_length = 46;
int addr_family = 10;
if (!ut.ut_addr_v6[1] && !ut.ut_addr_v6[2] && !ut.ut_addr_v6[3]) {
addr_family = 2;
addr_length = 16;
in_addr = &ut.ut_addr_v6[0];
}
if ((addr_string = inet_ntop(addr_family, in_addr, addr_buf, addr_length)) ==
0) {
addr_buf[0] = '\0';
addr_string = &addr_buf[0];
}
time_string = timetostr(ut.ut_tv.tv_sec);
xcleanse(ut.ut_id, sizeof(ut.ut_id));
xcleanse(ut.ut_user, sizeof(ut.ut_user));
xcleanse(ut.ut_line, sizeof(ut.ut_line));
xcleanse(ut.ut_host, sizeof(ut.ut_host));
printf(
"[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15.15s] [%-28.28s]\n",
ut.ut_type, ut.ut_pid, ut.ut_id, 8, 32, ut.ut_user, 12, 32, ut.ut_line,
20, 256, ut.ut_host, addr_string, time_string);
} | int print_utline() {
unsigned long v0;
unsigned long long v1;
unsigned long long v2;
unsigned long v3;
unsigned long long v4;
unsigned long long v5;
unsigned long v6;
unsigned long v7;
unsigned long v8;
unsigned int v9;
char *v10;
void *v11;
unsigned long long v12;
unsigned long v13;
char v14;
unsigned long v15;
char v16;
char v17;
char v18;
char v19;
char v20;
char v21;
char v22;
char v23;
char v24;
v11 = &v21;
v12 = 46;
v9 = 10;
if (!*(&v22) && !*(&v23) && !*(&v24)) {
v9 = 2;
v12 = 16;
v11 = &v21;
}
v10 = inet_ntop(v9, v11, &v14, v12);
if (!v10) {
v14 = 0;
v10 = &v14;
}
v13 = timetostr(*(&v20));
xcleanse(&v17, 0x4);
xcleanse(&v18, 0x20);
xcleanse(&v16, 0x20);
xcleanse(&v19, 0x100);
v8 = v13;
v7 = v10;
v6 = &v19;
v5 = 0x100;
v4 = 20;
v3 = &v16;
v2 = 32;
v1 = 12;
v0 = &v18;
printf(
"[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15.15s] [%-28.28s]\n",
v15, *((&v15 + 4)));
return;
} | sysvinit | angr_dream |
static int history_def_set(void *p, HistEventW *ev, const int n) {
history_t *h = (history_t *)p;
if (h->cur == 0) {
{
ev->num = 5;
ev->str = he_errlist[5];
};
return -1;
}
if (h->cursor == &h->list || h->cursor->ev.num != n) {
for (h->cursor = h->list.next; h->cursor != &h->list;
h->cursor = h->cursor->next)
if (h->cursor->ev.num == n)
break;
}
if (h->cursor == &h->list) {
{
ev->num = 9;
ev->str = he_errlist[9];
};
return -1;
}
return 0;
} | long history_def_set(long a1, long a2, int a3) {
if (*(_DWORD *)(a1 + 52)) {
if (*(_QWORD *)(a1 + 40) == a1 || a3 != **(_DWORD **)(a1 + 40)) {
for (*(_QWORD *)(a1 + 40) = *(_QWORD *)(a1 + 24);
*(_QWORD *)(a1 + 40) != a1 && a3 != **(_DWORD **)(a1 + 40);
*(_QWORD *)(a1 + 40) = *(_QWORD *)(*(_QWORD *)(a1 + 40) + 24LL)) {
;
}
}
if (*(_QWORD *)(a1 + 40) == a1) {
*(_DWORD *)a2 = 9;
*(_QWORD *)(a2 + 8) = "e";
return 0xFFFFFFFFLL;
} else {
return 0LL;
}
} else {
*(_DWORD *)a2 = 5;
*(_QWORD *)(a2 + 8) = "e";
return 0xFFFFFFFFLL;
}
} | libedit | ida |
static _Bool
read_block(size_t n, char *block, size_t *n_bytes_in_buffer) {
_Bool ok = 1;
((void)sizeof((0 < n && n <= bytes_per_block) ? 1 : 0), __extension__({
if (0 < n && n <= bytes_per_block)
;
else
__assert_fail("0 < n && n <= bytes_per_block", "src/od.c", 1293,
__extension__ __PRETTY_FUNCTION__);
}));
*n_bytes_in_buffer = 0;
while (in_stream != ((void *)0)) {
size_t n_needed;
size_t n_read;
n_needed = n - *n_bytes_in_buffer;
n_read = fread_unlocked(block + *n_bytes_in_buffer, 1, n_needed, in_stream);
*n_bytes_in_buffer += n_read;
if (n_read == n_needed)
break;
ok &= check_and_close((*__errno_location()));
ok &= open_next_file();
}
return ok;
} | int read_block(unsigned long a0, unsigned long a1, unsigned long long *a2) {
unsigned long long *v0;
char v1;
unsigned int v2;
unsigned long v3;
v0 = a2;
v1 = 1;
if (a0 && a0 <= bytes_per_block) {
*(a2) = 0;
while (true) {
if (!in_stream)
break;
*(&v2) = a0 - *(a2);
v3 = fread_unlocked(*(a2) + a1, 0x1, *(&v2), in_stream);
*(a2) = *(a2) + v3;
if (v3 == *(&v2))
break;
v1 = (check_and_close(*(__errno_location())) & v1);
v1 = (open_next_file() & v1);
}
return v1;
}
__assert_fail();
} | coreutils | angr_phoenix |
static int open_listen_match_streamlocal(struct permission *allowed_open,
const char *requestedpath) {
if (allowed_open->host_to_connect == ((void *)0))
return 0;
if (allowed_open->listen_port != -2)
return 0;
if (allowed_open->listen_path == ((void *)0) ||
strcmp(allowed_open->listen_path, requestedpath) != 0)
return 0;
return 1;
} | int open_listen_match_streamlocal(struct_0 *a0, char *a1) {
unsigned int v1;
if (!a0->field_0) {
v1 = 0;
} else if (a0->field_20 != -2) {
v1 = 0;
} else {
if (a0->field_18) {
v1 = strcmp(a0->field_18, a1);
if (!v1)
v1 = 1;
}
if (!a0->field_18 || v1)
v1 = 0;
}
return v1;
} | openssh-portable | angr_dream |
struct sshauthopt *sshauthopt_new(void) {
struct sshauthopt *ret;
if ((ret = calloc(1, sizeof(*ret))) == ((void *)0))
return ((void *)0);
ret->force_tun_device = -1;
return ret;
} | int sshauthopt_new() {
struct_0 *v0;
unsigned int v2;
v0 = calloc(0x1, 0x88);
if (!v0) {
v2 = 0;
} else {
v0->field_30 = -1;
v2 = v0;
}
return v2;
} | openssh-portable | angr_phoenix |
static int compare_forward(struct Forward *a, struct Forward *b) {
if (!compare_host(a->listen_host, b->listen_host))
return 0;
if (!compare_host(a->listen_path, b->listen_path))
return 0;
if (a->listen_port != b->listen_port)
return 0;
if (!compare_host(a->connect_host, b->connect_host))
return 0;
if (!compare_host(a->connect_path, b->connect_path))
return 0;
if (a->connect_port != b->connect_port)
return 0;
return 1;
} | int compare_forward(struct_0 *a0, struct_0 *a1) {
return (
!compare_host(a0->field_0, a1->field_0)
? (!compare_host(a0->field_10, a1->field_10)
? (a0->field_8 == a1->field_8
? 0
: (!compare_host(a0->field_18, a1->field_18)
? (!compare_host(a0->field_28, a1->field_28)
? (a0->field_20 == a1->field_20 ? 0 : 1)
: 0)
: 0))
: 0)
: 0);
} | openssh-portable | angr_sailr |
void shtimer_flush(sh_timer *t) {
do {
if (t->data)
sh_xfree((t->data), "timers.c", 87);
} while (0);
shtimer_zero(t);
} | long long shtimer_flush(struct_0 *a0) {
if (a0->field_100)
sh_xfree(a0->field_100, "timers.c", 0x57);
return shtimer_zero(a0);
} | bash | angr_dream |
static intmax_t parameter_brace_expand_length(name)
char *name;
{
char *t, *newname;
intmax_t number, arg_index;
WORD_LIST *list;
SHELL_VAR *var;
var = (SHELL_VAR *)((void *)0);
if (name[1] == '\0')
number = number_of_args();
else if (((name[1]) == '@' || (name[1]) == '*') && name[2] == '\0')
number = number_of_args();
else if ((sh_syntaxtab[(unsigned char)name[1]] & 0x0800) && name[2] == '\0') {
switch (name[1]) {
case '-':
t = which_set_flags();
break;
case '?':
t = itos(last_command_exit_value);
break;
case '$':
t = itos(dollar_dollar_pid);
break;
case '!':
if (last_asynchronous_pid == (pid_t)-1)
t = (char *)((void *)0);
else
t = itos(last_asynchronous_pid);
break;
case '#':
t = itos(number_of_args());
break;
}
number = (((t) && (t)[0]) ? ((t)[1] ? ((t)[2] ? strlen(t) : 2) : 1) : 0);
do {
if (t)
sh_xfree((t), "subst.c", 8010);
} while (0);
}
else if (valid_array_reference(name + 1, 0))
number = array_length_reference(name + 1);
else {
number = 0;
if (legal_number(name + 1, &arg_index)) {
t = get_dollar_var_value(arg_index);
if (t == 0 && unbound_vars_is_error)
return (-9223372036854775807L - 1);
number = (((__ctype_get_mb_cur_max()) > 1)
? (((t) && (t)[0]) ? ((t)[1] ? mbstrlen(t) : 1) : 0)
: (((t) && (t)[0]) ? ((t)[1] ? ((t)[2] ? strlen(t) : 2) : 1)
: 0));
do {
if (t)
sh_xfree((t), "subst.c", 8026);
} while (0);
}
else if ((var = find_variable(name + 1)) &&
(((((var)->attributes) & (0x0001000))) == 0) &&
(((((var)->attributes) & (0x0000004))) ||
((((var)->attributes) & (0x0000040))))) {
if (((((var)->attributes) & (0x0000040))))
t = assoc_reference((HASH_TABLE *)((var)->value), "0");
else
t = array_reference((ARRAY *)((var)->value), 0);
if (t == 0 && unbound_vars_is_error)
return (-9223372036854775807L - 1);
number = (((__ctype_get_mb_cur_max()) > 1)
? (((t) && (t)[0]) ? ((t)[1] ? mbstrlen(t) : 1) : 0)
: (((t) && (t)[0]) ? ((t)[1] ? ((t)[2] ? strlen(t) : 2) : 1)
: 0));
}
else if ((var || (var = find_variable(name + 1))) &&
((((var)->attributes) & (0x0001000))) == 0 &&
((((var)->attributes) & (0x0000004))) == 0 &&
((((var)->attributes) & (0x0000040))) == 0 &&
var->dynamic_value == 0)
number =
((var)->value)
? (((__ctype_get_mb_cur_max()) > 1)
? (((((var)->value)) && (((var)->value))[0])
? ((((var)->value))[1] ? mbstrlen(((var)->value))
: 1)
: 0)
: (((((var)->value)) && (((var)->value))[0])
? ((((var)->value))[1]
? ((((var)->value))[2]
? strlen(((var)->value))
: 2)
: 1)
: 0))
: 0;
else if (var == 0 && unbound_vars_is_error == 0)
number = 0;
else {
newname = (char *)strcpy(sh_xmalloc((1 + strlen(name)), "subst.c", 8051),
(name));
newname[0] = '$';
list = expand_string(newname, 0x001);
t = list ? string_list(list) : (char *)((void *)0);
sh_xfree((newname), "subst.c", 8055);
if (list)
dispose_words(list);
number =
t ? (((__ctype_get_mb_cur_max()) > 1)
? (((t) && (t)[0]) ? ((t)[1] ? mbstrlen(t) : 1) : 0)
: (((t) && (t)[0]) ? ((t)[1] ? ((t)[2] ? strlen(t) : 2) : 1)
: 0))
: 0;
do {
if (t)
sh_xfree((t), "subst.c", 8060);
} while (0);
}
}
return (number);
} | int parameter_brace_expand_length(char a0[3], unsigned long long a1,
unsigned long long a2, unsigned long long a3,
unsigned long long a4,
unsigned long long a5) {
char v0;
void *v1;
unsigned long long v2;
struct_0 *v3;
char *v4;
void *v5;
char v6;
unsigned long long v7;
char v8;
unsigned long long v9;
void *v13;
v3 = 0;
if (!a0[1]) {
v2 = number_of_args();
} else {
if ((a0[1] == 64 || a0[1] == 42) && !a0[2])
v2 = number_of_args();
if (a0[2] || a0[1] != 64 && a0[1] != 42) {
if ((sh_syntaxtab[a0[1]] & 0x800) && !a0[2]) {
switch (a0[1]) {
case 33:
if (last_asynchronous_pid == -1) {
v1 = 0;
break;
} else {
v1 = itos(last_asynchronous_pid);
break;
}
case 35:
v1 = itos(number_of_args());
break;
case 36:
v1 = itos(dollar_dollar_pid);
break;
case 45:
v1 = which_set_flags();
break;
case 63:
v1 = itos(last_command_exit_value);
break;
}
if (true) {
if (!v1) {
v9 = 0;
} else if (*(v1)) {
if (!v1[1]) {
v9 = 1;
} else if (v1[2]) {
v9 = strlen(v1);
} else {
v9 = 2;
}
}
}
v2 = v9;
if (v1)
sh_xfree(v1, "subst.c", 0x1f4a);
}
if (!(sh_syntaxtab[a0[1]] & 0x800) || a0[2]) {
v9 = valid_array_reference(&a0[1], 0x0);
if (v9) {
v2 = array_length_reference(&a0[1], 0x0, a2, a3, a4, a5);
} else {
v2 = 0;
v9 = legal_number(&a0[1], &v0, &a0[1]);
if (v9) {
*(&v1) = get_dollar_var_value(*(&v0));
if (!v1 && *(&unbound_vars_is_error))
v9 = 0;
} else {
v3 = find_variable(&a0[1]);
}
}
}
}
}
if (!v9 && a0[1] && v9 && (!(sh_syntaxtab[a0[1]] & 0x800) || a0[2]) &&
(a0[2] || a0[1] != 64) && (a0[2] || a0[1] != 42) && !v1 &&
!*(&unbound_vars_is_error) ||
!v9 && a0[1] && v9 && (!(sh_syntaxtab[a0[1]] & 0x800) || a0[2]) &&
(a0[2] || a0[1] != 64) && (a0[2] || a0[1] != 42) && v1) {
if (__ctype_get_mb_cur_max(a0, &v0, a2, a3, a4, a5, *(&v6), v7, *(&v8)) >
1) {
if (v1 && *(v1)) {
if (v1[1])
v9 = mbstrlen(v1);
else
v9 = 1;
}
if (!v1[0] || !v1)
v9 = 0;
} else {
if (v1 && *(v1)) {
if (!v1[1]) {
v9 = 1;
} else if (v1[2]) {
v9 = strlen(v1);
} else {
v9 = 2;
}
}
if (!v1 || !v1[0])
v9 = 0;
}
v2 = v9;
if (v1)
sh_xfree(v1, "subst.c", 0x1f5a);
}
if (...) {
if ((v3->field_28 & 64))
*(&v1) = assoc_reference(v3->field_8, "0", a2);
else
*(&v1) = array_reference(v3->field_8, 0x0, a2);
if (!v1 && *(&unbound_vars_is_error))
v9 = 0;
}
if (...) {
if (!v3)
v3 = find_variable(&a0[1]);
if ((v3 || v3) && !(v3->field_28 & 0x1000) && !(v3->field_28 & 4) &&
!(v3->field_28 & 64) && !v3->field_18) {
if (!v3->field_8) {
v9 = 0;
} else if (__ctype_get_mb_cur_max(a0, &v0, a2, a3, a4, a5, *(&v6), v7,
*(&v8)) > 1) {
if (v3->field_8 && v3->field_8->field_0) {
if (v3->field_8->field_1)
v9 = mbstrlen(v3->field_8);
else
v9 = 1;
}
if (!v3->field_8->field_0 || !v3->field_8)
v9 = 0;
} else {
if (v3->field_8 && v3->field_8->field_0) {
if (!v3->field_8->field_1) {
v9 = 1;
} else if (v3->field_8->field_2) {
v9 = strlen(v3->field_8);
} else {
v9 = 2;
}
}
if (!v3->field_8 || !v3->field_8->field_0)
v9 = 0;
}
v2 = v9;
}
if (v3->field_18 || (v3->field_28 & 0x1000) || (v3->field_28 & 4) ||
(v3->field_28 & 64) || !v3 && !v3) {
if (!v3 && !*(&unbound_vars_is_error))
v2 = 0;
if (*(&unbound_vars_is_error) || v3) {
v4 = strcpy(sh_xmalloc(strlen(a0) + 1, "subst.c", 0x1f73), a0);
*(v4) = 36;
v5 = expand_string(v4, 0x1, 0x1f73, a3, a4, a5);
if (v5)
v13 = string_list(v5);
else
v13 = 0;
v1 = v13;
sh_xfree(v4, "subst.c", 0x1f77);
if (v5)
dispose_words(v5);
if (!v1) {
v9 = 0;
} else if (__ctype_get_mb_cur_max(a0, "subst.c", 0x1f77, a3, a4, a5,
*(&v6), v7, *(&v8)) > 1) {
if (v1 && *(v1)) {
if (v1[1])
v9 = mbstrlen(v1);
else
v9 = 1;
}
if (!v1[0] || !v1)
v9 = 0;
} else {
if (v1 && *(v1)) {
if (!v1[1]) {
v9 = 1;
} else if (v1[2]) {
v9 = strlen(v1);
} else {
v9 = 2;
}
}
if (!v1[0] || !v1)
v9 = 0;
}
v2 = v9;
if (v1)
sh_xfree(v1, "subst.c", 0x1f7c);
}
}
}
if (...) {
if (__ctype_get_mb_cur_max(a0, a1, a2, a3, a4, a5, *(&v6), v7, *(&v8)) >
1) {
if (v1 && *(v1)) {
if (v1[1])
v9 = mbstrlen(v1);
else
v9 = 1;
}
if (!v1 || !v1[0])
v9 = 0;
} else {
if (v1 && *(v1)) {
if (!v1[1]) {
v9 = 1;
} else if (v1[2]) {
v9 = strlen(v1);
} else {
v9 = 2;
}
}
if (!v1[0] || !v1)
v9 = 0;
}
v2 = v9;
}
if (...)
v9 = v2;
return v9;
} | bash | angr_dream |
_Bool
sys_compare_gid (struct stat *a, struct stat *b)
{
return a->st_gid == b->st_gid;
} | bool sys_compare_gid(long a1, long a2) {
return *(_DWORD *)(a1 + 32) == *(_DWORD *)(a2 + 32);
} | tar | ida |
static size_t quote_name(char const *name,
struct quoting_options const *options,
int needs_general_quoting, const struct bin_str *color,
_Bool allow_pad, struct obstack *stack,
char const *absolute_name) {
char smallbuf[8192];
char *buf = smallbuf;
size_t len;
_Bool pad;
len = quote_name_buf(&buf, sizeof smallbuf, (char *)name, options,
needs_general_quoting, ((void *)0), &pad);
if (pad && allow_pad)
dired_outbyte(' ');
if (color)
print_color_indicator(color);
_Bool skip_quotes = 0;
if (absolute_name) {
if (align_variable_outer_quotes && cwd_some_quoted && !pad) {
skip_quotes = 1;
putchar_unlocked(*buf);
}
char *h = file_escape(hostname, 0);
char *n = file_escape(absolute_name, 1);
printf ("\033]8;;file:
free (h);
free (n);
}
if (stack)
push_current_dired_pos(stack);
fwrite_unlocked(buf + skip_quotes, 1, len - (skip_quotes * 2), stdout);
dired_pos += len;
if (stack)
push_current_dired_pos(stack);
if (absolute_name) {
fputs_unlocked("\033]8;;\a", stdout);
if (skip_quotes)
putchar_unlocked(*(buf + len - 1));
}
if (buf != smallbuf && buf != name)
free(buf);
return len + pad;
} | int quote_name(unsigned long long a0, unsigned long long a1, unsigned long a2,
unsigned long long a3, unsigned long a4, void *a5,
unsigned long long v10) {
unsigned long long v0;
char v1;
char v2;
char *v3;
unsigned long v4;
void *v5;
char *v6;
char v7;
unsigned long long v8;
unsigned long long v9;
unsigned int v11;
v9 = *(&v9);
v8 = *(&v8);
v0 = v10;
v3 = &v7;
v4 = quote_name_buf(&v3, 0x2000, a0, a1, a2, 0x0, &v1);
if (v1 && a4)
dired_outbyte(0x20);
if (a3)
print_color_indicator(a3);
v2 = 0;
if (v0) {
if (align_variable_outer_quotes && cwd_some_quoted && (v1 ^ 1)) {
v2 = 1;
putchar_unlocked(*(v3));
}
v5 = file_escape(hostname, 0x0);
v6 = file_escape(v0, 0x1);
if (*(v6) != 47)
v11 = &g_40deab;
else
v11 = &g_40bb1b;
printf(&g_40dead, v5, v11, v6);
free(v5);
free(v6);
}
if (a5)
push_current_dired_pos(a5);
fwrite_unlocked(&v3[v2], 0x1, v4 - v2 * 2, stdout);
dired_pos = v4 + dired_pos;
if (a5)
push_current_dired_pos(a5);
if (v0) {
fputs_unlocked(&g_40dec1, stdout);
if (v2)
putchar_unlocked(v3[1 + v4]);
}
if (v3 != &v7 && a0 != v3)
free(v3);
return v4 + v1;
} | coreutils | angr_sailr |
int main(int argc, char **argv) {
_Bool ok;
int optc;
;
set_program_name(argv[0]);
setlocale(6, "");
bindtextdomain("coreutils", "/usr/local/share/locale");
textdomain("coreutils");
atexit(close_stdout);
append = 0;
ignore_interrupts = 0;
while ((optc = getopt_long(argc, argv, "aip", long_options, ((void *)0))) !=
-1) {
switch (optc) {
case 'a':
append = 1;
break;
case 'i':
ignore_interrupts = 1;
break;
case 'p':
if (optarg)
output_error = ((output_error_types)[__xargmatch_internal(
"--output-error", optarg, output_error_args,
(void const *)(output_error_types), sizeof *(output_error_types),
argmatch_die, 1)]);
else
output_error = output_error_warn_nopipe;
break;
case GETOPT_HELP_CHAR:
usage(0);
break;
;
case GETOPT_VERSION_CHAR:
version_etc(stdout, "tee", "GNU coreutils", Version, ("Mike Parker"),
("Richard M. Stallman"), ("David MacKenzie"),
(char *)((void *)0));
exit(0);
break;
;
default:
usage(1);
}
}
if (ignore_interrupts)
signal(2, ((__sighandler_t)1));
if (output_error != output_error_sigpipe)
signal(13, ((__sighandler_t)1));
ok = tee_files(argc - optind, &argv[optind]);
if (close(0) != 0)
((!!sizeof(struct {
_Static_assert(1, "verify_expr ("
"1"
", "
"(error (1, (*__errno_location ()), \"%s\", gettext "
"(\"standard input\")), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, (*__errno_location()), "%s", gettext("standard input")),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, (*__errno_location()), "%s", gettext("standard input")),
((0) ? (void)0 : __builtin_unreachable()))));
return ok ? 0 : 1;
} | int main(unsigned long a0, unsigned long long *a1) {
void *v0;
char v1;
unsigned int v2;
unsigned long long v5;
set_program_name(*(a1));
setlocale(0x6, &g_400d63);
bindtextdomain("coreutils", "/usr/local/share/locale");
textdomain("coreutils");
atexit(got.close_stdout);
append = 0;
ignore_interrupts = 0;
while (true) {
v2 = getopt_long(a0, a1, "aip", &long_options, NULL);
if (v2 == -1) {
if (ignore_interrupts)
signal(0x2, 0x1);
if (output_error) {
signal(0xd, 0x1);
break;
}
}
if (v2 == 112) {
if (!optarg) {
output_error = 2;
continue;
} else {
output_error = *((4 * __xargmatch_internal(
"--output-error", optarg, &output_error_args,
&output_error_types, 0x4, argmatch_die) +
&output_error_types));
}
continue;
}
if (v2 > 112) {
LABEL_40054d:
usage(0x1);
}
if (v2 == 105) {
ignore_interrupts = 1;
continue;
}
if (!(v2 <= 105))
goto LABEL_40054d;
if (v2 == 97) {
append = 1;
} else {
if (v2 <= 97) {
if (v2 == -131) {
v0 = 0;
version_etc(stdout, "tee", "GNU coreutils", Version, "Mike Parker",
"Richard M. Stallman", "David MacKenzie");
exit(0x0);
} else if (v2 == -130) {
usage(0x0);
}
}
goto LABEL_40054d;
}
}
v1 = tee_files(a0 - optind, &a1[optind]);
if (!close(0x0))
return v1 ^ 1;
v5 = gettext("standard input");
error(0x1, *(__errno_location()), "%s");
} | coreutils | angr_phoenix |
int ssh_ecdsa_sk_verify(const struct sshkey *key, const u_char *signature,
size_t signaturelen, const u_char *data, size_t datalen,
u_int compat, struct sshkey_sig_details **detailsp) {
ECDSA_SIG *sig = ((void *)0);
BIGNUM *sig_r = ((void *)0), *sig_s = ((void *)0);
u_char sig_flags;
u_char msghash[32], apphash[32], sighash[32];
u_int sig_counter;
int is_webauthn = 0, ret = -1;
struct sshbuf *b = ((void *)0), *sigbuf = ((void *)0),
*original_signed = ((void *)0);
struct sshbuf *webauthn_wrapper = ((void *)0), *webauthn_exts = ((void *)0);
char *ktype = ((void *)0), *webauthn_origin = ((void *)0);
struct sshkey_sig_details *details = ((void *)0);
if (detailsp != ((void *)0))
*detailsp = ((void *)0);
if (key == ((void *)0) || key->ecdsa == ((void *)0) ||
sshkey_type_plain(key->type) != KEY_ECDSA_SK ||
signature == ((void *)0) || signaturelen == 0)
return -10;
if (key->ecdsa_nid != 415)
return -1;
if ((b = sshbuf_from(signature, signaturelen)) == ((void *)0))
return -2;
if ((details = calloc(1, sizeof(*details))) == ((void *)0)) {
ret = -2;
goto out;
}
if (sshbuf_get_cstring(b, &ktype, ((void *)0)) != 0) {
ret = -4;
goto out;
}
if (strcmp(ktype, "webauthn-sk-ecdsa-sha2-nistp256@openssh.com") == 0)
is_webauthn = 1;
else if (strcmp(ktype, "sk-ecdsa-sha2-nistp256@openssh.com") != 0) {
ret = -4;
goto out;
}
if (sshbuf_froms(b, &sigbuf) != 0 || sshbuf_get_u8(b, &sig_flags) != 0 ||
sshbuf_get_u32(b, &sig_counter) != 0) {
ret = -4;
goto out;
}
if (is_webauthn) {
if (sshbuf_get_cstring(b, &webauthn_origin, ((void *)0)) != 0 ||
sshbuf_froms(b, &webauthn_wrapper) != 0 ||
sshbuf_froms(b, &webauthn_exts) != 0) {
ret = -4;
goto out;
}
}
if (sshbuf_len(b) != 0) {
ret = -23;
goto out;
}
if (sshbuf_get_bignum2(sigbuf, &sig_r) != 0 ||
sshbuf_get_bignum2(sigbuf, &sig_s) != 0) {
ret = -4;
goto out;
}
if (sshbuf_len(sigbuf) != 0) {
ret = -23;
goto out;
}
if ((sig = ECDSA_SIG_new()) == ((void *)0)) {
ret = -2;
goto out;
}
if (!ECDSA_SIG_set0(sig, sig_r, sig_s)) {
ret = -22;
goto out;
}
sig_r = sig_s = ((void *)0);
if ((original_signed = sshbuf_new()) == ((void *)0)) {
ret = -2;
goto out;
}
if (is_webauthn) {
if ((ret = webauthn_check_prepare_hash(
data, datalen, webauthn_origin, webauthn_wrapper, sig_flags,
webauthn_exts, msghash, sizeof(msghash))) != 0)
goto out;
} else if ((ret = ssh_digest_memory(2, data, datalen, msghash,
sizeof(msghash))) != 0)
goto out;
if ((ret = ssh_digest_memory(2, key->sk_application,
strlen(key->sk_application), apphash,
sizeof(apphash))) != 0)
goto out;
if ((ret = sshbuf_put(original_signed, apphash, sizeof(apphash))) != 0 ||
(ret = sshbuf_put_u8(original_signed, sig_flags)) != 0 ||
(ret = sshbuf_put_u32(original_signed, sig_counter)) != 0 ||
(ret = sshbuf_putb(original_signed, webauthn_exts)) != 0 ||
(ret = sshbuf_put(original_signed, msghash, sizeof(msghash))) != 0)
goto out;
if ((ret = ssh_digest_buffer(2, original_signed, sighash, sizeof(sighash))) !=
0)
goto out;
details->sk_counter = sig_counter;
details->sk_flags = sig_flags;
switch (ECDSA_do_verify(sighash, sizeof(sighash), sig, key->ecdsa)) {
case 1:
ret = 0;
break;
case 0:
ret = -21;
goto out;
default:
ret = -22;
goto out;
}
if (detailsp != ((void *)0)) {
*detailsp = details;
details = ((void *)0);
}
out:
explicit_bzero(&sig_flags, sizeof(sig_flags));
explicit_bzero(&sig_counter, sizeof(sig_counter));
explicit_bzero(msghash, sizeof(msghash));
explicit_bzero(sighash, sizeof(msghash));
explicit_bzero(apphash, sizeof(apphash));
sshkey_sig_details_free(details);
sshbuf_free(webauthn_wrapper);
sshbuf_free(webauthn_exts);
free(webauthn_origin);
sshbuf_free(original_signed);
sshbuf_free(sigbuf);
sshbuf_free(b);
ECDSA_SIG_free(sig);
BN_clear_free(sig_r);
BN_clear_free(sig_s);
free(ktype);
return ret;
} | long long ssh_ecdsa_sk_verify(struct_0 *a0, unsigned long long a1,
unsigned long long a2, unsigned long long a3,
unsigned long long a4, unsigned long a5,
unsigned long v20) {
unsigned long long *v0;
unsigned int v1;
char v2;
char v3;
unsigned int v4;
unsigned int v5;
void *v6;
void *v7;
void *v8;
void *v9;
void *v10;
void *v11;
void *v12;
void *v13;
void *v14;
void *v15;
void *v16;
char v17;
char v18;
char v19;
unsigned long long v21;
unsigned long long v22;
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;
unsigned long long v31;
unsigned long long v33;
unsigned long long v34;
unsigned long long v37;
v1 = a5;
v0 = v20;
v13 = 0;
v6 = 0;
v7 = 0;
v4 = 0;
v5 = -1;
v16 = 0;
v8 = 0;
v14 = 0;
v9 = 0;
v10 = 0;
v11 = 0;
v12 = 0;
v15 = 0;
if (v0)
*(v0) = 0;
if (a0 && a0->field_20) {
v21 = sshkey_type_plain(a0->field_0);
if (v21 == 10 && a1 && a2) {
if (a0->field_18 != 415) {
v22 = 4294967295;
} else {
v16 = sshbuf_from(a1, a2, a2);
if (!v16) {
v22 = 4294967294;
} else {
v15 = calloc(0x1, 0x8);
if (!v15) {
v5 = -2;
} else if (sshbuf_get_cstring(v16, &v11, 0x0, &v11)) {
v5 = -0x4;
} else {
v24 = strcmp(v11, "webauthn-sk-ecdsa-sha2-nistp256@openssh.com");
if (!v24) {
v4 = 1;
} else {
v25 = strcmp(v11, "sk-ecdsa-sha2-nistp256@openssh.com");
if (v25)
v5 = -0x4;
}
if (!v25 || !v24) {
v26 = sshbuf_froms(v16, &v8, &v8);
if (!v26) {
v27 = sshbuf_get_u8(v16, &v2, &v2);
if (!v27) {
v28 = sshbuf_get_u32(v16, &v3, &v3);
if (!v28) {
if (v4) {
v29 = sshbuf_get_cstring(v16, &v12, 0x0, &v12);
if (!v29) {
v30 = sshbuf_froms(v16, &v9, &v9);
if (!v30)
v31 = sshbuf_froms(v16, &v10, &v10);
}
if (v30 || v29 || v31)
v5 = -0x4;
}
if (!v4 || !v30 && !v29 && !v31) {
if (sshbuf_len(v16)) {
v5 = -23;
} else {
v33 = sshbuf_get_bignum2(v8, &v6, &v6);
if (!v33) {
v34 = sshbuf_get_bignum2(v8, &v7, &v7);
if (!v34) {
if (sshbuf_len(v8)) {
v5 = -23;
} else {
v13 = ECDSA_SIG_new();
if (!v13) {
v5 = -2;
} else if (!ECDSA_SIG_set0(v13, v6, v7, v6)) {
v5 = -22;
} else {
v7 = 0;
v6 = v7;
v14 = sshbuf_new();
if (!v14) {
v5 = -2;
} else {
if (v4)
v5 = webauthn_check_prepare_hash(
a3, a4, v12, v9, v2, v10, &v17, 0x20);
else
v5 = ssh_digest_memory(0x2, a3, a4, &v17,
0x20);
if (!v5 && !v4 || !v5 && v4) {
v5 = ssh_digest_memory(0x2, a0->field_60,
strlen(a0->field_60),
&v18, 0x20);
if (!v5) {
v5 = sshbuf_put(v14, &v18, 0x20);
if (!v5) {
v5 = sshbuf_put_u8(v14, v2, v2);
if (!v5) {
v5 = sshbuf_put_u32(v14, *(&v3),
*(&v3));
if (!v5) {
v5 = sshbuf_putb(v14, v10, v10);
if (!v5) {
v5 = sshbuf_put(v14, &v17, 0x20);
if (!v5) {
v5 = ssh_digest_buffer(
0x2, v14, &v19, 0x20);
if (!v5) {
*(v15) = *(&v3);
*(&v15[4]) = v2;
v37 = ECDSA_do_verify(
&v19, 0x20, v13,
a0->field_20);
if (!v37) {
v5 = -21;
} else if (v37 == 1) {
v5 = 0;
if (v0) {
*(v0) = v15;
v15 = 0;
}
} else {
v5 = -22;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
if (v33 || v34)
v5 = -0x4;
}
}
}
}
}
if (v28 || v27 || v26)
v5 = -0x4;
}
}
explicit_bzero(&v2, 0x1);
explicit_bzero(&v3, 0x4);
explicit_bzero(&v17, 0x20);
explicit_bzero(&v19, 0x20);
explicit_bzero(&v18, 0x20);
sshkey_sig_details_free(v15);
sshbuf_free(v9);
sshbuf_free(v10);
free(v12);
sshbuf_free(v14);
sshbuf_free(v8);
sshbuf_free(v16);
ECDSA_SIG_free(v13);
BN_clear_free(v6);
BN_clear_free(v7);
free(v11);
v22 = v5;
}
}
}
}
if (!a0 || !a2 || !a1 || !a0->field_20 || v21 != 10)
v22 = 4294967286;
return v22;
} | openssh-portable | angr_dream |
static int ipntable_modify(int cmd, int flags, int argc, char **argv) {
struct {
struct nlmsghdr n;
struct ndtmsg ndtm;
char buf[1024];
} req = {
.n.nlmsg_len =
((sizeof(struct ndtmsg)) +
((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1)))),
.n.nlmsg_flags = 0x01 | flags,
.n.nlmsg_type = cmd,
.ndtm.ndtm_family = preferred_family,
};
char *namep = ((void *)0);
char *threshsp = ((void *)0);
char *gc_intp = ((void *)0);
char parms_buf[1024] = {};
struct rtattr *parms_rta = (struct rtattr *)parms_buf;
int parms_change = 0;
parms_rta->rta_type = NDTA_PARMS;
parms_rta->rta_len = ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0));
while (argc > 0) {
if (strcmp(*argv, "name") == 0) {
int len;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (namep)
duparg("NAME", *argv);
namep = *argv;
len = strlen(namep) + 1;
addattr_l(&req.n, sizeof(req), NDTA_NAME, namep, len);
} else if (strcmp(*argv, "thresh1") == 0) {
__u32 thresh1;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
threshsp = *argv;
if (get_u32(&thresh1, *argv, 0))
invarg("\"thresh1\" value is invalid", *argv);
addattr32(&req.n, sizeof(req), NDTA_THRESH1, thresh1);
} else if (strcmp(*argv, "thresh2") == 0) {
__u32 thresh2;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
threshsp = *argv;
if (get_u32(&thresh2, *argv, 0))
invarg("\"thresh2\" value is invalid", *argv);
addattr32(&req.n, sizeof(req), NDTA_THRESH2, thresh2);
} else if (strcmp(*argv, "thresh3") == 0) {
__u32 thresh3;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
threshsp = *argv;
if (get_u32(&thresh3, *argv, 0))
invarg("\"thresh3\" value is invalid", *argv);
addattr32(&req.n, sizeof(req), NDTA_THRESH3, thresh3);
} else if (strcmp(*argv, "gc_int") == 0) {
__u64 gc_int;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
gc_intp = *argv;
if (get_u64(&gc_int, *argv, 0))
invarg("\"gc_int\" value is invalid", *argv);
addattr_l(&req.n, sizeof(req), NDTA_GC_INTERVAL, &gc_int, sizeof(gc_int));
} else if (strcmp(*argv, "dev") == 0) {
__u32 ifindex;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
ifindex = ll_name_to_index(*argv);
if (!ifindex)
return nodev(*argv);
rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_IFINDEX, ifindex);
} else if (strcmp(*argv, "base_reachable") == 0) {
__u64 breachable;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u64(&breachable, *argv, 0))
invarg("\"base_reachable\" value is invalid", *argv);
rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_BASE_REACHABLE_TIME,
&breachable, sizeof(breachable));
parms_change = 1;
} else if (strcmp(*argv, "retrans") == 0) {
__u64 retrans;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u64(&retrans, *argv, 0))
invarg("\"retrans\" value is invalid", *argv);
rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_RETRANS_TIME, &retrans,
sizeof(retrans));
parms_change = 1;
} else if (strcmp(*argv, "gc_stale") == 0) {
__u64 gc_stale;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u64(&gc_stale, *argv, 0))
invarg("\"gc_stale\" value is invalid", *argv);
rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_GC_STALETIME, &gc_stale,
sizeof(gc_stale));
parms_change = 1;
} else if (strcmp(*argv, "delay_probe") == 0) {
__u64 delay_probe;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u64(&delay_probe, *argv, 0))
invarg("\"delay_probe\" value is invalid", *argv);
rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_DELAY_PROBE_TIME,
&delay_probe, sizeof(delay_probe));
parms_change = 1;
} else if (strcmp(*argv, "queue") == 0) {
__u32 queue;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u32(&queue, *argv, 0))
invarg("\"queue\" value is invalid", *argv);
rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_QUEUE_LEN, queue);
parms_change = 1;
} else if (strcmp(*argv, "app_probes") == 0) {
__u32 aprobe;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u32(&aprobe, *argv, 0))
invarg("\"app_probes\" value is invalid", *argv);
rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_APP_PROBES, aprobe);
parms_change = 1;
} else if (strcmp(*argv, "ucast_probes") == 0) {
__u32 uprobe;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u32(&uprobe, *argv, 0))
invarg("\"ucast_probes\" value is invalid", *argv);
rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_UCAST_PROBES, uprobe);
parms_change = 1;
} else if (strcmp(*argv, "mcast_probes") == 0) {
__u32 mprobe;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u32(&mprobe, *argv, 0))
invarg("\"mcast_probes\" value is invalid", *argv);
rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_MCAST_PROBES, mprobe);
parms_change = 1;
} else if (strcmp(*argv, "anycast_delay") == 0) {
__u64 anycast_delay;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u64(&anycast_delay, *argv, 0))
invarg("\"anycast_delay\" value is invalid", *argv);
rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_ANYCAST_DELAY,
&anycast_delay, sizeof(anycast_delay));
parms_change = 1;
} else if (strcmp(*argv, "proxy_delay") == 0) {
__u64 proxy_delay;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u64(&proxy_delay, *argv, 0))
invarg("\"proxy_delay\" value is invalid", *argv);
rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_PROXY_DELAY,
&proxy_delay, sizeof(proxy_delay));
parms_change = 1;
} else if (strcmp(*argv, "proxy_queue") == 0) {
__u32 pqueue;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u32(&pqueue, *argv, 0))
invarg("\"proxy_queue\" value is invalid", *argv);
rta_addattr32(parms_rta, sizeof(parms_buf), NDTPA_PROXY_QLEN, pqueue);
parms_change = 1;
} else if (strcmp(*argv, "locktime") == 0) {
__u64 locktime;
do {
argv++;
if (--argc <= 0)
incomplete_command();
} while (0);
if (get_u64(&locktime, *argv, 0))
invarg("\"locktime\" value is invalid", *argv);
rta_addattr_l(parms_rta, sizeof(parms_buf), NDTPA_LOCKTIME, &locktime,
sizeof(locktime));
parms_change = 1;
} else {
invarg("unknown", *argv);
}
argc--;
argv++;
}
if (!namep)
missarg("NAME");
if (!threshsp && !gc_intp && !parms_change) {
fprintf(stderr,
"Not enough information: changeable attributes required.\n");
exit(-1);
}
if (parms_rta->rta_len >
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))) {
addattr_l(
&req.n, sizeof(req), NDTA_PARMS,
((void *)(((char *)(parms_rta)) +
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))),
((int)((parms_rta)->rta_len) -
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))));
}
if (rtnl_talk(&rth, &req.n, ((void *)0)) < 0)
exit(2);
return 0;
} | void ipntable_modify(unsigned long a0, unsigned long a1, unsigned long a2,
unsigned long a3) {
unsigned long long *v0;
unsigned int v1;
unsigned int v2;
unsigned int v3;
unsigned int v4;
unsigned int v5;
char v6;
void *v7;
unsigned long v8;
void *v9;
unsigned short v10[2];
char v11;
unsigned short v12;
unsigned short v13;
char v14;
void *v15;
void *v16;
char v17;
unsigned long long v19;
void *v20;
unsigned 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 v28;
unsigned long long v30;
unsigned long long v32;
unsigned long long v58;
void *v60;
v2 = a0;
v1 = a2;
v0 = a3;
v19 = 130;
for (v20 = &v11; v19; v20 += v21 * 8) {
v19 -= 1;
v11 = 0;
}
*(v20) = 0;
v11 = 20;
v12 = v2;
v13 = a1 | 1;
v14 = preferred_family;
v7 = 0;
v8 = 0;
v9 = 0;
v15 = 0;
v16 = 0;
v23 = 126;
for (v22 = &v17; v23; v22 = &v22[v21]) {
v23 -= 1;
v17 = 0;
}
*(&v10) = &v15;
v3 = 0;
v10[1] = 6;
v10[0] = 4;
while (true) {
if (v1 > 0) {
v24 = strcmp(*(v0), "name");
if (!v24) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (v7)
duparg("NAME", *(v0));
v7 = *(v0);
v5 = strlen(v7) + 1;
addattr_l(&v11, 0x414, 0x1, v7, v5);
} else {
v25 = strcmp(*(v0), "thresh1");
if (!v25) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
v8 = *(v0);
if (get_u32(&v6, *(v0), 0x0, *(v0)))
invarg("\"thresh1\" value is invalid", *(v0));
addattr32(&v11, 0x414, 0x2, *(&v6));
} else {
v26 = strcmp(*(v0), "thresh2");
if (!v26) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
v8 = *(v0);
if (get_u32(&v6, *(v0), 0x0, *(v0)))
invarg("\"thresh2\" value is invalid", *(v0));
addattr32(&v11, 0x414, 0x3, *(&v6));
} else {
v28 = strcmp(*(v0), "thresh3");
if (!v28) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
v8 = *(v0);
if (get_u32(&v6, *(v0), 0x0, *(v0)))
invarg("\"thresh3\" value is invalid", *(v0));
addattr32(&v11, 0x414, 0x4, *(&v6));
} else {
v30 = strcmp(*(v0), "gc_int");
if (!v30) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
v9 = *(v0);
if (get_u64(&v6, *(v0), 0x0, *(v0)))
invarg("\"gc_int\" value is invalid", *(v0));
addattr_l(&v11, 0x414, 0x8, &v6, 0x8);
} else {
v32 = strcmp(*(v0), "dev");
if (!v32) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
v4 = ll_name_to_index(*(v0));
if (!v4) {
v58 = nodev(*(v0));
break;
} else {
rta_addattr32(v10, 0x400, 0x1, v4);
}
} else if (!strcmp(*(v0), "base_reachable")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u64(&v6, *(v0), 0x0, *(v0)))
invarg("\"base_reachable\" value is invalid", *(v0));
rta_addattr_l(v10, 0x400, 0x4, &v6, 0x8);
v3 = 1;
} else if (!strcmp(*(v0), "retrans")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u64(&v6, *(v0), 0x0, *(v0)))
invarg("\"retrans\" value is invalid", *(v0));
rta_addattr_l(v10, 0x400, 0x5, &v6, 0x8);
v3 = 1;
} else if (!strcmp(*(v0), "gc_stale")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u64(&v6, *(v0), 0x0, *(v0)))
invarg("\"gc_stale\" value is invalid", *(v0));
rta_addattr_l(v10, 0x400, 0x6, &v6, 0x8);
v3 = 1;
} else if (!strcmp(*(v0), "delay_probe")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u64(&v6, *(v0), 0x0, *(v0)))
invarg("\"delay_probe\" value is invalid", *(v0));
rta_addattr_l(v10, 0x400, 0x7, &v6, 0x8);
v3 = 1;
} else if (!strcmp(*(v0), "queue")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u32(&v6, *(v0), 0x0, *(v0)))
invarg("\"queue\" value is invalid", *(v0));
rta_addattr32(v10, 0x400, 0x8, *(&v6));
v3 = 1;
} else if (!strcmp(*(v0), "app_probes")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u32(&v6, *(v0), 0x0, *(v0)))
invarg("\"app_probes\" value is invalid", *(v0));
rta_addattr32(v10, 0x400, 0x9, *(&v6));
v3 = 1;
} else if (!strcmp(*(v0), "ucast_probes")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u32(&v6, *(v0), 0x0, *(v0)))
invarg("\"ucast_probes\" value is invalid", *(v0));
rta_addattr32(v10, 0x400, 0xa, *(&v6));
v3 = 1;
} else if (!strcmp(*(v0), "mcast_probes")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u32(&v6, *(v0), 0x0, *(v0)))
invarg("\"mcast_probes\" value is invalid", *(v0));
rta_addattr32(v10, 0x400, 0xb, *(&v6));
v3 = 1;
} else if (!strcmp(*(v0), "anycast_delay")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u64(&v6, *(v0), 0x0, *(v0)))
invarg("\"anycast_delay\" value is invalid", *(v0));
rta_addattr_l(v10, 0x400, 0xc, &v6, 0x8);
v3 = 1;
} else if (!strcmp(*(v0), "proxy_delay")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u64(&v6, *(v0), 0x0, *(v0)))
invarg("\"proxy_delay\" value is invalid", *(v0));
rta_addattr_l(v10, 0x400, 0xd, &v6, 0x8);
v3 = 1;
} else if (!strcmp(*(v0), "proxy_queue")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u32(&v6, *(v0), 0x0, *(v0)))
invarg("\"proxy_queue\" value is invalid", *(v0));
rta_addattr32(v10, 0x400, 0xe, *(&v6));
v3 = 1;
} else if (!strcmp(*(v0), "locktime")) {
v0 = v0 + 1;
v1 -= 1;
if (v1 <= 0)
incomplete_command();
if (get_u64(&v6, *(v0), 0x0, *(v0)))
invarg("\"locktime\" value is invalid", *(v0));
rta_addattr_l(v10, 0x400, 0xf, &v6, 0x8);
v3 = 1;
} else {
invarg("unknown", *(v0));
}
}
}
}
}
}
if (!v24 || !v25 || !v26 || !v28 || !v30 || v4 || v32) {
v1 -= 1;
v0 += 1;
}
} else {
if (!v7)
missarg("NAME");
if (!v8 && !v9 && !v3) {
fprintf(stderr,
"Not enough information: changeable attributes required.\n");
exit(0xffffffff);
}
if (v9 || v3 || v8) {
if (v10[0] > 4)
addattr_l(&v11, 0x414, 0x6, v10 + 1, v10[0] - 4);
if (rtnl_talk(0x5000c0, &v11, 0x0) < 0)
exit(0x2);
v60 = 0;
break;
}
}
}
return;
} | iproute2-6.0.0 | angr_dream |
void restore_uid(void) {
if (!privileged) {
sshlog("uidswap.c", __func__, 146, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0),
"restore_uid: (unprivileged)");
return;
}
if (!temporarily_use_uid_effective)
sshfatal("uidswap.c", __func__, 150, 0, SYSLOG_LEVEL_FATAL, ((void *)0),
"restore_uid: temporarily_use_uid not effective");
sshlog("uidswap.c", __func__, 153, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0),
"restore_uid: %u/%u", (u_int)saved_euid, (u_int)saved_egid);
if (seteuid(saved_euid) == -1)
sshfatal("uidswap.c", __func__, 156, 0, SYSLOG_LEVEL_FATAL, ((void *)0),
"seteuid %u: %.100s", (u_int)saved_euid,
strerror((*__errno_location())));
if (setegid(saved_egid) == -1)
sshfatal("uidswap.c", __func__, 158, 0, SYSLOG_LEVEL_FATAL, ((void *)0),
"setegid %u: %.100s", (u_int)saved_egid,
strerror((*__errno_location())));
if (setgroups(saved_egroupslen, saved_egroups) == -1)
sshfatal("uidswap.c", __func__, 172, 0, SYSLOG_LEVEL_FATAL, ((void *)0),
"setgroups: %.100s", strerror((*__errno_location())));
temporarily_use_uid_effective = 0;
} | int restore_uid() {
int result;
int *v1;
char *v2;
int *v3;
char *v4;
int *v5;
char *v6;
if (!privileged)
return sshlog("uidswap.c", "restore_uid", 146LL, 0LL, 5LL, 0LL,
"restore_uid: (unprivileged)");
if (!temporarily_use_uid_effective)
sshfatal("uidswap.c", "restore_uid", 150LL, 0LL, 1LL, 0LL,
"restore_uid: temporarily_use_uid not effective");
sshlog("uidswap.c", "restore_uid", 153LL, 0LL, 5LL, 0LL, "restore_uid: %u/%u",
saved_euid, saved_egid);
if (seteuid(saved_euid) == -1) {
v1 = _errno_location();
v2 = strerror(*v1);
sshfatal("uidswap.c", "restore_uid", 156LL, 0LL, 1LL, 0LL,
"seteuid %u: %.100s", saved_euid, v2);
}
if (setegid(saved_egid) == -1) {
v3 = _errno_location();
v4 = strerror(*v3);
sshfatal("uidswap.c", "restore_uid", 158LL, 0LL, 1LL, 0LL,
"setegid %u: %.100s", saved_egid, v4);
}
result = setgroups(saved_egroupslen, saved_egroups);
if (result == -1) {
v5 = _errno_location();
v6 = strerror(*v5);
result = sshfatal("uidswap.c", "restore_uid", 172LL, 0LL, 1LL, 0LL,
"setgroups: %.100s", v6);
}
temporarily_use_uid_effective = 0;
return result;
} | openssh-portable | ida |
static void chan_shutdown_read(struct ssh *ssh, Channel *c) {
if (c->type == 10)
return;
sshlog("nchan.c", __func__, 404, 1, SYSLOG_LEVEL_DEBUG2, ((void *)0),
"channel %d: (i%d o%d sock %d wfd %d efd %d [%s])", c->self, c->istate,
c->ostate, c->sock, c->rfd, c->efd, channel_format_extended_usage(c))
;
if (c->sock != -1) {
if (shutdown(c->sock, SHUT_RD) == -1 && (*__errno_location()) != 107) {
sshlog("nchan.c", __func__, 414, 1, SYSLOG_LEVEL_ERROR, ((void *)0),
"channel %d: shutdown() failed for "
"fd %d [i%d o%d]: %.100s",
c->self, c->sock, c->istate, c->ostate,
strerror((*__errno_location())))
;
}
} else {
if (channel_close_fd(ssh, c, &c->rfd) < 0) {
sshlog("nchan.c", __func__, 420, 1, SYSLOG_LEVEL_INFO, ((void *)0),
"channel %d: close() failed for "
"fd %d [i%d o%d]: %.100s",
c->self, c->rfd, c->istate, c->ostate,
strerror((*__errno_location())))
;
}
}
} | void chan_shutdown_read(unsigned long long a0, unsigned int a1[11]) {
unsigned long v0;
unsigned long v1;
unsigned long v2;
unsigned long long v4;
unsigned long long v8;
unsigned long long v9;
v4 = a1[0];
if (a1[0] == 10)
return;
v2 = channel_format_extended_usage(a1);
v1 = a1[9];
v0 = a1[7];
sshlog("nchan.c", "chan_shutdown_read", 0x194, 0x1, 0x6, 0x0,
"channel %d: (i%d o%d sock %d wfd %d efd %d [%s])", a1[1], a1[4]);
if (a1[10] != -1) {
if (shutdown(a1[10], 0x0) != -1) {
return;
} else if (*(__errno_location()) == 107) {
return;
} else {
v2 = strerror(*(__errno_location()));
v1 = a1[5];
v0 = a1[4];
v9 = sshlog("nchan.c", "chan_shutdown_read", 0x19e, 0x1, 0x2, 0x0,
"channel %d: shutdown() failed for fd %d [i%d o%d]: %.100s",
a1[1], a1[10]);
return;
}
} else {
if (channel_close_fd(a0, a1, &a1[7], a1) >= 0)
return;
v2 = strerror(*(__errno_location()));
v1 = a1[5];
v0 = a1[4];
v8 = sshlog("nchan.c", "chan_shutdown_read", 0x1a4, 0x1, 0x3, 0x0,
"channel %d: close() failed for fd %d [i%d o%d]: %.100s", a1[1],
a1[7]);
return;
}
} | openssh-portable | angr_sailr |
Channel *channel_lookup(struct ssh *ssh, int id) {
Channel *c;
if ((c = channel_by_id(ssh, id)) == ((void *)0))
return ((void *)0);
switch (c->type) {
case 7:
case 10:
case 12:
case 13:
case 21:
case 22:
case 3:
case 4:
case 17:
case 20:
return c;
}
sshlog("channels.c", __func__, 295, 0, SYSLOG_LEVEL_INFO, ((void *)0),
"Non-public channel %d, type %d.", id, c->type);
return ((void *)0);
} | undefined4 *channel_lookup(undefined8 param_1, undefined4 param_2)
{
undefined4 uVar1;
undefined4 *puVar2;
undefined8 uVar3;
puVar2 = (undefined4 *)channel_by_id(param_1, param_2);
if (puVar2 == (undefined4 *)0x0) {
puVar2 = (undefined4 *)0x0;
} else {
uVar3 = 0x100263;
uVar1 = __addvsi3(*puVar2, 0xfffffffd);
switch (uVar1) {
case 0:
case 1:
case 4:
case 7:
case 9:
case 10:
case 0xe:
case 0x11:
case 0x12:
case 0x13:
break;
default:
sshlog("channels.c", "channel_lookup", 0x127, 0, 3, 0,
"Non-public channel %d, type %d.", param_2, *puVar2, uVar3);
puVar2 = (undefined4 *)0x0;
}
}
return puVar2;
} | openssh-portable | ghidra |
int do_rm(struct sftp_conn *conn, const char *path) {
u_int status, id;
sshlog("sftp-client.c", __func__, 858, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0),
"Sending SSH2_FXP_REMOVE \"%s\"", path);
id = conn->msg_id++;
send_string_request(conn, id, 13, path, strlen(path));
status = get_status(conn, id);
if (status != 0)
sshlog("sftp-client.c", __func__, 864, 0, SYSLOG_LEVEL_ERROR, ((void *)0),
"remote delete %s: %s", path, fx2txt(status));
return status == 0 ? 0 : -1;
} | long do_rm(unsigned int *a1, const char *a2) {
unsigned int v2;
unsigned int v3;
const char *v4;
unsigned int v6;
unsigned int status;
sshlog("sftp-client.c", "do_rm", 858LL, 0LL, 6LL, 0LL,
"Sending SSH2_FXP_REMOVE \"%s\"", a2);
v2 = a1[6];
a1[6] = v2 + 1;
v6 = v2;
v3 = strlen(a2);
send_string_request((long)a1, v6, 0xDu, (long)a2, v3);
status = get_status(a1, v6);
if (!status)
return 0LL;
v4 = (const char *)fx2txt(status);
sshlog("sftp-client.c", "do_rm", 864LL, 0LL, 2LL, 0LL, "remote delete %s: %s",
a2, v4);
return 0xFFFFFFFFLL;
} | openssh-portable | ida |
void do_setusercontext(struct passwd *pw) {
char uidstr[32], *chroot_path, *tmp;
platform_setusercontext(pw);
if (platform_privileged_uidswap()) {
if (setlogin(pw->pw_name) < 0)
sshlog("session.c", __func__, 1373, 0, SYSLOG_LEVEL_ERROR, ((void *)0),
"setlogin failed: %s", strerror((*__errno_location())));
if (setgid(pw->pw_gid) < 0) {
perror("setgid");
exit(1);
}
if (initgroups(pw->pw_name, pw->pw_gid) < 0) {
perror("initgroups");
exit(1);
}
endgrent();
platform_setusercontext_post_groups(pw);
if (!in_chroot && options.chroot_directory != ((void *)0) &&
strcasecmp(options.chroot_directory, "none") != 0) {
tmp = tilde_expand_filename(options.chroot_directory, pw->pw_uid);
snprintf(uidstr, sizeof(uidstr), "%llu", (unsigned long long)pw->pw_uid);
chroot_path = percent_expand(tmp, "h", pw->pw_dir, "u", pw->pw_name, "U",
uidstr, (char *)((void *)0));
safely_chroot(chroot_path, pw->pw_uid);
free(tmp);
free(chroot_path);
free(options.chroot_directory);
options.chroot_directory = ((void *)0);
in_chroot = 1;
}
permanently_set_uid(pw);
} else if (options.chroot_directory != ((void *)0) &&
strcasecmp(options.chroot_directory, "none") != 0) {
sshfatal("session.c", __func__, 1433, 0, SYSLOG_LEVEL_FATAL, ((void *)0),
"server lacks privileges to chroot to ChrootDirectory");
}
if (getuid() != pw->pw_uid || geteuid() != pw->pw_uid)
sshfatal("session.c", __func__, 1437, 0, SYSLOG_LEVEL_FATAL, ((void *)0),
"Failed to set uids to %u.", (u_int)pw->pw_uid);
} | void do_setusercontext(struct_0 *a0, unsigned long long a1,
unsigned long long a2, unsigned long long a3,
unsigned long long a4, unsigned long long a5) {
void *v0;
void *v1;
void *v2;
char v3;
unsigned long long v4;
unsigned long v5;
char v6;
unsigned long long *v8;
unsigned long long v9;
platform_setusercontext(a0);
if (platform_privileged_uidswap(a0, a1, a2, a3, a4, a5, *(&v6))) {
if (setlogin(a0->field_0) < 0) {
v0 = strerror(*(__errno_location()));
sshlog("session.c", "do_setusercontext", 0x55d, 0x0, 0x2, 0x0);
}
if (setgid(a0->field_14) < 0) {
perror("setgid");
exit(0x1);
}
if (initgroups(a0->field_0, a0->field_14) < 0) {
perror("initgroups");
exit(0x1);
}
endgrent();
platform_setusercontext_post_groups(a0);
if (!in_chroot && g_501f00 && strcasecmp(g_501f00, "none")) {
v1 = tilde_expand_filename(g_501f00, a0->field_10, a0->field_10);
snprintf(&v3, 0x20, "%llu", a0->field_10);
v0 = 0;
v2 = percent_expand(v1, "h", a0->field_20, "u", a0->field_0, "U", &v3);
safely_chroot(v2, a0->field_10);
free(v1);
free(v2);
free(g_501f00);
g_501f00 = 0;
in_chroot = 1;
}
permanently_set_uid(a0);
} else if (g_501f00 && strcasecmp(g_501f00, "none")) {
sshfatal("session.c", "do_setusercontext", 0x599, 0x0, 0x1, 0x0);
}
if (getuid() == a0->field_10 && geteuid() == a0->field_10)
goto LABEL_4032e1;
v5 = a0->field_10;
v4 = "Failed to set uids to %u.";
sshfatal("session.c", "do_setusercontext", 0x59d, 0x0, 0x1, 0x0);
LABEL_4032e1:
v9 = v4 ^ v8[5];
return;
} | openssh-portable | angr_phoenix |
static char const *debug_strfdatetime(struct tm const *tm,
parser_control const *pc, char *buf,
int n) {
int m = nstrftime(buf, n, "(Y-M-D) %Y-%m-%d %H:%M:%S", tm, 0, 0);
if (pc && m < n && pc->zones_seen) {
int tz = pc->time_zone;
if (pc->local_zones_seen && !pc->zones_seen && 0 < pc->local_isdst)
tz += 60 * 60;
char time_zone_buf[TIME_ZONE_BUFSIZE];
snprintf(&buf[m], n - m, " TZ=%s", time_zone_str(tz, time_zone_buf));
}
return buf;
} | int debug_strfdatetime(unsigned long long a0, struct_0 *a1,
unsigned long long a2, unsigned long a3) {
char v0;
unsigned int v1;
unsigned int v2;
char v3;
v2 = nstrftime(a2, a3, "(Y-M-D) %Y-%m-%d %H:%M:%S", a0, 0x0, 0x0, *(&v0), a2,
a1);
if (a1 && v2 < a3 && a1->field_d0) {
v1 = a1->field_18;
if (a1->field_b8 && !a1->field_d0 && a1->field_14 > 0)
v1 += 3600;
snprintf(v2 + a2, a3 - v2, " TZ=%s", time_zone_str(v1, &v3));
}
return a2;
} | gnutls | angr_dream |
static SHELL_VAR *get_seconds(var)
SHELL_VAR *var;
{
time_t time_since_start;
struct timeval tv;
gettimeofday(&tv, ((void *)0));
time_since_start = tv.tv_sec - shell_start_time;
return (set_int_value(var, seconds_value_assigned + time_since_start, 1));
} | long long get_seconds(void *a0) {
unsigned long v0;
char v1;
gettimeofday(&v1, NULL);
v0 = *(&v1) - shell_start_time;
return set_int_value(a0, seconds_value_assigned + v0, 0x1);
} | bash | angr_phoenix |
static inline __u16 rta_getattr_u16(const struct rtattr *rta) {
return *(__u16 *)((
void *)(((char *)(rta)) +
((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))));
} | int rta_getattr_u16(struct_0 *a0) { return a0->field_4; } | iproute2-6.0.0 | angr_phoenix |
int sl_add(StringList *sl, char *name) {
;
if (sl->sl_cur == sl->sl_max - 1) {
char **new;
new = reallocarray(sl->sl_str, (sl->sl_max + 20), sizeof(char *));
if (new == ((void *)0))
return -1;
sl->sl_max += 20;
sl->sl_str = new;
}
sl->sl_str[sl->sl_cur++] = name;
return 0;
} | long long sl_add(unsigned long long a0[3], unsigned long a1) {
unsigned long v0;
int tmp_26;
unsigned long long v1[3];
unsigned long v2;
unsigned long long v4;
unsigned long long *v5;
v1[0] = a0;
v0 = a1;
if (a0[2] == a0[1] - 1) {
v2 = reallocarray(a0[0], a0[1] + 20, 0x8);
if (!v2) {
v4 = 4294967295;
goto LABEL_400137;
} else {
a0[1] = a0[1] + 20;
a0[0] = v2;
}
}
v5 = a0[0];
tmp_26 = a0[2];
a0[2] = a0[2] + 1;
v5[tmp_26] = v0;
v4 = 0;
LABEL_400137:
return v4;
} | libbsd-0.11.7 | angr_phoenix |
static _Bool
audit_infofile(struct pkginfo *pkg, const struct audit_problem *problem) {
if (pkg->status < PKG_STAT_HALFINSTALLED)
return 0;
return !pkg_infodb_has_file(pkg, &pkg->installed, problem->value.string);
} | long long audit_infofile(struct_0 *a0, struct_1 *a1) {
void *v1;
unsigned long long v2;
if (a0->field_18 <= 1) {
v1 = 0;
return v1;
}
v2 = pkg_infodb_has_file(a0, &a0[2].padding_0[16], a1->field_8,
&a0[2].padding_0[16]);
*(&v2) = v2;
*(&v2) = v2 ^ 1;
v1 = v2 & 1;
return v1;
} | dpkg | angr_sailr |
static inline _Bool is_addrtype_inet(const inet_prefix *p) {
return p->flags & ADDRTYPE_INET;
} | int is_addrtype_inet(unsigned short *a0) {
unsigned int v1;
v1 = *(a0) & 2;
*(&v1) = (*(a0) & 2);
return v1;
} | iproute2-6.0.0 | angr_dream |
static int _rl_vi_callback_getchar(char *mb, int mlen) {
return (_rl_bracketed_read_mbstring(mb, mlen));
} | void _rl_vi_callback_getchar(undefined8 param_1, undefined4 param_2)
{
_rl_bracketed_read_mbstring(param_1, param_2);
return;
} | bash | ghidra |
static int open_listen_match_tcpip(struct permission *allowed_open,
const char *requestedhost,
u_short requestedport, int translate) {
const char *allowed_host;
if (allowed_open->host_to_connect == ((void *)0))
return 0;
if (allowed_open->listen_port != requestedport)
return 0;
if (!translate && allowed_open->listen_host == ((void *)0) &&
requestedhost == ((void *)0))
return 1;
allowed_host = translate ? channel_rfwd_bind_host(allowed_open->listen_host)
: allowed_open->listen_host;
if (allowed_host == ((void *)0) || requestedhost == ((void *)0) ||
strcmp(allowed_host, requestedhost) != 0)
return 0;
return 1;
} | int open_listen_match_tcpip(struct_0 *a0, char *a1, unsigned long a2,
unsigned long a3) {
unsigned int v0;
unsigned int v2;
if (!a0->field_0) {
v2 = 0;
return v2;
} else if (a0->field_20 == a2) {
if (!a3 && !a0->field_10 && !a1) {
v2 = 1;
return v2;
}
if (!a3)
v2 = a0->field_10;
else
v2 = channel_rfwd_bind_host(a0->field_10);
v0 = v2;
if (!*(&v0)) {
v2 = 0;
return v2;
} else if (!a1) {
v2 = 0;
return v2;
} else if (strcmp(*(&v0), a1)) {
v2 = 0;
return v2;
} else {
v2 = 1;
return v2;
}
} else {
v2 = 0;
return v2;
}
} | openssh-portable | angr_sailr |
static void cmov_aff(ge25519_aff *r, const ge25519_aff *p, unsigned char b) {
crypto_sign_ed25519_ref_fe25519_cmov(&r->x, &p->x, b);
crypto_sign_ed25519_ref_fe25519_cmov(&r->y, &p->y, b);
} | void cmov_aff(unsigned long long a0, unsigned long long a1, unsigned long a2) {
unsigned long long v1;
crypto_sign_ed25519_ref_fe25519_cmov(a0, a1, a2, a1);
v1 = crypto_sign_ed25519_ref_fe25519_cmov(a0 + 128, a1 + 128, a2, a0 + 128);
return;
} | openssh-portable | angr_dream |
void evalbackcmd(union node *n, struct backcmd *result) {
int pip[2];
struct job *jp;
result->fd = -1;
result->buf = ((void *)0);
result->nleft = 0;
result->jp = ((void *)0);
if (n == ((void *)0)) {
goto out;
}
if (pipe(pip) < 0)
sh_error("Pipe call failed");
jp = makejob(n, 1);
if (forkshell(jp, n, 2) == 0) {
({
({ __asm__ __volatile__("" : : : "memory"); });
suppressint = 0;
if (intpending)
onint();
0;
});
close(pip[0]);
if (pip[1] != 1) {
dup2(pip[1], 1);
close(pip[1]);
}
ifsfree();
evaltreenr(n, 01);
}
close(pip[1]);
result->fd = pip[0];
result->jp = jp;
out:
;
} | long long evalbackcmd(unsigned long long a0, struct_0 *a1) {
unsigned long long v0;
char v1;
char v2;
a1->field_0 = -1;
a1->field_8 = 0;
a1->field_10 = 0;
a1->field_18 = 0;
if (!a0)
return 0;
if (pipe(&v1) < 0)
sh_error("Pipe call failed");
v0 = makejob(a0, 0x1);
if (forkshell(v0, a0, 0x2, a0)) {
close(*(&v2));
a1->field_0 = *(&v1);
a1->field_18 = v0;
return 0;
}
suppressint = 0;
if (intpending)
onint();
close(*(&v1));
if (*(&v2) != 1) {
dup2(*(&v2), 0x1);
close(*(&v2));
}
ifsfree();
evaltreenr(a0, 0x1);
} | dash-0.5.11+git20210903+057cd650a4ed | angr_sailr |
stderr
,
gettext ("%s: %s was created, but could not be removed\n"),
Prog, prefix_user_home);
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 remove %s", prefix_user_home);
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
} } while ( | void gettext(void)
{
halt_baddata();
} | shadow | ghidra |
static struct alias *freealias(struct alias *ap) {
struct alias *next;
if (ap->flag & 1) {
ap->flag |= 2;
return ap;
}
next = ap->next;
free((pointer)(ap->name));
free((pointer)(ap->val));
free((pointer)(ap));
return next;
} | int freealias(struct_0 *a0) {
unsigned long v0;
unsigned int v2;
if ((a0->field_18 & 1)) {
a0->field_18 = a0->field_18 | 2;
v2 = a0;
} else {
v0 = a0->field_0;
free(a0->field_8);
free(a0->field_10);
free(a0);
v2 = v0;
}
return v2;
} | dash-0.5.11+git20210903+057cd650a4ed | angr_dream |
static int match_link_kind(struct rtattr **tb, const char *kind, _Bool slave) {
if (!tb[IFLA_LINKINFO])
return -1;
return strcmp(parse_link_kind(tb[IFLA_LINKINFO], slave), kind);
} | int match_link_kind(struct_0 *a0, char *a1, unsigned long a2) {
unsigned int v1;
if (!a0->field_90) {
v1 = -1;
return v1;
}
v1 = strcmp(parse_link_kind(a0->field_90, a2), a1);
return v1;
} | iproute2-6.0.0 | angr_sailr |
static void new_pwent(struct passwd *pwent) {
if (lflg) {
if (pw_locate(user_newname) != ((void *)0)) {
fprintf(stderr, gettext("%s: user '%s' already exists in %s\n"), Prog,
user_newname, pw_dbname());
fail_exit(9);
}
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(6, "change user name '%s' to '%s'", pwent->pw_name, user_newname);
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0)
;
pwent->pw_name = xstrdup(user_newname);
}
if ((!is_shadow_pwd) || (strcmp(pwent->pw_passwd, "x") != 0)) {
pwent->pw_passwd = new_pw_passwd(pwent->pw_passwd);
}
if (uflg) {
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(6, "change user '%s' UID from '%d' to '%d'", pwent->pw_name,
pwent->pw_uid, user_newid);
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0)
;
pwent->pw_uid = user_newid;
}
if (gflg) {
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(6, "change user '%s' GID from '%d' to '%d'", pwent->pw_name,
pwent->pw_gid, user_newgid);
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0)
;
pwent->pw_gid = user_newgid;
}
if (cflg) {
pwent->pw_gecos = user_newcomment;
}
if (dflg) {
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(6, "change user '%s' home from '%s' to '%s'", pwent->pw_name,
pwent->pw_dir, user_newhome);
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0)
;
if (strlen(user_newhome) > 1 &&
'/' == user_newhome[strlen(user_newhome) - 1]) {
user_newhome[strlen(user_newhome) - 1] = '\0';
}
pwent->pw_dir = user_newhome;
}
if (sflg) {
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(6, "change user '%s' shell from '%s' to '%s'", pwent->pw_name,
pwent->pw_shell, user_newshell);
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0)
;
pwent->pw_shell = user_newshell;
}
} | void new_pwent(undefined8 *param_1)
{
char *pcVar1;
undefined8 uVar2;
int iVar3;
long lVar4;
undefined8 uVar5;
char *pcVar6;
undefined8 uVar7;
size_t sVar8;
char *local_78;
char *local_70;
char *local_68;
char *local_60;
char *local_58;
if (lflg != '\0') {
lVar4 = pw_locate(user_newname);
if (lVar4 != 0) {
uVar5 = pw_dbname();
uVar2 = Prog;
uVar7 = user_newname;
pcVar6 = (char *)gettext("%s: user \'%s\' already exists in %s\n");
fprintf(stderr, pcVar6, uVar2, uVar7, uVar5);
fail_exit(9);
}
pcVar6 = setlocale(6, (char *)0x0);
local_78 = (char *)0x0;
if (pcVar6 != (char *)0x0) {
local_78 = strdup(pcVar6);
}
if (local_78 != (char *)0x0) {
setlocale(6, "C");
}
syslog(6, "change user name \'%s\' to \'%s\'", *param_1, user_newname);
if (local_78 != (char *)0x0) {
setlocale(6, local_78);
free(local_78);
}
uVar7 = xstrdup(user_newname);
*param_1 = uVar7;
}
if (is_shadow_pwd == '\x01') {
iVar3 = strcmp((char *)param_1[1], "x");
if (iVar3 == 0)
goto LAB_00100b0c;
}
uVar7 = new_pw_passwd(param_1[1]);
param_1[1] = uVar7;
LAB_00100b0c:
if (uflg != '\0') {
pcVar6 = setlocale(6, (char *)0x0);
local_70 = (char *)0x0;
if (pcVar6 != (char *)0x0) {
local_70 = strdup(pcVar6);
}
if (local_70 != (char *)0x0) {
setlocale(6, "C");
}
syslog(6, "change user \'%s\' UID from \'%d\' to \'%d\'", *param_1,
(ulong) * (uint *)(param_1 + 2), (ulong)user_newid);
if (local_70 != (char *)0x0) {
setlocale(6, local_70);
free(local_70);
}
*(uint *)(param_1 + 2) = user_newid;
}
if (gflg != '\0') {
pcVar6 = setlocale(6, (char *)0x0);
local_68 = (char *)0x0;
if (pcVar6 != (char *)0x0) {
local_68 = strdup(pcVar6);
}
if (local_68 != (char *)0x0) {
setlocale(6, "C");
}
syslog(6, "change user \'%s\' GID from \'%d\' to \'%d\'", *param_1,
(ulong) * (uint *)((long)param_1 + 0x14), (ulong)user_newgid);
if (local_68 != (char *)0x0) {
setlocale(6, local_68);
free(local_68);
}
*(uint *)((long)param_1 + 0x14) = user_newgid;
}
if (cflg != '\0') {
param_1[3] = user_newcomment;
}
if (dflg != '\0') {
pcVar6 = setlocale(6, (char *)0x0);
local_60 = (char *)0x0;
if (pcVar6 != (char *)0x0) {
local_60 = strdup(pcVar6);
}
if (local_60 != (char *)0x0) {
setlocale(6, "C");
}
syslog(6, "change user \'%s\' home from \'%s\' to \'%s\'", *param_1,
param_1[4], user_newhome);
if (local_60 != (char *)0x0) {
setlocale(6, local_60);
free(local_60);
}
sVar8 = strlen(user_newhome);
pcVar6 = user_newhome;
if (1 < sVar8) {
sVar8 = strlen(user_newhome);
pcVar1 = user_newhome;
if (pcVar6[sVar8 - 1] == '/') {
sVar8 = strlen(user_newhome);
pcVar1[sVar8 - 1] = '\0';
}
}
param_1[4] = user_newhome;
}
if (sflg != '\0') {
pcVar6 = setlocale(6, (char *)0x0);
local_58 = (char *)0x0;
if (pcVar6 != (char *)0x0) {
local_58 = strdup(pcVar6);
}
if (local_58 != (char *)0x0) {
setlocale(6, "C");
}
syslog(6, "change user \'%s\' shell from \'%s\' to \'%s\'", *param_1,
param_1[5], user_newshell);
if (local_58 != (char *)0x0) {
setlocale(6, local_58);
free(local_58);
}
param_1[5] = user_newshell;
}
return;
} | shadow | ghidra |
enum dump_status sparse_skip_file(struct tar_stat_info *st) {
_Bool rc = 1;
struct tar_sparse_file file;
if (!tar_sparse_init(&file))
return dump_status_not_implemented;
file.stat_info = st;
file.fd = -1;
rc = tar_sparse_decode_header(&file);
skip_file(file.stat_info->archive_file_size - file.dumped_size);
return (tar_sparse_done(&file) && rc) ? dump_status_ok : dump_status_short;
} | long long sparse_skip_file(struct_0 *a0) {
char v0;
unsigned int v1;
char v2;
unsigned long long v5;
unsigned long long v6;
v0 = 1;
if ((tar_sparse_init(&v1) ^ 1)) {
v5 = 3;
} else {
v1 = -1;
v0 = tar_sparse_decode_header(&v1);
skip_file(a0->field_118 - *(&v2));
v6 = tar_sparse_done(&v1);
if (v6 && v0)
v5 = 0;
if (!v0 || !v6)
v5 = 1;
}
return v5;
} | tar | angr_dream |
void sv_optind(name) char *name;
{
SHELL_VAR *var;
char *tt;
int s;
var = find_variable("OPTIND");
tt = var ? get_variable_value(var) : (char *)((void *)0);
if (tt && *tt) {
s = atoi(tt);
if (s < 0 || s == 1)
s = 0;
} else
s = 0;
getopts_reset(s);
} | long long sv_optind(unsigned long a0) {
unsigned long v0;
unsigned int v1;
void *v2;
void *v3;
void *v5;
v0 = a0;
v2 = find_variable("OPTIND");
if (v2)
v5 = get_variable_value(v2);
else
v5 = 0;
v3 = v5;
if (v3 && *(v3)) {
v1 = atoi(v3);
if (v1 < 0 || v1 == 1)
v1 = 0;
}
if (!v3 || !*(v3))
v1 = 0;
return getopts_reset(v1);
} | bash | angr_dream |
static void ssh_tun_confirm(struct ssh *ssh, int id, int success, void *arg) {
if (!success) {
sshlog("ssh.c", __func__, 1862, 0, SYSLOG_LEVEL_ERROR, ((void *)0),
"Tunnel forwarding failed");
if (options.exit_on_forward_failure)
cleanup_exit(255);
}
sshlog("ssh.c", __func__, 1867, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0),
"tunnel forward established, id=%d", id);
forwarding_success();
} | long long ssh_tun_confirm(unsigned long a0, unsigned long a1, unsigned long a2,
unsigned long a3) {
char v0;
unsigned long v1;
unsigned long v2;
v2 = a0;
v1 = a3;
if (!a2) {
sshlog("ssh.c", "ssh_tun_confirm", 0x746, 0x0, 0x2, 0x0,
"Tunnel forwarding failed", *(&v0));
cleanup_exit(0xff);
}
sshlog("ssh.c", "ssh_tun_confirm", 0x74b, 0x1, 0x5, 0x0,
"tunnel forward established, id=%d", a1);
return forwarding_success();
} | openssh-portable | angr_sailr |
static void print_pkcs7_sig_info(gnutls_pkcs7_signature_info_st *info,
common_info_st *cinfo) {
int ret;
gnutls_datum_t str;
ret = gnutls_pkcs7_print_signature_info(info, GNUTLS_CRT_PRINT_COMPACT, &str);
if (ret < 0) {
fprintf(stderr, "printing error: %s\n", gnutls_strerror(ret));
app_exit(1);
}
fprintf(outfile, "%s", str.data);
gnutls_free((void *)(str.data)), str.data = ((void *)0);
} | void print_pkcs7_sig_info(unsigned long long a0, unsigned long a1) {
unsigned long v0;
unsigned int v1;
char v2;
char v3;
unsigned long long *v5;
unsigned long long v6;
v0 = a1;
v1 = gnutls_pkcs7_print_signature_info(a0, 0x3, &v2);
if (v1 < 0) {
fprintf(stderr, "printing error: %s\n", gnutls_strerror(v1));
app_exit(0x1);
}
fprintf(outfile, "%s", *(&v2));
*(5243720)(*(&v2));
v2 = 0;
v6 = *(&v3) ^ v5[5];
return;
} | gnutls | angr_phoenix |
static void sshsk_free(struct sshsk_provider *p) {
if (p == ((void *)0))
return;
free(p->path);
if (p->dlhandle != ((void *)0))
dlclose(p->dlhandle);
free(p);
} | void sshsk_free(unsigned long long a0[2]) {
unsigned long long v1;
if (a0) {
free(a0[0]);
if (a0[1])
dlclose(a0[1]);
v1 = free(a0);
}
return;
} | openssh-portable | angr_dream |
((*__ctype_b_loc ())[(int) ((
c
))] & (unsigned short int) _ISgraph)
) {
*cp = c;
*astate = (((uint32_t)(0) << 24) | (0));
return 1;
} | ushort **__ctype_b_loc(void)
{
halt_baddata();
} | libedit | ghidra |
static inline _Bool is_addrtype_inet(const inet_prefix *p) {
return p->flags & ADDRTYPE_INET;
} | bool is_addrtype_inet(ushort *param_1)
{
return (*param_1 & 2) != 0;
} | iproute2-6.0.0 | ghidra |
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(int argc, const char **argv, const char **envp) {
long v3;
long v4;
char *v5;
long v6;
long v7;
char *v8;
long v9;
long v10;
char *v11;
long v12;
long v13;
char *v14;
long v15;
long v16;
long v17;
char *v18;
long v19;
long v20;
long v21;
long v22;
long v23;
char *v24;
const char *v25;
long v26;
long v27;
long v28;
long v29;
char *v30;
long v31;
long v32;
char *v33;
const char *v34;
long v35;
long v36;
char *v37;
const char *v38;
long v39;
long v40;
char *v41;
const char *v42;
long v43;
long v44;
char *v45;
const char *v46;
char *locale;
char *v49;
char *v50;
char *v51;
long *v52;
long *v53;
long v54;
const char *v55;
const char *v56;
const char *v57;
const char *v58;
long v59;
const char *v60;
long v61;
long v62;
long s[10];
s[5] = __readfsqword(0x28u);
Prog = Basename(*argv, argv, envp);
log_set_progname(Prog);
log_set_logfd(stderr);
setlocale(6, &byte_C78);
bindtextdomain("shadow", "/usr/share/locale");
textdomain("shadow");
process_root_flag("-R", (unsigned int)argc, argv);
openlog("grpconv", 1, 80);
process_flags(argc, (char *const *)argv);
if (!(unsigned int)gr_lock()) {
v3 = gr_dbname();
v4 = Prog;
v5 = gettext("%s: cannot lock %s; try again later.\n");
fprintf(stderr, v5, v4, v3);
fail_exit(5);
}
gr_locked = 1;
if (!(unsigned int)gr_open(66LL)) {
v6 = gr_dbname();
v7 = Prog;
v8 = gettext("%s: cannot open %s\n");
fprintf(stderr, v8, v7, v6);
fail_exit(1);
}
if (!(unsigned int)sgr_lock()) {
v9 = sgr_dbname();
v10 = Prog;
v11 = gettext("%s: cannot lock %s; try again later.\n");
fprintf(stderr, v11, v10, v9);
fail_exit(5);
}
sgr_locked = 1;
if (!(unsigned int)sgr_open(66LL)) {
v12 = sgr_dbname();
v13 = Prog;
v14 = gettext("%s: cannot open %s\n");
fprintf(stderr, v14, v13, v12);
fail_exit(1);
}
LABEL_13:
sgr_rewind();
while (1) {
v52 = (long *)sgr_next();
if (!v52)
break;
if (!gr_locate(*v52)) {
if (!(unsigned int)sgr_remove(*v52)) {
v15 = sgr_dbname();
v16 = *v52;
v17 = Prog;
v18 = gettext("%s: cannot remove entry '%s' from %s\n");
fprintf(stderr, v18, v17, v16, v15);
fail_exit(3);
}
goto LABEL_13;
}
}
gr_rewind();
while (1) {
v54 = gr_next();
if (!v54)
break;
v53 = (long *)sgr_locate(*(_QWORD *)v54);
if (v53) {
v19 = v53[1];
s[0] = *v53;
s[1] = v19;
v20 = v53[3];
s[2] = v53[2];
s[3] = v20;
if (strcmp(*(const char **)(v54 + 8), "x"))
s[1] = *(_QWORD *)(v54 + 8);
} else {
memset(s, 0, 0x20uLL);
s[0] = *(_QWORD *)v54;
s[1] = *(_QWORD *)(v54 + 8);
s[2] = (long)&empty_5668;
}
s[3] = *(_QWORD *)(v54 + 24);
if (!(unsigned int)sgr_update(s)) {
v21 = s[0];
v22 = sgr_dbname();
v23 = Prog;
v24 = gettext("%s: failed to prepare the new %s entry '%s'\n");
fprintf(stderr, v24, v23, v22, v21);
fail_exit(3);
}
v25 = *(const char **)(v54 + 8);
v59 = *(_QWORD *)v54;
v60 = v25;
v26 = *(_QWORD *)(v54 + 24);
v61 = *(_QWORD *)(v54 + 16);
v62 = v26;
v60 = "x";
if (!(unsigned int)gr_update(&v59)) {
v27 = v59;
v28 = gr_dbname();
v29 = Prog;
v30 = gettext("%s: failed to prepare the new %s entry '%s'\n");
fprintf(stderr, v30, v29, v28, v27);
fail_exit(3);
}
}
if (!(unsigned int)sgr_close()) {
v31 = sgr_dbname();
v32 = Prog;
v33 = gettext("%s: failure while writing changes to %s\n");
fprintf(stderr, v33, v32, v31);
v55 = setlocale(6, 0LL);
locale = 0LL;
if (v55)
locale = strdup(v55);
if (locale)
setlocale(6, "C");
v34 = (const char *)sgr_dbname();
syslog(3, "failure while writing changes to %s", v34);
if (locale) {
setlocale(6, locale);
free(locale);
}
fail_exit(3);
}
if (!(unsigned int)gr_close()) {
v35 = gr_dbname();
v36 = Prog;
v37 = gettext("%s: failure while writing changes to %s\n");
fprintf(stderr, v37, v36, v35);
v56 = setlocale(6, 0LL);
v49 = 0LL;
if (v56)
v49 = strdup(v56);
if (v49)
setlocale(6, "C");
v38 = (const char *)gr_dbname();
syslog(3, "failure while writing changes to %s", v38);
if (v49) {
setlocale(6, v49);
free(v49);
}
fail_exit(3);
}
if (!(unsigned int)sgr_unlock()) {
v39 = sgr_dbname();
v40 = Prog;
v41 = gettext("%s: failed to unlock %s\n");
fprintf(stderr, v41, v40, v39);
v57 = setlocale(6, 0LL);
v50 = 0LL;
if (v57)
v50 = strdup(v57);
if (v50)
setlocale(6, "C");
v42 = (const char *)sgr_dbname();
syslog(3, "failed to unlock %s", v42);
if (v50) {
setlocale(6, v50);
free(v50);
}
}
if (!(unsigned int)gr_unlock()) {
v43 = gr_dbname();
v44 = Prog;
v45 = gettext("%s: failed to unlock %s\n");
fprintf(stderr, v45, v44, v43);
v58 = setlocale(6, 0LL);
v51 = 0LL;
if (v58)
v51 = strdup(v58);
if (v51)
setlocale(6, "C");
v46 = (const char *)gr_dbname();
syslog(3, "failed to unlock %s", v46);
if (v51) {
setlocale(6, v51);
free(v51);
}
}
nscd_flush_cache("group");
sssd_flush_cache(2LL);
return 0;
} | shadow | ida |
static char *isolate_tilde_prefix(const char *fname, int *lenp) {
char *ret;
int i;
ret = (char *)sh_xmalloc((strlen(fname)), "tilde.c", 271);
for (i = 1; fname[i] && fname[i] != '/'; i++)
ret[i - 1] = fname[i];
ret[i - 1] = '\0';
if (lenp)
*lenp = i;
return ret;
} | long isolate_tilde_prefix(char *param_1, int *param_2)
{
size_t sVar1;
long lVar2;
int local_14;
sVar1 = strlen(param_1);
lVar2 = sh_xmalloc(sVar1, "tilde.c", 0x10f);
for (local_14 = 1; (param_1[local_14] != '\0' && (param_1[local_14] != '/'));
local_14 = local_14 + 1) {
*(char *)(lVar2 + (long)local_14 + -1) = param_1[local_14];
}
*(undefined *)(lVar2 + (long)local_14 + -1) = 0;
if (param_2 != (int *)0x0) {
*param_2 = local_14;
}
return lVar2;
} | bash | ghidra |
static _Bool
tar_sparse_member_p(struct tar_sparse_file *file) {
if (file->optab->sparse_member_p)
return file->optab->sparse_member_p(file);
return 0;
} | long tar_sparse_member_p(long a1) {
if (*(_QWORD *)(*(_QWORD *)(a1 + 32) + 16LL))
return (*(long (**)(long))(*(_QWORD *)(a1 + 32) + 16LL))(a1);
else
return 0LL;
} | tar | ida |
int main(int argc, char **argv) {
int optc_status;
int prev_optc_status = MUST_BE_OPERAND;
int operand_status[2];
int joption_count[2] = {0, 0};
FILE *fp1, *fp2;
int optc;
int nfiles = 0;
int i;
;
set_program_name(argv[0]);
setlocale(6, "");
bindtextdomain("coreutils", "/usr/local/share/locale");
textdomain("coreutils");
hard_LC_COLLATE = hard_locale(3);
atexit(close_stdout);
atexit(free_spareline);
print_pairables = 1;
seen_unpairable = 0;
issued_disorder_warning[0] = issued_disorder_warning[1] = 0;
check_input_order = CHECK_ORDER_DEFAULT;
while ((optc = getopt_long(argc, argv, "-a:e:i1:2:j:o:t:v:z", longopts,
((void *)0))) != -1) {
optc_status = MUST_BE_OPERAND;
switch (optc) {
case 'v':
print_pairables = 0;
__attribute__((__fallthrough__));
case 'a': {
unsigned long int val;
if (xstrtoul(optarg, ((void *)0), 10, &val, "") != LONGINT_OK ||
(val != 1 && val != 2))
((!!sizeof(struct {
_Static_assert(1, "verify_expr ("
"1"
", "
"(error (1, 0, gettext (\"invalid field number: "
"%s\"), quote (optarg)), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, 0, gettext("invalid field number: %s"),
quote(optarg)),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, 0, gettext("invalid field number: %s"),
quote(optarg)),
((0) ? (void)0 : __builtin_unreachable()))));
if (val == 1)
print_unpairables_1 = 1;
else
print_unpairables_2 = 1;
} break;
case 'e':
if (empty_filler && !(strcmp(empty_filler, optarg) == 0))
((!!sizeof(struct {
_Static_assert(1, "verify_expr ("
"1"
", "
"(error (1, 0, gettext (\"conflicting empty-field "
"replacement strings\")), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, 0,
gettext("conflicting empty-field replacement strings")),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, 0,
gettext("conflicting empty-field replacement strings")),
((0) ? (void)0 : __builtin_unreachable()))));
empty_filler = optarg;
break;
case 'i':
ignore_case = 1;
break;
case '1':
set_join_field(&join_field_1, string_to_join_field(optarg));
break;
case '2':
set_join_field(&join_field_2, string_to_join_field(optarg));
break;
case 'j':
if ((optarg[0] == '1' || optarg[0] == '2') && !optarg[1] &&
optarg == argv[optind - 1] + 2) {
_Bool is_j2 = (optarg[0] == '2');
joption_count[is_j2]++;
optc_status = MIGHT_BE_J1_ARG + is_j2;
} else {
set_join_field(&join_field_1, string_to_join_field(optarg));
set_join_field(&join_field_2, join_field_1);
}
break;
case 'o':
if ((strcmp(optarg, "auto") == 0))
autoformat = 1;
else {
add_field_list(optarg);
optc_status = MIGHT_BE_O_ARG;
}
break;
case 't': {
unsigned char newtab = optarg[0];
if (!newtab)
newtab = '\n';
else if (optarg[1]) {
if ((strcmp(optarg, "\\0") == 0))
newtab = '\0';
else
((!!sizeof(struct {
_Static_assert(1, "verify_expr ("
"1"
", "
"(error (1, 0, gettext (\"multi-character tab "
"%s\"), quote (optarg)), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, 0, gettext("multi-character tab %s"),
quote(optarg)),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, 0, gettext("multi-character tab %s"),
quote(optarg)),
((0) ? (void)0 : __builtin_unreachable()))));
}
if (0 <= tab && tab != newtab)
((!!sizeof(struct {
_Static_assert(
1,
"verify_expr ("
"1"
", "
"(error (1, 0, gettext (\"incompatible tabs\")), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, 0, gettext("incompatible tabs")),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, 0, gettext("incompatible tabs")),
((0) ? (void)0 : __builtin_unreachable()))));
tab = newtab;
} break;
case 'z':
eolchar = 0;
break;
case NOCHECK_ORDER_OPTION:
check_input_order = CHECK_ORDER_DISABLED;
break;
case CHECK_ORDER_OPTION:
check_input_order = CHECK_ORDER_ENABLED;
break;
case 1:
add_file_name(optarg, g_names, operand_status, joption_count, &nfiles,
&prev_optc_status, &optc_status);
break;
case HEADER_LINE_OPTION:
join_header_lines = 1;
break;
case GETOPT_HELP_CHAR:
usage(0);
break;
;
case GETOPT_VERSION_CHAR:
version_etc(stdout, "join", "GNU coreutils", Version, ("Mike Haertel"),
(char *)((void *)0));
exit(0);
break;
;
default:
usage(1);
}
prev_optc_status = optc_status;
}
prev_optc_status = MUST_BE_OPERAND;
while (optind < argc)
add_file_name(argv[optind++], g_names, operand_status, joption_count,
&nfiles, &prev_optc_status, &optc_status);
if (nfiles != 2) {
if (nfiles == 0)
error(0, 0, gettext("missing operand"));
else
error(0, 0, gettext("missing operand after %s"), quote(argv[argc - 1]));
usage(1);
}
for (i = 0; i < 2; i++)
if (joption_count[i] != 0) {
set_join_field(&join_field_1, i);
set_join_field(&join_field_2, i);
}
if (join_field_1 == (18446744073709551615UL))
join_field_1 = 0;
if (join_field_2 == (18446744073709551615UL))
join_field_2 = 0;
fp1 = (strcmp(g_names[0], "-") == 0) ? stdin : fopen_safer(g_names[0], "r");
if (!fp1)
((!!sizeof(struct {
_Static_assert(
1,
"verify_expr ("
"1"
", "
"(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon "
"(0, shell_escape_quoting_style, g_names[0])), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, (*__errno_location()), "%s",
quotearg_n_style_colon(0, shell_escape_quoting_style,
g_names[0])),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, (*__errno_location()), "%s",
quotearg_n_style_colon(0, shell_escape_quoting_style,
g_names[0])),
((0) ? (void)0 : __builtin_unreachable()))));
fp2 = (strcmp(g_names[1], "-") == 0) ? stdin : fopen_safer(g_names[1], "r");
if (!fp2)
((!!sizeof(struct {
_Static_assert(
1,
"verify_expr ("
"1"
", "
"(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon "
"(0, shell_escape_quoting_style, g_names[1])), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, (*__errno_location()), "%s",
quotearg_n_style_colon(0, shell_escape_quoting_style,
g_names[1])),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, (*__errno_location()), "%s",
quotearg_n_style_colon(0, shell_escape_quoting_style,
g_names[1])),
((0) ? (void)0 : __builtin_unreachable()))));
if (fp1 == fp2)
((!!sizeof(struct {
_Static_assert(1, "verify_expr ("
"1"
", "
"(error (1, (*__errno_location ()), gettext (\"both "
"files cannot be standard input\")), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, (*__errno_location()),
gettext("both files cannot be standard input")),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, (*__errno_location()),
gettext("both files cannot be standard input")),
((0) ? (void)0 : __builtin_unreachable()))));
system_join(fp1, fp2);
if (rpl_fclose(fp1) != 0)
((!!sizeof(struct {
_Static_assert(
1,
"verify_expr ("
"1"
", "
"(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon "
"(0, shell_escape_quoting_style, g_names[0])), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, (*__errno_location()), "%s",
quotearg_n_style_colon(0, shell_escape_quoting_style,
g_names[0])),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, (*__errno_location()), "%s",
quotearg_n_style_colon(0, shell_escape_quoting_style,
g_names[0])),
((0) ? (void)0 : __builtin_unreachable()))));
if (rpl_fclose(fp2) != 0)
((!!sizeof(struct {
_Static_assert(
1,
"verify_expr ("
"1"
", "
"(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon "
"(0, shell_escape_quoting_style, g_names[1])), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, (*__errno_location()), "%s",
quotearg_n_style_colon(0, shell_escape_quoting_style,
g_names[1])),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, (*__errno_location()), "%s",
quotearg_n_style_colon(0, shell_escape_quoting_style,
g_names[1])),
((0) ? (void)0 : __builtin_unreachable()))));
if (issued_disorder_warning[0] || issued_disorder_warning[1])
((!!sizeof(struct {
_Static_assert(1, "verify_expr ("
"1"
", "
"(error (1, 0, gettext (\"input is not in sorted "
"order\")), assume (false))"
")");
int _gl_dummy;
}))
? ((error(1, 0, gettext("input is not in sorted order")),
((0) ? (void)0 : __builtin_unreachable())))
: ((error(1, 0, gettext("input is not in sorted order")),
((0) ? (void)0 : __builtin_unreachable()))));
else
return 0;
} | undefined8 main(int param_1, undefined8 *param_2)
{
byte bVar1;
uint uVar2;
int iVar3;
long lVar4;
undefined8 uVar5;
int *piVar6;
long in_FS_OFFSET;
undefined8 uVar7;
byte local_5e;
int local_5c;
int local_58;
int local_54;
int local_50;
int local_4c;
long local_48;
long local_40;
long local_38;
undefined local_30[8];
int local_28[2];
long local_20;
local_20 = *(long *)(in_FS_OFFSET + 0x28);
local_58 = 0;
local_28[0] = 0;
local_28[1] = 0;
local_54 = 0;
set_program_name(*param_2);
setlocale(6, "");
bindtextdomain("coreutils", "/usr/local/share/locale");
textdomain("coreutils");
hard_LC_COLLATE = hard_locale(3);
atexit(p_Ram0000000000101ef8);
atexit(free_spareline);
print_pairables = 1;
seen_unpairable = 0;
issued_disorder_warning._1_1_ = '\0';
issued_disorder_warning._0_1_ = '\0';
check_input_order = 0;
do {
uVar7 = 0x1023cf;
local_4c =
getopt_long(param_1, param_2, "-a:e:i1:2:j:o:t:v:z", longopts, 0);
if (local_4c == -1) {
local_58 = 0;
while (optind < param_1) {
lVar4 = (long)optind;
optind = optind + 1;
add_file_name(param_2[lVar4], g_names, local_30, local_28, &local_54,
&local_58, &local_5c, uVar7);
}
if (local_54 != 2) {
if (local_54 == 0) {
uVar7 = gettext("missing operand");
error(0, 0, uVar7);
} else {
uVar7 = quote(param_2[(long)param_1 + -1]);
uVar5 = gettext("missing operand after %s");
error(0, 0, uVar5, uVar7);
}
usage(1);
}
for (local_50 = 0; local_50 < 2; local_50 = local_50 + 1) {
if (local_28[local_50] != 0) {
set_join_field(&join_field_1, (long)local_50);
set_join_field(&join_field_2, (long)local_50);
}
}
if (join_field_1 == -1) {
join_field_1 = 0;
}
if (join_field_2 == -1) {
join_field_2 = 0;
}
iVar3 = strcmp(g_names._0_8_, "-");
local_40 = stdin;
if (iVar3 != 0) {
local_40 = fopen_safer(g_names._0_8_, &DAT_00103581);
}
if (local_40 == 0) {
uVar7 = quotearg_n_style_colon(0, 3, g_names._0_8_);
piVar6 = __errno_location();
error(1, *piVar6, &DAT_00103583, uVar7);
}
iVar3 = strcmp(g_names._8_8_, "-");
local_38 = stdin;
if (iVar3 != 0) {
local_38 = fopen_safer(g_names._8_8_, &DAT_00103581);
}
if (local_38 == 0) {
uVar7 = quotearg_n_style_colon(0, 3, g_names._8_8_);
piVar6 = __errno_location();
error(1, *piVar6, &DAT_00103583, uVar7);
}
if (local_40 == local_38) {
uVar7 = gettext("both files cannot be standard input");
piVar6 = __errno_location();
error(1, *piVar6, uVar7);
}
system_join(local_40, local_38);
iVar3 = rpl_fclose(local_40);
if (iVar3 != 0) {
uVar7 = quotearg_n_style_colon(0, 3, g_names._0_8_);
piVar6 = __errno_location();
error(1, *piVar6, &DAT_00103583, uVar7);
}
iVar3 = rpl_fclose(local_38);
if (iVar3 != 0) {
uVar7 = quotearg_n_style_colon(0, 3, g_names._8_8_);
piVar6 = __errno_location();
error(1, *piVar6, &DAT_00103583, uVar7);
}
if (((char)issued_disorder_warning != '\0') ||
(issued_disorder_warning._1_1_ != '\0')) {
uVar7 = gettext("input is not in sorted order");
error(1, 0, uVar7);
}
if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) {
__stack_chk_fail();
}
return 0;
}
local_5c = 0;
if (local_4c < 0x83) {
if (local_4c < 0x31) {
if (local_4c != 1) {
if (local_4c < 2) {
if (local_4c == -0x83) {
LAB_0010235a:
version_etc(stdout, &DAT_001033a2, "GNU coreutils", Version,
"Mike Haertel", 0);
exit(0);
}
if (local_4c == -0x82) {
usage(0);
goto LAB_0010235a;
}
}
goto switchD_00101fb9_caseD_33;
}
add_file_name(optarg, g_names, local_30, local_28, &local_54, &local_58,
&local_5c, uVar7);
} else {
switch (local_4c) {
case 0x31:
uVar7 = string_to_join_field(optarg);
set_join_field(&join_field_1, uVar7);
break;
case 0x32:
uVar7 = string_to_join_field(optarg);
set_join_field(&join_field_2, uVar7);
break;
default:
goto switchD_00101fb9_caseD_33;
case 0x65:
if ((empty_filler != (byte *)0x0) &&
(iVar3 = strcmp((char *)empty_filler, (char *)optarg),
iVar3 != 0)) {
uVar7 = gettext("conflicting empty-field replacement strings");
error(1, 0, uVar7);
}
empty_filler = optarg;
break;
case 0x69:
ignore_case = 1;
break;
case 0x6a:
if ((((*optarg == 0x31) || (*optarg == 0x32)) && (optarg[1] == 0)) &&
((byte *)(param_2[(long)optind + -1] + 2) == optarg)) {
bVar1 = *optarg;
uVar2 = (uint)(bVar1 == 0x32);
local_28[(int)uVar2] = local_28[(int)uVar2] + 1;
local_5c = (bVar1 == 0x32) + 1;
} else {
uVar7 = string_to_join_field(optarg);
set_join_field(&join_field_1, uVar7);
set_join_field(&join_field_2, join_field_1);
}
break;
case 0x6f:
iVar3 = strcmp((char *)optarg, "auto");
if (iVar3 == 0) {
autoformat = 1;
} else {
add_field_list();
local_5c = 3;
}
break;
case 0x74:
local_5e = *optarg;
if (local_5e == 0) {
local_5e = 10;
} else if (optarg[1] != 0) {
iVar3 = strcmp((char *)optarg, "\\0");
if (iVar3 == 0) {
local_5e = 0;
} else {
uVar7 = quote(optarg);
uVar5 = gettext("multi-character tab %s");
error(1, 0, uVar5, uVar7);
}
}
if ((-1 < (int)tab) && (local_5e != tab)) {
uVar7 = gettext("incompatible tabs");
error(1, 0, uVar7);
}
tab = (uint)local_5e;
break;
case 0x76:
print_pairables = 0;
case 0x61:
iVar3 = xstrtoul(optarg, 0, 10, &local_48, &DAT_001029ab);
if ((iVar3 != 0) || ((local_48 != 1 && (local_48 != 2)))) {
uVar7 = quote(optarg);
uVar5 = gettext("invalid field number: %s");
error(1, 0, uVar5, uVar7);
}
if (local_48 == 1) {
print_unpairables_1 = 1;
} else {
print_unpairables_2 = 1;
}
break;
case 0x7a:
eolchar = 0;
break;
case 0x80:
check_input_order = 1;
break;
case 0x81:
check_input_order = 2;
break;
case 0x82:
join_header_lines = 1;
}
}
} else {
switchD_00101fb9_caseD_33:
usage();
}
local_58 = local_5c;
} while (true);
} | coreutils | ghidra |
int add_history(const char *line) {
HistEvent ev;
if (h == ((void *)0) || e == ((void *)0))
rl_initialize();
if (history(h, &ev, 10, line) == -1)
return 0;
(void)history(h, &ev, 2);
if (ev.num == history_length)
history_base++;
else {
history_offset++;
history_length = ev.num;
}
return 0;
} | void add_history(undefined8 param_1)
{
long in_FS_OFFSET;
undefined local_28[24];
undefined8 local_10;
local_10 = *(undefined8 *)(in_FS_OFFSET + 0x28);
if ((h != 0) && (e != 0)) {
history(h, local_28, 10, param_1);
}
rl_initialize();
} | libedit | ghidra |
static void digits_to_date_time(parser_control *pc, textint text_int) {
if (pc->dates_seen && !pc->year.digits && !pc->rels_seen &&
(pc->times_seen || 2 < text_int.digits)) {
pc->year_seen = 1;
pc->year = text_int;
} else {
if (4 < text_int.digits) {
pc->dates_seen++;
pc->day = text_int.value % 100;
pc->month = (text_int.value / 100) % 100;
pc->year.value = text_int.value / 10000;
pc->year.digits = text_int.digits - 4;
} else {
pc->times_seen++;
if (text_int.digits <= 2) {
pc->hour = text_int.value;
pc->minutes = 0;
} else {
pc->hour = text_int.value / 100;
pc->minutes = text_int.value % 100;
}
pc->seconds.tv_sec = 0;
pc->seconds.tv_nsec = 0;
pc->meridian = MER24;
}
}
} | long digits_to_date_time(long a1, long a2, long a3, long a4, long a5, long a6,
long a7, long a8, long a9) {
long result;
if (*(_QWORD *)(a1 + 168) && !*(_QWORD *)(a1 + 48) &&
*(_BYTE *)(a1 + 161) != 1 && (*(_QWORD *)(a1 + 200) || a9 > 2)) {
*(_BYTE *)(a1 + 216) = 1;
*(_QWORD *)(a1 + 32) = a7;
*(_QWORD *)(a1 + 40) = a8;
result = a9;
*(_QWORD *)(a1 + 48) = a9;
} else if (a9 <= 4) {
++*(_QWORD *)(a1 + 200);
if (a9 > 2) {
*(_QWORD *)(a1 + 72) = a8 / 100;
*(_QWORD *)(a1 + 80) = a8 % 100;
} else {
*(_QWORD *)(a1 + 72) = a8;
*(_QWORD *)(a1 + 80) = 0LL;
}
*(_QWORD *)(a1 + 88) = 0LL;
*(_QWORD *)(a1 + 96) = 0LL;
result = a1;
*(_DWORD *)(a1 + 28) = 2;
} else {
++*(_QWORD *)(a1 + 168);
*(_QWORD *)(a1 + 64) = a8 % 100;
*(_QWORD *)(a1 + 56) = a8 / 100 % 100;
*(_QWORD *)(a1 + 40) = a8 / 10000;
result = a1;
*(_QWORD *)(a1 + 48) = a9 - 4;
}
return result;
} | gnutls | ida |
int ssh_update_card(int sock, int add, const char *reader_id, const char *pin,
u_int life, u_int confirm,
struct dest_constraint **dest_constraints,
size_t ndest_constraints) {
struct sshbuf *msg;
int r, constrained = (life || confirm);
u_char type;
if (add) {
type = constrained ? 26 : 20;
} else
type = 21;
if ((msg = sshbuf_new()) == ((void *)0))
return -2;
if ((r = sshbuf_put_u8(msg, type)) != 0 ||
(r = sshbuf_put_cstring(msg, reader_id)) != 0 ||
(r = sshbuf_put_cstring(msg, pin)) != 0)
goto out;
if (constrained &&
(r = encode_constraints(msg, life, confirm, 0, ((void *)0),
dest_constraints, ndest_constraints)) != 0)
goto out;
if ((r = ssh_request_reply_decode(sock, msg)) != 0)
goto out;
r = 0;
out:
sshbuf_free(msg);
return r;
} | long long ssh_update_card(unsigned long a0, unsigned long a1,
unsigned long long a2, unsigned long long a3,
unsigned long a4, unsigned long a5, void *v4,
unsigned int a6) {
char v0;
unsigned int v1;
unsigned int v2;
unsigned long long v3;
unsigned int v5;
unsigned long long v6;
if (a4) {
LABEL_401540:
v5 = 1;
} else {
if (!(!a5))
goto LABEL_401540;
v5 = 0;
}
v2 = v5;
if (!a1) {
v0 = 21;
} else {
if (v2)
*(&v5) = 26;
else
*(&v5) = 20;
v0 = v5;
}
v3 = sshbuf_new();
if (!v3) {
v6 = 4294967294;
} else {
v1 = sshbuf_put_u8(v3, v0, v0);
if (!v1) {
v1 = sshbuf_put_cstring(v3, a2, a2);
if (!v1) {
v1 = sshbuf_put_cstring(v3, a3, a3);
if (!v1) {
if (v2) {
v1 = encode_constraints(v3, a4, a5, 0x0, 0x0, v4, *(&a6));
if (!(!v1))
goto LABEL_401646;
}
v1 = ssh_request_reply_decode(a0, v3);
if (!v1)
v1 = 0;
}
}
}
LABEL_401646:
sshbuf_free(v3);
v6 = v1;
}
return v6;
} | openssh-portable | angr_phoenix |
void add_local_forward(Options *options, const struct Forward *newfwd) {
struct Forward *fwd;
int i;
for (i = 0; i < options->num_local_forwards; i++) {
if (forward_equals(newfwd, options->local_forwards + i))
return;
}
options->local_forwards =
xreallocarray(options->local_forwards, options->num_local_forwards + 1,
sizeof(*options->local_forwards));
fwd = &options->local_forwards[options->num_local_forwards++];
fwd->listen_host = newfwd->listen_host;
fwd->listen_port = newfwd->listen_port;
fwd->listen_path = newfwd->listen_path;
fwd->connect_host = newfwd->connect_host;
fwd->connect_port = newfwd->connect_port;
fwd->connect_path = newfwd->connect_path;
} | void add_local_forward(struct_0 *a0, struct_1 *a1) {
unsigned int v0;
struct_1 *v1;
unsigned long long v4;
unsigned long long v5;
unsigned long long v6;
struct_1 *v7;
v0 = 0;
while (v0 >= a0->field_12e0) {
LABEL_400242:
v4 = __addvsi3(a0->field_12e0, 0x1);
a0->field_12e8 = xreallocarray(a0->field_12e8, v4, 0x38, v4);
v5 = a0->field_12e8;
v6 = a0->field_12e0;
a0->field_12e0 = __addvsi3(a0->field_12e0, 0x1);
v1 = v6 * 56 + v5;
v1->field_0 = a1->field_0;
v1->field_8 = a1->field_8;
v1->field_10 = a1->field_10;
v1->field_18 = a1->field_18;
v1->field_20 = a1->field_20;
v7 = v1;
v1->field_28 = a1->field_28;
return;
}
if (forward_equals(a1, a0->field_12e8 + v0 * 56, a0->field_12e8 + v0 * 56,
a0->field_12e8))
return;
v0 = __addvsi3(v0, 0x1);
goto LABEL_400242;
} | openssh-portable | angr_sailr |
static int dopass(int fd, struct stat const *st, char const *qname,
off_t *sizep, int type, struct randread_source *s,
unsigned long int k, unsigned long int n) {
off_t size = *sizep;
off_t offset;
time_t thresh;
time_t now = 0;
size_t lim;
size_t soff;
ssize_t ssize;
size_t page_size = getpagesize();
_Static_assert((60 * 1024) % 3 == 0, "verify ("
"PERIODIC_OUTPUT_SIZE % 3 == 0"
")");
size_t output_size = periodic_pattern(type) ? (60 * 1024) : (64 * 1024);
unsigned char *pbuf = xalignalloc(page_size, (((output_size + 2) / 3) * 3));
char pass_string[7];
_Bool write_error = 0;
_Bool other_error = 0;
char previous_offset_buf
[((2 * sizeof(uintmax_t) * 8 * 146 / 485 + 1) * (16 + 1) - 16 + 1 + 3) +
1];
char const *previous_human_offset;
_Bool try_without_directio = 0 < size && size < output_size;
if (!try_without_directio)
direct_mode(fd, 1);
if (!dorewind(fd, st)) {
error(0, (*__errno_location()), gettext("%s: cannot rewind"), qname);
other_error = 1;
goto free_pattern_mem;
}
if (type >= 0) {
lim = known(size) && size < (((output_size + 2) / 3) * 3)
? size
: (((output_size + 2) / 3) * 3);
fillpattern(type, pbuf, lim);
passname(pbuf, pass_string);
} else {
passname(0, pass_string);
}
if (n) {
error(0, 0, gettext("%s: pass %lu/%lu (%s)..."), qname, k, n, pass_string);
thresh = time(((void *)0)) + VERBOSE_UPDATE;
previous_human_offset = "";
}
offset = 0;
while (1) {
lim = output_size;
if (known(size) && size - offset < output_size) {
if (size < offset)
break;
lim = size - offset;
if (!lim)
break;
}
if (type < 0)
randread(s, pbuf, lim);
for (soff = 0; soff < lim; soff += ssize) {
ssize = write(fd, pbuf + soff, lim - soff);
if (0 < ssize)
((ssize <= lim - soff) ? (void)0 : __builtin_unreachable());
else {
if (!known(size) && (ssize == 0 || (*__errno_location()) == 28)) {
if (soff <=
((off_t)(!(!((off_t)0 < (off_t)-1))
? (off_t)-1
: ((((off_t)1 << ((sizeof(off_t) * 8) - 2)) - 1) *
2 +
1))) -
offset)
*sizep = size = offset + soff;
break;
} else {
int errnum = (*__errno_location());
char buf[(
(((((sizeof(uintmax_t) * 8) -
(!((__typeof__(uintmax_t))0 < (__typeof__(uintmax_t))-1))) *
146 +
484) /
485) +
(!((__typeof__(uintmax_t))0 < (__typeof__(uintmax_t))-1))) +
1)];
if (!try_without_directio && (*__errno_location()) == 22) {
direct_mode(fd, 0);
ssize = 0;
try_without_directio = 1;
continue;
}
error(0, errnum, gettext("%s: error writing at offset %s"), qname,
umaxtostr(offset + soff, buf));
_Static_assert((60 * 1024) % SECTOR_SIZE == 0,
"verify ("
"PERIODIC_OUTPUT_SIZE % SECTOR_SIZE == 0"
")");
_Static_assert((64 * 1024) % SECTOR_SIZE == 0,
"verify ("
"NONPERIODIC_OUTPUT_SIZE % SECTOR_SIZE == 0"
")");
if (errnum == 5 && known(size) && (soff | SECTOR_MASK) < lim) {
size_t soff1 = (soff | SECTOR_MASK) + 1;
if (lseek(fd, offset + soff1, 0) != -1) {
ssize = soff1 - soff;
write_error = 1;
continue;
}
error(0, (*__errno_location()), gettext("%s: lseek failed"), qname);
}
other_error = 1;
goto free_pattern_mem;
}
}
}
if (((off_t)(!(!((off_t)0 < (off_t)-1))
? (off_t)-1
: ((((off_t)1 << ((sizeof(off_t) * 8) - 2)) - 1) * 2 +
1))) -
offset <
soff) {
error(0, 0, gettext("%s: file too large"), qname);
other_error = 1;
goto free_pattern_mem;
}
offset += soff;
_Bool done = offset == size;
if (n && ((done && *previous_human_offset) ||
thresh <= (now = time(((void *)0))))) {
char offset_buf[((2 * sizeof(uintmax_t) * 8 * 146 / 485 + 1) * (16 + 1) -
16 + 1 + 3) +
1];
char size_buf[((2 * sizeof(uintmax_t) * 8 * 146 / 485 + 1) * (16 + 1) -
16 + 1 + 3) +
1];
int human_progress_opts =
(human_autoscale | human_SI | human_base_1024 | human_B);
char const *human_offset = human_readable(
offset, offset_buf, human_floor | human_progress_opts, 1, 1);
if (done || !(strcmp(previous_human_offset, human_offset) == 0)) {
if (!known(size))
error(0, 0, gettext("%s: pass %lu/%lu (%s)...%s"), qname, k, n,
pass_string, human_offset);
else {
uintmax_t off = offset;
int percent =
(size == 0
? 100
: (off <= ((uintmax_t)(!(!((uintmax_t)0 < (uintmax_t)-1))
? (uintmax_t)-1
: ((((uintmax_t)1
<< ((sizeof(uintmax_t) * 8) -
2)) -
1) *
2 +
1))) /
100
? off * 100 / size
: off / (size / 100)));
char const *human_size = human_readable(
size, size_buf, human_ceiling | human_progress_opts, 1, 1);
if (done)
human_offset = human_size;
error(0, 0, gettext("%s: pass %lu/%lu (%s)...%s/%s %d%%"), qname, k,
n, pass_string, human_offset, human_size, percent);
}
strcpy(previous_offset_buf, human_offset);
previous_human_offset = previous_offset_buf;
thresh = now + VERBOSE_UPDATE;
if (dosync(fd, qname) != 0) {
if ((*__errno_location()) != 5) {
other_error = 1;
goto free_pattern_mem;
}
write_error = 1;
}
}
}
}
if (dosync(fd, qname) != 0) {
if ((*__errno_location()) != 5) {
other_error = 1;
goto free_pattern_mem;
}
write_error = 1;
}
free_pattern_mem:
alignfree(pbuf);
return other_error ? -1 : write_error;
} | ulong dopass(int param_1, undefined8 param_2, undefined8 param_3,
ulong *param_4, int param_5, undefined8 param_6,
undefined8 param_7, long param_8)
{
bool bVar1;
bool bVar2;
char cVar3;
int iVar4;
undefined4 uVar5;
ulong uVar6;
long lVar7;
undefined8 uVar8;
int *piVar9;
ulong uVar10;
time_t tVar11;
__off_t _Var12;
char *pcVar13;
long in_FS_OFFSET;
bool bVar14;
undefined8 uVar15;
byte local_868;
ulong local_858;
ulong local_850;
long local_848;
time_t local_840;
ulong local_838;
ulong local_830;
long local_828;
char *local_820;
char *local_818;
undefined local_7df[7];
char local_7d8[656];
undefined local_548[656];
undefined local_2b8[664];
long local_20;
local_20 = *(long *)(in_FS_OFFSET + 0x28);
local_858 = *param_4;
local_840 = 0;
iVar4 = getpagesize();
cVar3 = periodic_pattern(param_5);
if (cVar3 == '\0') {
uVar6 = 0x10000;
} else {
uVar6 = 0xf000;
}
lVar7 = xalignalloc((long)iVar4, ((uVar6 + 2) / 3) * 3);
local_868 = 0;
bVar2 = false;
if (((long)local_858 < 1) || (uVar6 <= local_858)) {
bVar1 = false;
} else {
bVar1 = true;
}
if (!bVar1) {
direct_mode(param_1, 1);
}
cVar3 = dorewind(param_1, param_2);
if (cVar3 == '\x01') {
if (param_5 < 0) {
passname(0, local_7df);
} else {
cVar3 = known(local_858);
if ((cVar3 == '\0') ||
(uVar10 = local_858, ((uVar6 + 2) / 3) * 3 <= local_858)) {
uVar10 = ((uVar6 + 2) / 3) * 3;
}
fillpattern(param_5, lVar7, uVar10);
passname(lVar7, local_7df);
}
if (param_8 != 0) {
uVar15 = 0x100b3c;
uVar8 = gettext("%s: pass %lu/%lu (%s)...");
error(0, 0, uVar8, param_3, param_7, param_8, local_7df, uVar15);
tVar11 = time((time_t *)0x0);
local_848 = tVar11 + 5;
local_820 = "";
}
local_850 = 0;
LAB_00100ba9:
cVar3 = known();
local_838 = uVar6;
if (((cVar3 != '\0') && (local_858 - local_850 < uVar6)) &&
(((long)local_858 < (long)local_850 ||
(local_838 = local_858 - local_850, local_838 == 0)))) {
iVar4 = dosync(param_1, param_3);
if (iVar4 != 0) {
piVar9 = __errno_location();
if (*piVar9 == 5) {
local_868 = 1;
} else {
bVar2 = true;
}
}
goto LAB_0010127c;
}
if (param_5 < 0) {
randread(param_6, lVar7, local_838);
}
for (local_830 = 0; local_830 < local_838;
local_830 = local_830 + local_828) {
local_828 =
write(param_1, (void *)(lVar7 + local_830), local_838 - local_830);
if (local_828 < 1) {
cVar3 = known();
if ((cVar3 != '\x01') &&
((local_828 == 0 ||
(piVar9 = __errno_location(), *piVar9 == 0x1c)))) {
if (local_830 <= 0x7fffffffffffffff - local_850) {
local_858 = local_830 + local_850;
*param_4 = local_858;
}
break;
}
piVar9 = __errno_location();
iVar4 = *piVar9;
if ((bVar1) || (piVar9 = __errno_location(), *piVar9 != 0x16)) {
uVar8 = umaxtostr(local_850 + local_830, local_2b8);
uVar15 = gettext("%s: error writing at offset %s");
error(0, iVar4, uVar15, param_3, uVar8);
if (((iVar4 == 5) && (cVar3 = known(), cVar3 != '\0')) &&
((local_830 | 0x1ff) < local_838)) {
local_828 = (local_830 | 0x1ff) + 1;
_Var12 = lseek(param_1, local_828 + local_850, 0);
if (_Var12 != -1) {
local_828 = local_828 - local_830;
local_868 = 1;
goto LAB_00100ebb;
}
uVar8 = gettext("%s: lseek failed");
piVar9 = __errno_location();
error(0, *piVar9, uVar8, param_3);
}
bVar2 = true;
goto LAB_0010127c;
}
direct_mode(param_1, 0);
local_828 = 0;
bVar1 = true;
}
LAB_00100ebb:
}
if (local_830 <= 0x7fffffffffffffff - local_850) {
local_850 = local_830 + local_850;
bVar14 = local_850 == local_858;
if ((param_8 != 0) &&
((((bVar14 && (*local_820 != '\0')) ||
(local_840 = time((time_t *)0x0), local_848 <= local_840)) &&
((local_818 =
(char *)human_readable(local_850, local_548, 0x1b2, 1, 1),
bVar14 ||
(iVar4 = strcmp(local_820, local_818), iVar4 != 0)))))) {
cVar3 = known(local_858);
if (cVar3 == '\x01') {
if (local_858 == 0) {
uVar5 = 100;
} else if (local_850 < 0x28f5c28f5c28f5d) {
uVar5 = (undefined4)((local_850 * 100) / local_858);
} else {
uVar5 = (undefined4)(local_850 / (ulong)((long)local_858 / 100));
}
pcVar13 = (char *)human_readable(local_858, local_2b8, 0x1b0, 1, 1);
if (bVar14) {
local_818 = pcVar13;
}
uVar8 = gettext("%s: pass %lu/%lu (%s)...%s/%s %d%%");
error(0, 0, uVar8, param_3, param_7, param_8, local_7df, local_818,
pcVar13, uVar5);
} else {
uVar8 = gettext("%s: pass %lu/%lu (%s)...%s");
error(0, 0, uVar8, param_3, param_7, param_8, local_7df, local_818);
}
strcpy(local_7d8, local_818);
local_820 = local_7d8;
local_848 = local_840 + 5;
iVar4 = dosync(param_1, param_3);
if (iVar4 != 0) {
piVar9 = __errno_location();
if (*piVar9 != 5) {
bVar2 = true;
goto LAB_0010127c;
}
local_868 = 1;
}
}
goto LAB_00100ba9;
}
uVar8 = gettext("%s: file too large");
error(0, 0, uVar8, param_3);
bVar2 = true;
} else {
uVar8 = gettext("%s: cannot rewind");
piVar9 = __errno_location();
error(0, *piVar9, uVar8, param_3);
bVar2 = true;
}
LAB_0010127c:
alignfree(lVar7);
if (bVar2) {
uVar6 = 0xffffffff;
} else {
uVar6 = (ulong)local_868;
}
if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) {
return uVar6;
}
__stack_chk_fail();
} | coreutils | ghidra |
static void process_flags(int argc, char **argv) {
int c;
int bad_s;
static struct option long_options[] = {
{"crypt-method", 1, ((void *)0), 'c'}, {"encrypted", 0, ((void *)0), 'e'},
{"help", 0, ((void *)0), 'h'}, {"md5", 0, ((void *)0), 'm'},
{"root", 1, ((void *)0), 'R'},
{"sha-rounds", 1, ((void *)0), 's'},
{((void *)0), 0, ((void *)0), '\0'}};
while ((c = getopt_long(argc, argv,
"c:ehmR:s:",
long_options, ((void *)0))) != -1) {
switch (c) {
case 'c':
crypt_method = optarg;
break;
case 'e':
eflg = 1;
break;
case 'h':
usage(0);
break;
case 'm':
md5flg = 1;
break;
case 'R':
break;
case 's':
sflg = 1;
bad_s = 0;
if ((((0 == strcmp(crypt_method, "SHA256")) ||
(0 == strcmp(crypt_method, "SHA512"))) &&
(0 == getlong(optarg, &sha_rounds)))) {
bad_s = 1;
}
if (bad_s != 0) {
fprintf(stderr, gettext("%s: invalid numeric argument '%s'\n"), Prog,
optarg);
usage(2);
}
break;
default:
usage(2);
break;
}
}
check_flags();
} | void process_flags(unsigned long a0, char **a1) {
unsigned int v0;
unsigned int v1;
unsigned long long v6;
do {
while (true) {
v1 = getopt_long(a0, a1, "c:ehmR:s:", &long_options.5664, NULL);
if (v1 != -1) {
switch (v1) {
case 82:
break;
case 99:
crypt_method = *(&optarg);
break;
case 101:
eflg = 1;
break;
case 104:
usage(0x0);
case 109:
md5flg = 1;
break;
case 115:
sflg = 1;
v0 = 0;
if (!strcmp(crypt_method, "SHA512") &&
!getlong(*(&optarg), &sha_rounds))
v0 = 1;
default:
usage(0x2);
}
} else {
v6 = check_flags();
return;
}
}
} while (!v0);
fprintf(stderr, gettext("%s: invalid numeric argument '%s'\n"));
usage(0x2);
} | shadow | angr_dream |
WORD_LIST *split_at_delims(string, slen, delims, sentinel, flags, nwp, cwp)
char *string;
int slen;
const char *delims;
int sentinel, flags;
int *nwp, *cwp;
{
int ts, te, i, nw, cw, ifs_split, dflags;
char *token, *d, *d2;
WORD_LIST *ret, *tl;
if (string == 0 || *string == '\0') {
if (nwp)
*nwp = 0;
if (cwp)
*cwp = 0;
return ((WORD_LIST *)((void *)0));
}
d = (delims == 0) ? ifs_value : (char *)delims;
ifs_split = delims == 0;
d2 = 0;
if (delims) {
size_t slength;
size_t mblength = 1;
mbstate_t state;
memset(&state, '\0', sizeof(mbstate_t));
slength = strlen(delims);
d2 = (char *)sh_xmalloc((slength + 1), "subst.c", 2637);
i = ts = 0;
while (delims[i]) {
mbstate_t state_bak;
state_bak = state;
mblength = (((__ctype_get_mb_cur_max()) > 1)
? mbrlen((delims + i), (slength), (&state))
: 1);
if (((mblength) == (size_t)-1 || (mblength) == (size_t)-2))
state = state_bak;
else if (mblength > 1) {
memcpy(d2 + ts, delims + i, mblength);
ts += mblength;
i += mblength;
slength -= mblength;
continue;
}
if ((((delims[i]) == ' ') || ((delims[i]) == '\t')) == 0)
d2[ts++] = delims[i];
i++;
slength--;
}
d2[ts] = '\0';
}
ret = (WORD_LIST *)((void *)0);
for (i = 0;
((string[i]) ? ((char *)mbschr((d), (string[i])) != (char *)((void *)0))
: 0) &&
((string[i]) == ' ' || (string[i]) == '\t' || (string[i]) == '\n');
i++)
;
if (string[i] == '\0') {
do {
if (d2)
sh_xfree((d2), "subst.c", 2673);
} while (0);
return (ret);
}
ts = i;
nw = 0;
cw = -1;
dflags = flags | 0x001;
while (1) {
te = skip_to_delim(string, ts, d, dflags);
if (ts == te && d2 &&
((string[ts])
? ((char *)mbschr((d2), (string[ts])) != (char *)((void *)0))
: 0)) {
te = ts + 1;
if (ifs_split)
while (
((string[te])
? ((char *)mbschr((d), (string[te])) != (char *)((void *)0))
: 0) &&
((string[te]) == ' ' || (string[te]) == '\t' ||
(string[te]) == '\n') &&
((flags & 0x004) == 0 || (string[te] != '\'' && string[te] != '"')))
te++;
else
while (
((string[te])
? ((char *)mbschr((d2), (string[te])) != (char *)((void *)0))
: 0) &&
((flags & 0x004) == 0 || (string[te] != '\'' && string[te] != '"')))
te++;
}
token = substring(string, ts, te);
ret = make_word_list(make_word(token), (ret));
sh_xfree((token), "subst.c", 2704);
nw++;
if (sentinel >= ts && sentinel <= te)
cw = nw;
if (cwp && cw == -1 && sentinel == ts - 1)
cw = nw;
if (cwp && cw == -1 && sentinel < ts) {
tl = make_word_list(make_word(""), ret->next);
ret->next = tl;
cw = nw;
nw++;
}
if (string[te] == 0)
break;
i = te;
while (
((string[i]) ? ((char *)mbschr((d), (string[i])) != (char *)((void *)0))
: 0) &&
(ifs_split ||
((string[i]) == ' ' || (string[i]) == '\t' || (string[i]) == '\n')) &&
((flags & 0x004) == 0 || (string[te] != '\'' && string[te] != '"')))
i++;
if (string[i])
ts = i;
else
break;
}
if (cwp && cw == -1 && (sentinel >= slen || sentinel >= te)) {
if ((((string[sentinel - 1]) == ' ') || ((string[sentinel - 1]) == '\t'))) {
token = "";
ret = make_word_list(make_word(token), (ret));
nw++;
}
cw = nw;
}
if (nwp)
*nwp = nw;
if (cwp)
*cwp = cw;
do {
if (d2)
sh_xfree((d2), "subst.c", 2761);
} while (0);
return (((ret && ret->next) ? (WORD_LIST *)list_reverse((GENERIC_LIST *)ret)
: (WORD_LIST *)(ret)));
} | long long split_at_delims(char *a0, unsigned long long a1,
unsigned long long a2, unsigned long a3,
unsigned long long a4, unsigned int *a5,
unsigned long long v18) {
unsigned int *v0;
int tmp_28;
char v1;
unsigned int v2;
unsigned int v3;
unsigned int v4;
unsigned int v5;
unsigned int v6;
unsigned int v7;
unsigned int v8;
void *v9;
void *v10;
unsigned long long v11;
unsigned long long v12;
unsigned long long v13;
unsigned long long v14;
unsigned long v15;
unsigned long v16;
unsigned long long v17;
unsigned long long v19;
unsigned long v21;
unsigned long long v22;
unsigned long long v24;
unsigned long long v25;
unsigned long long v26;
unsigned long long v27;
void *v28;
unsigned long long v29;
v0 = v18;
if (a0 && *(a0)) {
if (!a2)
v19 = 425802354520363004;
else
v19 = a2;
v12 = v19;
v7 = !a2;
v9 = 0;
if (a2) {
v13 = 1;
memset(&v16, 0x0, 0x8);
v11 = strlen(a2);
v9 = sh_xmalloc(v11 + 1, "subst.c", 0xa4d);
v2 = 0;
v4 = v2;
while (*((a2 + v4))) {
v17 = v16;
if (__ctype_get_mb_cur_max(a0, a1, v4, v4 + a2, a4, a5, v18, a5,
*(&v1)) > 1)
v21 = mbrlen(v4 + a2, v11, &v16, v4 + a2);
else
v21 = 1;
v13 = v21;
if (v13 != -1 && v13 != -2 && v13 > 1) {
memcpy(v2 + v9, v4 + a2, v13);
v2 += v13;
v4 += v13;
v11 -= v13;
continue;
}
if (v13 == -2 || v13 == -1)
v16 = v17;
if (v13 <= 1 || v13 == -2 || v13 == -1) {
if (*((a2 + v4)) != 32 && *((a2 + v4)) != 9)
*(&v21) = 0;
if (*((a2 + v4)) == 32 || *((a2 + v4)) == 9)
*(&v21) = 1;
if (!v21) {
tmp_28 = v2;
v2 += 1;
*(tmp_28 + v9) = *((v4 + a2));
}
v4 += 1;
v11 -= 1;
}
}
*(v9 + v2) = 0;
}
v10 = 0;
for (v4 = 0; a0[v4]; v4 += 1) {
v22 = mbschr(v12, a0[v4]);
if (!v22)
break;
if (v22 && a0[v4] != 32 && a0[v4] != 9) {
if (a0[v4] != 10)
break;
}
}
if (!a0[v4]) {
if (v9)
sh_xfree(v9, "subst.c", 0xa71);
v28 = v10;
} else {
v2 = v4;
v5 = 0;
v6 = -1;
v8 = a4 | 1;
while (true) {
v3 = skip_to_delim(a0, v2, v12, v8, a4, a5);
if (v2 == v3 && v9 && a0[v2] && mbschr(v9, a0[v2])) {
if (v7) {
for (v3 = v2 + 1; a0[v3]; v3 += 1) {
v25 = mbschr(v12, a0[v3]);
if (!v25)
break;
if (v25) {
if (a0[v3] != 32 && a0[v3] != 9) {
if (a0[v3] != 10)
break;
}
if (a0[v3] == 10 && (a4 & 4)) {
if (a0[v3] == 39)
break;
if (a0[v3] != 39) {
if (a0[v3] == 34)
break;
}
}
}
}
} else {
for (; a0[v3]; v3 += 1) {
v24 = mbschr(v9, a0[v3]);
if (!v24)
break;
if (v24 && (a4 & 4)) {
if (a0[v3] == 39)
break;
if (a0[v3] != 39) {
if (a0[v3] == 34)
break;
}
}
}
}
}
v14 = substring(a0, v2, v3, v2);
v26 = make_word(v14);
v10 = make_word_list(v26, v10, v26);
sh_xfree(v14, "subst.c", 0xa90);
v5 += 1;
if (a3 >= v2 && a3 <= v3)
v6 = v5;
if (v0 && v6 == -1 && a3 == v2 - 1)
v6 = v5;
if (v0 && v6 == -1 && a3 < v2) {
v15 = make_word_list(make_word(&g_41fa65), *(v10), 0xa90);
*(v10) = v15;
v6 = v5;
v5 += 1;
}
if (!a0[v3])
break;
if (a0[v3]) {
for (v4 = v3; a0[v4]; v4 += 1) {
v27 = mbschr(v12, a0[v4]);
if (!v27)
break;
if (v27) {
if (!v7 && a0[v4] != 32 && a0[v4] != 9) {
if (a0[v4] != 10)
break;
}
if (a0[v4] == 10 && (a4 & 4)) {
if (a0[v3] == 39)
break;
if (a0[v3] != 39) {
if (a0[v3] == 34)
break;
}
}
}
}
if (!a0[v4])
break;
}
v2 = v4;
}
if (v0 && v6 == -1 && (a3 >= a1 || a3 >= v3)) {
if (a0[1 + a3] == 9 || a0[1 + a3] == 32) {
v14 = &g_41fa65;
v29 = make_word(v14);
v10 = make_word_list(v29, v10, v29);
v5 += 1;
}
v6 = v5;
}
if (a5)
*(a5) = v5;
if (v0)
*(v0) = v6;
if (v9)
sh_xfree(v9, "subst.c", 0xac9);
if (v10 && *(v10))
v28 = list_reverse(v10);
if (!*(v10) || !v10)
v28 = v10;
}
}
if (!a0 || !*(a0)) {
if (a5)
*(a5) = 0;
if (v0)
*(v0) = 0;
v28 = 0;
}
return v28;
} | bash | angr_dream |
char *remove_quoted_nulls(string)
char *string;
{
register size_t slen;
register int i, j, prev_i;
mbstate_t state;
memset(&state, '\0', sizeof(mbstate_t));
if (strchr(string, '\177') == 0)
return string;
slen = strlen(string);
i = j = 0;
while (i < slen) {
if (string[i] == '\001') {
i++;
string[j++] = '\001';
if (i == slen)
break;
} else if (string[i] == '\177') {
i++;
continue;
}
prev_i = i;
do {
if (locale_mb_cur_max > 1) {
mbstate_t state_bak;
size_t mblength;
int _f;
_f = is_basic((string)[i]);
if (_f)
mblength = 1;
else if (locale_utf8locale && (((string)[i] & 0x80) == 0))
mblength = (string)[i] != 0;
else {
state_bak = state;
mblength = mbrlen((string) + (i), (slen) - (i), &state);
}
if (mblength == (size_t)-2 || mblength == (size_t)-1) {
state = state_bak;
(i)++;
} else if (mblength == 0)
(i)++;
else
(i) += mblength;
} else
(i)++;
} while (0);
if (j < prev_i) {
do
string[j++] = string[prev_i++];
while (prev_i < i);
} else
j = i;
}
string[j] = '\0';
return (string);
} | char *remove_quoted_nulls(char *param_1)
{
int iVar1;
char *pcVar2;
size_t sVar3;
int iVar4;
int iVar5;
int iVar6;
int iVar7;
long in_FS_OFFSET;
ulong local_48;
mbstate_t local_40;
mbstate_t local_38;
long local_30;
local_30 = *(long *)(in_FS_OFFSET + 0x28);
memset(&local_40, 0, 8);
pcVar2 = strchr(param_1, 0x7f);
if (pcVar2 != (char *)0x0) {
sVar3 = strlen(param_1);
iVar5 = 0;
iVar1 = 0;
while (iVar6 = iVar1, (ulong)(long)iVar5 < sVar3) {
if (param_1[iVar5] == '\x01') {
iVar6 = iVar1 + 1;
param_1[iVar1] = '\x01';
iVar4 = iVar5 + 1;
if (sVar3 == (long)(iVar5 + 1))
break;
LAB_0010cb9d:
if (locale_mb_cur_max < 2) {
iVar5 = iVar4 + 1;
} else {
iVar1 = is_basic((int)param_1[iVar4]);
if (iVar1 == 0) {
if ((locale_utf8locale == 0) || (param_1[iVar4] < '\0')) {
local_38 = local_40;
local_48 =
mbrlen(param_1 + iVar4, sVar3 - (long)iVar4, &local_40);
} else {
local_48 = (ulong)(param_1[iVar4] != '\0');
}
} else {
local_48 = 1;
}
if ((local_48 == 0xfffffffffffffffe) ||
(local_48 == 0xffffffffffffffff)) {
local_40 = local_38;
iVar5 = iVar4 + 1;
} else if (local_48 == 0) {
iVar5 = iVar4 + 1;
} else {
iVar5 = iVar4 + (int)local_48;
}
}
iVar1 = iVar5;
if (iVar6 < iVar4) {
do {
iVar7 = iVar4 + 1;
iVar1 = iVar6 + 1;
param_1[iVar6] = param_1[iVar4];
iVar6 = iVar1;
iVar4 = iVar7;
} while (iVar7 < iVar5);
}
} else {
iVar4 = iVar5;
if (param_1[iVar5] != '\x7f')
goto LAB_0010cb9d;
iVar5 = iVar5 + 1;
}
}
param_1[iVar6] = '\0';
}
if (local_30 == *(long *)(in_FS_OFFSET + 0x28)) {
return param_1;
}
__stack_chk_fail();
} | bash | ghidra |
static void chan_set_istate(Channel *c, u_int next) {
if (c->istate > 3 || next > 3)
sshfatal("nchan.c", __func__, 96, 0, SYSLOG_LEVEL_FATAL, ((void *)0),
"chan_set_istate: bad state %d -> %d", c->istate, next);
sshlog("nchan.c", __func__, 97, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0),
"channel %d: input %s -> %s", c->self, istates[c->istate],
istates[next]);
c->istate = next;
} | void chan_set_istate(unsigned long a0, unsigned long a1) {
unsigned long v0;
unsigned long long v1;
unsigned long v2;
unsigned int v3[5];
unsigned long v4;
char v5;
unsigned long long v6;
char v7;
unsigned int v8[5];
v3 = a0;
if (a1 > 3 || v3->field_10 > 3) {
v0 = a1;
sshfatal("nchan.c", "chan_set_istate", 0x60, 0x0, 0x1, 0x0,
"chan_set_istate: bad state %d -> %d", v3->field_10);
}
v4 = (&istates)[a1];
*(&v3[0]) = (&istates)[v3->field_10];
v2 = v3[1];
v1 = "channel %d: input %s -> %s";
sshlog("nchan.c", "chan_set_istate", 0x61, 0x0, 0x6, 0x0, *(&v5), v6, *(&v7));
v8 = v3;
v3[4] = *((&v2 + 4));
return;
} | openssh-portable | angr_dream |
static inline void emit_mandatory_arg_note(void) {
fputs_unlocked(gettext("\nMandatory arguments to long options are mandatory "
"for short options too.\n"),
stdout)
;
} | void emit_mandatory_arg_note() {
unsigned long long v1;
v1 = fputs_unlocked(gettext("\nMandatory arguments to long options are "
"mandatory for short options too.\n"),
stdout);
return;
} | coreutils | angr_sailr |
static void fail_exit(int code) {
if (pw_locked) {
if (pw_unlock() == 0) {
fprintf(stderr, gettext("%s: failed to unlock %s\n"), Prog, pw_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", pw_dbname());
if (((void *)0) != saved_locale) {
(void)setlocale(6, saved_locale);
free(saved_locale);
}
} while (0);
}
}
pw_locked = 0;
closelog();
exit(code);
} | void fail_exit(unsigned long a0) {
void *v0;
char *v1;
unsigned long v2;
unsigned long v3;
unsigned long v5;
unsigned long v6;
unsigned long long v8;
v3 = v5;
v2 = v6;
if (pw_locked && !pw_unlock()) {
v8 = pw_dbname();
fprintf(stderr, gettext("%s: failed to unlock %s\n"));
v1 = setlocale(0x6, NULL);
v0 = 0;
if (v1)
v0 = strdup(v1);
if (v0)
setlocale(0x6, "C");
pw_dbname();
syslog(0x3, "failed to unlock %s");
if (v0) {
setlocale(0x6, v0);
free(v0);
}
}
pw_locked = 0;
closelog();
exit(a0);
} | shadow | angr_dream |
static void dev_ino_free(void *x) { free(x); } | void dev_ino_free(void *a0) {
unsigned long long v1;
v1 = free(a0);
return;
} | coreutils | 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(
"Write lines consisting of the sequentially corresponding lines "
"from\neach FILE, separated by TABs, to standard output.\n"),
stdout)
;
emit_stdin_note();
emit_mandatory_arg_note();
fputs_unlocked(gettext(" -d, --delimiters=LIST reuse characters from "
"LIST instead of TABs\n -s, --serial "
"paste one file at a time instead of in parallel\n"),
stdout)
;
fputs_unlocked(
gettext(
" -z, --zero-terminated line delimiter is NUL, not newline\n"),
stdout)
;
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("paste");
}
exit(status);
} | void usage(unsigned long a0) {
unsigned long v0;
unsigned long v2;
v0 = v2;
if (a0) {
fprintf(stderr, gettext("Try '%s --help' for more information.\n"));
} else {
printf(gettext("Usage: %s [OPTION]... [FILE]...\n"));
fputs_unlocked(
gettext(
"Write lines consisting of the sequentially corresponding lines "
"from\neach FILE, separated by TABs, to standard output.\n"),
stdout);
emit_stdin_note();
emit_mandatory_arg_note();
fputs_unlocked(gettext(" -d, --delimiters=LIST reuse characters from "
"LIST instead of TABs\n -s, --serial "
"paste one file at a time instead of in parallel\n"),
stdout);
fputs_unlocked(
gettext(
" -z, --zero-terminated line delimiter is NUL, not newline\n"),
stdout);
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("paste");
}
exit(a0);
} | coreutils | angr_dream |
static void new_socket(sock_type type, int fd) {
u_int i, old_alloc, new_alloc;
sshlog("ssh-agent.c", __func__, 1700, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0),
"type = %s",
type == AUTH_CONNECTION
? "CONNECTION"
: (type == AUTH_SOCKET ? "SOCKET" : "UNKNOWN"));
set_nonblock(fd);
if (fd > max_fd)
max_fd = fd;
for (i = 0; i < sockets_alloc; i++)
if (sockets[i].type == AUTH_UNUSED) {
sockets[i].fd = fd;
if ((sockets[i].input = sshbuf_new()) == ((void *)0) ||
(sockets[i].output = sshbuf_new()) == ((void *)0) ||
(sockets[i].request = sshbuf_new()) == ((void *)0))
sshfatal("ssh-agent.c", __func__, 1713, 1, SYSLOG_LEVEL_FATAL,
((void *)0), "sshbuf_new failed");
sockets[i].type = type;
return;
}
old_alloc = sockets_alloc;
new_alloc = sockets_alloc + 10;
sockets = xrecallocarray(sockets, old_alloc, new_alloc, sizeof(sockets[0]));
for (i = old_alloc; i < new_alloc; i++)
sockets[i].type = AUTH_UNUSED;
sockets_alloc = new_alloc;
sockets[old_alloc].fd = fd;
if ((sockets[old_alloc].input = sshbuf_new()) == ((void *)0) ||
(sockets[old_alloc].output = sshbuf_new()) == ((void *)0) ||
(sockets[old_alloc].request = sshbuf_new()) == ((void *)0))
sshfatal("ssh-agent.c", __func__, 1728, 1, SYSLOG_LEVEL_FATAL, ((void *)0),
"sshbuf_new failed");
sockets[old_alloc].type = type;
} | long new_socket(unsigned int a1, unsigned int a2) {
const char *v2;
long v3;
long v4;
long v5;
long result;
long v7;
long v8;
long v9;
unsigned int i;
unsigned int j;
unsigned int v12;
unsigned int v13;
if (a1 == 2) {
v2 = "CONNECTION";
} else if (a1 == 1) {
v2 = "SOCKET";
} else {
v2 = "UNKNOWN";
}
sshlog("ssh-agent.c", "new_socket", 1700LL, 1LL, 5LL, 0LL, "type = %s", v2);
set_nonblock(a2);
if ((int)a2 > max_fd)
max_fd = a2;
for (i = 0;; ++i) {
if (i >= sockets_alloc) {
v12 = sockets_alloc;
v13 = sockets_alloc + 10;
sockets = xrecallocarray(sockets, (unsigned int)sockets_alloc,
(unsigned int)(sockets_alloc + 10), 48LL);
for (j = v12; j < v13; ++j)
*(_DWORD *)(sockets + 48LL * j + 4) = 0;
sockets_alloc = v13;
*(_DWORD *)(sockets + 48LL * v12) = a2;
v7 = sockets + 48LL * v12;
*(_QWORD *)(v7 + 8) = sshbuf_new();
if (!*(_QWORD *)(v7 + 8) ||
(v8 = sockets + 48LL * v12,
(*(_QWORD *)(v8 + 16) = sshbuf_new()) == 0LL) ||
(v9 = sockets + 48LL * v12,
(*(_QWORD *)(v9 + 24) = sshbuf_new()) == 0LL)) {
sshfatal("ssh-agent.c", "new_socket", 1728LL, 1LL, 1LL, 0LL,
"sshbuf_new failed");
}
result = a1;
*(_DWORD *)(sockets + 48LL * v12 + 4) = a1;
return result;
}
if (!*(_DWORD *)(sockets + 48LL * i + 4))
break;
}
*(_DWORD *)(sockets + 48LL * i) = a2;
v3 = sockets + 48LL * i;
*(_QWORD *)(v3 + 8) = sshbuf_new();
if (!*(_QWORD *)(v3 + 8) ||
(v4 = sockets + 48LL * i, (*(_QWORD *)(v4 + 16) = sshbuf_new()) == 0LL) ||
(v5 = sockets + 48LL * i, (*(_QWORD *)(v5 + 24) = sshbuf_new()) == 0LL)) {
sshfatal("ssh-agent.c", "new_socket", 1713LL, 1LL, 1LL, 0LL,
"sshbuf_new failed");
}
result = a1;
*(_DWORD *)(sockets + 48LL * i + 4) = a1;
return result;
} | openssh-portable | ida |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.