input
stringlengths
26
172k
output
stringlengths
18
318k
repo_name
stringclasses
23 values
decompiler
stringclasses
5 values
static char *ctime_format(struct timespec ts) { const struct tm *ptm; static char resultbuf[1024]; int nout; ptm = localtime(&ts.tv_sec); if (ptm) { ((void)sizeof((ptm->tm_wday >= 0) ? 1 : 0), __extension__({ if (ptm->tm_wday >= 0) ; else __assert_fail("ptm->tm_wday >= 0", "print.c", 749, __extension__ __PRETTY_FUNCTION__); })); ((void)sizeof((ptm->tm_wday < 7) ? 1 : 0), __extension__({ if (ptm->tm_wday < 7) ; else __assert_fail("ptm->tm_wday < 7", "print.c", 750, __extension__ __PRETTY_FUNCTION__); })); ((void)sizeof((ptm->tm_mon >= 0) ? 1 : 0), __extension__({ if (ptm->tm_mon >= 0) ; else __assert_fail("ptm->tm_mon >= 0", "print.c", 751, __extension__ __PRETTY_FUNCTION__); })); ((void)sizeof((ptm->tm_mon < 12) ? 1 : 0), __extension__({ if (ptm->tm_mon < 12) ; else __assert_fail("ptm->tm_mon < 12", "print.c", 752, __extension__ __PRETTY_FUNCTION__); })); ((void)sizeof((ptm->tm_hour >= 0) ? 1 : 0), __extension__({ if (ptm->tm_hour >= 0) ; else __assert_fail("ptm->tm_hour >= 0", "print.c", 753, __extension__ __PRETTY_FUNCTION__); })); ((void)sizeof((ptm->tm_hour < 24) ? 1 : 0), __extension__({ if (ptm->tm_hour < 24) ; else __assert_fail("ptm->tm_hour < 24", "print.c", 754, __extension__ __PRETTY_FUNCTION__); })); ((void)sizeof((ptm->tm_min < 60) ? 1 : 0), __extension__({ if (ptm->tm_min < 60) ; else __assert_fail("ptm->tm_min < 60", "print.c", 755, __extension__ __PRETTY_FUNCTION__); })); ((void)sizeof((ptm->tm_sec <= 61) ? 1 : 0), __extension__({ if (ptm->tm_sec <= 61) ; else __assert_fail("ptm->tm_sec <= 61", "print.c", 756, __extension__ __PRETTY_FUNCTION__); })); nout = snprintf(resultbuf, 1024, "%3s %3s %2d %02d:%02d:%02d.%09ld0 %04d", weekdays[ptm->tm_wday], months[ptm->tm_mon], ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec, (long int)ts.tv_nsec, 1900 + ptm->tm_year); ((void)sizeof((nout < 1024) ? 1 : 0), __extension__({ if (nout < 1024) ; else __assert_fail("nout < TIME_BUF_LEN", "print.c", 770, __extension__ __PRETTY_FUNCTION__); })); return resultbuf; } else { return format_date(ts, '@'); } }
char *ctime_format(time_t a1, long a2) { time_t timer; long v4; int v5; struct tm *v6; timer = a1; v4 = a2; v6 = localtime(&timer); if (!v6) return format_date(timer, v4, 64); if (v6->tm_wday < 0) _assert_fail("ptm->tm_wday >= 0", "print.c", 0x2EDu, "ctime_format"); if (v6->tm_wday > 6) _assert_fail("ptm->tm_wday < 7", "print.c", 0x2EEu, "ctime_format"); if (v6->tm_mon < 0) _assert_fail("ptm->tm_mon >= 0", "print.c", 0x2EFu, "ctime_format"); if (v6->tm_mon > 11) _assert_fail("ptm->tm_mon < 12", "print.c", 0x2F0u, "ctime_format"); if (v6->tm_hour < 0) _assert_fail("ptm->tm_hour >= 0", "print.c", 0x2F1u, "ctime_format"); if (v6->tm_hour > 23) _assert_fail("ptm->tm_hour < 24", "print.c", 0x2F2u, "ctime_format"); if (v6->tm_min > 59) _assert_fail("ptm->tm_min < 60", "print.c", 0x2F3u, "ctime_format"); if (v6->tm_sec > 61) _assert_fail("ptm->tm_sec <= 61", "print.c", 0x2F4u, "ctime_format"); v5 = snprintf( resultbuf_10528, 0x400uLL, "%3s %3s %2d %02d:%02d:%02d.%09ld0 %04d", weekdays[v6->tm_wday], months[v6->tm_mon], (unsigned int)v6->tm_mday, (unsigned int)v6->tm_hour, (unsigned int)v6->tm_min, (unsigned int)v6->tm_sec, v4, (unsigned int)(v6->tm_year + 1900)); if (v5 > 1023) _assert_fail("nout < TIME_BUF_LEN", "print.c", 0x302u, "ctime_format"); return resultbuf_10528; }
findutils
ida
void chachapoly_free(struct chachapoly_ctx *cpctx) { if (cpctx == ((void *)0)) return; EVP_CIPHER_CTX_free(cpctx->main_evp); EVP_CIPHER_CTX_free(cpctx->header_evp); freezero(cpctx, sizeof(*cpctx)); }
long chachapoly_free(_QWORD *a1) { long result; if (a1) { EVP_CIPHER_CTX_free(*a1); EVP_CIPHER_CTX_free(a1[1]); return freezero(a1, 16LL); } return result; }
openssh-portable
ida
static int dowait(int block, struct job *jp) { int gotchld = *(volatile int *)&gotsigchld; int rpid; int pid; if (jp && jp->state != 0) block = 0; if (block == 0 && !gotchld) return 1; rpid = 1; do { pid = waitone(block, jp); rpid &= !!pid; block &= ~4; if (!pid || (jp && jp->state != 0)) block = 0; } while (pid >= 0); return rpid; }
byte dowait(uint param_1, long param_2) { byte bVar1; int iVar2; uint local_1c; local_1c = param_1; if ((param_2 != 0) && (*(char *)(param_2 + 0x1e) != '\0')) { local_1c = 0; } if ((local_1c == 0) && (gotsigchld == 0)) { bVar1 = 1; } else { bVar1 = 1; do { iVar2 = waitone(local_1c, param_2); bVar1 = bVar1 & iVar2 != 0; local_1c = local_1c & 0xfffffffb; if ((iVar2 == 0) || ((param_2 != 0 && (*(char *)(param_2 + 0x1e) != '\0')))) { local_1c = 0; } } while (-1 < iVar2); } return bVar1; }
dash-0.5.11+git20210903+057cd650a4ed
ghidra
_Bool pred_execdir (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr) { (void)&pathname; return impl_pred_exec(state.rel_pathname, stat_buf, pred_ptr); }
void pred_execdir(undefined8 param_1, undefined8 param_2, undefined8 param_3) { impl_pred_exec(_strcmp, param_2, param_3); return; }
findutils
ghidra
map_init_emacs(EditLine *el) { int i; wchar_t buf[3]; el_action_t *key = el->el_map.key; el_action_t *alt = el->el_map.alt; const el_action_t *emacs = el->el_map.emacs; el->el_map.type = 0; el->el_map.current = el->el_map.key; keymacro_reset(el); for (i = 0; i < 256; i++) { key[i] = emacs[i]; alt[i] = 28; } map_init_meta(el); map_init_nls(el); buf[0] = (('X') & 037); buf[1] = (('X') & 037); buf[2] = 0; keymacro_add(el, buf, keymacro_map_cmd(el, 35), 0); tty_bind_char(el, 1); terminal_bind_arrow(el); }
void map_init_emacs(struct_0 *a0) { unsigned int v0; char *v1; char *v2; char *v3; unsigned int v4; unsigned int v5; unsigned int v6; char v7; unsigned long long v9; unsigned long long *v10; unsigned long long v11; v1 = a0->field_3f8; v2 = a0->field_3f0; v3 = a0->field_408; a0->field_420 = 0; a0->field_400 = a0->field_3f8; keymacro_reset(a0); for (v0 = 0; v0 <= 255; v0 += 1) { v1[v0] = v3[v0]; v2[v0] = 28; } map_init_meta(a0); map_init_nls(a0); v4 = 24; v5 = 24; v6 = 0; keymacro_add(a0, &v4, keymacro_map_cmd(a0, 0x23, v9), 0x0); tty_bind_char(a0, 0x1); terminal_bind_arrow(a0); v11 = *(&v7) ^ v10[5]; return; }
libedit
angr_dream
static struct dumpdir *dumpdir_create(const char *contents) { return dumpdir_create0(contents, "YND"); }
int dumpdir_create(void *a0) { return dumpdir_create0(a0, "YND"); }
tar
angr_sailr
int ssh_krl_revoke_key_sha256(struct ssh_krl *krl, const u_char *p, size_t len) { sshlog("krl.c", __func__, 445, 1, SYSLOG_LEVEL_DEBUG3, ((void *)0), "revoke by sha256"); if (len != 32) return -4; return revoke_by_hash(&krl->revoked_sha256s, p, len); }
long ssh_krl_revoke_key_sha256(long a1, const void *a2, long a3) { sshlog("krl.c", "ssh_krl_revoke_key_sha256", 445LL, 1LL, 7LL, 0LL, "revoke by sha256"); if (a3 == 32) return revoke_by_hash((long *)(a1 + 48), a2, (char *)&loc_1D + 3); else return 4294967292LL; }
openssh-portable
ida
int client_x11_get_proto(struct ssh *ssh, const char *display, const char *xauth_path, u_int trusted, u_int timeout, char **_proto, char **_data) { char *cmd, line[512], xdisplay[512]; char xauthfile[4096], xauthdir[4096]; static char proto[512], data[512]; FILE *f; int got_data = 0, generated = 0, do_unlink = 0, r; struct stat st; u_int now, x11_timeout_real; *_proto = proto; *_data = data; proto[0] = data[0] = xauthfile[0] = xauthdir[0] = '\0'; if (!client_x11_display_valid(display)) { if (display != ((void *)0)) sshlog("clientloop.c", __func__, 304, 0, SYSLOG_LEVEL_INFO, ((void *)0), "DISPLAY \"%s\" invalid; disabling X11 forwarding", display); return -1; } if (xauth_path != ((void *)0) && stat(xauth_path, &st) == -1) { sshlog("clientloop.c", __func__, 309, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "No xauth program."); xauth_path = ((void *)0); } if (xauth_path != ((void *)0)) { if (strncmp(display, "localhost:", 10) == 0) { if ((r = snprintf(xdisplay, sizeof(xdisplay), "unix:%s", display + 10)) < 0 || (size_t)r >= sizeof(xdisplay)) { sshlog("clientloop.c", __func__, 325, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "display name too long"); return -1; } display = xdisplay; } if (trusted == 0) { mktemp_proto(xauthdir, sizeof(xauthdir)); if (mkdtemp(xauthdir) == ((void *)0)) { sshlog("clientloop.c", __func__, 340, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "mkdtemp: %s", strerror((*__errno_location()))); return -1; } do_unlink = 1; if ((r = snprintf(xauthfile, sizeof(xauthfile), "%s/xauthfile", xauthdir)) < 0 || (size_t)r >= sizeof(xauthfile)) { sshlog("clientloop.c", __func__, 347, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "xauthfile path too long"); rmdir(xauthdir); return -1; } if (timeout == 0) { xasprintf(&cmd, "%s -f %s generate %s %s " "untrusted 2>%s", xauth_path, xauthfile, display, "MIT-MAGIC-COOKIE-1", "/dev/null"); } else { if (timeout < (0x7fffffff * 2U + 1U) - 60) x11_timeout_real = timeout + 60; else { x11_timeout_real = (0x7fffffff * 2U + 1U); } xasprintf(&cmd, "%s -f %s generate %s %s " "untrusted timeout %u 2>%s", xauth_path, xauthfile, display, "MIT-MAGIC-COOKIE-1", x11_timeout_real, "/dev/null"); } sshlog("clientloop.c", __func__, 373, 1, SYSLOG_LEVEL_DEBUG2, ((void *)0), "xauth command: %s", cmd); if (timeout != 0 && x11_refuse_time == 0) { now = monotime() + 1; if ((0x7fffffff * 2U + 1U) - timeout < now) x11_refuse_time = (0x7fffffff * 2U + 1U); else x11_refuse_time = now + timeout; channel_set_x11_refuse_time(ssh, x11_refuse_time); } if (system(cmd) == 0) generated = 1; free(cmd); } if (trusted || generated) { xasprintf(&cmd, "%s %s%s list %s 2>" "/dev/null", xauth_path, generated ? "-f " : "", generated ? xauthfile : "", display); sshlog("clientloop.c", __func__, 401, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "x11_get_proto: %s", cmd); f = popen(cmd, "r"); if (f && fgets(line, sizeof(line), f) && sscanf(line, "%*s %511s %511s", proto, data) == 2) got_data = 1; if (f) pclose(f); free(cmd); } } if (do_unlink) { unlink(xauthfile); rmdir(xauthdir); } if (!trusted && !got_data) { sshlog("clientloop.c", __func__, 419, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Warning: untrusted X11 forwarding setup failed: " "xauth key data not generated"); return -1; } if (!got_data) { u_int8_t rnd[16]; u_int i; sshlog("clientloop.c", __func__, 436, 0, SYSLOG_LEVEL_INFO, ((void *)0), "Warning: No xauth data; " "using fake authentication data for X11 forwarding."); strlcpy(proto, "MIT-MAGIC-COOKIE-1", sizeof proto); arc4random_buf(rnd, sizeof(rnd)); for (i = 0; i < sizeof(rnd); i++) { snprintf(data + 2 * i, sizeof data - 2 * i, "%02x", rnd[i]); } } return 0; }
long long client_x11_get_proto(unsigned long long a0, void *a1, char *a2, unsigned long a3, unsigned long a4, unsigned long long *a5, unsigned long v23) { unsigned long long v0; unsigned long long v1; unsigned long long *v2; unsigned int v3; void *v4; void *v5; unsigned int v6; unsigned int v7; unsigned int v8; unsigned int v9; unsigned int v10; unsigned int v11; unsigned int v12; char v13; void *v14; char v15; char v16; char v17; char v18; char v19; char v20; char v21; unsigned long long v22; unsigned long long v24; v22 = *(&v22); v20 = *(&v20); v5 = a1; v4 = a2; v3 = a4; v2 = v23; v6 = 0; v7 = 0; v8 = 0; *(a5) = &proto.20208; *(v2) = &data.20209; v21 = 0; v19 = v21; data.20209 = v19; proto.20208 = data.20209; if (client_x11_display_valid(v5)) { if (v4 && stat(v4, &v15) == -1) { v0 = "No xauth program."; sshlog("clientloop.c", "client_x11_get_proto", 0x135, 0x0, 0x5, 0x0); v4 = 0; } if (v4) { if (!strncmp(v5, "localhost:", 0xa)) { v11 = snprintf(&v18, 0x200, "unix:%s", (v5 + 10)); if (!(v11 >= 0) || !(v11 <= 511)) { v0 = "display name too long"; sshlog("clientloop.c", "client_x11_get_proto", 0x145, 0x1, 0x2, 0x0); v24 = 4294967295; return v24; } v5 = &v18; } if (!a3) { mktemp_proto(&v21, 0x1000); if (!mkdtemp(&v21)) { v1 = strerror(*(__errno_location())); v0 = "mkdtemp: %s"; sshlog("clientloop.c", "client_x11_get_proto", 0x154, 0x1, 0x2, 0x0); v24 = 4294967295; return v24; } v8 = 1; v11 = snprintf(&v19, 0x1000, "%s/xauthfile", &v21); if (!(v11 >= 0) || !(v11 <= 4095)) { v0 = "xauthfile path too long"; sshlog("clientloop.c", "client_x11_get_proto", 0x15b, 0x1, 0x2, 0x0); rmdir(&v21); v24 = 4294967295; return v24; } if (a4) { if (a4 > -62) v9 = -1; else v9 = a4 + 60; v1 = "/dev/null"; v0 = v9; xasprintf(&v13, "%s -f %s generate %s %s untrusted timeout %u 2>%s", v4, &v19, v5, "MIT-MAGIC-COOKIE-1"); } else { v0 = "/dev/null"; xasprintf(&v13, "%s -f %s generate %s %s untrusted 2>%s", v4, &v19, v5, "MIT-MAGIC-COOKIE-1"); } v1 = *(&v13); v0 = "xauth command: %s"; sshlog("clientloop.c", "client_x11_get_proto", 0x175, 0x1, 0x6, 0x0); if (a4 && !x11_refuse_time) { v12 = monotime() + 1; if (v12 > !(v3)) x11_refuse_time = -1; else x11_refuse_time = a4 + v12; channel_set_x11_refuse_time(a0, x11_refuse_time, x11_refuse_time); } if (!system(*(&v13))) v7 = 1; free(*(&v13)); } if (a3 || v7) { xasprintf(&v13, "%s %s%s list %s 2>/dev/null", v4, (!v7 ? "-f " : &g_408c6c), (!v7 ? &v19 : &g_408c6c), v5); v1 = *(&v13); v0 = "x11_get_proto: %s"; sshlog("clientloop.c", "client_x11_get_proto", 0x191, 0x0, 0x6, 0x0); v14 = popen(*(&v13), "r"); if (v14 && fgets(&v17, 0x200, v14) && __isoc99_sscanf(&v17, "%*s %511s %511s", &proto.20208, &data.20209) == 2) v6 = 1; if (v14) pclose(v14); free(*(&v13)); } } if (v8) { unlink(&v19); rmdir(&v21); } if (!a3 && !v6) { v0 = "Warning: untrusted X11 forwarding setup failed: xauth key data not " "generated"; sshlog("clientloop.c", "client_x11_get_proto", 0x1a3, 0x0, 0x2, 0x0); v24 = 4294967295; return v24; } if (v6) { v24 = 0; return v24; } v0 = "Warning: No xauth data; using fake authentication data for X11 " "forwarding."; sshlog("clientloop.c", "client_x11_get_proto", 0x1b4, 0x0, 0x3, 0x0); strlcpy(&proto.20208, "MIT-MAGIC-COOKIE-1", 0x200); arc4random_buf(&v16, 0x10); for (v10 = 0; v10 <= 15; v10 += 1) { snprintf(&(&data.20209)[2 * v10], 0x200 - v10 * 2, "%02x", (&v16)[v10]); } v24 = 0; return v24; } else if (!v5) { v24 = 4294967295; return v24; } else { v1 = v5; v0 = "DISPLAY \"%s\" invalid; disabling X11 forwarding"; sshlog("clientloop.c", "client_x11_get_proto", 0x130, 0x0, 0x3, 0x0); v24 = 4294967295; return v24; } }
openssh-portable
angr_sailr
int builtin_arrayref_flags(w, baseflags) WORD_DESC *w; int baseflags; { char *t; int vflags; vflags = baseflags; if (w->flags & (1 << 9)) vflags |= 0x002 | 0x001; return vflags; }
long long builtin_arrayref_flags(struct_0 *a0, unsigned long a1) { unsigned int v0; v0 = a1; if ((a0->field_8 & 0x200)) v0 |= 3; return v0; }
bash
angr_phoenix
void usage(int result) { printf("Usage: utmpdump [ -froh ] [ filename ]\n"); exit(result); }
void usage(unsigned long a0) { printf("Usage: utmpdump [ -froh ] [ filename ]\n"); exit(a0); }
sysvinit
angr_sailr
&& !okname(suser)) { ++errs; continue; }
undefined8 okname(char *param_1) { char cVar1; uint uVar2; ushort **ppuVar3; char *local_10; local_10 = param_1; while (true) { cVar1 = *local_10; uVar2 = (uint)cVar1; if (((uVar2 & 0x80) != 0) || (((ppuVar3 = __ctype_b_loc(), ((*ppuVar3)[(int)uVar2] & 0x400) == 0 && (ppuVar3 = __ctype_b_loc(), ((*ppuVar3)[uVar2 & 0xff] & 0x800) == 0)) && ((uVar2 == 0x20 || ((((0x1f < (int)uVar2 && ((int)uVar2 < 0x61)) && (0x21 < (int)uVar2)) && ((1 << (cVar1 - 0x22U & 0x3f) & 0x4000000000000023U) != 0)))))))) break; local_10 = local_10 + 1; if (*local_10 == '\0') { return 1; } } fmprintf(stderr, "%s: invalid user name\n", param_1); return 0; }
openssh-portable
ghidra
static intmax_t get_first_line_in_buffer(void) { if (head == ((void *)0) && !load_buffer()) ((!!sizeof(struct { _Static_assert(1, "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), gettext (\"input " "disappeared\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, (*__errno_location()), gettext("input disappeared")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, (*__errno_location()), gettext("input disappeared")), ((0) ? (void)0 : __builtin_unreachable())))); return head->first_available; }
undefined8 get_first_line_in_buffer(void) { char cVar1; undefined8 uVar2; int *piVar3; if (head == 0) { cVar1 = load_buffer(); if (cVar1 != '\x01') { uVar2 = gettext("input disappeared"); piVar3 = __errno_location(); error(1, *piVar3, uVar2); } } return *(undefined8 *)(head + 0x18); }
coreutils
ghidra
u_int cipher_is_cbc(const struct sshcipher *c) { return (c->flags & (1 << 0)) != 0; }
long long cipher_is_cbc(struct_0 *a0) { return (a0->field_18 & 1); }
openssh-portable
angr_dream
SHELL_VAR *assign_array_var_from_word_list(var, list, flags) SHELL_VAR *var; WORD_LIST *list; int flags; { register arrayind_t i; register WORD_LIST *l; ARRAY *a; a = (ARRAY *)((var)->value); i = (flags & 0x0001) ? ((a)->max_index) + 1 : 0; for (l = list; l; l = l->next, i++) bind_array_var_internal(var, i, 0, l->word->word, flags & ~0x0001); ((var)->attributes &= ~(0x0001000)); return var; }
long long assign_array_var_from_word_list(struct_0 *a0, unsigned long long a1, unsigned long a2) { unsigned long long *v0; int tmp_30; unsigned long long v3; struct_1 *v4; unsigned long long v5; v0 = a0->field_8; v3 = (!(a2 & 1) ? *(v0) + 1 : 0); for (v4 = a1; v4; v3 += 1) { bind_array_var_internal(a0, v3, 0x0, v4->field_8->field_0, a2 & -2); v4 = v4->field_0; } v5 = a0->field_28; *(&v5) = (a0->field_28 >> 8) & 239; tmp_30 = v5; a0->field_28 = tmp_30; return a0; }
bash
angr_sailr
vi_search_prev(EditLine *el, wint_t c __attribute__((__unused__))) { return cv_search(el, 24); }
long long vi_search_prev(unsigned long long a0, unsigned long a1) { unsigned int v0; v0 = a1; return cv_search(a0, 0x18); }
libedit
angr_sailr
static void print_all_completions() { progcomp_walk(print_compitem); }
void print_all_completions() { unsigned long long v1; v1 = progcomp_walk(print_compitem); return; }
bash
angr_sailr
hist_get(EditLine *el) { const wchar_t *hp; int h; size_t blen, hlen; if (el->el_history.eventno == 0) { (void)wcsncpy(el->el_line.buffer, el->el_history.buf, el->el_history.sz); el->el_line.lastchar = el->el_line.buffer + (el->el_history.last - el->el_history.buf); if (el->el_map.type == 1) el->el_line.cursor = el->el_line.buffer; else el->el_line.cursor = el->el_line.lastchar; return 4; } if (el->el_history.ref == ((void *)0)) return 6; hp = (((el)->el_flags & 0x040) ? hist_convert(el, 3, ((void *)0)) : ((((*(el)->el_history.fun)((el)->el_history.ref, &(el)->el_history.ev, 3, ((void *)0))) == -1) ? ((void *)0) : (el)->el_history.ev.str)); if (hp == ((void *)0)) return 6; for (h = 1; h < el->el_history.eventno; h++) if ((hp = (((el)->el_flags & 0x040) ? hist_convert(el, 6, ((void *)0)) : ((((*(el)->el_history.fun)((el)->el_history.ref, &(el)->el_history.ev, 6, ((void *)0))) == -1) ? ((void *)0) : (el)->el_history.ev.str))) == ((void *)0)) goto out; hlen = wcslen(hp) + 1; blen = (size_t)(el->el_line.limit - el->el_line.buffer); if (hlen > blen && !ch_enlargebufs(el, hlen)) goto out; memcpy(el->el_line.buffer, hp, hlen * sizeof(*hp)); el->el_line.lastchar = el->el_line.buffer + hlen - 1; if (el->el_line.lastchar > el->el_line.buffer && el->el_line.lastchar[-1] == '\n') el->el_line.lastchar--; if (el->el_line.lastchar > el->el_line.buffer && el->el_line.lastchar[-1] == ' ') el->el_line.lastchar--; if (el->el_map.type == 1) el->el_line.cursor = el->el_line.buffer; else el->el_line.cursor = el->el_line.lastchar; return 4; out: el->el_history.eventno = h; return 6; }
long long hist_get(struct_0 *a0) { unsigned int v0; void *v1; unsigned long v2; unsigned long long v3; unsigned long long v5; void *v6; void *v7; if (!a0->field_470) { wcsncpy(a0->field_50, a0->field_458, a0->field_460); a0->field_60 = a0->field_50 + a0->field_468 - a0->field_458; if (a0->field_420 == 1) { a0->field_58 = a0->field_50; v5 = 4; return v5; } a0->field_58 = a0->field_60; v5 = 4; return v5; } else if (a0->field_478) { if (!(a0->field_2c & 64)) v6 = (a0->field_480(a0->field_478, &a0->padding_488, 3, 0, a0->field_480) == -1 ? a0->field_490 : 0); else v6 = hist_convert(a0, 0x3, 0x0); v1 = v6; if (!v1) { v5 = 6; return v5; } for (v0 = 1; v0 < a0->field_470; v0 += 1) { if (!(a0->field_2c & 64)) v7 = (a0->field_480(a0->field_478, &a0->padding_488, 6, 0, a0->field_480) == -1 ? a0->field_490 : 0); else v7 = hist_convert(a0, 0x6, 0x0); v1 = v7; if (!v1) { a0->field_470 = v0; v5 = 6; return v5; } } v2 = wcslen(v1) + 1; v3 = a0->field_68 - a0->field_50 >> 2; if (v2 > v3 && !ch_enlargebufs(a0, v2, v2)) { a0->field_470 = v0; v5 = 6; return v5; } memcpy(a0->field_50, v1, v2 * 4); a0->field_60 = v2 * 4 - 4 + a0->field_50; if (a0->field_60 > a0->field_50 && *((a0->field_60 - 4)) == 10) a0->field_60 = a0->field_60 - 4; if (a0->field_60 > a0->field_50 && *((a0->field_60 - 4)) == 32) a0->field_60 = a0->field_60 - 4; if (a0->field_420 == 1) { a0->field_58 = a0->field_50; v5 = 4; return v5; } a0->field_58 = a0->field_60; v5 = 4; return v5; } else { v5 = 6; return v5; } }
libedit
angr_sailr
void chan_read_failed(struct ssh *ssh, Channel *c) { sshlog("nchan.c", __func__, 115, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "channel %d: read failed", c->self); switch (c->istate) { case 0: chan_shutdown_read(ssh, c); chan_set_istate(c, 1); break; default: sshlog("nchan.c", __func__, 122, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "channel %d: chan_read_failed for istate %d", c->self, c->istate); break; } }
long long chan_read_failed(unsigned long long a0, unsigned int a1[5]) { unsigned long long v1; sshlog("nchan.c", "chan_read_failed", 0x73, 0x0, 0x6, 0x0, "channel %d: read failed", a1[1], a1); if (!a1[4]) { chan_shutdown_read(a0, a1); v1 = chan_set_istate(a1, 0x1); return v1; } v1 = sshlog("nchan.c", "chan_read_failed", 0x7a, 0x0, 0x2, 0x0, "channel %d: chan_read_failed for istate %d", a1[1], a1[4]); return v1; }
openssh-portable
angr_sailr
void outfmt(struct output *file, const char *fmt, ...) { va_list ap; __builtin_va_start(ap, fmt); doformat(file, fmt, ap); __builtin_va_end(ap); }
long long outfmt() { unsigned int v0; unsigned int v1; unsigned long v2; unsigned long v3; unsigned long v4; char v5; unsigned long v6; unsigned long v7; unsigned long v8; unsigned long v9; int v10; int v11; int v12; int v13; int v14; int v15; int v16; int v17; unsigned long v18; unsigned long v19; unsigned long v20; unsigned long v21; unsigned long v22; char v23; int v24; int v25; int v26; int v27; int v28; int v29; int v30; int v31; unsigned long long *v32; void *v33; unsigned long long v34; v6 = v19; v7 = v20; v8 = v21; v9 = v22; if (v23) { v10 = v24; v11 = v25; v12 = v26; v13 = v27; v14 = v28; v15 = v29; v16 = v30; v17 = v31; } v4 = v32[5]; v0 = 16; v1 = 48; v2 = &v18; v3 = &v5; doformat(v33, v34, &v0); if (!(v4 ^ v32[5])) return 0; __stack_chk_fail(); }
dash-0.5.11+git20210903+057cd650a4ed
angr_phoenix
static int ipvrf_filter_req(struct nlmsghdr *nlh, int reqlen) { struct rtattr *linkinfo; int err; if (vrf_filter.kind) { linkinfo = addattr_nest(nlh, reqlen, IFLA_LINKINFO); err = addattr_l(nlh, reqlen, IFLA_INFO_KIND, vrf_filter.kind, strlen(vrf_filter.kind)); if (err) return err; addattr_nest_end(nlh, linkinfo); } return 0; }
long long ipvrf_filter_req(unsigned long long a0, unsigned long a1) { unsigned int v0; unsigned long long v1; void *v3; if (g_401b38) { v1 = addattr_nest(a0, a1, 0x12, a1); v0 = addattr_l(a0, a1, 0x1, g_401b38, strlen(g_401b38)); if (v0) v3 = v0; else addattr_nest_end(a0, v1, v1); } if (!v0 || !g_401b38) v3 = 0; return v3; }
iproute2-6.0.0
angr_dream
char *filename_completion_function(const char *s, int i) { return rl_filename_completion_function(s, i); }
long long filename_completion_function(unsigned long long a0, unsigned long a1) { return rl_filename_completion_function(a0, a1, a1); }
bash
angr_phoenix
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 wchar_t *do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc, int iswextra) { if (flags & 0x0002) { switch (c) { case L'\n': *dst++ = L'\\'; *dst++ = L'n'; return dst; case L'\r': *dst++ = L'\\'; *dst++ = L'r'; return dst; case L'\b': *dst++ = L'\\'; *dst++ = L'b'; return dst; case L'\a': *dst++ = L'\\'; *dst++ = L'a'; return dst; case L'\v': *dst++ = L'\\'; *dst++ = L'v'; return dst; case L'\t': *dst++ = L'\\'; *dst++ = L't'; return dst; case L'\f': *dst++ = L'\\'; *dst++ = L'f'; return dst; case L' ': *dst++ = L'\\'; *dst++ = L's'; return dst; case L'\0': *dst++ = L'\\'; *dst++ = L'0'; if ((((u_char)(nextc)) >= L'0' && ((u_char)(nextc)) <= L'7')) { *dst++ = L'0'; *dst++ = L'0'; } return dst; case L'n': case L'r': case L'b': case L'a': case L'v': case L't': case L'f': case L's': case L'0': case L'M': case L'^': case L'$': break; default: if ((((flags) & 0x4000) ? ((*__ctype_b_loc())[(int)((c))] & (unsigned short int)_ISgraph) : iswgraph(c)) && !(((u_char)(c)) >= L'0' && ((u_char)(c)) <= L'7')) { *dst++ = L'\\'; *dst++ = c; return dst; } } } if (iswextra || ((c & 0177) == L' ') || (flags & 0x0001)) { *dst++ = L'\\'; *dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + L'0'; *dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + L'0'; *dst++ = (c & 07) + L'0'; } else { if ((flags & 0x0040) == 0) *dst++ = L'\\'; if (c & 0200) { c &= 0177; *dst++ = L'M'; } if (iswcntrl(c)) { *dst++ = L'^'; if (c == 0177) *dst++ = L'?'; else *dst++ = c + L'@'; } else { *dst++ = L'-'; *dst++ = c; } } return dst; }
undefined4 *do_mbyte(undefined4 *param_1, wint_t param_2, uint param_3, byte param_4, int param_5) { int iVar1; ushort **ppuVar2; undefined4 *puVar3; bool bVar4; uint local_14; undefined4 *local_10; if ((param_3 & 2) == 0) goto LAB_001004a3; switch (param_2) { case 0: *param_1 = 0x5c; puVar3 = param_1 + 2; param_1[1] = 0x30; if ((0x2f < param_4) && (param_4 < 0x38)) { *puVar3 = 0x30; puVar3 = param_1 + 4; param_1[3] = 0x30; } break; default: if ((param_3 & 0x4000) == 0) { iVar1 = iswgraph(param_2); bVar4 = iVar1 != 0; } else { ppuVar2 = __ctype_b_loc(); bVar4 = SUB21((*ppuVar2)[(int)param_2] >> 0xf, 0); } if ((bVar4 != false) && (((byte)param_2 < 0x30 || (0x37 < (byte)param_2)))) { *param_1 = 0x5c; param_1[1] = param_2; return param_1 + 2; } case 0x24: case 0x30: case 0x4d: case 0x5e: case 0x61: case 0x62: case 0x66: case 0x6e: case 0x72: case 0x73: case 0x74: case 0x76: LAB_001004a3: if (((param_5 == 0) && ((param_2 & 0x7f) != 0x20)) && ((param_3 & 1) == 0)) { local_10 = param_1; if ((param_3 & 0x40) == 0) { local_10 = param_1 + 1; *param_1 = 0x5c; } local_14 = param_2; if ((param_2 & 0x80) != 0) { local_14 = param_2 & 0x7f; *local_10 = 0x4d; local_10 = local_10 + 1; } iVar1 = iswcntrl(local_14); if (iVar1 == 0) { *local_10 = 0x2d; puVar3 = local_10 + 2; local_10[1] = local_14; } else { *local_10 = 0x5e; if (local_14 == 0x7f) { puVar3 = local_10 + 2; local_10[1] = 0x3f; } else { puVar3 = local_10 + 2; local_10[1] = local_14 + 0x40; } } } else { *param_1 = 0x5c; param_1[1] = (param_2 >> 6 & 3) + 0x30; param_1[2] = (param_2 >> 3 & 7) + 0x30; puVar3 = param_1 + 4; param_1[3] = (param_2 & 7) + 0x30; } break; case 7: *param_1 = 0x5c; puVar3 = param_1 + 2; param_1[1] = 0x61; break; case 8: *param_1 = 0x5c; puVar3 = param_1 + 2; param_1[1] = 0x62; break; case 9: *param_1 = 0x5c; puVar3 = param_1 + 2; param_1[1] = 0x74; break; case 10: *param_1 = 0x5c; puVar3 = param_1 + 2; param_1[1] = 0x6e; break; case 0xb: *param_1 = 0x5c; puVar3 = param_1 + 2; param_1[1] = 0x76; break; case 0xc: *param_1 = 0x5c; puVar3 = param_1 + 2; param_1[1] = 0x66; break; case 0xd: *param_1 = 0x5c; puVar3 = param_1 + 2; param_1[1] = 0x72; break; case 0x20: *param_1 = 0x5c; puVar3 = param_1 + 2; param_1[1] = 0x73; } return puVar3; }
libedit
ghidra
int match_host_and_ip(const char *host, const char *ipaddr, const char *patterns) { int mhost, mip; if ((mip = addr_match_list(ipaddr, patterns)) == -2) return -1; else if (host == ((void *)0) || ipaddr == ((void *)0) || mip == -1) return 0; if ((mhost = match_hostname(host, patterns)) == -1) return 0; if (mhost == 0 && mip == 0) return 0; return 1; }
undefined8 match_host_and_ip(long param_1, long param_2, undefined8 param_3) { int iVar1; int iVar2; undefined8 uVar3; iVar1 = addr_match_list(param_2, param_3); if (iVar1 == -2) { uVar3 = 0xffffffff; } else if (((param_1 == 0) || (param_2 == 0)) || (iVar1 == -1)) { uVar3 = 0; } else { iVar2 = match_hostname(param_1, param_3); if (iVar2 == -1) { uVar3 = 0; } else if ((iVar2 == 0) && (iVar1 == 0)) { uVar3 = 0; } else { uVar3 = 1; } } return uVar3; }
openssh-portable
ghidra
int absolute_pathname(string) const char *string; { if (string == 0 || *string == '\0') return (0); if (((string)[0] == '/')) return (1); if (string[0] == '.' && (((string[1]) == '/') || (string[1]) == 0)) return (1); if (string[0] == '.' && string[1] == '.' && (((string[2]) == '/') || (string[2]) == 0)) return (1); return (0); }
undefined8 absolute_pathname(char *param_1) { undefined8 uVar1; if ((param_1 == (char *)0x0) || (*param_1 == '\0')) { uVar1 = 0; } else if (*param_1 == '/') { uVar1 = 1; } else if ((*param_1 == '.') && ((param_1[1] == '/' || (param_1[1] == '\0')))) { uVar1 = 1; } else if ((*param_1 == '.') && ((param_1[1] == '.' && ((param_1[2] == '/' || (param_1[2] == '\0')))))) { uVar1 = 1; } else { uVar1 = 0; } return uVar1; }
bash
ghidra
static void usage(int status) { FILE *usageout = (0 != status) ? stderr : stdout; (void)fprintf(usageout, gettext("Usage: %s [option] GROUP\n" "\n" "Options:\n") , Prog); (void)fputs(gettext(" -a, --add USER add USER to GROUP\n"), usageout); (void)fputs( gettext(" -d, --delete USER remove USER from GROUP\n"), usageout); (void)fputs(gettext(" -h, --help display this help " "message and exit\n"), usageout); (void)fputs( gettext(" -Q, --root CHROOT_DIR directory to chroot into\n"), usageout); (void)fputs( gettext(" -r, --remove-password remove the GROUP's password\n"), usageout); (void)fputs(gettext(" -R, --restrict restrict access to " "GROUP to its members\n"), usageout); (void)fputs( gettext( " -M, --members USER,... set the list of members of GROUP\n"), usageout); (void)fputs(gettext(" -A, --administrators ADMIN,...\n" " set the list of " "administrators for GROUP\n"), usageout); (void)fputs(gettext("Except for the -A and -M options, the options cannot be " "combined.\n"), usageout); exit(status); }
void usage(unsigned long a0) { void *v0; unsigned long v1; unsigned long v3; void *v4; v1 = v3; if (a0) v4 = stderr; else v4 = stdout; v0 = v4; fprintf(v0, gettext("Usage: %s [option] GROUP\n\nOptions:\n")); fputs(gettext(" -a, --add USER add USER to GROUP\n"), v0); fputs(gettext(" -d, --delete USER remove USER from GROUP\n"), v0); fputs(gettext(" -h, --help display this help message and " "exit\n"), v0); fputs(gettext(" -Q, --root CHROOT_DIR directory to chroot into\n"), v0); fputs( gettext(" -r, --remove-password remove the GROUP's password\n"), v0); fputs(gettext(" -R, --restrict restrict access to GROUP to " "its members\n"), v0); fputs( gettext( " -M, --members USER,... set the list of members of GROUP\n"), v0); fputs(gettext(" -A, --administrators ADMIN,...\n " " set the list of administrators for GROUP\n"), v0); fputs(gettext("Except for the -A and -M options, the options cannot be " "combined.\n"), v0); exit(a0); }
shadow
angr_phoenix
static void check_perms(void) {}
long long check_perms() { unsigned long v1; return v1; }
shadow
angr_phoenix
static int set_tty_settings(int tty, struct termios *tiop) { if (_set_tty_settings(tty, tiop) < 0) return -1; return 0; }
int set_tty_settings(unsigned long a0, void *a1) { return (_set_tty_settings(a0, a1) < 0 ? 0 : -1); }
bash
angr_sailr
static errcode_t pass1_write_inode(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode) { e2fsck_t ctx = (e2fsck_t)fs->priv_data; if ((ino == ctx->stashed_ino) && ctx->stashed_inode && (inode != ctx->stashed_inode)) *ctx->stashed_inode = *inode; return (2133571393L); }
long long pass1_write_inode(struct_0 *a0, unsigned long a1, unsigned long long a2[16]) { unsigned long long v0[16]; int tmp_47; int tmp_57; int tmp_69; int tmp_81; int tmp_93; int tmp_105; int tmp_117; struct_1 *v1; unsigned long long v3[16]; unsigned long long v4; v0[0] = a2; v1 = a0->field_e0; if (a1 == v1->field_218 && v1->field_220 && a2 != v1->field_220) { v3 = v1->field_220; tmp_47 = a2[1]; v1->field_220->field_0 = a2[0]; v3[1] = tmp_47; tmp_57 = a2[3]; v3[2] = a2[2]; v3[3] = tmp_57; tmp_69 = a2[5]; v3[4] = a2[4]; v3[5] = tmp_69; tmp_81 = a2[7]; v3[6] = a2[6]; v3[7] = tmp_81; tmp_93 = a2[9]; v3[8] = a2[8]; v3[9] = tmp_93; tmp_105 = a2[11]; v3[10] = a2[10]; v3[11] = tmp_105; tmp_117 = a2[13]; v3[12] = a2[12]; v3[13] = tmp_117; v4 = a2[15]; v3[14] = a2[14]; v3[15] = v4; } return 2133571393; }
e2fsprogs-1.46.5
angr_sailr
static wchar_t *do_mvis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra) { if ((c != L'\n') && ((iswspace(c) && (nextc == L'\r' || nextc == L'\n')) || (!iswspace(c) && (c < 33 || (c > 60 && c < 62) || c > 126)) || wcschr(L"#$@[\\]^`{|}~", c) != ((void *)0))) { *dst++ = L'='; *dst++ = L"0123456789ABCDEF"[((unsigned int)c >> 4) & 0xf]; *dst++ = L"0123456789ABCDEF"[(unsigned int)c & 0xf]; } else dst = do_svis(dst, c, flags, nextc, extra); return dst; }
wint_t *do_mvis(wint_t *a1, wint_t a2, short a3, unsigned int a4, const wchar_t *a5) { _DWORD *v9; if (a2 == 10 || (!iswspace(a2) || a4 != 13 && a4 != 10) && (iswspace(a2) || a2 > 0x20 && a2 != 61 && a2 <= 0x7E) && !wcschr(U"#$@[\\]^`{|}~", a2)) { return do_svis(a1, a2, a3, a4, a5); } *a1 = 61; a1[1] = dword_16C8[(unsigned char)a2 >> 4]; v9 = a1 + 3; a1[2] = dword_16C8[a2 & 0xF]; return v9; }
libbsd-0.11.7
ida
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]... NAME TYPE [MAJOR MINOR]\n"), program_name); fputs_unlocked(gettext("Create the special file NAME of the given TYPE.\n"), stdout) ; emit_mandatory_arg_note(); fputs_unlocked(gettext(" -m, --mode=MODE set file permission bits to " "MODE, not a=rw - umask\n"), stdout) ; fputs_unlocked( gettext(" -Z set the SELinux security context to " "default type\n --context[=CTX] like -Z, or if CTX is " "specified then set the SELinux\n or " "SMACK security context to CTX\n"), stdout) ; fputs_unlocked(gettext(" --help display this help and exit\n"), stdout); fputs_unlocked( gettext(" --version output version information and exit\n"), stdout); fputs_unlocked( gettext("\nBoth MAJOR and MINOR must be specified when TYPE is b, c, " "or u, and they\nmust be omitted when TYPE is p. If MAJOR or " "MINOR begins with 0x or 0X,\nit is interpreted as " "hexadecimal; otherwise, if it begins with 0, as " "octal;\notherwise, as decimal. TYPE may be:\n"), stdout) ; fputs_unlocked(gettext("\n b create a block (buffered) special " "file\n c, u create a character (unbuffered) " "special file\n p create a FIFO\n"), stdout) ; printf(gettext("\n" "NOTE: your shell may have its own version of %s, which " "usually supersedes\n" "the version described here. Please refer to your shell's " "documentation\n" "for details about the options it supports.\n"), "mknod"); emit_ancillary_info("mknod"); } 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]... NAME TYPE [MAJOR MINOR]\n")); fputs_unlocked(gettext("Create the special file NAME of the given TYPE.\n"), stdout); emit_mandatory_arg_note(); fputs_unlocked(gettext(" -m, --mode=MODE set file permission bits to " "MODE, not a=rw - umask\n"), stdout); fputs_unlocked( gettext(" -Z set the SELinux security context to " "default type\n --context[=CTX] like -Z, or if CTX is " "specified then set the SELinux\n or " "SMACK security context to CTX\n"), stdout); fputs_unlocked(gettext(" --help display this help and exit\n"), stdout); fputs_unlocked( gettext(" --version output version information and exit\n"), stdout); fputs_unlocked( gettext("\nBoth MAJOR and MINOR must be specified when TYPE is b, c, " "or u, and they\nmust be omitted when TYPE is p. If MAJOR or " "MINOR begins with 0x or 0X,\nit is interpreted as " "hexadecimal; otherwise, if it begins with 0, as " "octal;\notherwise, as decimal. TYPE may be:\n"), stdout); fputs_unlocked(gettext("\n b create a block (buffered) special " "file\n c, u create a character (unbuffered) " "special file\n p create a FIFO\n"), stdout); printf(gettext( "\nNOTE: your shell may have its own version of %s, which usually " "supersedes\nthe version described here. Please refer to your shell's " "documentation\nfor details about the options it supports.\n")); emit_ancillary_info("mknod"); } exit(a0); }
coreutils
angr_sailr
static int xfrm_ae_print(struct nlmsghdr *n, void *arg) { FILE *fp = (FILE *)arg; struct xfrm_aevent_id *id = ((void *)(((char *)n) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))))); fprintf(fp, "Async event "); xfrm_ae_flags_print(id->flags, arg); fprintf(fp, "\n\t"); fprintf(fp, "src %s ", rt_addr_n2a(id->sa_id.family, sizeof(id->saddr), &id->saddr)); xfrm_usersa_print(&id->sa_id, id->reqid, fp); fprintf(fp, "\n"); fflush(fp); return 0; }
undefined8 xfrm_ae_print(long param_1, FILE *param_2) { undefined8 uVar1; fprintf(param_2, "Async event "); xfrm_ae_flags_print(*(undefined4 *)(param_1 + 0x38), param_2); fprintf(param_2, "\n\t"); uVar1 = rt_addr_n2a(*(undefined2 *)(param_1 + 0x24), 0x10, param_1 + 0x28); fprintf(param_2, "src %s ", uVar1); xfrm_usersa_print(param_1 + 0x10, *(undefined4 *)(param_1 + 0x3c), param_2); fprintf(param_2, "\n"); fflush(param_2); return 0; }
iproute2-6.0.0
ghidra
static char *user_group_str(char const *user, char const *group) { char *spec = ((void *)0); if (user) { if (group) { spec = xmalloc(strlen(user) + 1 + strlen(group) + 1); stpcpy(stpcpy(stpcpy(spec, user), ":"), group); } else { spec = xstrdup(user); } } else if (group) { spec = xstrdup(group); } return spec; }
char *user_group_str(const char *a1, const char *a2) { size_t v2; size_t v3; char *v4; char *v5; char *dest; dest = 0LL; if (a1) { if (a2) { v2 = strlen(a1); v3 = strlen(a2); dest = (char *)xmalloc(v2 + v3 + 2); v4 = stpcpy(dest, a1); v5 = stpcpy(v4, ":"); stpcpy(v5, a2); } else { return (char *)xstrdup(a1); } } else if (a2) { return (char *)xstrdup(a2); } return dest; }
coreutils
ida
int main(int argc, char **argv) { int c, i; int common; int mapping[3]; int rev_mapping[3]; int incompat = 0; enum { OPTION_3, OPTION_A, OPTION_E, OPTION_X, OPTION_e, OPTION_x }; _Bool conflicts_found; struct diff_block *thread0, *thread1, *last_block; struct diff3_block *diff3; int tag_count = 0; char *tag_strings[3]; char *commonname; char **file; struct stat statb; exit_failure = 2; ; set_program_name(argv[0]); setlocale(6, ""); bindtextdomain("diffutils", "/usr/local/share/locale"); textdomain("diffutils"); c_stack_action(0); xstdopen(); while ((c = getopt_long(argc, argv, "aeimvx3AEL:TX", longopts, 0)) != -1) { switch (c) { case 'a': text = 1; break; case 'A': show_2nd = 1; flagging = 1; incompat |= 1 << OPTION_A; break; case 'x': overlap_only = 1; incompat |= 1 << OPTION_x; break; case '3': simple_only = 1; incompat |= 1 << OPTION_3; break; case 'i': finalwrite = 1; break; case 'm': merge = 1; break; case 'X': overlap_only = 1; incompat |= 1 << OPTION_X; break; case 'E': flagging = 1; incompat |= 1 << OPTION_E; break; case 'e': incompat |= 1 << OPTION_e; break; case 'T': initial_tab = 1; break; case STRIP_TRAILING_CR_OPTION: strip_trailing_cr = 1; break; case 'v': version_etc(stdout, "diff3", "GNU diffutils", Version, proper_name("Randy Smith"), (char *)((void *)0)); check_stdout(); return 0; case DIFF_PROGRAM_OPTION: diff_program = optarg; break; case HELP_OPTION: usage(); check_stdout(); return 0; case 'L': if (tag_count < 3) { tag_strings[tag_count++] = optarg; break; } try_help("too many file label options", 0); default: try_help(0, 0); } } edscript = !!incompat & !merge; show_2nd |= !incompat & merge; flagging |= !incompat & merge; if (incompat & (incompat - 1) || finalwrite & merge || (tag_count && !flagging)) try_help("incompatible options", 0); if (argc - optind != 3) { if (argc - optind < 3) try_help("missing operand after '%s'", argv[argc - 1]); else try_help("extra operand '%s'", argv[optind + 3]); } file = &argv[optind]; for (i = tag_count; i < 3; i++) tag_strings[i] = file[i]; common = 2 - (edscript | merge); if ((strcmp(file[common], "-") == 0)) { common = 3 - common; if ((strcmp(file[0], "-") == 0) || (strcmp(file[common], "-") == 0)) fatal("'-' specified for more than one input file"); } mapping[0] = 0; mapping[1] = 3 - common; mapping[2] = common; for (i = 0; i < 3; i++) rev_mapping[mapping[i]] = i; for (i = 0; i < 3; i++) if (!(strcmp(file[i], "-") == 0)) { if (stat(file[i], &statb) < 0) perror_with_exit(file[i]); else if (((((statb.st_mode)) & 0170000) == (0040000))) ((!!sizeof(struct { _Static_assert(2, "verify_expr (" "2" ", " "(error (2, 21, \"%s\", file[i]), assume (false))" ")"); int _gl_dummy; })) ? ((error(2, 21, "%s", file[i]), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(2, 21, "%s", file[i]), ((0) ? (void)0 : __builtin_unreachable())))); } signal(17, ((__sighandler_t)0)); char *b0, *b1; commonname = file[rev_mapping[2]]; thread1 = process_diff(file[rev_mapping[1]], commonname, &last_block, &b1); thread0 = process_diff(file[rev_mapping[0]], commonname, &last_block, &b0); next_to_n2(thread0); next_to_n2(thread1); diff3 = make_3way_diff(thread0, thread1); free_diff_block(thread0); free_diff_block(thread1); if (edscript) conflicts_found = output_diff3_edscript(stdout, diff3, mapping, rev_mapping, tag_strings[0], tag_strings[1], tag_strings[2]); else if (merge) { xfreopen(file[rev_mapping[0]], "r", stdin); conflicts_found = output_diff3_merge(stdin, stdout, diff3, mapping, rev_mapping, tag_strings[0], tag_strings[1], tag_strings[2]); if (ferror_unlocked(stdin)) fatal("read failed"); } else { output_diff3(stdout, diff3, mapping, rev_mapping); conflicts_found = 0; } free(b0); free(b1); check_stdout(); exit(conflicts_found); }
undefined8 main(int param_1, undefined8 *param_2) { int iVar1; long in_FS_OFFSET; undefined8 uVar2; byte local_135; int local_134; int local_130; uint local_12c; int local_128; undefined local_120[8]; void *local_118; void *local_110; char **local_108; char *local_100; undefined8 local_f8; undefined8 local_f0; undefined8 local_e8; int local_e0[4]; int local_d0; int local_cc; char *local_c8[4]; stat local_a8; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_12c = 0; local_128 = 0; _exit_failure = 2; set_program_name(*param_2); setlocale(6, ""); bindtextdomain("diffutils", "/usr/local/share/locale"); textdomain("diffutils"); c_stack_action(0); xstdopen(); LAB_00100262: iVar1 = getopt_long(param_1, param_2, "aeimvx3AEL:TX", longopts, 0); if (iVar1 != -1) { switch (iVar1) { case 0x33: simple_only = 1; local_12c = local_12c | 1; break; case 0x41: show_2nd = 1; flagging = 1; local_12c = local_12c | 2; break; case 0x45: flagging = 1; local_12c = local_12c | 4; break; case 0x4c: if (local_128 < 3) { local_c8[local_128] = optarg; local_128 = local_128 + 1; break; } try_help("too many file label options", 0); default: try_help(0, 0); break; case 0x54: initial_tab = 1; break; case 0x58: overlap_only = 1; local_12c = local_12c | 8; break; case 0x61: text = 1; break; case 0x65: local_12c = local_12c | 0x10; break; case 0x69: finalwrite = 1; break; case 0x6d: merge = 1; break; case 0x76: uVar2 = proper_name("Randy Smith"); version_etc(stdout, "diff3", "GNU diffutils", Version, uVar2, 0); check_stdout(); goto LAB_001008fa; case 0x78: overlap_only = 1; local_12c = local_12c | 0x20; break; case 0x80: diff_program = optarg; break; case 0x81: usage(); check_stdout(); LAB_001008fa: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return 0; case 0x82: goto switchD_001000ef_caseD_82; } goto LAB_00100262; } edscript = ((merge ^ 1) & local_12c != 0) != 0; show_2nd = (byte)(show_2nd | merge & local_12c == 0) != 0; flagging = (byte)(flagging | merge & local_12c == 0) != 0; if ((((local_12c - 1 & local_12c) != 0) || ((merge & finalwrite) != 0)) || ((local_128 != 0 && (!(bool)flagging)))) { try_help("incompatible options", 0); } if (param_1 - optind != 3) { if (param_1 - optind < 3) { try_help("missing operand after \'%s\'", param_2[(long)param_1 + -1]); } try_help("extra operand \'%s\'", param_2[(long)optind + 3]); } local_108 = (char **)(param_2 + optind); for (local_134 = local_128; local_134 < 3; local_134 = local_134 + 1) { local_c8[local_134] = local_108[local_134]; } local_130 = 2 - (uint)(merge | edscript); iVar1 = strcmp(local_108[local_130], "-"); if (iVar1 == 0) { local_130 = 3 - local_130; iVar1 = strcmp(*local_108, "-"); if ((iVar1 == 0) || (iVar1 = strcmp(local_108[local_130], "-"), iVar1 == 0)) { fatal("\'-\' specified for more than one input file"); } } local_e0[0] = 0; local_e0[1] = 3 - local_130; local_e0[2] = local_130; for (local_134 = 0; local_134 < 3; local_134 = local_134 + 1) { local_e0[(long)local_e0[local_134] + 3] = local_134; } for (local_134 = 0; local_134 < 3; local_134 = local_134 + 1) { iVar1 = strcmp(local_108[local_134], "-"); if (iVar1 != 0) { iVar1 = stat(local_108[local_134], &local_a8); if (iVar1 < 0) { perror_with_exit(local_108[local_134]); } if ((local_a8.st_mode & 0xf000) == 0x4000) { error(2, 0x15, &DAT_001035db, local_108[local_134]); } } } signal(0x11, (__sighandler_t)0x0); local_100 = local_108[local_cc]; local_f8 = process_diff(local_108[local_d0], local_100, local_120, &local_110); local_f0 = process_diff(local_108[local_e0[3]], local_100, local_120, &local_118); next_to_n2(local_f0); next_to_n2(local_f8); local_e8 = make_3way_diff(local_f0, local_f8); free_diff_block(local_f0); uVar2 = 0x100795; free_diff_block(local_f8); if (edscript == 0) { if (merge != 0) { xfreopen(local_108[local_e0[3]], &DAT_001035de, stdin); local_135 = output_diff3_merge(stdin, stdout, local_e8, local_e0, local_e0 + 3, local_c8[0], local_c8[1], local_c8[2]); iVar1 = ferror_unlocked(stdin); if (iVar1 == 0) goto LAB_001008c9; fatal("read failed"); } output_diff3(stdout, local_e8, local_e0, local_e0 + 3); local_135 = 0; } else { local_135 = output_diff3_edscript(stdout, local_e8, local_e0, local_e0 + 3, local_c8[0], local_c8[1], local_c8[2], uVar2); } LAB_001008c9: free(local_118); free(local_110); check_stdout(); exit((uint)local_135); switchD_001000ef_caseD_82: strip_trailing_cr = 1; goto LAB_00100262; }
diffutils
ghidra
void rl_initialize_funmap(void) { register int i; if (funmap_initialized) return; for (i = 0; default_funmap[i].name; i++) rl_add_funmap_entry(default_funmap[i].name, default_funmap[i].function); funmap_initialized = 1; funmap_program_specific_entry_start = i; }
char *rl_initialize_funmap() { char *result; int i; result = (char *)(unsigned int)funmap_initialized; if (!funmap_initialized) { for (i = 0;; ++i) { result = (&default_funmap)[2 * i]; if (!result) break; rl_add_funmap_entry((long)(&default_funmap)[2 * i], (long)*(&off_BA8 + 2 * i)); } funmap_initialized = 1; funmap_program_specific_entry_start = i; } return result; }
bash
ida
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] NAME...\n") , program_name); fputs_unlocked( gettext("Output each NAME with its last non-slash component and " "trailing slashes\nremoved; if NAME contains no /'s, output " "'.' (meaning the current directory).\n\n"), stdout) ; fputs_unlocked( gettext( " -z, --zero end each output line with 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); printf(gettext("\nExamples:\n %s /usr/bin/ -> \"/usr\"\n %s " "dir1/str dir2/str -> \"dir1\" followed by \"dir2\"\n %s " "stdio.h -> \".\"\n") , program_name, program_name, program_name); emit_ancillary_info("dirname"); } exit(status); }
void usage(unsigned long a0) { unsigned long v0; unsigned long v1; unsigned long v2; unsigned long v4; unsigned long v5; unsigned long v6; v2 = v4; v1 = v5; v0 = v6; if (a0) { fprintf(stderr, gettext("Try '%s --help' for more information.\n")); } else { printf(gettext("Usage: %s [OPTION] NAME...\n")); fputs_unlocked( gettext("Output each NAME with its last non-slash component and " "trailing slashes\nremoved; if NAME contains no /'s, output " "'.' (meaning the current directory).\n\n"), stdout); fputs_unlocked( gettext( " -z, --zero end each output line with 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); printf(gettext("\nExamples:\n %s /usr/bin/ -> \"/usr\"\n %s " "dir1/str dir2/str -> \"dir1\" followed by \"dir2\"\n %s " "stdio.h -> \".\"\n")); emit_ancillary_info("dirname"); } exit(a0); }
coreutils
angr_phoenix
int do_cmd(char *program, char *host, char *remuser, int port, int subsystem, char *cmd, int *fdin, int *fdout, pid_t *pid) { int pin[2], pout[2], reserved[2]; if (verbose_mode) fmprintf(stderr, "Executing: program %s host %s, user %s, command %s\n", program, host, remuser ? remuser : "(unspecified)", cmd); if (port == -1) port = sshport; if (pipe(reserved) == -1) sshfatal("scp.c", __func__, 291, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "pipe: %s", strerror((*__errno_location()))); if (pipe(pin) == -1) sshfatal("scp.c", __func__, 295, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "pipe: %s", strerror((*__errno_location()))); if (pipe(pout) == -1) sshfatal("scp.c", __func__, 297, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "pipe: %s", strerror((*__errno_location()))); close(reserved[0]); close(reserved[1]); ssh_signal(20, suspchild); ssh_signal(21, suspchild); ssh_signal(22, suspchild); *pid = fork(); if (*pid == 0) { close(pin[1]); close(pout[0]); dup2(pin[0], 0); dup2(pout[1], 1); close(pin[0]); close(pout[1]); replacearg(&args, 0, "%s", program); if (port != -1) { addargs(&args, "-p"); addargs(&args, "%d", port); } if (remuser != ((void *)0)) { addargs(&args, "-l"); addargs(&args, "%s", remuser); } if (subsystem) addargs(&args, "-s"); addargs(&args, "--"); addargs(&args, "%s", host); addargs(&args, "%s", cmd); execvp(program, args.list); perror(program); exit(1); } else if (*pid == -1) { sshfatal("scp.c", __func__, 337, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "fork: %s", strerror((*__errno_location()))); } close(pin[0]); *fdout = pin[1]; close(pout[1]); *fdin = pout[0]; ssh_signal(15, killchild); ssh_signal(2, killchild); ssh_signal(1, killchild); return 0; }
int do_cmd(char *a0, unsigned long a1, unsigned long a2, unsigned long a3, unsigned long a4, unsigned long a5, unsigned long v16, unsigned long a6, unsigned long a7) { unsigned long long v0; unsigned long v1; unsigned int *v2; unsigned int *v3; unsigned int *v4; unsigned long v5; unsigned int v6; unsigned long v7; char v8; char v9; char v10; char v11; char v12; char v13; unsigned long long v14; unsigned long v15; v7 = a1; v6 = a3; v5 = a5; v4 = v16; v3 = a6; v2 = a7; if (verbose_mode) fmprintf(stderr, "Executing: program %s host %s, user %s, command %s\n", a0); if (v6 == -1) v6 = sshport; if (pipe(&v12) == -1) { v1 = strerror(*(__errno_location())); v0 = "pipe: %s"; sshfatal("scp.c", "do_cmd", 0x123, 0x0, 0x1, 0x0); } if (pipe(&v8) == -1) { v15 = strerror(*(__errno_location())); v14 = "pipe: %s"; sshfatal("scp.c", "do_cmd", 0x127, 0x0, 0x1, 0x0); } if (pipe(&v10) == -1) { v15 = strerror(*(__errno_location())); v14 = "pipe: %s"; sshfatal("scp.c", "do_cmd", 0x129, 0x0, 0x1, 0x0); } close(*(&v12)); close(*(&v13)); ssh_signal(0x14, suspchild); ssh_signal(0x15, suspchild); ssh_signal(0x16, suspchild); *(v2) = fork(); if (!*(v2)) { close(*(&v9)); close(*(&v10)); dup2(*(&v8), 0x0); dup2(*(&v11), 0x1); close(*(&v8)); close(*(&v11)); replacearg(&remote_remote_args, 0x0, "%s", a0); if (v6 != -1) { addargs(&remote_remote_args, "-p"); addargs(&remote_remote_args, "%d"); } if (a2) { addargs(&remote_remote_args, "-l"); addargs(&remote_remote_args, "%s"); } if (a4) addargs(&remote_remote_args, "-s"); addargs(&remote_remote_args, "--"); addargs(&remote_remote_args, "%s"); addargs(&remote_remote_args, "%s"); execvp(a0, 142007424292452101); perror(a0); exit(0x1); } else { if (*(v2) == -1) { v15 = strerror(*(__errno_location())); v14 = "fork: %s"; sshfatal("scp.c", "do_cmd", 0x151, 0x0, 0x1, 0x0); } close(*(&v8)); *(v3) = *(&v9); close(*(&v11)); *(v4) = *(&v10); ssh_signal(0xf, killchild); ssh_signal(0x2, killchild); ssh_signal(0x1, killchild); return 0; } }
openssh-portable
angr_sailr
int sshsig_armor(const struct sshbuf *blob, struct sshbuf **out) { struct sshbuf *buf = ((void *)0); int r = -1; *out = ((void *)0); if ((buf = sshbuf_new()) == ((void *)0)) { sshlog("sshsig.c", __func__, 57, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "sshbuf_new failed"); r = -2; goto out; } if ((r = sshbuf_put(buf, "-----BEGIN SSH SIGNATURE-----\n", sizeof("-----BEGIN SSH SIGNATURE-----\n") - 1)) != 0) { sshlog("sshsig.c", __func__, 64, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "sshbuf_putf"); goto out; } if ((r = sshbuf_dtob64(blob, buf, 1)) != 0) { sshlog("sshsig.c", __func__, 69, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "base64 encode signature"); goto out; } if ((r = sshbuf_put(buf, "-----END SSH SIGNATURE-----", sizeof("-----END SSH SIGNATURE-----") - 1)) != 0 || (r = sshbuf_put_u8(buf, '\n')) != 0) { sshlog("sshsig.c", __func__, 76, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "sshbuf_put"); goto out; } *out = buf; buf = ((void *)0); r = 0; out: sshbuf_free(buf); return r; }
int sshsig_armor(undefined8 param_1, long *param_2) { undefined8 uVar1; undefined8 uVar2; int local_14; long local_10; *param_2 = 0; uVar1 = 0x100033; local_10 = sshbuf_new(); if (local_10 == 0) { sshlog("sshsig.c", "sshsig_armor", 0x39, 1, 2, 0, "sshbuf_new failed", uVar1); local_14 = -2; } else { local_14 = sshbuf_put(local_10, "-----BEGIN SSH SIGNATURE-----\n", 0x1e); if (local_14 == 0) { local_14 = sshbuf_dtob64(param_1, local_10, 1); if (local_14 == 0) { local_14 = sshbuf_put(local_10, "-----END SSH SIGNATURE-----", 0x1b); if (local_14 == 0) { local_14 = sshbuf_put_u8(local_10, 10); if (local_14 == 0) { *param_2 = local_10; local_10 = 0; local_14 = 0; goto LAB_001001fa; } } uVar2 = 0x1001a3; uVar1 = ssh_err(local_14); sshlog("sshsig.c", "sshsig_armor", 0x4c, 1, 2, uVar1, "sshbuf_put", uVar2); } else { uVar2 = 0x10011e; uVar1 = ssh_err(local_14); sshlog("sshsig.c", "sshsig_armor", 0x45, 1, 2, uVar1, "base64 encode signature", uVar2); } } else { uVar2 = 0x1000b3; uVar1 = ssh_err(local_14); sshlog("sshsig.c", "sshsig_armor", 0x40, 1, 2, uVar1, "sshbuf_putf", uVar2); } } LAB_001001fa: sshbuf_free(local_10); return local_14; }
openssh-portable
ghidra
static int hexchar(const char *s) { unsigned char result[2]; int i; for (i = 0; i < 2; i++) { if (s[i] >= '0' && s[i] <= '9') result[i] = (unsigned char)(s[i] - '0'); else if (s[i] >= 'a' && s[i] <= 'f') result[i] = (unsigned char)(s[i] - 'a') + 10; else if (s[i] >= 'A' && s[i] <= 'F') result[i] = (unsigned char)(s[i] - 'A') + 10; else return -1; } return (result[0] << 4) | result[1]; }
int hexchar(char *a0) { unsigned int v0; char v1; char v2; unsigned int v4; v0 = 0; while (true) { if (v0 > 1) { v4 = v2 | (v1 * 16); break; } if (a0[v0] > 47 && a0[v0] <= 57) { (&v1)[v0] = a0[v0] - 48; goto LABEL_401e77; } if (a0[v0] > 96 && a0[v0] <= 102) { (&v1)[v0] = a0[v0] - 87; goto LABEL_401e77; } if (a0[v0] <= 64) { LABEL_401e70: v4 = -1; break; } else { if (!(a0[v0] <= 70)) goto LABEL_401e70; (&v1)[v0] = a0[v0] - 55; LABEL_401e77: v0 = __addvsi3(v0, 0x1); } } return v4; }
openssh-portable
angr_phoenix
static int get_session(struct l2tp_data *p) { struct { struct nlmsghdr n; struct genlmsghdr g; char buf[(((0) + 4U - 1) & ~(4U - 1)) + (128)]; } req = { .n = { .nlmsg_type = (genl_family), .nlmsg_flags = (0x100 | 0x200 | 0x01), .nlmsg_len = (((((sizeof(struct genlmsghdr)) + 4U - 1) & ~(4U - 1)) + (0)) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1)))), }, .g = { .cmd = (L2TP_CMD_SESSION_GET), .version = (0x1), }, } ; req.n.nlmsg_seq = genl_rth.dump = ++genl_rth.seq; if (p->config.tunnel_id && p->config.session_id) { addattr32(&req.n, 128, L2TP_ATTR_CONN_ID, p->config.tunnel_id); addattr32(&req.n, 128, L2TP_ATTR_SESSION_ID, p->config.session_id); } if (rtnl_send(&genl_rth, &req, req.n.nlmsg_len) < 0) return -2; new_json_obj(json); if (rtnl_dump_filter_nc(&genl_rth, session_nlmsg, p, 0) < 0) { fprintf(stderr, "Dump terminated\n"); exit(1); } delete_json_obj(); fflush(stdout); return 0; }
void get_session(unsigned long long a0) { unsigned int v0[3]; unsigned int v1; unsigned short v2; unsigned short v3; unsigned int v4; char v5; char v6; unsigned long long v8; void *v9; unsigned long v10; unsigned long long v11; void *v12; *(&v0[0]) = a0; v8 = 18; for (v9 = &v1; v8; v9 += v10 * 8) { v8 -= 1; v1 = 0; } *(v9) = 0; v1 = 20; v2 = genl_family; v3 = 769; v5 = 8; v6 = 1; g_402dfc = g_402dfc + 1; g_402e00 = g_402dfc; v4 = g_402e00; if (v0[0] && v0[2]) { addattr32(&v1, 0x80, 0x9, v0[0]); addattr32(&v1, 0x80, 0xb, v0[2]); } if (rtnl_send(&genl_rth, &v1, v1) < 0) { v11 = 4294967294; } else { new_json_obj(json); if (rtnl_dump_filter_nc(&genl_rth, session_nlmsg, v0, 0x0) < 0) { fprintf(stderr, "Dump terminated\n"); exit(0x1); } delete_json_obj(); fflush(stdout); v12 = 0; } return; }
iproute2-6.0.0
angr_phoenix
static void pkg_array_show_item(struct pkg_array *array, struct pkginfo *pkg, void *pkg_data) { struct pkg_format_node *fmt = pkg_data; pkg_format_show(fmt, pkg, &pkg->installed); }
long long pkg_array_show_item(unsigned long a0, unsigned long long a1, unsigned long long a2) { unsigned long v0; v0 = a0; return pkg_format_show(a2, a1, a1 + 72, a1); }
dpkg
angr_dream
translate_line_number(struct file_data const *file, lin i) { return i + file->prefix_lines + 1; }
int translate_line_number(struct_0 *a0, unsigned long a1) { return a1 + a0->field_e8 + 1; }
diffutils
angr_phoenix
static void usage(void) { fprintf( stderr, "Usage: ip mptcp endpoint add ADDRESS [ dev NAME ] [ id ID ]\n" " [ port NR ] [ FLAG-LIST ]\n" " ip mptcp endpoint delete id ID [ ADDRESS ]\n" " ip mptcp endpoint change [ id ID ] [ ADDRESS ] [ port NR ] CHANGE-OPT\n" " ip mptcp endpoint show [ id ID ]\n" " ip mptcp endpoint flush\n" " ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n" " ip mptcp limits show\n" " ip mptcp monitor\n" "FLAG-LIST := [ FLAG-LIST ] FLAG\n" "FLAG := [ signal | subflow | backup | fullmesh ]\n" "CHANGE-OPT := [ backup | nobackup | fullmesh | nofullmesh ]\n"); exit(-1); }
void usage(void) { fprintf( stderr, "Usage:\tip mptcp endpoint add ADDRESS [ dev NAME ] [ id ID ]\n\t\t\t\t " " [ port NR ] [ FLAG-LIST ]\n\tip mptcp endpoint delete id ID [ " "ADDRESS ]\n\tip mptcp endpoint change [ id ID ] [ ADDRESS ] [ port NR ] " "CHANGE-OPT\n\tip mptcp endpoint show [ id ID ]\n\tip mptcp endpoint " "flush\n\tip mptcp limits set [ subflows NR ] [ add_addr_accepted NR " "]\n\tip mptcp limits show\n\tip mptcp monitor\nFLAG-LIST := [ FLAG-LIST " "] FLAG\nFLAG := [ signal | subflow | backup | fullmesh ]\nCHANGE-OPT " ":= [ backup | nobackup | fullmesh | nofullmesh ]\n"); exit(-1); }
iproute2-6.0.0
ghidra
static int speed_to_baud(speed_t speed) { switch (speed) { case 0000000: return 0; case 0000001: return 50; case 0000002: return 75; case 0000003: return 110; case 0000004: return 134; case 0000005: return 150; case 0000006: return 200; case 0000007: return 300; case 0000010: return 600; case 0000011: return 1200; case 0000012: return 1800; case 0000013: return 2400; case 0000014: return 4800; case 0000015: return 9600; case 0000016: return 19200; case 0000017: return 38400; case 0010001: return 57600; case 0010002: return 115200; case 0010003: return 230400; default: return 9600; } }
long speed_to_baud(unsigned int a1) { long result; if (a1 == 4099) return 230400LL; if (a1 > 0x1003) return 9600LL; if (a1 == 4098) return 115200LL; if (a1 > 0xF) { if (a1 == 4097) return 57600LL; return 9600LL; } switch (a1) { case 0u: result = 0LL; break; case 1u: result = 50LL; break; case 2u: result = 75LL; break; case 3u: result = 110LL; break; case 4u: result = 134LL; break; case 5u: result = 150LL; break; case 6u: result = 200LL; break; case 7u: result = 300LL; break; case 8u: result = 600LL; break; case 9u: result = 1200LL; break; case 0xAu: result = 1800LL; break; case 0xBu: result = 2400LL; break; case 0xCu: result = 4800LL; break; case 0xDu: result = 9600LL; break; case 0xEu: result = 19200LL; break; case 0xFu: result = 38400LL; break; default: return 9600LL; } return result; }
openssh-portable
ida
static void tcfinal(struct console *con) { struct termios *tio = &con->tio; int fd = con->fd; (*__errno_location()) = 0; if ((con->flags & 0x0001) == 0) { setenv("TERM", "linux", 1); return; } if (con->flags & 0x0002) return; setenv("TERM", "vt100", 1); tio->c_iflag |= (0002000 | 0010000); tio->c_lflag |= (0000002 | 0000001 | 0000010 | 0000020 | 0000040 | 0004000); tio->c_oflag |= 0000001; tio->c_cc[0] = ('c' & 037); tio->c_cc[1] = 034; tio->c_cc[2] = con->cp.erase; tio->c_cc[3] = con->cp.kill; tio->c_cc[4] = ('d' & 037); tio->c_cc[7] = '\0'; tio->c_cc[8] = ('q' & 037); tio->c_cc[9] = ('s' & 037); tio->c_cc[10] = ('z' & 037); tio->c_cc[11] = '\0'; if (con->cp.eol == ('m' & 037)) { tio->c_iflag |= 0000400; tio->c_iflag &= ~(0000100 | 0000200); tio->c_oflag |= 0000004; tio->c_oflag &= ~(0000010 | 0000040); } switch (con->cp.parity) { default: case 0: tio->c_cflag &= ~(0001000 | 0000400); tio->c_iflag &= ~(0000020 | 0000040); break; case 1: tio->c_cflag |= 0001000; case 2: tio->c_cflag |= 0000400; tio->c_iflag |= (0000020 | 0000040); case (1 | 2): tio->c_cflag &= ~0000060; tio->c_cflag |= 0000040; break; } (void)tcsetattr(fd, 0, tio); }
void tcfinal(struct_0 *a0) { unsigned int v0; int tmp_58; int tmp_36; int tmp_17; int tmp_24; struct_1 *v1; unsigned long long v3; unsigned long long v4; unsigned long long v5; unsigned long long v6; unsigned long long v7; unsigned long long v8; unsigned long long v9; unsigned long long v10; v1 = &a0[1].padding_0; v0 = a0->field_14; *(__errno_location()) = 0; if (!(a0->field_10 & 1)) { v3 = setenv("TERM", "linux", 0x1); } else { v4 = a0->field_10 & 2; if (!(a0->field_10 & 2)) { setenv("TERM", "vt100", 0x1); v5 = v1->field_0; *(&v5) = (v1->field_0 >> 8) | 20; tmp_58 = v5; v1->field_0 = tmp_58; v1->field_c = v1->field_c | 2107; v1->field_4 = v1->field_4 | 1; v1->field_11 = 3; v1->field_12 = 28; v1->field_13 = a0->field_20; v1->field_14 = a0->field_21; v1->field_15 = 4; v1->field_18 = 0; v1->field_19 = 17; v1->field_1a = 19; v1->field_1b = 26; v1->field_1c = 0; if (a0->field_22 == 13) { v6 = v1->field_0; *(&v6) = (v1->field_0 >> 8) | 1; tmp_36 = v6; v1->field_0 = tmp_36; *(&v6) = v1->field_0; *(&v6) = v1->field_0 & 63; v1->field_0 = v6; v1->field_4 = v1->field_4 | 4; v1->field_4 = v1->field_4 & -41; } if (a0->field_23 == 3) { LABEL_40047e: v1->field_8 = v1->field_8 & -49; v1->field_8 = v1->field_8 | 32; } else { if (a0->field_23 <= 3) { if (a0->field_23 == 1) { v7 = v1->field_8; *(&v7) = (v1->field_8 >> 8) | 2; tmp_17 = v7; v1->field_8 = tmp_17; LABEL_400456: v9 = v1->field_8; *(&v9) = (v1->field_8 >> 8) | 1; tmp_24 = v9; v1->field_8 = tmp_24; v1->field_0 = v1->field_0 | 48; goto LABEL_40047e; } else if (a0->field_23 == 2) { goto LABEL_400456; } } v8 = v1->field_8; *(&v8) = (v1->field_8 >> 8) & 252; tmp_24 = v8; v1->field_8 = tmp_24; v1->field_0 = v1->field_0 & -49; } v10 = tcsetattr(v0, 0x0, v1); } } return; }
sysvinit
angr_phoenix
static void xattr_coder(struct tar_stat_info const *st, char const *keyword, struct xheader *xhdr, void const *data) { struct xattr_array *xattr_map = st->xattr_map; const size_t *off = data; xheader_print_n(xhdr, keyword, xattr_map[*off].xval_ptr, xattr_map[*off].xval_len); }
long long xattr_coder(struct_2 *a0, unsigned long a1, void *a2, unsigned long long *a3) { unsigned long v0; v0 = a0->field_160; return xheader_print_n(a2, a1, *((v0 + *(a3) * 24 + 8)), *((v0 + *(a3) * 24 + 16))); }
tar
angr_phoenix
static void mkprint(char *dst, unsigned char *src, size_t len) { while (len-- > 0) { unsigned char ch = *src++; if (ch < ' ') { *dst++ = '^'; *dst++ = (char)(ch + '@'); } else if (ch < 0177) { *dst++ = (char)ch; } else if (ch == 0177) { *dst++ = '^'; *dst++ = '?'; } else { sprintf(dst, "\\%03o", ch); dst += 4; } } *dst = '\0'; }
void mkprint(char *a0, unsigned long a1, unsigned long long a2) { unsigned long long v0; int tmp_11; int tmp_12; int tmp_29; int tmp_10; int tmp_18; char *v1; char *v2; char v3; unsigned long long v5; char *v6; char *v7; v2 = a0; v1 = a1; v0 = a2; while (true) { v5 = v0; v0 -= 1; if (!v5) break; tmp_11 = v1; v1 += 1; *(&v5) = *(tmp_11); v3 = v5; if (v3 <= 31) { tmp_12 = v2; v2 += 1; *(tmp_12) = 94; tmp_29 = v2; v2 += 1; *(tmp_29) = v3 + 64; } else if (v3 <= 126) { v6 = v2; v2 += 1; *(v6) = v3; } else if (v3 == 127) { tmp_10 = v2; v2 += 1; *(tmp_10) = 94; tmp_18 = v2; v2 += 1; *(tmp_18) = 63; } else { sprintf(v2, "\\%03o", v3); v2 += 4; } } v7 = v2; *(v2) = 0; return; }
cronie
angr_dream
static void print_sep_string(void) { char const *s = col_sep_string; int l = col_sep_length; if (separators_not_printed <= 0) { if (spaces_not_printed > 0) print_white_space(); } else { for (; separators_not_printed > 0; --separators_not_printed) { while (l-- > 0) { if (*s == ' ') { s++; ++spaces_not_printed; } else { if (spaces_not_printed > 0) print_white_space(); putchar_unlocked(*s++); ++output_position; } } if (spaces_not_printed > 0) print_white_space(); } } }
void print_sep_string() { unsigned long long v0; int tmp_8; char *v1; unsigned long long v3; unsigned long long v4; unsigned long long v5; v1 = col_sep_string; *(&v0) = col_sep_length; if (separators_not_printed <= 0) { v3 = spaces_not_printed; if (spaces_not_printed > 0) v5 = print_white_space(); } else { while (true) { v4 = separators_not_printed; if (separators_not_printed <= 0) break; while (true) { *(&v4) = v0; *(&v0) = v0 - 1; if (v4 <= 0) break; if (*(v1) == 32) { v1 += 1; spaces_not_printed = spaces_not_printed + 1; } else { if (spaces_not_printed > 0) print_white_space(); tmp_8 = v1; v1 += 1; *(&v4) = *(tmp_8); putchar_unlocked(v4); output_position = output_position + 1; } } if (spaces_not_printed > 0) print_white_space(); separators_not_printed = separators_not_printed - 1; } } return; }
coreutils
angr_phoenix
int rl_read_key(void) { char fooarr[2 * sizeof(int)]; if (e == ((void *)0) || h == ((void *)0)) rl_initialize(); return el_getc(e, fooarr); }
void rl_read_key(void) { long in_FS_OFFSET; undefined local_18[8]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); if ((e != 0) && (h != 0)) { el_getc(e, local_18); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return; } rl_initialize(); }
libedit
ghidra
static char * default_client_percent_dollar_expand(const char *str, const struct ssh_conn_info *cinfo) { char *ret; ret = percent_dollar_expand( str, "C", cinfo->conn_hash_hex, "L", cinfo->shorthost, "i", cinfo->uidstr, "k", cinfo->keyalias, "l", cinfo->thishost, "n", cinfo->host_arg, "p", cinfo->portstr, "d", cinfo->homedir, "h", cinfo->remhost, "r", cinfo->remuser, "u", cinfo->locuser, (char *)((void *)0)); if (ret == ((void *)0)) sshfatal("ssh.c", __func__, 240, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "invalid environment variable expansion"); return ret; }
long default_client_percent_dollar_expand(undefined8 param_1, undefined8 *param_2) { long lVar1; lVar1 = percent_dollar_expand( param_1, &DAT_0010884e, *param_2, &DAT_0010884c, param_2[1], &DAT_0010884a, param_2[2], &DAT_0010885e, param_2[3], &DAT_0010885c, param_2[4], &DAT_0010885a, param_2[5], &DAT_00108858, param_2[6], &DAT_00108856, param_2[9], &DAT_00108854, param_2[7], &DAT_00108852, param_2[8], &DAT_00108850, param_2[10], 0); if (lVar1 == 0) { sshfatal("ssh.c", "default_client_percent_dollar_expand", 0xf0, 0, 1, 0, "invalid environment variable expansion"); } return lVar1; }
openssh-portable
ghidra
0 ) { error( 0, restore_errno, gettext("cannot create " "directory %s"), quotearg_style( shell_escape_always_quoting_style, to)); return 0; }
void error(void) { halt_baddata(); }
coreutils
ghidra
void hash_flush(table, free_data) HASH_TABLE *table; sh_free_func_t *free_data; { int i; register BUCKET_CONTENTS *bucket, *item; if (table == 0 || ((table) ? (table)->nentries : 0) == 0) return; for (i = 0; i < table->nbuckets; i++) { bucket = table->bucket_array[i]; while (bucket) { item = bucket; bucket = bucket->next; if (free_data) (*free_data)(item->data); else sh_xfree((item->data), "hashlib.c", 397); sh_xfree((item->key), "hashlib.c", 398); sh_xfree((item), "hashlib.c", 399); } table->bucket_array[i] = (BUCKET_CONTENTS *)((void *)0); } table->nentries = 0; }
long hash_flush(long a1, void (*a2)(_QWORD)) { long result; _QWORD *v3; _QWORD *v4; int i; if (a1) { result = *(unsigned int *)(a1 + 12); if ((_DWORD)result) { for (i = 0; i < *(_DWORD *)(a1 + 8); ++i) { v3 = *(_QWORD **)(8LL * i + *(_QWORD *)a1); while (v3) { v4 = v3; v3 = (_QWORD *)*v3; if (a2) a2(v4[2]); else sh_xfree(v4[2], "hashlib.c", 397LL); sh_xfree(v4[1], "hashlib.c", 398LL); sh_xfree(v4, "hashlib.c", 399LL); } *(_QWORD *)(8LL * i + *(_QWORD *)a1) = 0LL; } result = a1; *(_DWORD *)(a1 + 12) = 0; } } return result; }
bash
ida
static inline _Bool is_addrtype_inet_multi(const inet_prefix *p) { return (p->flags & ADDRTYPE_INET_MULTI) == ADDRTYPE_INET_MULTI; }
bool is_addrtype_inet_multi(_WORD *a1) { return (*a1 & 0xA) == 10; }
iproute2-6.0.0
ida
static void cfg_file_free(struct cfg_file *f) { free(f); }
void cfg_file_free(void *param_1) { free(param_1); return; }
kmod
ghidra
struct timeval *divtimeval(d, m) struct timeval *d; int m; { time_t t; t = d->tv_sec; d->tv_sec = t / m; d->tv_usec = (d->tv_usec + 1000000 * (t % m)) / m; return d; }
long long divtimeval(unsigned long long a0[2], unsigned long a1) { unsigned long v0; v0 = a0[0]; a0[0] = (v0 >> 63 CONCAT v0) / m a1; a0[1] = (((v0 >> 63 CONCAT v0) / m a1 >> 64) * 1000000 + a0[1] >> 63 CONCAT((v0 >> 63 CONCAT v0) / m a1 >> 64) * 1000000 + a0[1]) / m a1; return a0; }
bash
angr_dream
void rl_initialize_funmap(void) { register int i; if (funmap_initialized) return; for (i = 0; default_funmap[i].name; i++) rl_add_funmap_entry(default_funmap[i].name, default_funmap[i].function); funmap_initialized = 1; funmap_program_specific_entry_start = i; }
void rl_initialize_funmap() { unsigned long long v1; void *v2; unsigned long long v3; v1 = funmap_initialized; if (funmap_initialized) return; v2 = 0; while (true) { v3 = *((0x10 * v2 + &default_funmap[0])); if (!*((0x10 * v2 + &default_funmap[0]))) break; rl_add_funmap_entry(*((0x10 * v2 + &default_funmap[0])), *((0x10 * v2 + &g_400ba8))); v2 = v2 + 1; } funmap_initialized = 1; funmap_program_specific_entry_start = v2; return; }
bash
angr_sailr
int main(int argc, char **argv) { int limit; char *sieve; size_t size, i; struct prime *prime_list; unsigned nprimes; if (argc != 2) { fprintf(stderr, "Usage: %s LIMIT\n" "Produces a list of odd primes <= LIMIT\n", argv[0]); return 1; } limit = atoi(argv[1]); if (limit < 3) return 0; if (!(limit & 1)) limit--; size = (limit - 1) / 2; sieve = xalloc(size); memset(sieve, 1, size); prime_list = xalloc(size * sizeof(*prime_list)); nprimes = 0; for (i = 0; i < size;) { unsigned p = 3 + 2 * i; unsigned j; process_prime(&prime_list[nprimes++], p); for (j = (p * p - 3) / 2; j < size; j += p) sieve[j] = 0; while (++i < size && sieve[i] == 0) ; } output_primes(prime_list, nprimes); free(sieve); free(prime_list); if (ferror(stdout) + fclose(stdout)) { fprintf(stderr, "write error: %s\n", strerror((*__errno_location()))); return 1; } return 0; }
int main(unsigned long a0, struct_0 *a1) { unsigned int v0; int tmp_52; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; void *v5; unsigned long long v6; void *v7; void *v8; unsigned int v10; v0 = a0; if (v0 != 2) { fprintf(*(&stderr), "Usage: %s LIMIT\nProduces a list of odd primes <= LIMIT\n", a1->padding_0); v10 = 1; return v10; } v1 = atoi(a1->field_8); if (v1 <= 2) { v10 = 0; return v10; } if (!(v1 & 1)) v1 -= 1; v6 = v1 - 1 + (v1 - 1 >> 31) >> 1; v7 = xalloc(v6); memset(v7, 0x1, v6); v8 = xalloc(v6 * 48); v2 = 0; v5 = 0; while (v5 < v6) { v4 = v5 * 2 + 3; tmp_52 = v2; v2 += 1; process_prime(tmp_52 * 48 + v8, v4); for (v3 = v4 * v4 - 3 >> 1; v6 > v3; v3 += v4) { *(v7 + v3) = 0; } do { v5 += 1; } while (v5 < v6 && !*((v5 + v7))); } output_primes(v8, v2); free(v7); free(v8); if (!fclose(stdout) + ferror(stdout)) { v10 = 0; return v10; } fprintf(*(&stderr), "write error: %s\n", strerror(*(__errno_location()))); v10 = 1; return v10; }
coreutils
angr_sailr
int rl_abort(int count, int key) { return (_rl_abort_internal()); }
void rl_abort() { rl_abort_internal(); }
bash
ida
static int card_of_complement(struct Spec_list *s) { int c; int cardinality = N_CHARS; _Bool in_set[N_CHARS] = { 0, }; s->state = ((18446744073709551615UL) - 1); while ((c = get_next(s, ((void *)0))) != -1) { cardinality -= (!in_set[c]); in_set[c] = 1; } return cardinality; }
int card_of_complement(void *a0) { struct_0 *v0; unsigned int v1; unsigned int v2; void *v3; unsigned long long v5; void *v6; unsigned long v7; v0 = a0; v1 = 0x100; v5 = 32; for (v6 = &v3; v5; v6 += v7 * 8) { v5 -= 1; v3 = 0; } v0->field_10 = -2; while (true) { v2 = get_next(v0, NULL); if (v2 == -1) break; v1 -= (&v3)[v2] ^ 1; (&v3)[v2] = 1; } return v1; }
coreutils
angr_phoenix
void array_add(element, array) char *element; ARRAY *array; { if (array->sindex + 2 > array->size) array->array = (char **)xrealloc( array->array, (array->size += array->growth_rate) * array->width); array->array[array->sindex++] = element; array->array[array->sindex] = (char *)((void *)0); }
void array_add(unsigned long a0, unsigned long a1) { struct_0 *v0; int tmp_48; unsigned long long *v2; unsigned long long v3; v0 = a1; if (v0->field_4 + 1 >= v0->field_0) { v0->field_0 = v0->field_0 + v0->field_c; v0->field_10 = xrealloc(v0->field_10, v0->field_8 * v0->field_0); } v2 = v0->field_10; tmp_48 = v0->field_4; v0->field_4 = v0->field_4 + 1; v2[tmp_48] = a0; v3 = v0->field_4 * 8 + v0->field_10; *((v0->field_4 * 8 + v0->field_10)) = 0; return; }
bash
angr_phoenix
_Bool name_match (const char *file_name) { size_t length = strlen(file_name); while (1) { struct name *cursor = namelist; if (!cursor) return 1; if (cursor->name[0] == 0) { chdir_do(cursor->change_dir); namelist = ((void *)0); nametail = ((void *)0); return 1; } cursor = namelist_match(file_name, length); if (starting_file_option) { if (cursor == namelist) starting_file_option = 0; else cursor = ((void *)0); } if (cursor) { if (!(((file_name[cursor->length]) == '/') && recursion_option) || cursor->found_count == 0) cursor->found_count++; chdir_do(cursor->change_dir); return (occurrence_option == 0 ? (cursor)->found_count != 0 : (cursor)->found_count == occurrence_option); } if (same_order_option && namelist->found_count) { name_gather(); if (namelist->found_count) return 0; } else return 0; } }
long long name_match(char *a0) { void *v0; unsigned int v1; unsigned long long v3; *(&v1) = strlen(a0); do { v0 = namelist; if (!v0) { v3 = 1; goto LABEL_401fc3; } if (!v0->field_10->field_0) { chdir_do(v0->field_28); namelist = 0; nametail = 0; v3 = 1; goto LABEL_401fc3; } v0 = namelist_match(a0, *(&v1)); if (starting_file_option) { if (v0 != namelist) v0 = 0; else starting_file_option = 0; } if (v0) { if (a0[v0[24]] == 47 && recursion_option && !(!v0[48])) goto LABEL_401f3f; *(&v0[48]) = v0[48] + 1; LABEL_401f3f: chdir_do(v0->field_28); if (!occurrence_option) { v3 = v0[48]; *(&v3) = v0[48]; goto LABEL_401fc3; } else { v3 = occurrence_option; *(&v3) = v0[48] == occurrence_option; goto LABEL_401fc3; } } if (!same_order_option) { LABEL_401fb7: v3 = 0; goto LABEL_401fc3; } if (!namelist[48]) goto LABEL_401fb7; name_gather(); } while (!namelist[48]); v3 = 0; LABEL_401fc3: return v3; }
tar
angr_phoenix
static char *skiparith(substr, delim) char *substr; int delim; { int i; char delims[2]; delims[0] = delim; delims[1] = '\0'; i = skip_to_delim(substr, 0, delims, 0x400); return (substr + i); }
long skiparith(long param_1, undefined param_2) { int iVar1; long in_FS_OFFSET; undefined local_12; undefined local_11; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_11 = 0; local_12 = param_2; iVar1 = skip_to_delim(param_1, 0, &local_12, 0x400); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return param_1 + iVar1; }
bash
ghidra
(ctx->options & 0x0400)) { com_err(ctx->program_name, 0, "%s", (gettext("The -n and -D options are incompatible."))); fatal_error(ctx, 0); }
void com_err(void) { halt_baddata(); }
e2fsprogs-1.46.5
ghidra
static char *parameter_brace_transform(varname, value, estatep, xform, rtype, quoted, pflags, flags) char *varname, *value; array_eltstate_t *estatep; char *xform; int rtype, quoted, pflags, flags; { int vtype, xc, starsub; char *temp1, *val, *oname; SHELL_VAR *v; xc = xform[0]; if (value == 0 && xc != 'A' && xc != 'a') return ((char *)((void *)0)); oname = this_command_name; this_command_name = varname; vtype = get_var_and_type(varname, value, estatep, quoted, flags, &v, &val); if (vtype == -1) { this_command_name = oname; return ((char *)((void *)0)); } if (xform[0] == 0 || valid_parameter_transform(xform) == 0) { this_command_name = oname; if (vtype == 0) do { if (val) sh_xfree((val), "subst.c", 8667); } while (0); return (interactive_shell ? &expand_param_error : &expand_param_fatal); } starsub = vtype & 128; vtype &= ~128; if ((xc == 'a' || xc == 'A') && vtype == 0 && varname && v == 0) v = find_variable(varname); temp1 = (char *)((void *)0); switch (vtype) { case 0: case 3: temp1 = string_transform(xc, v, val); if (vtype == 0) do { if (val) sh_xfree((val), "subst.c", 8686); } while (0); if (temp1) { val = (quoted & (0x002 | 0x001)) ? quote_string(temp1) : quote_escapes(temp1); sh_xfree((temp1), "subst.c", 8692); temp1 = val; } break; case 2: temp1 = array_transform(xc, v, starsub, quoted); if (temp1 && quoted == 0 && ifs_is_null) { } else if (temp1 && ((quoted & (0x002 | 0x001)) == 0)) { val = quote_escapes(temp1); sh_xfree((temp1), "subst.c", 8706); temp1 = val; } break; case 1: temp1 = parameter_list_transform(xc, varname[0], quoted); if (temp1 && quoted == 0 && ifs_is_null) { } else if (temp1 && ((quoted & (0x002 | 0x001)) == 0)) { val = quote_escapes(temp1); sh_xfree((temp1), "subst.c", 8720); temp1 = val; } break; } this_command_name = oname; return temp1; }
int parameter_brace_transform(char *a0, void *a1, void *a2, char *a3, unsigned long long a4, unsigned long a5, unsigned int v8) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned int v3; unsigned long v4; void *v5; unsigned long v6; unsigned long long v7; char v9; unsigned int v10; v0 = a4; v1 = *(a3); if (!a1 && v1 != 65 && v1 != 97) v10 = 0; if (v1 == 65 || v1 == 97 || a1) { v7 = this_command_name; this_command_name = a0; v2 = get_var_and_type(a0, a1, a2, a5, *(&v9), &v5, &v4); if (v2 == -1) { this_command_name = v7; v10 = 0; } else { if (*(a3)) { v10 = valid_parameter_transform(a3); if (v10) { v3 = v2 & 128; v2 &= -129; if ((v1 == 65 || v1 == 97) && !v2 && a0 && !v5) v5 = find_variable(a0); v6 = 0; if (v2 != 3 && v2 <= 3) { if (v2 == 2) { v6 = array_transform(v1, v5, v3, a5, a4, &v5); if ((!v6 || a5) && v6 && !(a5 & 3)) { v4 = quote_escapes(v6); sh_xfree(v6, "subst.c", 0x2202); v6 = v4; } } else if (v2 <= 2 && v2 && v2 == 1) { v6 = parameter_list_transform(v1, *(a0), a5, *(a0), a4, &v5); if ((!v6 || a5) && v6 && !(a5 & 3)) { v4 = quote_escapes(v6); sh_xfree(v6, "subst.c", 0x2210); v6 = v4; } } } if (v2 == 3 || !v2 && v2 <= 3 && v2 <= 2 && v2 != 2) { v6 = string_transform(v1, v5, *(&v4)); if (!v2 && *(&v4)) sh_xfree(*(&v4), "subst.c", 0x21ee); if (v6) { if ((a5 & 3)) v10 = quote_string(v6); else v10 = quote_escapes(v6); v4 = v10; sh_xfree(v6, "subst.c", 0x21f4); v6 = v4; } } this_command_name = v7; v10 = v6; } } if (!v10 || !*(a3)) { this_command_name = v7; if (!v2 && *(&v4)) sh_xfree(*(&v4), "subst.c", 0x21db); if (interactive_shell) v10 = &expand_param_error; else v10 = &expand_param_fatal; } } } return v10; }
bash
angr_dream
SHELL_VAR *find_variable_internal(name, flags) const char *name; int flags; { SHELL_VAR *var; int search_tempenv, force_tempenv; VAR_CONTEXT *vc; var = (SHELL_VAR *)((void *)0); force_tempenv = (flags & 0x01); search_tempenv = force_tempenv || (expanding_redir == 0 && subshell_environment); if (search_tempenv && temporary_env) var = hash_lookup(name, temporary_env); if (var == 0) { if ((flags & 0x02) == 0) var = var_lookup(name, shell_variables); else { for (vc = shell_variables; vc; vc = vc->down) { var = hash_lookup(name, vc->table); if (var && ((((var)->attributes) & (0x0001000)))) var = 0; if (var) break; } } } if (var == 0) return ((SHELL_VAR *)((void *)0)); return (var->dynamic_value ? (*(var->dynamic_value))(var) : var); }
long find_variable_internal(undefined8 param_1, uint param_2) { bool bVar1; long local_18; long local_10; local_18 = 0; if (((param_2 & 1) == 0) && ((expanding_redir != 0 || (subshell_environment == 0)))) { bVar1 = false; } else { bVar1 = true; } if ((bVar1) && (temporary_env != 0)) { local_18 = hash_lookup(param_1, temporary_env); } if (local_18 == 0) { if ((param_2 & 2) == 0) { local_18 = var_lookup(param_1, shell_variables); } else { for (local_10 = shell_variables; local_10 != 0; local_10 = *(long *)(local_10 + 0x18)) { local_18 = hash_lookup(param_1, *(undefined8 *)(local_10 + 0x20)); if ((local_18 != 0) && ((*(uint *)(local_18 + 0x28) & 0x1000) != 0)) { local_18 = 0; } if (local_18 != 0) break; } } } if (local_18 == 0) { local_18 = 0; } else if (*(long *)(local_18 + 0x18) != 0) { local_18 = (**(code **)(local_18 + 0x18))(local_18); } return local_18; }
bash
ghidra
static long getwidth(FILE *fp) { char const *columns; struct winsize ws; if (ioctl(fileno(fp), 0x5413, &ws) == 0 && 0 < ws.ws_col) return ws.ws_col; columns = getenv("COLUMNS"); if (columns) { long int col = strtol(columns, ((void *)0), 10); if (0 < col) return col; } return 80; }
int getwidth(void *a0) { char *v0; unsigned long v1; char v2; unsigned int v4; v4 = ioctl(fileno(a0), 0x5413); if (!v4 && *(&v2)) v4 = *(&v2); if (!*(&v2) || v4) { v0 = getenv("COLUMNS"); if (v0) { v1 = strtol(v0, NULL, 0xa); if (v1 > 0) v4 = v1; } if (v1 <= 0 || !v0) v4 = 80; } return v4; }
tar
angr_dream
static char *authmethods_get(void) { Authmethod *method = ((void *)0); struct sshbuf *b; char *list; int r; if ((b = sshbuf_new()) == ((void *)0)) sshfatal("sshconnect2.c", __func__, 2384, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new failed"); for (method = authmethods; method->name != ((void *)0); method++) { if (authmethod_is_enabled(method)) { if ((r = sshbuf_putf(b, "%s%s", sshbuf_len(b) ? "," : "", method->name)) != 0) sshfatal("sshconnect2.c", __func__, 2389, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "buffer error"); } } if ((list = sshbuf_dup_string(b)) == ((void *)0)) sshfatal("sshconnect2.c", __func__, 2393, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_dup_string failed"); sshbuf_free(b); return list; }
long authmethods_get() { const char *v0; const char *v1; long v2; unsigned int v4; char **i; long v6; long v7; v6 = sshbuf_new(); if (!v6) sshfatal("sshconnect2.c", "authmethods_get", 2384LL, 1LL, 1LL, 0LL, "sshbuf_new failed"); for (i = &authmethods; *i; i += 5) { if (authmethod_is_enabled((long)i)) { v0 = *i; v1 = sshbuf_len(v6) ? "," : (const char *)&unk_7745; v4 = sshbuf_putf(v6, "%s%s", v1, v0); if (v4) { v2 = ssh_err(v4); sshfatal("sshconnect2.c", "authmethods_get", 2389LL, 1LL, 1LL, v2, "buffer error"); } } } v7 = sshbuf_dup_string(v6); if (!v7) sshfatal("sshconnect2.c", "authmethods_get", 2393LL, 1LL, 1LL, 0LL, "sshbuf_dup_string failed"); sshbuf_free(v6); return v7; }
openssh-portable
ida
static _Bool mp_prime_p(mpz_t n) { _Bool is_prime; mpz_t q, a, nm1, tmp; struct mp_factors factors; if ((__builtin_constant_p(1) && (1) == 0 ? ((n)->_mp_size < 0 ? -1 : (n)->_mp_size > 0) : __gmpz_cmp_ui(n, 1)) <= 0) return 0; if ((__builtin_constant_p((long)5003 * 5003) && ((long)5003 * 5003) == 0 ? ((n)->_mp_size < 0 ? -1 : (n)->_mp_size > 0) : __gmpz_cmp_ui(n, (long)5003 * 5003)) < 0) return 1; __gmpz_inits(q, a, nm1, tmp, ((void *)0)); __gmpz_sub_ui(nm1, n, 1); unsigned long int k = __gmpz_scan1(nm1, 0); __gmpz_tdiv_q_2exp(q, nm1, k); __gmpz_set_ui(a, 2); if (!mp_millerrabin(n, nm1, a, tmp, q, k)) { is_prime = 0; goto ret2; } if (flag_prove_primality) { __gmpz_set(tmp, nm1); mp_factor(tmp, &factors); } for (unsigned int r = 0; r < (sizeof(primes_diff) / sizeof(primes_diff[0]) - 8 + 1); r++) { if (flag_prove_primality) { is_prime = 1; for (unsigned long int i = 0; i < factors.nfactors && is_prime; i++) { __gmpz_divexact(tmp, nm1, factors.p[i]); __gmpz_powm(tmp, a, tmp, n); is_prime = (__builtin_constant_p(1) && (1) == 0 ? ((tmp)->_mp_size < 0 ? -1 : (tmp)->_mp_size > 0) : __gmpz_cmp_ui(tmp, 1)) != 0; } } else { is_prime = (r == 25 - 1); } if (is_prime) goto ret1; __gmpz_add_ui(a, a, primes_diff[r]); if (!mp_millerrabin(n, nm1, a, tmp, q, k)) { is_prime = 0; goto ret1; } } error(0, 0, gettext("Lucas prime test failure. This should not happen")); abort(); ret1: if (flag_prove_primality) mp_factor_clear(&factors); ret2: __gmpz_clears(q, a, nm1, tmp, ((void *)0)); return is_prime; }
bool mp_prime_p(undefined8 param_1) { char cVar1; int iVar2; undefined8 uVar3; long in_FS_OFFSET; bool local_8d; uint local_8c; ulong local_88; long local_78[2]; ulong local_68; undefined local_58[16]; undefined local_48[16]; undefined local_38[16]; undefined local_28[24]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); iVar2 = __gmpz_cmp_ui(param_1, 1); if (iVar2 < 1) { local_8d = false; } else { iVar2 = __gmpz_cmp_ui(param_1, 0x17ded79); if (iVar2 < 0) { local_8d = true; } else { __gmpz_inits(local_58, local_48, local_38, local_28, 0); __gmpz_sub_ui(local_38, param_1, 1); uVar3 = __gmpz_scan1(local_38, 0); __gmpz_tdiv_q_2exp(local_58, local_38, uVar3); __gmpz_set_ui(local_48, 2); cVar1 = mp_millerrabin(param_1, local_38, local_48, local_28, local_58, uVar3); if (cVar1 == '\x01') { if (flag_prove_primality != '\0') { __gmpz_set(local_28, local_38); mp_factor(local_28, local_78); } local_8c = 0; while (true) { if (0x29b < local_8c) { uVar3 = gettext("Lucas prime test failure. This should not happen"); error(0, 0, uVar3); abort(); } if (flag_prove_primality == '\0') { local_8d = local_8c == 0x18; } else { local_88 = 0; local_8d = true; while ((local_88 < local_68 && (local_8d != false))) { __gmpz_divexact(local_28, local_38, local_88 * 0x10 + local_78[0]); __gmpz_powm(local_28, local_48, local_28, param_1); iVar2 = __gmpz_cmp_ui(local_28, 1); local_88 = local_88 + 1; local_8d = iVar2 != 0; } } if (local_8d != false) break; __gmpz_add_ui(local_48, local_48, primes_diff[local_8c]); cVar1 = mp_millerrabin(param_1, local_38, local_48, local_28, local_58, uVar3); if (cVar1 != '\x01') { local_8d = false; break; } local_8c = local_8c + 1; } if (flag_prove_primality != '\0') { mp_factor_clear(local_78); } } else { local_8d = false; } __gmpz_clears(local_58, local_48, local_38, local_28, 0); } } if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return local_8d; } __stack_chk_fail(); }
coreutils
ghidra
int sshbuf_get_string(struct sshbuf *buf, u_char **valp, size_t *lenp) { const u_char *val; size_t len; int r; if (valp != ((void *)0)) *valp = ((void *)0); if (lenp != ((void *)0)) *lenp = 0; if ((r = sshbuf_get_string_direct(buf, &val, &len)) < 0) return r; if (valp != ((void *)0)) { if ((*valp = malloc(len + 1)) == ((void *)0)) { ; return -2; } if (len != 0) memcpy(*valp, val, len); (*valp)[len] = '\0'; } if (lenp != ((void *)0)) *lenp = len; return 0; }
long long sshbuf_get_string(unsigned long long a0, unsigned long long *a1, unsigned long long *a2) { unsigned int v0; char v1; char v2; unsigned long long v4; if (a1) *(a1) = 0; if (a2) *(a2) = 0; v0 = sshbuf_get_string_direct(a0, &v1, &v2); if (v0 < 0) { v4 = v0; } else { if (a1) { *(a1) = malloc(*(&v2) + 1); if (!*(a1)) { v4 = 4294967294; } else { if (*(&v2)) memcpy(*(a1), *(&v1), *(&v2)); *((*(&v2) + *(a1))) = 0; } } if (!a1 || *(a1)) { if (a2) *(a2) = *(&v2); v4 = 0; } } return v4; }
openssh-portable
angr_dream
void bash_clear_history() { clear_history(); history_lines_this_session = 0; }
long long bash_clear_history() { dont_save_function_defs = 0; return clear_history(); }
bash
angr_sailr
static int jobno(const struct job *jp) { return jp - jobtab + 1; }
int jobno(unsigned long a0) { return ((a0 - jobtab >> 3) * 14757395258967641293) + 1; }
dash-0.5.11+git20210903+057cd650a4ed
angr_dream
static _Bool hash_ins(struct di_set *di_set, ino_t ino, dev_t dev) { int inserted = di_set_insert(di_set, dev, ino); if (inserted < 0) xalloc_die(); return inserted; }
int hash_ins(unsigned long long a0, unsigned long long a1, unsigned long long a2) { unsigned int v0; unsigned long long v2; v2 = di_set_insert(a0, a2, a1, a2); v0 = v2; if (v0 < 0) xalloc_die(); *(&v2) = v0; return v2; }
coreutils
angr_sailr
static int control_list(const char *const *argv) { struct pkginfo *pkg; const char *pkgname; pkgname = *argv++; if (!pkgname || *argv) badusage(gettext("--%s takes one package name argument"), cipaction->olong); modstatdb_open(msdbrw_readonly); pkg = dpkg_options_parse_pkgname(cipaction, pkgname); if (pkg->status == PKG_STAT_NOTINSTALLED) ohshit(gettext("package '%s' is not installed"), pkg_name(pkg, pnaw_nonambig)); pkg_infodb_foreach(pkg, &pkg->installed, pkg_infodb_print_filetype); modstatdb_shutdown(); return 0; }
long long control_list(unsigned long long a0, unsigned long long a1, unsigned long long a2, unsigned long long a3, unsigned long long a4, unsigned long long a5) { unsigned long long *v0; int tmp_27; unsigned long long v1; struct_0 *v2; v0 = a0; tmp_27 = v0; v0 += 1; v1 = *(tmp_27); if (!v1 || *(v0)) badusage(gettext("--%s takes one package name argument")); modstatdb_open(0x0); v2 = dpkg_options_parse_pkgname(cipaction, v1, v1); if (!v2->field_18) ohshit(gettext("package '%s' is not installed"), pkg_name(v2, 0x1, a2)); pkg_infodb_foreach(v2, &v2[2].padding_0[16], pkg_infodb_print_filetype, &v2[2].padding_0[16]); modstatdb_shutdown(a0, a1, pkg_infodb_print_filetype, a3, a4, a5); return 0; }
dpkg
angr_dream
static _Bool three_arguments(void) { _Bool value; if (binop(argv[pos + 1])) value = binary_operator(0); else if ((strcmp(argv[pos], "!") == 0)) { advance(1); value = !two_arguments(); } else if ((strcmp(argv[pos], "(") == 0) && (strcmp(argv[pos + 2], ")") == 0)) { advance(0); value = one_argument(); advance(0); } else if ((strcmp(argv[pos + 1], "-a") == 0) || (strcmp(argv[pos + 1], "-o") == 0)) value = expr(); else test_syntax_error(gettext("%s: binary operator expected"), quote(argv[pos + 1])); return (value); }
int three_arguments() { char v0; unsigned long long v2; unsigned long long v3; unsigned long long v4; unsigned long long v5; unsigned long long v6; unsigned long long v7; unsigned long long v8; v2 = binop(*((argv + (pos + 1) * 8))); if (v2) { v0 = binary_operator(0x0); } else { v3 = strcmp(*((argv + pos * 8)), "!"); if (!v3) { advance(0x1); v5 = two_arguments(); *(&v5) = v5; *(&v5) = v5 ^ 1; v0 = v5; v0 &= 1; } else { v4 = strcmp(*((argv + pos * 8)), "("); if (!v4) { v6 = strcmp(*((argv + (pos + 2) * 8)), ")"); if (!v6) { advance(0x0); v0 = one_argument(); advance(0x0); } } if (v4 || v6) { v7 = strcmp(*((argv + (pos + 1) * 8)), "-a"); if (v7) { v8 = strcmp(*((argv + (pos + 1) * 8)), "-o"); if (v8) test_syntax_error(gettext("%s: binary operator expected"), quote(*((argv + (pos + 1) * 8)))); } if (!v8 || !v7) v0 = expr(); } } } if (!v8 || !v7 || !v3 || v2 || !v4 && !v6) return v0; }
coreutils
angr_dream
cv_repeat_srch(EditLine *el, wint_t c) { el->el_state.lastcmd = (el_action_t)c; el->el_line.lastchar = el->el_line.buffer; switch (c) { case 23: return ed_search_next_history(el, 0); case 24: return ed_search_prev_history(el, 0); default: return 6; } }
long cv_repeat_srch(long a1, int a2) { *(_BYTE *)(a1 + 128) = a2; *(_QWORD *)(a1 + 96) = *(_QWORD *)(a1 + 80); if (a2 == 23) return ed_search_next_history(a1, 0LL); if (a2 == 24) return ed_search_prev_history(a1, 0LL); return 6LL; }
libedit
ida
static void usage(void) { fprintf(stderr, "Usage: ip l2tp add tunnel\n" " remote ADDR local ADDR\n" " tunnel_id ID peer_tunnel_id ID\n" " [ encap { ip | udp } ]\n" " [ udp_sport PORT ] [ udp_dport PORT ]\n" " [ udp_csum { on | off } ]\n" " [ udp6_csum_tx { on | off } ]\n" " [ udp6_csum_rx { on | off } ]\n" "Usage: ip l2tp add session [ name NAME ]\n" " tunnel_id ID\n" " session_id ID peer_session_id ID\n" " [ cookie HEXSTR ] [ peer_cookie HEXSTR ]\n" " [ seq { none | send | recv | both } ]\n" " [ l2spec_type L2SPEC ]\n" " ip l2tp del tunnel tunnel_id ID\n" " ip l2tp del session tunnel_id ID session_id ID\n" " ip l2tp show tunnel [ tunnel_id ID ]\n" " ip l2tp show session [ tunnel_id ID ] [ session_id ID ]\n" "\n" "Where: NAME := STRING\n" " ADDR := { IP_ADDRESS | any }\n" " PORT := { 0..65535 }\n" " ID := { 1..4294967295 }\n" " HEXSTR := { 8 or 16 hex digits (4 / 8 bytes) }\n" " L2SPEC := { none | default }\n"); exit(-1); }
void usage() { fprintf( stderr, "Usage: ip l2tp add tunnel\n remote ADDR local ADDR\n " "tunnel_id ID peer_tunnel_id ID\n [ encap { ip | udp } ]\n " " [ udp_sport PORT ] [ udp_dport PORT ]\n [ udp_csum { on | " "off } ]\n [ udp6_csum_tx { on | off } ]\n [ " "udp6_csum_rx { on | off } ]\nUsage: ip l2tp add session [ name NAME ]\n " " tunnel_id ID\n session_id ID peer_session_id ID\n " " [ cookie HEXSTR ] [ peer_cookie HEXSTR ]\n [ seq { none | " "send | recv | both } ]\n [ l2spec_type L2SPEC ]\n ip " "l2tp del tunnel tunnel_id ID\n ip l2tp del session tunnel_id ID " "session_id ID\n ip l2tp show tunnel [ tunnel_id ID ]\n ip " "l2tp show session [ tunnel_id ID ] [ session_id ID ]\n\nWhere: NAME " ":= STRING\n ADDR := { IP_ADDRESS | any }\n PORT := { " "0..65535 }\n ID := { 1..4294967295 }\n HEXSTR := { 8 or " "16 hex digits (4 / 8 bytes) }\n L2SPEC := { none | default }\n"); exit(0xffffffff); }
iproute2-6.0.0
angr_sailr
gnutls_pk_algorithm_t figure_key_type(const char *key_type) { if (strcasecmp(key_type, "rsa") == 0) return GNUTLS_PK_RSA; else if (strcasecmp(key_type, "rsa-pss") == 0) return GNUTLS_PK_RSA_PSS; else if (strcasecmp(key_type, "ed25519") == 0 || strcasecmp(key_type, "eddsa") == 0) return GNUTLS_PK_EDDSA_ED25519; else if (strcasecmp(key_type, "ed448") == 0) return GNUTLS_PK_EDDSA_ED448; else if (strcasecmp(key_type, "x25519") == 0) return GNUTLS_PK_ECDH_X25519; else if (strcasecmp(key_type, "x448") == 0) return GNUTLS_PK_ECDH_X448; else if (strcasecmp(key_type, "dsa") == 0) return GNUTLS_PK_DSA; else if (strcasecmp(key_type, "ecdsa") == 0 || strcasecmp(key_type, "ecc") == 0) return GNUTLS_PK_ECDSA; else if (strcasecmp(key_type, "gost01") == 0) return GNUTLS_PK_GOST_01; else if (strcasecmp(key_type, "gost12-256") == 0) return GNUTLS_PK_GOST_12_256; else if (strcasecmp(key_type, "gost12-512") == 0) return GNUTLS_PK_GOST_12_512; else { fprintf(stderr, "unknown key type: %s\n", key_type); return GNUTLS_PK_UNKNOWN; } }
long long figure_key_type(char *a0) { unsigned long long v1; if (!strcasecmp(a0, "rsa")) { v1 = 1; } else if (!strcasecmp(a0, "rsa-pss")) { v1 = 6; } else if (!strcasecmp(a0, "ed25519")) { LABEL_40408f: v1 = 7; } else { if (!strcasecmp(a0, "eddsa")) goto LABEL_40408f; if (!strcasecmp(a0, "ed448")) { v1 = 12; } else if (!strcasecmp(a0, "x25519")) { v1 = 5; } else if (!strcasecmp(a0, "x448")) { v1 = 11; } else if (!strcasecmp(a0, "dsa")) { v1 = 2; } else if (!strcasecmp(a0, "ecdsa")) { LABEL_40414b: v1 = 4; } else { if (!strcasecmp(a0, "ecc")) goto LABEL_40414b; if (!strcasecmp(a0, "gost01")) { v1 = 8; } else if (!strcasecmp(a0, "gost12-256")) { v1 = 9; } else if (!strcasecmp(a0, "gost12-512")) { v1 = 10; } else { fprintf(stderr, "unknown key type: %s\n", a0); v1 = 0; } } } return v1; }
gnutls
angr_phoenix
static inline int is_basic(char c) { return (is_basic_table[(unsigned char)c >> 5] >> ((unsigned char)c & 31)) & 1; }
int is_basic(unsigned long a0) { return (*((4 * (a0 >> 5) + &is_basic_table)) >> (a0 & 31 & 31)) & 1; }
bash
angr_phoenix
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" : ""); }
void emit_ancillary_info(char *a0) { unsigned long v0; unsigned long long v1[2]; char *v2; unsigned long v3; unsigned long long v4; unsigned long long v5; unsigned long long v6; unsigned long long v7; unsigned long long v8; unsigned long long v9; unsigned long long v10; unsigned long long v11; unsigned long long v12; unsigned long long v13; unsigned long long v14; unsigned long long v15; void *v16; void *v17; char v18; unsigned long long *v21; unsigned long long v22; v4 = "["; v5 = "test invocation"; v6 = "coreutils"; v7 = "Multi-call invocation"; v8 = "sha224sum"; v9 = "sha2 utilities"; v10 = "sha256sum"; v11 = "sha2 utilities"; v12 = "sha384sum"; v13 = "sha2 utilities"; v14 = "sha512sum"; v15 = "sha2 utilities"; v16 = 0; v17 = 0; v0 = a0; for (v1[0] = &v4; v1[0] && strcmp(a0, v1[0]); v1[0] = v1 + 1) ; if (v1[1]) v0 = v1[1]; printf(gettext("\n%s online help: <%s>\n")); v2 = setlocale(0x5, NULL); if (v2 && strncmp(v2, "en_", 0x3)) fputs_unlocked(gettext("Report any translation bugs to <https: *(&v3) = (!strcmp(a0, "[") ? a0 : "test"); printf(gettext("Full documentation <%s%s>\n")); printf(gettext("or available locally via: info '(coreutils) %s%s'\n")); v22 = *(&v18) ^ v21[5]; return; }
coreutils
angr_sailr
_Bool sparse_fixup_header (struct tar_stat_info *st) { struct tar_sparse_file file; if (!tar_sparse_init(&file)) return 0; file.stat_info = st; return tar_sparse_fixup_header(&file); }
undefined8 sparse_fixup_header(undefined8 param_1) { char cVar1; undefined8 uVar2; long in_FS_OFFSET; undefined local_48[24]; undefined8 local_30; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); cVar1 = tar_sparse_init(local_48); if (cVar1 == '\x01') { local_30 = param_1; uVar2 = tar_sparse_fixup_header(local_48); } else { uVar2 = 0; } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return uVar2; }
tar
ghidra
int do_lsetstat(struct sftp_conn *conn, const char *path, Attrib *a) { struct sshbuf *msg; u_int status, id; int r; if ((conn->exts & 0x00000020) == 0) { sshlog("sftp-client.c", __func__, 1486, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Server does not support lsetstat@openssh.com extension"); return -1; } sshlog("sftp-client.c", __func__, 1490, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "Sending SSH2_FXP_EXTENDED(lsetstat@openssh.com) \"%s\"", path); id = conn->msg_id++; if ((msg = sshbuf_new()) == ((void *)0)) sshfatal("sftp-client.c", __func__, 1494, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new failed"); if ((r = sshbuf_put_u8(msg, 200)) != 0 || (r = sshbuf_put_u32(msg, id)) != 0 || (r = sshbuf_put_cstring(msg, "lsetstat@openssh.com")) != 0 || (r = sshbuf_put_cstring(msg, path)) != 0 || (r = encode_attrib(msg, a)) != 0) sshfatal("sftp-client.c", __func__, 1500, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "compose"); send_msg(conn, msg); sshbuf_free(msg); status = get_status(conn, id); if (status != 0) sshlog("sftp-client.c", __func__, 1506, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "remote lsetstat \"%s\": %s", path, fx2txt(status)); return status == 0 ? 0 : -1; }
long long do_lsetstat(unsigned int a0[8], unsigned long long a1, unsigned long long a2) { unsigned long v0; int tmp_16; unsigned int v1[8]; unsigned long long v2; unsigned int v3; unsigned long v4; unsigned int v5; unsigned long long v6; char v7; unsigned long long v9; *(&v1[0]) = a0; if (!(a0[7] & 32)) { sshlog("sftp-client.c", "do_lsetstat", 0x5ce, 0x0, 0x2, 0x0, "Server does not support lsetstat@openssh.com extension"); v9 = 4294967295; } else { v0 = a1; sshlog("sftp-client.c", "do_lsetstat", 0x5d2, 0x0, 0x6, 0x0, "Sending SSH2_FXP_EXTENDED(lsetstat@openssh.com) \"%s\""); tmp_16 = a0[6]; a0[6] = a0[6] + 1; v4 = tmp_16; v6 = sshbuf_new(); if (!v6) sshfatal("sftp-client.c", "do_lsetstat", 0x5d6, 0x1, 0x1, 0x0, "sshbuf_new failed"); v3 = sshbuf_put_u8(v6, 0xc8, a2); if (!v3) { v3 = sshbuf_put_u32(v6, v4, v4); if (!v3) { v3 = sshbuf_put_cstring(v6, "lsetstat@openssh.com"); if (!v3) { v3 = sshbuf_put_cstring(v6, a1); if (!v3) v3 = encode_attrib(v6, a2, a2); } } } if (v3 || v3 || v3 || v3 || v3) { v6 = "compose"; sshfatal("sftp-client.c", "do_lsetstat", 0x5dc, 0x1, 0x1, ssh_err(v3), *(&v7)); } send_msg(a0, v6); sshbuf_free(v6); v5 = get_status(a0, v4); if (v5) { v6 = fx2txt(v5); v4 = a1; v2 = "remote lsetstat \"%s\": %s"; sshlog("sftp-client.c", "do_lsetstat", 0x5e2, 0x0, 0x2, 0x0, *(&v7)); } if (!*((&v4 + 4))) v9 = 0; else v9 = 4294967295; } return v9; }
openssh-portable
angr_dream
static struct mount_entry const *me_for_dev(dev_t dev) { struct devlist *dl = devlist_for_dev(dev); if (dl) return dl->me; return ((void *)0); }
int me_for_dev(unsigned int a0) { struct_0 *v0; unsigned int v2; v0 = devlist_for_dev(a0); if (!v0) v2 = 0; else v2 = v0->field_8; return v2; }
coreutils
angr_phoenix
static idx_t iwrite(int fd, char const *buf, idx_t size) { idx_t total_written = 0; if ((output_flags & 040000) && size < output_blocksize) { int old_flags = rpl_fcntl(1, 3); if (rpl_fcntl(1, 4, old_flags & ~040000) != 0 && status_level != STATUS_NONE) nl_error( 0, (*__errno_location()), gettext("failed to turn off O_DIRECT: %s"), quotearg_n_style_colon(0, shell_escape_quoting_style, output_file)); o_nocache_eof = 1; invalidate_cache(1, 0); conversions_mask |= C_FSYNC; } while (total_written < size) { ssize_t nwritten = 0; process_signals(); final_op_was_seek = 0; if ((conversions_mask & C_SPARSE) && is_nul(buf, size)) { if (lseek(fd, size, 1) < 0) { conversions_mask &= ~C_SPARSE; } else { final_op_was_seek = 1; nwritten = size; } } if (!nwritten) nwritten = write(fd, buf + total_written, size - total_written); if (nwritten < 0) { if ((*__errno_location()) != 4) break; } else if (nwritten == 0) { (*__errno_location()) = 28; break; } else total_written += nwritten; } if (o_nocache && total_written) invalidate_cache(fd, total_written); return total_written; }
int iwrite(unsigned long a0, unsigned int a1, unsigned int a2, unsigned long a3, unsigned int a4, unsigned int a5) { unsigned int v0; int tmp_9; void *v1; unsigned long v2; unsigned long v5; unsigned long long v6; v1 = 0; if ((output_flags & 0x4000) && a2 < output_blocksize) { v0 = rpl_fcntl(0x1, 0x3); if (rpl_fcntl(0x1, 0x4) && status_level != 1) { v5 = quotearg_n_style_colon(0x0, 0x3, output_file); nl_error(0x0, *(__errno_location()), gettext("failed to turn off O_DIRECT: %s"), v5, a4, a5); } o_nocache_eof = 1; a1 = 0; invalidate_cache(0x1, 0x0); v6 = conversions_mask; *(&v6) = (conversions_mask >> 8) | 128; tmp_9 = v6; conversions_mask = tmp_9; } for (; v1 < a2; v1 += v2) { v2 = 0; process_signals(a0, a1, a2, v5, a4, a5); final_op_was_seek = 0; if ((conversions_mask & 0x10000)) { a1 = a2; v6 = is_nul(a1, a2); if (v6) { a2 = 1; v6 = lseek(a0, a2, 0x1); if (v6 < 0) { conversions_mask = conversions_mask & -65537; } else { final_op_was_seek = 1; *(&v2) = a2; } } } if (!v2) { v6 = write(a0, v1 + a1, a2 - v1); v2 = v6; } if ((v2 - 0 >> 63)) { *(&v6) = *(__errno_location()); if (v6 != 4) break; } else if (!v2) { *(__errno_location()) = 28; break; } } if (o_nocache && v1) invalidate_cache(a0, v1); return v1; }
coreutils
angr_dream
inline ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap) { return (ext2_ino_t)ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap)bitmap); }
&& (v1 = **(_DWORD **)(v26 + 32), v1 <= (unsigned int)ext2fs_get_inode_bitmap_end2(*(_QWORD *)(a1 + 360))) ) { if ((unsigned int)ext2fs_get_inode_bitmap_start2(*(_QWORD *)(v26 + 80)) <= 1 && (v2 = **(_DWORD **)(v26 + 32), v2 <= (unsigned int)ext2fs_get_inode_bitmap_end2( *(_QWORD *)(v26 + 80)))) { has_group_desc_csum = ext2fs_has_group_desc_csum(v26); while (1) { v18 = 0; v16 = 0; inode_bitmap_end2 = 0; inode_bitmap_start2 = 0; if (has_group_desc_csum && (unsigned int)ext2fs_bg_flags_test(v26, 0LL, 1LL)) ++v19; for (i = 1; i <= **(_DWORD **)(v26 + 32) && i; ++i) { v14 = 0; if (v19 && i % *(_DWORD *)(*(_QWORD *)(v26 + 32) + 40LL) == 1 && (unsigned int)ext2fs_test_inode_bitmap_range( *(_QWORD *)(a1 + 360), i, *(unsigned int *)(*(_QWORD *)(v26 + 32) + 40LL))) { v21 = 1; v13 = *(_DWORD *)(*(_QWORD *)(v26 + 32) + 40LL) - 1; v10 = v13; v9 += v13; i += v13; v19 = 0; } else { v23 = ext2fs_fast_test_inode_bitmap2(*(_QWORD *)(a1 + 360), i); if (v20) { v14 = v23; } else if (!v19) { v14 = ext2fs_fast_test_inode_bitmap2(*(_QWORD *)(v26 + 80), i); } if ((v23 != 0) == (v14 == 0)) { if (v23 || !v14) { v15 = 327689; if (v19) { v36 = i; v37 = v12; if ((unsigned int)fix_problem(a1, 327705LL, v35)) { ext2fs_bg_flags_clear(v26, v12, 1LL); v19 = 0; } } } else { v15 = 327688; } if (inode_bitmap_start2) { if (v15 == v16 && inode_bitmap_end2 == i - 1) { ++inode_bitmap_end2; } else { print_bitmap_problem(a1, v16, (long)v28); inode_bitmap_end2 = i; inode_bitmap_start2 = i; v16 = v15; } } else { inode_bitmap_end2 = i; inode_bitmap_start2 = i; v16 = v15; } *(_DWORD *)(a1 + 72) |= 0x40u; ++v18; v3 = *(_DWORD *)(a1 + 76); BYTE1(v3) &= ~0x20u; *(_DWORD *)(a1 + 76) = v3; } } ++v13; if (v14) { if ((unsigned int)ext2fs_test_inode_bitmap2(*(_QWORD *)(a1 + 376), i)) ++v11; if (v13 > v21) { e2fsck_discard_inodes(a1, v12, v21, v13 - v21); v21 = *(_DWORD *)(*(_QWORD *)(v26 + 32) + 40LL) + 1; } } else { ++v10; ++v9; if (v21 > v13) v21 = v13; } if (v13 == *(_DWORD *)(*(_QWORD *)(v26 + 32) + 40LL) || i == **(_DWORD **)(v26 + 32)) { if (!v14 && v13 >= v21) e2fsck_discard_inodes(a1, v12, v21, v13 - v21 + 1); if ((*(_DWORD *)(a1 + 76) & 0x2000) != 0 && (*(_DWORD *)(*(_QWORD *)(v26 + 8) + 52LL) & 2) != 0 && !(unsigned int)ext2fs_bg_flags_test(v26, v12, 4LL)) { ext2fs_bg_flags_set(v26, v12, 4LL); ext2fs_group_desc_csum_set(v26, v12); } v21 = *(_DWORD *)(*(_QWORD *)(v26 + 32) + 40LL) + 1; *((_DWORD *)s + v12) = v10; *((_DWORD *)memory + v12++) = v11; v13 = 0; v19 = 0; v10 = 0; v11 = 0; if (*(_QWORD *)(a1 + 352) && (*(unsigned int (**)(long, long, _QWORD, _QWORD))(a1 + 352))( a1, 5LL, *(_DWORD *)(v26 + 48) + v12, (unsigned int)(2 * *(_DWORD *)(v26 + 48)))) { goto LABEL_84; } if (has_group_desc_csum && i != **(_DWORD **)(v26 + 32) && (unsigned int)ext2fs_bg_flags_test(v26, v12, 1LL)) { v19 = 1; } } } if (inode_bitmap_start2) print_bitmap_problem(a1, v16, (long)v28); v17 = v18 ? end_problem_latch(a1, 48LL) : -1; *(_DWORD *)(a1 + 72) &= ~0x40u; if (v17 != 1) break; ext2fs_free_inode_bitmap(*(_QWORD *)(v26 + 80)); if (ext2fs_copy_bitmap(*(_QWORD *)(a1 + 360), v26 + 80)) { clear_problem_context(v28); fix_problem(a1, 327698LL, v28); *(_DWORD *)(a1 + 72) |= 1u; goto LABEL_84; } ext2fs_set_bitmap_padding(*(_QWORD *)(v26 + 80)); ext2fs_mark_ib_dirty(v26); v13 = 0; v9 = 0; v10 = 0; v11 = 0; v12 = 0; memset(s, 0, 4LL * *(unsigned int *)(v26 + 48)); memset(memory, 0, 4LL * *(unsigned int *)(v26 + 48)); ++v20; } if (!v17) ext2fs_unmark_valid(v26); for (j = 0; j < *(_DWORD *)(v26 + 48); ++j) { v4 = *((_DWORD *)s + j); if (v4 != (unsigned int)ext2fs_bg_free_inodes_count(v26, j)) { v33 = j; inode_bitmap_start2 = ext2fs_bg_free_inodes_count(v26, j); inode_bitmap_end2 = *((_DWORD *)s + j); if ((unsigned int)fix_problem(a1, 327691LL, v28)) { ext2fs_bg_free_inodes_count_set(v26, j, *((unsigned int *)s + j)); ext2fs_mark_super_dirty(v26); } else { ext2fs_unmark_valid(v26); } } v5 = *((_DWORD *)memory + j); if (v5 != (unsigned int)ext2fs_bg_used_dirs_count(v26, j)) { v33 = j; inode_bitmap_start2 = ext2fs_bg_used_dirs_count(v26, j); inode_bitmap_end2 = *((_DWORD *)memory + j); if ((unsigned int)fix_problem(a1, 327692LL, v28)) { ext2fs_bg_used_dirs_count_set(v26, j, *((unsigned int *)memory + j)); ext2fs_mark_super_dirty(v26); } else { ext2fs_unmark_valid(v26); } } } if (v9 != *(_DWORD *)(*(_QWORD *)(v26 + 32) + 16LL)) { v33 = -1; inode_bitmap_start2 = *(_DWORD *)(*(_QWORD *)(v26 + 32) + 16LL); inode_bitmap_end2 = v9; if ((unsigned int)fix_problem(a1, 327693LL, v28)) { *(_DWORD *)(*(_QWORD *)(v26 + 32) + 16LL) = v9; ext2fs_mark_super_dirty(v26); } } } else { v34 = 4LL; v31 = 1LL; v32 = **(unsigned int **)(v26 + 32); inode_bitmap_start2 = ext2fs_get_inode_bitmap_start2(*(_QWORD *)(v26 + 80)); inode_bitmap_end2 = ext2fs_get_inode_bitmap_end2(*(_QWORD *)(v26 + 80)); fix_problem(a1, 327696LL, v28); *(_DWORD *)(a1 + 72) |= 1u; } }
e2fsprogs-1.46.5
ida
static struct vcs_ignore_file *get_vcs_ignore_file(const char *name) { struct vcs_ignore_file *p; for (p = vcs_ignore_files; p->filename; p++) if (strcmp(p->filename, name) == 0) break; return p; }
int get_vcs_ignore_file(char *a0) { unsigned long long v0; for (v0 = &vcs_ignore_files; *(v0); v0 += 40) { if (!strcmp(*(v0), a0)) break; } return v0; }
tar
angr_dream
void monitor_clear_keystate(struct ssh *ssh, struct monitor *pmonitor) { ssh_clear_newkeys(ssh, MODE_IN); ssh_clear_newkeys(ssh, MODE_OUT); sshbuf_free(child_state); child_state = ((void *)0); }
long long monitor_clear_keystate(unsigned long long a0, unsigned long a1) { unsigned long v0; v0 = a1; ssh_clear_newkeys(a0, 0x0); ssh_clear_newkeys(a0, 0x1); child_state = 0; return sshbuf_free(child_state); }
openssh-portable
angr_phoenix
static void channel_post_mux_client(struct ssh *ssh, Channel *c) { channel_post_mux_client_read(ssh, c); channel_post_mux_client_write(ssh, c); }
long long channel_post_mux_client(unsigned long long a0, void *a1) { channel_post_mux_client_read(a0, a1); return channel_post_mux_client_write(a0, a1); }
openssh-portable
angr_dream
!matches(*argv, "vni")) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); check_duparg(&attrs, IFLA_VXLAN_ID, "id", *argv); if (get_u32(&vni, *argv, 0) || vni >= 1u << 24) invarg("invalid id", *argv); } else if (!matches(*argv, "group")) {
void matches(void) { halt_baddata(); }
iproute2-6.0.0
ghidra
void _rl_fix_point(int fix_mark_too) { do { if (rl_point > rl_end) rl_point = rl_end; else if (rl_point < 0) rl_point = 0; } while (0); if (fix_mark_too) do { if (rl_mark > rl_end) rl_mark = rl_end; else if (rl_mark < 0) rl_mark = 0; } while (0); }
void _rl_fix_point(unsigned long a0) { unsigned long long v1; unsigned long long v2; unsigned long long v3; unsigned long long v4; if (rl_point > rl_end) { v1 = rl_end; rl_point = rl_end; } else { v2 = rl_point; if (rl_point < 0) rl_point = 0; } if (a0) { if (rl_mark > rl_end) { v3 = rl_end; rl_mark = rl_end; } else { v4 = rl_mark; if (rl_mark < 0) rl_mark = 0; } } return; }
bash
angr_dream
static int statdb_node_remove(const char *filename) { struct fsys_namenode *file; file = fsys_hash_find_node(filename, FHFF_NONE); if (!file || !file->statoverride) return 0; file->statoverride = ((void *)0); return 1; }
undefined8 statdb_node_remove(undefined8 param_1) { long lVar1; undefined8 uVar2; lVar1 = fsys_hash_find_node(param_1, 2); if ((lVar1 == 0) || (*(long *)(lVar1 + 0x20) == 0)) { uVar2 = 0; } else { *(undefined8 *)(lVar1 + 0x20) = 0; uVar2 = 1; } return uVar2; }
dpkg
ghidra
idx_t wordchars_size(char const *buf, char const *end) { return wordchars_count(buf, end, 1); }
long long wordchars_size(void *a0, unsigned int a1) { return wordchars_count(a0, a1, 0x1); }
grep
angr_dream
static void mp_factor_using_pollard_rho(mpz_t n, unsigned long int a, struct mp_factors *factors) { mpz_t x, z, y, P; mpz_t t, t2; do { if (dev_debug) fprintf(stderr, "[pollard-rho (%lu)] ", a); } while (0); __gmpz_inits(t, t2, ((void *)0)); __gmpz_init_set_si(y, 2); __gmpz_init_set_si(x, 2); __gmpz_init_set_si(z, 2); __gmpz_init_set_ui(P, 1); unsigned long long int k = 1; unsigned long long int l = 1; while ((__builtin_constant_p(1) && (1) == 0 ? ((n)->_mp_size < 0 ? -1 : (n)->_mp_size > 0) : __gmpz_cmp_ui(n, 1)) != 0) { for (;;) { do { __gmpz_mul(t, x, x); __gmpz_mod(x, t, n); __gmpz_add_ui(x, x, a); __gmpz_sub(t, z, x); __gmpz_mul(t2, P, t); __gmpz_mod(P, t2, n); if (k % 32 == 1) { __gmpz_gcd(t, P, n); if ((__builtin_constant_p(1) && (1) == 0 ? ((t)->_mp_size < 0 ? -1 : (t)->_mp_size > 0) : __gmpz_cmp_ui(t, 1)) != 0) goto factor_found; __gmpz_set(y, x); } } while (--k != 0); __gmpz_set(z, x); k = l; l = 2 * l; for (unsigned long long int i = 0; i < k; i++) { __gmpz_mul(t, x, x); __gmpz_mod(x, t, n); __gmpz_add_ui(x, x, a); } __gmpz_set(y, x); } factor_found: do { __gmpz_mul(t, y, y); __gmpz_mod(y, t, n); __gmpz_add_ui(y, y, a); __gmpz_sub(t, z, y); __gmpz_gcd(t, t, n); } while ((__builtin_constant_p(1) && (1) == 0 ? ((t)->_mp_size < 0 ? -1 : (t)->_mp_size > 0) : __gmpz_cmp_ui(t, 1)) == 0); __gmpz_divexact(n, n, t); if (!mp_prime_p(t)) { do { if (dev_debug) fprintf(stderr, "[composite factor--restarting pollard-rho] "); } while (0); mp_factor_using_pollard_rho(t, a + 1, factors); } else { mp_factor_insert(factors, t); } if (mp_prime_p(n)) { mp_factor_insert(factors, n); break; } __gmpz_mod(x, x, n); __gmpz_mod(z, z, n); __gmpz_mod(y, y, n); } __gmpz_clears(P, t2, t, z, x, y, ((void *)0)); }
long long mp_factor_using_pollard_rho(unsigned long long a0, unsigned long a1, void *a2, unsigned long long a3, unsigned long long a4) { void *v0; unsigned long long v1; unsigned long long v2; void *v3; char v4; char v5; char v6; char v7; char v8; char v9; unsigned long long v12; unsigned long long v13; if (dev_debug) fprintf(stderr, "[pollard-rho (%lu)] ", a1); __gmpz_inits(&v8, &v9, 0x0, &v9, a4); __gmpz_init_set_si(&v6, 0x2); __gmpz_init_set_si(&v4, 0x2); __gmpz_init_set_si(&v5, 0x2); __gmpz_init_set_ui(&v7, 0x1, 0x0); v1 = 1; v2 = 1; while (true) { if (!__gmpz_cmp_ui(a0, 0x1, a2)) break; while (true) { __gmpz_mul(&v8, &v4, &v4, &v4); __gmpz_mod(&v4, &v8, a0, &v8); __gmpz_add_ui(&v4, &v4, a1, &v4); __gmpz_sub(&v8, &v5, &v4, &v5); __gmpz_mul(&v9, &v7, &v8, &v7); __gmpz_mod(&v7, &v9, a0, &v9); if ((v1 & 31) == 1) { __gmpz_gcd(&v8, &v7, a0, &v7); v12 = __gmpz_cmp_ui(&v8, 0x1, a2); if (!v12) { __gmpz_set(&v6, &v4, &v4, &v7); } else { while (true) { __gmpz_mul(&v8, &v6, &v6, &v6); __gmpz_mod(&v6, &v8, a0, &v8); __gmpz_add_ui(&v6, &v6, a1, &v6); __gmpz_sub(&v8, &v5, &v6, &v5); __gmpz_gcd(&v8, &v8, a0, &v8); v13 = __gmpz_cmp_ui(&v8, 0x1, a2); if (v13) break; } } } if (!v12 || (v1 & 31) != 1) { v1 -= 1; if (v1) continue; __gmpz_set(&v5, &v4, &v4, a3); v1 = v2; v2 *= 2; for (v3 = 0; v3 < v1; v3 += 1) { __gmpz_mul(&v8, &v4, &v4, &v4); __gmpz_mod(&v4, &v8, a0, &v8); __gmpz_add_ui(&v4, &v4, a1, &v4); } __gmpz_set(&v6, &v4, &v4, a3); } } __gmpz_divexact(a0, a0, &v8, a0); *(&v13) = mp_prime_p(&v8, a1, &v8) ^ 1; if (v13) { if (dev_debug) fprintf(stderr, "[composite factor--restarting pollard-rho] "); mp_factor_using_pollard_rho(&v8, a1 + 1, a2, a1 + 1, a4); } else { mp_factor_insert(a2, &v8); } if (mp_prime_p(a0, a1, a2)) { mp_factor_insert(a2, a0); break; } else { __gmpz_mod(&v4, &v4, a0, &v4); __gmpz_mod(&v5, &v5, a0, &v5); __gmpz_mod(&v6, &v6, a0, &v6); } } v0 = 0; __gmpz_clears(&v7, &v9, &v8, &v5, &v4); return 0; }
coreutils
angr_dream
static void add_to_grand_total(struct field_values_t *bv, struct field_values_t *iv) { if (known_value(iv->total)) grand_fsu.fsu_files += iv->total; if (known_value(iv->available)) grand_fsu.fsu_ffree += iv->available; if (known_value(bv->total)) grand_fsu.fsu_blocks += bv->input_units * bv->total; if (known_value(bv->available_to_root)) grand_fsu.fsu_bfree += bv->input_units * bv->available_to_root; if (known_value(bv->available)) add_uint_with_neg_flag( &grand_fsu.fsu_bavail, &grand_fsu.fsu_bavail_top_bit_set, bv->input_units * bv->available, bv->negate_available); }
void add_to_grand_total(long *param_1, long param_2) { char cVar1; cVar1 = known_value(*(undefined8 *)(param_2 + 0x10)); if (cVar1 != '\0') { grand_fsu._40_8_ = *(long *)(param_2 + 0x10) + grand_fsu._40_8_; } cVar1 = known_value(*(undefined8 *)(param_2 + 0x18)); if (cVar1 != '\0') { grand_fsu._48_8_ = *(long *)(param_2 + 0x18) + grand_fsu._48_8_; } cVar1 = known_value(param_1[2]); if (cVar1 != '\0') { grand_fsu._8_8_ = param_1[2] * *param_1 + grand_fsu._8_8_; } cVar1 = known_value(param_1[5]); if (cVar1 != '\0') { grand_fsu._16_8_ = param_1[5] * *param_1 + grand_fsu._16_8_; } cVar1 = known_value(param_1[3]); if (cVar1 != '\0') { add_uint_with_neg_flag(0x104058, 0x104060, param_1[3] * *param_1, *(undefined *)(param_1 + 4)); } return; }
coreutils
ghidra
static char *user_group_str(char const *user, char const *group) { char *spec = ((void *)0); if (user) { if (group) { spec = xmalloc(strlen(user) + 1 + strlen(group) + 1); stpcpy(stpcpy(stpcpy(spec, user), ":"), group); } else { spec = xstrdup(user); } } else if (group) { spec = xstrdup(group); } return spec; }
int user_group_str(char *a0, char *a1) { void *v0; v0 = 0; if (a0) { if (a1) { v0 = xmalloc(strlen(a1) + strlen(a0) + 2); stpcpy(stpcpy(stpcpy(v0, a0), ":"), a1); } else { v0 = xstrdup(a0); } } else { if (a1) v0 = xstrdup(a1); } return v0; }
coreutils
angr_dream
static int monitor_read_log(struct monitor *pmonitor) { struct sshbuf *logmsg; u_int len, level, forced; char *msg; u_char *p; int r; if ((logmsg = sshbuf_new()) == ((void *)0)) sshfatal("monitor.c", __func__, 424, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new"); if ((r = sshbuf_reserve(logmsg, 4, &p)) != 0) sshfatal("monitor.c", __func__, 428, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "reserve len"); if (atomicio(read, pmonitor->m_log_recvfd, p, 4) != 4) { if ((*__errno_location()) == 32) { sshbuf_free(logmsg); sshlog("monitor.c", __func__, 432, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0), "child log fd closed"); close(pmonitor->m_log_recvfd); pmonitor->m_log_recvfd = -1; return -1; } sshfatal("monitor.c", __func__, 437, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "log fd read: %s", strerror((*__errno_location()))); } if ((r = sshbuf_get_u32(logmsg, &len)) != 0) sshfatal("monitor.c", __func__, 440, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse len"); if (len <= 4 || len > 8192) sshfatal("monitor.c", __func__, 442, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "invalid log message length %u", len); sshbuf_reset(logmsg); if ((r = sshbuf_reserve(logmsg, len, &p)) != 0) sshfatal("monitor.c", __func__, 447, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "reserve msg"); if (atomicio(read, pmonitor->m_log_recvfd, p, len) != len) sshfatal("monitor.c", __func__, 449, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "log fd read: %s", strerror((*__errno_location()))); if ((r = sshbuf_get_u32(logmsg, &level)) != 0 || (r = sshbuf_get_u32(logmsg, &forced)) != 0 || (r = sshbuf_get_cstring(logmsg, &msg, ((void *)0))) != 0) sshfatal("monitor.c", __func__, 453, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse"); if (log_level_name(level) == ((void *)0)) sshfatal("monitor.c", __func__, 457, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "invalid log level %u (corrupted message?)", level); sshlogdirect(level, forced, "%s [preauth]", msg); sshbuf_free(logmsg); free(msg); return 0; }
int monitor_read_log(struct_0 *a0) { char v0; char v1; char v2; unsigned int v3; char v4; char v5; unsigned long long v6; unsigned long long v7; unsigned long v8; char v9; unsigned int v12; v6 = sshbuf_new(); if (!v6) sshfatal("monitor.c", "monitor_read_log", 0x1a8, 0x1, 0x1, 0x0, "sshbuf_new"); v3 = sshbuf_reserve(v6, 0x4, &v5); if (v3) { v7 = "reserve len"; sshfatal("monitor.c", "monitor_read_log", 0x1ac, 0x1, 0x1, ssh_err(v3), *(&v9)); } if (atomicio(got.read, a0->field_8, *(&v5), 0x4) != 4) { if (*(__errno_location()) == 32) { sshbuf_free(v6); v7 = "child log fd closed"; sshlog("monitor.c", "monitor_read_log", 0x1b0, 0x1, 0x5, 0x0); close(a0->field_8); a0->field_8 = -1; v12 = -1; goto LABEL_400b7f; } else { v8 = strerror(*(__errno_location())); v7 = "log fd read: %s"; sshfatal("monitor.c", "monitor_read_log", 0x1b5, 0x1, 0x1, 0x0, *(&v9)); } } v3 = sshbuf_get_u32(v6, &v0, &v0); if (v3) { v7 = "parse len"; sshfatal("monitor.c", "monitor_read_log", 0x1b8, 0x1, 0x1, ssh_err(v3), *(&v9)); } if (*(&v0) > 4 && *(&v0) <= 0x2000) goto LABEL_40097f; v8 = *(&v0); v7 = "invalid log message length %u"; sshfatal("monitor.c", "monitor_read_log", 0x1ba, 0x1, 0x1, 0x0, *(&v9)); LABEL_40097f: sshbuf_reset(v6); v3 = sshbuf_reserve(v6, *(&v0), &v5); if (v3) { v7 = "reserve msg"; sshfatal("monitor.c", "monitor_read_log", 0x1bf, 0x1, 0x1, ssh_err(v3), *(&v9)); } if (atomicio(got.read, a0->field_8, *(&v5), *(&v0)) != *(&v0)) { v8 = strerror(*(__errno_location())); v7 = "log fd read: %s"; sshfatal("monitor.c", "monitor_read_log", 0x1c1, 0x1, 0x1, 0x0, *(&v9)); } v3 = sshbuf_get_u32(v6, &v1, &v1); if (!v3) { v3 = sshbuf_get_u32(v6, &v2, &v2); if (!v3) { v3 = sshbuf_get_cstring(v6, &v4, 0x0, &v4); if (!v3) goto LABEL_400af7; } } v7 = "parse"; sshfatal("monitor.c", "monitor_read_log", 0x1c5, 0x1, 0x1, ssh_err(v3), *(&v9)); LABEL_400af7: if (!log_level_name(*(&v1))) { v8 = *(&v1); v7 = "invalid log level %u (corrupted message?)"; sshfatal("monitor.c", "monitor_read_log", 0x1c9, 0x1, 0x1, 0x0, *(&v9)); } sshlogdirect(*(&v1), *(&v2), "%s [preauth]", *(&v4)); sshbuf_free(v6); free(*(&v4)); v12 = 0; LABEL_400b7f: return v12; }
openssh-portable
angr_phoenix
static int parse_id(uintmax_t *retval, char const *arg, char const *what, uintmax_t maxval, char const *file, unsigned line) { uintmax_t v; char *p; (*__errno_location()) = 0; v = strtoumax(arg, &p, 10); if (*p || (*__errno_location())) { error(0, 0, gettext("%s:%u: invalid %s: %s"), file, line, what, arg); return -1; } if (v > maxval) { error(0, 0, gettext("%s:%u: %s out of range: %s"), file, line, what, arg); return -1; } *retval = v; return 0; }
long parse_id(uintmax_t *a1, const char *a2, long a3, uintmax_t a4, long a5, unsigned int a6) { char *v6; char *v8; char *endptr; uintmax_t v14; unsigned long v15; v15 = __readfsqword(0x28u); *_errno_location() = 0; v14 = strtoumax(a2, &endptr, 10); if (*endptr || *_errno_location()) { v6 = gettext("%s:%u: invalid %s: %s"); error(0, 0, v6, a5, a6, a3, a2); return 0xFFFFFFFFLL; } else if (v14 <= a4) { *a1 = v14; return 0LL; } else { v8 = gettext("%s:%u: %s out of range: %s"); error(0, 0, v8, a5, a6, a3, a2); return 0xFFFFFFFFLL; } }
tar
ida
static int glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last, Char *pattern, Char *restpattern, Char *restpattern_last, _ssh_compat_glob_t *pglob, struct glob_lim *limitp) { struct dirent *dp; DIR *dirp; int err; char buf[4096]; struct dirent *(*readdirfunc)(void *); if (pathend > pathend_last) return (1); *pathend = '\0'; (*__errno_location()) = 0; if ((dirp = g_opendir(pathbuf, pglob)) == ((void *)0)) { if (pglob->gl_errfunc) { if (g_Ctoc(pathbuf, buf, sizeof(buf))) return ((-2)); if (pglob->gl_errfunc(buf, (*__errno_location())) || pglob->gl_flags & 0x0004) return ((-2)); } return (0); } err = 0; if (pglob->gl_flags & 0x0040) readdirfunc = pglob->gl_readdir; else readdirfunc = (struct dirent * (*)(void *)) readdir; while ((dp = (*readdirfunc)(dirp))) { u_char *sc; Char *dc; if ((pglob->gl_flags & 0x2000) && limitp->glim_readdir++ >= 16384) { (*__errno_location()) = 0; *pathend++ = '/'; *pathend = '\0'; err = (-1); break; } if (dp->d_name[0] == '.' && *pattern != '.') continue; dc = pathend; sc = (u_char *)dp->d_name; while (dc < pathend_last && (*dc++ = *sc++) != '\0') ; if (dc >= pathend_last) { *dc = '\0'; err = 1; break; } if (!match(pathend, pattern, restpattern)) { *pathend = '\0'; continue; } err = glob2(pathbuf, pathbuf_last, --dc, pathend_last, restpattern, restpattern_last, pglob, limitp); if (err) break; } if (pglob->gl_flags & 0x0040) (*pglob->gl_closedir)(dirp); else closedir(dirp); return (err); }
void glob3(unsigned long long a0, unsigned long long a1, unsigned long long a2, unsigned long a3, unsigned short *a4, unsigned long long a5, unsigned long long v12, unsigned long a6, unsigned long long *a7) { struct_1 *v0; int tmp_10; int tmp_14; int tmp_25; struct_0 *v1; unsigned long long v2; unsigned short *v3; unsigned int v4; unsigned long v5; char *v6; unsigned short *v7; unsigned long long v8; struct_2 *v9; char v10; char v11; unsigned long long v13; unsigned long long v14; unsigned long long v16; void *v18; unsigned long long v19; unsigned long long v20; v11 = *(&v11); v3 = a2; v2 = v12; v1 = a6; v0 = &a7; if (v3 > a3) { v13 = 1; } else { *(v3) = 0; *(__errno_location()) = 0; v8 = g_opendir(a0, v1); if (v8) { v4 = 0; if (!(v1->field_18 & 64)) v5 = got.readdir; else v5 = v1->field_40; while (true) { v9 = (stack_base)[4176](v8); if (!v9) break; if ((v1->field_18 & 0x2000)) { v14 = v0->field_10; v0->field_10 = v0->field_10 + 1; if (v14 > 16383) { *(__errno_location()) = 0; tmp_10 = v3; v3 += 1; *(tmp_10) = 47; *(v3) = 0; v4 = -1; break; } } if (v9->field_13 == 46 && !(*(a4) == 46)) continue; v7 = v3; v6 = &v9->field_13; while (true) { if (v7 >= a3) break; tmp_14 = v6; v6 += 1; a3 = *(tmp_14); tmp_25 = v7; v7 += 1; *(tmp_25) = a3; *(&v14) = *(tmp_25); if (!v14) break; } if (v7 >= a3) { *(v7) = 0; v4 = 1; break; } else if (match(v3, a4, a5)) { v7 += 1; v4 = glob2(a0, a1, v7, a3, a5, v2, v1, v0); if (v4) break; } else { *(v3) = 0; } } if (!(v1->field_18 & 64)) closedir(v8); else *(((stack_base)[4248] + 56))(v8); v20 = v4; } else { if (v1->field_30) { if (g_Ctoc(a0, &v10, 0x1000)) { v16 = 4294967294; goto LABEL_401c45; } if (*(((stack_base)[4248] + 48))(&v10, *(__errno_location()), *(__errno_location()))) { LABEL_4019cb: v19 = 4294967294; goto LABEL_401c45; } else if (!(!(v1->field_18 & 4))) { goto LABEL_4019cb; } } v18 = 0; } } LABEL_401c45: return; }
openssh-portable
angr_phoenix
int get_ca_status(void) { if (batch) { return cfg.ca; } else { return read_yesno("Does the certificate belong to an authority? (y/N): ", 0); } }
ulong get_ca_status(void) { ulong uVar1; if (*piRam000000000010730e == 0) { uVar1 = read_yesno("Does the certificate belong to an authority? (y/N): ", 0); } else { uVar1 = (ulong) * (uint *)(lRam000000000010731b + 0x21c); } return uVar1; }
gnutls
ghidra
void coproc_dispose(cp) struct coproc *cp; { sigset_t set, oset; if (cp == 0) return; do { sigemptyset(&set); sigaddset(&set, 17); sigemptyset(&oset); sigprocmask(0, &set, &oset); } while (0); cp->c_lock = 3; coproc_unsetvars(cp); do { if (cp->c_name) sh_xfree((cp->c_name), "execute_cmd.c", 2077); } while (0); coproc_close(cp); coproc_init(cp); cp->c_lock = 0; sigprocmask(2, &oset, (sigset_t *)((void *)0)); }
long long coproc_dispose(struct_0 *a0) { char v0; char v1; if (!a0) return 0; sigemptyset(&v0); sigaddset(&v0, 0x11); sigemptyset(&v1); sigprocmask(0x0, &v0, &v1); a0->field_24 = 3; coproc_unsetvars(a0); if (a0->field_0) sh_xfree(a0->field_0, "execute_cmd.c", 0x81d); coproc_close(a0); coproc_init(a0); a0->field_24 = 0; sigprocmask(0x2, &v1, NULL); return 0; }
bash
angr_sailr
static void reap_some(void) { reap(-1); reap_exited(); }
void reap_some() { unsigned long long v1; reap(0xffffffff); v1 = reap_exited(); return; }
coreutils
angr_sailr