input
stringlengths
26
172k
output
stringlengths
18
318k
repo_name
stringclasses
23 values
decompiler
stringclasses
5 values
test_code_t test_version_oob(gnutls_session_t session) { int ret; sprintf(prio_str, "NONE:" "+CIPHER-ALL:+ARCFOUR-128:+3DES-CBC" ":+GOST28147-TC26Z-CNT" ":" "+COMP-NULL" ":%s:" "+MAC-ALL:+MD5:+SHA1" ":+GOST28147-TC26Z-IMIT" ":" "+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+ECDHE-RSA:+ECDHE-ECDSA:+ANON-ECDH" ":+VKO-GOST-12" ":%s", protocol_str, rest); { int _ret; if ((_ret = __gnutls_priority_set_direct(session, prio_str, 1426)) != TEST_SUCCEED) { return _ret; } }; gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred); _gnutls_record_set_default_version(session, 5, 5); ret = test_do_handshake(session); return ret; }
long test_version_oob(long a1) { unsigned int v2; sprintf(prio_str, "NONE:+CIPHER-ALL:+ARCFOUR-128:+3DES-CBC:+GOST28147-TC26Z-CNT:+COMP-" "NULL:%s:+MAC-ALL:+MD5:+SHA1:+GOST28147-TC26Z-IMIT" ":+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+ECDHE-RSA:+ECDHE-ECDSA:+ANON-ECDH:" "+VKO-GOST-12:%s", protocol_str, rest); v2 = _gnutls_priority_set_direct(a1, prio_str, 0x592u); if (v2) return v2; gnutls_credentials_set(a1, 1LL, xcred); gnutls_record_set_default_version(a1, 5LL, 5LL); return (unsigned int)test_do_handshake(a1); }
gnutls
ida
static void listener_free(const void *elt) { listener_item *j = (listener_item *)elt; free(j->http_request); free(j->http_response); if (j->fd >= 0) { if (j->close_ok) gnutls_bye(j->tls_session, GNUTLS_SHUT_WR); shutdown(j->fd, 2); close(j->fd); gnutls_deinit(j->tls_session); } }
long long listener_free(struct_0 *a0) { unsigned long long v1; free(a0->field_0); free(a0->field_8); v1 = a0->field_24; if (a0->field_24 >= 0) { if (a0->field_34) gnutls_bye(a0->field_28, 0x1); shutdown(a0->field_24, 0x2); close(a0->field_24); v1 = gnutls_deinit(a0->field_28); } return v1; }
gnutls
angr_dream
static idx_t get_format_flags(char const *format, int *flags_ptr) { int flags = 0; for (idx_t count = 0;; count++) { switch (format[count]) { case '-': case '0': break; case '\'': flags |= FLAG_THOUSANDS; break; case '#': flags |= FLAG_ALTERNATIVE; break; default: *flags_ptr = flags; return count; } } }
long get_format_flags(long a1, _DWORD *a2) { int v2; int v4; long i; v4 = 0; for (i = 0LL;; ++i) { v2 = *(char *)(i + a1); if (v2 != 48) { if (v2 > 48) goto LABEL_10; if (v2 != 45) break; } LABEL_11:; } if (v2 > 45) goto LABEL_10; if (v2 == 35) { v4 |= 2u; goto LABEL_11; } if (v2 == 39) { v4 |= 1u; goto LABEL_11; } LABEL_10: *a2 = v4; return i; }
coreutils
ida
_Bool transform_name_fp (char **pinput, int flags, char *(*fun)(char *, void *), void *dat) { char *str; _Bool ret = _transform_name_to_obstack(flags, *pinput, &str); if (ret) { assign_string(pinput, fun ? fun(str, dat) : str); __extension__({ struct obstack *__o = (&stk); void *__obj = (void *)(str); if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) __o->next_free = __o->object_base = (char *)__obj; else _obstack_free(__o, __obj); }); } else if (fun) { *pinput = ((void *)0); assign_string(pinput, fun(str, dat)); free(str); ret = 1; } return ret; }
void transform_name_fp(unsigned long long *a0, unsigned long a1, unsigned long long a2, unsigned long long a3) { char v0; char v1; unsigned long long v2; unsigned long long v3; unsigned long long v5; unsigned long long v6; unsigned long long v7; v0 = _transform_name_to_obstack(a1, *(a0), &v1); if (v0) { if (!a2) v6 = *(&v1); else v6 = (stack_base)[80](*(&v1), a3, a3, a2); assign_string(a0, v6, a0); v2 = &stk; v3 = *(&v1); if (v3 <= *((v2 + 8)) || v3 >= *((v2 + 32))) { _obstack_free(v2, v3); } else { *((v2 + 16)) = v3; *((v2 + 24)) = *((v2 + 16)); } } else if (a2) { *(a0) = 0; v5 = (stack_base)[80](*(&v1), a3, a3, a2); assign_string(a0, v5, v5); free(*(&v1)); v0 = 1; } v7 = v0; return; }
tar
angr_sailr
static void verify_package(struct pkginfo *pkg) { struct fsys_namenode_list *file; struct varbuf filename = {0, 0, ((void *)0)}; ensure_packagefiles_available(pkg); parse_filehash(pkg, &pkg->installed); pkg_conffiles_mark_old(pkg); for (file = pkg->files; file; file = file->next) { struct verify_checks checks; struct fsys_namenode *fnn; char hash[32 + 1]; int failures = 0; fnn = namenodetouse(file->namenode, pkg, &pkg->installed); if (fnn->newhash == ((void *)0)) { if (fnn->oldhash == ((void *)0)) continue; else fnn->newhash = fnn->oldhash; } varbuf_reset(&filename); varbuf_add_buf(&filename, instdir, strlen(instdir)); varbuf_add_buf(&filename, fnn->name, strlen(fnn->name)); varbuf_end_str(&filename); memset(&checks, 0, sizeof(checks)); md5hash(pkg, hash, filename.buf); if (strcmp(hash, fnn->newhash) != 0) { checks.md5sum = VERIFY_FAIL; failures++; } if (failures) verify_output(fnn, &checks); } varbuf_destroy(&filename); }
void verify_package(struct_0 *a0) { unsigned int v0; unsigned int v1; unsigned long long v2[2]; unsigned long long v3[9]; void *v4; void *v5; void *v6; char v7; char v8; unsigned long long *v10; unsigned long long v11; v4 = 0; v5 = 0; v6 = 0; ensure_packagefiles_available(a0); parse_filehash(a0, &a0->padding_0[72], &a0->padding_0[72]); pkg_conffiles_mark_old(a0); v2[0] = a0->field_168; while (true) { if (!v2) break; v1 = 0; v3[0] = namenodetouse(v2[1], a0, &a0->padding_0[72], a0); if (!v3[8]) { if (!v3[7]) goto LABEL_4002c5; v3[8] = v3[7]; } varbuf_reset(&v4); varbuf_add_buf(&v4, instdir, strlen(instdir), instdir); varbuf_add_buf(&v4, v3[1], strlen(v3[1]), v3[1]); varbuf_end_str(&v4); memset(&v0, 0x0, 0x4); md5hash(a0, &v7, v6, &v7); if (strcmp(&v7, v3[8])) { v0 = 2; v1 += 1; } if (v1) verify_output_rpm(v3, &v0); LABEL_4002c5: v2[0] = v2[0]; } varbuf_destroy(&v4); v11 = *(&v8) ^ v10[5]; return; }
dpkg
angr_phoenix
static inline size_t acl_ea_size(int count) { return sizeof(acl_ea_header) + count * sizeof(acl_ea_entry); }
int acl_ea_size(unsigned long a0) { return a0 * 8 + 4; }
acl-2.3.1
angr_dream
static void print_encap_ioam6(FILE *fp, struct rtattr *encap) { struct rtattr *tb[(__IOAM6_IPTUNNEL_MAX - 1) + 1]; struct ioam6_trace_hdr *trace; __u32 freq_k, freq_n; __u8 mode; (parse_rtattr_flags( (tb), ((__IOAM6_IPTUNNEL_MAX - 1)), ((void *)(((char *)(encap)) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))), ((int)((encap)->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), (1 << 15))); if (!tb[IOAM6_IPTUNNEL_MODE] || !tb[IOAM6_IPTUNNEL_TRACE] || !tb[IOAM6_IPTUNNEL_FREQ_K] || !tb[IOAM6_IPTUNNEL_FREQ_N]) return; freq_k = rta_getattr_u32(tb[IOAM6_IPTUNNEL_FREQ_K]); freq_n = rta_getattr_u32(tb[IOAM6_IPTUNNEL_FREQ_N]); print_uint(PRINT_ANY, "freqk", "freq %u", freq_k); print_uint(PRINT_ANY, "freqn", "/%u ", freq_n); mode = rta_getattr_u8(tb[IOAM6_IPTUNNEL_MODE]); if (!tb[IOAM6_IPTUNNEL_DST] && mode != IOAM6_IPTUNNEL_MODE_INLINE) return; print_string(PRINT_ANY, "mode", "mode %s ", format_ioam6mode_type(mode)); if (mode != IOAM6_IPTUNNEL_MODE_INLINE) print_string( PRINT_ANY, "tundst", "tundst %s ", rt_addr_n2a( 10, ((int)((tb[IOAM6_IPTUNNEL_DST])->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), ((void *)(((char *)(tb[IOAM6_IPTUNNEL_DST])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))))); trace = ((void *)(((char *)(tb[IOAM6_IPTUNNEL_TRACE])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))); print_null(PRINT_ANY, "trace", "trace ", ((void *)0)); print_null(PRINT_ANY, "prealloc", "prealloc ", ((void *)0)); print_hex(PRINT_ANY, "type", "type %#08x ", ntohl(trace->type_be32) >> 8); print_uint(PRINT_ANY, "ns", "ns %u ", ntohs(trace->namespace_id)); print_uint(PRINT_ANY, "size", "size %u ", trace->remlen * 4); }
void print_encap_ioam6(undefined8 param_1, ushort *param_2) { char cVar1; uint16_t uVar2; undefined4 uVar3; undefined4 uVar4; uint32_t uVar5; undefined8 uVar6; undefined8 in_R9; long in_FS_OFFSET; undefined local_48[8]; long local_40; ushort *local_38; long local_30; long local_28; long local_20; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); parse_rtattr_flags(local_48, 5, param_2 + 2, *param_2 - 4, 0x8000, in_R9, param_2, param_1); if ((((local_40 != 0) && (local_30 != 0)) && (local_28 != 0)) && (local_20 != 0)) { uVar3 = rta_getattr_u32(local_28); uVar4 = rta_getattr_u32(local_20); print_uint(4, "freqk", "freq %u", uVar3); print_uint(4, "freqn", &DAT_00106d83, uVar4); cVar1 = rta_getattr_u8(local_40); if ((local_38 != (ushort *)0x0) || (cVar1 == '\x01')) { uVar6 = format_ioam6mode_type(cVar1); print_string(4, &DAT_00106d6b, "mode %s ", uVar6); if (cVar1 != '\x01') { uVar6 = rt_addr_n2a(10, *local_38 - 4, local_38 + 2); print_string(4, "tundst", "tundst %s ", uVar6); } print_null(4, "trace", "trace ", 0); print_null(4, "prealloc", "prealloc ", 0); uVar5 = ntohl(*(uint32_t *)(local_30 + 8)); print_hex(4, &DAT_00106dcc, "type %#08x ", uVar5 >> 8); uVar2 = ntohs(*(uint16_t *)(local_30 + 4)); print_uint(4, &DAT_00106dd8, "ns %u ", uVar2); print_uint(4, &DAT_00106de4, "size %u ", (ulong)(*(byte *)(local_30 + 7) & 0x7f) << 2); } } if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return; } __stack_chk_fail(); }
iproute2-6.0.0
ghidra
static inline void grabstackblock(size_t len) { stalloc(len); }
void grabstackblock(unsigned long long a0) { unsigned long long v1; v1 = stalloc(a0); return; }
dash-0.5.11+git20210903+057cd650a4ed
angr_phoenix
void add_documentation(defs, line) DEF_FILE *defs; char *line; { register BUILTIN_DESC *builtin; builtin = current_builtin("(implied LONGDOC)", defs); remove_trailing_whitespace(line); if (!*line && !builtin->longdoc) return; if (!builtin->longdoc) builtin->longdoc = array_create(sizeof(char *)); array_add(line, builtin->longdoc); }
void add_documentation(unsigned long long a0, char *a1, unsigned long long a2, unsigned long long a3) { struct_0 *v1; unsigned long long v2; unsigned long long v3; v1 = current_builtin("(implied LONGDOC)", a0, a2, a3); remove_trailing_whitespace(a1); if (!*(a1)) v2 = v1->field_20; if (*(a1) || v1->field_20) { if (!v1->field_20) v1->field_20 = array_create(0x8); v3 = array_add(a1, v1->field_20); } return; }
bash
angr_dream
void monitor_child_postauth(struct ssh *ssh, struct monitor *pmonitor) { close(pmonitor->m_recvfd); pmonitor->m_recvfd = -1; monitor_set_child_handler(pmonitor->m_pid); ssh_signal(1, &monitor_child_handler); ssh_signal(15, &monitor_child_handler); ssh_signal(2, &monitor_child_handler); ssh_signal(25, ((__sighandler_t)1)); mon_dispatch = mon_dispatch_postauth20; monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); if (auth_opts->permit_pty_flag) { monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1); } for (;;) monitor_read(ssh, pmonitor, mon_dispatch, ((void *)0)); }
long long monitor_child_postauth() { unsigned int v1[7]; unsigned long long v2; close(v1[0]); v1[0] = -1; monitor_set_child_handler(v1[6]); ssh_signal(0x1, monitor_child_handler); ssh_signal(0xf, monitor_child_handler); ssh_signal(0x2, monitor_child_handler); ssh_signal(0x19, 0x1); mon_dispatch = &mon_dispatch_postauth20; monitor_permit(0x89f47589f87d8948, 0x0, 0x1); monitor_permit(0x89f47589f87d8948, 0x6, 0x1); monitor_permit(0x89f47589f87d8948, 0x32, 0x1); if (*((auth_opts + 12))) { monitor_permit(0x89f47589f87d8948, 0x1c, 0x1); monitor_permit(0x89f47589f87d8948, 0x1e, 0x1); } while (true) { monitor_read(v2, v1, 0x89f47589f87d8948, 0x0); } }
openssh-portable
angr_phoenix
BUILTIN_DESC *current_builtin(directive, defs) char *directive; DEF_FILE *defs; { must_be_building(directive, defs); if (defs->builtins) return ((BUILTIN_DESC *)defs->builtins->array[defs->builtins->sindex - 1]); else return ((BUILTIN_DESC *)((void *)0)); }
int current_builtin(unsigned long a0, struct_0 *a1, unsigned long a2, unsigned long a3) { unsigned int v1; must_be_building(a0, a1, a1, a3); if (!a1->field_28) v1 = 0; else v1 = *((a1->field_28->field_4 * 8 - 8 + a1->field_28->field_10)); return v1; }
bash
angr_phoenix
static int confirm_sk_overwrite(const char *application, const char *user) { char yesno[3]; printf("A resident key scoped to '%s' with user id '%s' already " "exists.\n", application == ((void *)0) ? "ssh:" : application, user == ((void *)0) ? "null" : user); printf("Overwrite key in token (y/n)? "); fflush(stdout); if (fgets(yesno, sizeof(yesno), stdin) == ((void *)0)) return 0; if (yesno[0] != 'y' && yesno[0] != 'Y') return 0; return 1; }
int confirm_sk_overwrite(unsigned long a0, unsigned long a1) { char v0; unsigned int v2; unsigned int v3; unsigned int v4; if (!a1) v2 = &g_412e10; else v2 = a1; if (!a0) v3 = &g_412bfc; else v3 = a0; printf("A resident key scoped to '%s' with user id '%s' already exists.\n", v3, v2); printf("Overwrite key in token (y/n)? "); fflush(stdout); if (!fgets(&v0, 0x3, stdin)) { v4 = 0; } else { if (v0 != 121 && v0 != 89) { v4 = 0; goto LABEL_40d0ce; } v4 = 1; } LABEL_40d0ce: return v4; }
openssh-portable
angr_phoenix
static void clear_mask_map(struct xattrs_mask_map *mask_map) { if (mask_map->size) free(mask_map->masks); }
void clear_mask_map(void **param_1) { if (param_1[1] != (void *)0x0) { free(*param_1); } return; }
tar
ghidra
int rl_vi_search_again(int count, int key) { switch (key) { case 'n': rl_noninc_reverse_search_again(count, key); break; case 'N': rl_noninc_forward_search_again(count, key); break; } return (0); }
long long rl_vi_search_again(unsigned long a0, unsigned long a1) { if (a1 == 78) { rl_noninc_forward_search_again(a0, a1, a1); } else if (a1 == 110) { rl_noninc_reverse_search_again(a0, a1, a1); } return 0; }
bash
angr_phoenix
static void depmod_list_remove_data(struct kmod_list **list, void *data) { struct kmod_list *l; l = kmod_list_remove_data(*list, data); *list = l; }
void depmod_list_remove_data(unsigned long long *a0, unsigned long long a1) { unsigned long v0; unsigned long long *v2; v0 = kmod_list_remove_data(*(a0), a1, a1); v2 = a0; *(a0) = v0; return; }
kmod
angr_phoenix
static void process_lstat(u_int32_t id) { process_do_stat(id, 1); }
unsigned long process_lstat(unsigned int a1) { return process_do_stat(a1, 1); }
openssh-portable
ida
void _rl_vi_initialize_line(void) { register int i, n; n = sizeof(vi_mark_chars) / sizeof(vi_mark_chars[0]); for (i = 0; i < n; i++) vi_mark_chars[i] = -1; (rl_readline_state &= ~(0x0400000)); }
long long _rl_vi_initialize_line() { void *v1; unsigned long long v2; for (v1 = 0; v1 < 26; v1 = v1 + 1) { *((0x4 * v1 + &vi_mark_chars)) = -1; } v2 = rl_readline_state & -4194305; rl_readline_state = rl_readline_state & -4194305; return v2; }
bash
angr_dream
) { fprintf( stderr, gettext( "Invalid member username %s\n"), token); exit(10); }
int fprintf(FILE *__stream, char *__format, ...) { halt_baddata(); }
shadow
ghidra
FILE *auth_openkeyfile(const char *file, struct passwd *pw, int strict_modes) { return auth_openfile(file, pw, strict_modes, 1, "authorized keys"); }
long long auth_openkeyfile(char *a0, unsigned long long *a1, unsigned long a2) { return auth_openfile(a0, a1, a2, 0x1, "authorized keys"); }
openssh-portable
angr_dream
static int deserialise_identity2(struct sshbuf *ids, struct sshkey **keyp, char **commentp) { int r; char *comment = ((void *)0); const u_char *blob; size_t blen; if ((r = sshbuf_get_string_direct(ids, &blob, &blen)) != 0 || (r = sshbuf_get_cstring(ids, &comment, ((void *)0))) != 0) goto out; if ((r = sshkey_from_blob(blob, blen, keyp)) != 0) goto out; if (commentp != ((void *)0)) { *commentp = comment; comment = ((void *)0); } r = 0; out: free(comment); return r; }
int deserialise_identity2(unsigned long long a0, unsigned long long a1, unsigned long long *a2) { unsigned int v0; void *v1; char v2; char v3; v1 = 0; v0 = sshbuf_get_string_direct(a0, &v2, &v3, &v2); if (!v0) { v0 = sshbuf_get_cstring(a0, &v1, 0x0, &v1); if (!v0) { v0 = sshkey_from_blob(*(&v2), *(&v3), a1, *(&v3)); if (!v0) { if (a2) { *(a2) = v1; v1 = 0; } v0 = 0; } } } free(v1); return v0; }
openssh-portable
angr_dream
static int read_a_char(void) { char c; int r; int fail = 0; while (1) { if (e2fsck_global_ctx && (e2fsck_global_ctx->flags & 0x0002)) { return 3; } r = read(0, &c, 1); if (r == 1) return c; if (fail++ > 100) break; } return (-1); }
int read_a_char() { char v0; unsigned int v1; unsigned int v2; unsigned int v4; unsigned int v5; v1 = 0; do { if (e2fsck_global_ctx && (*((e2fsck_global_ctx + 72)) & 2)) { v5 = 3; goto LABEL_400600; } v2 = read(0x0, &v0, 0x1); if (v2 == 1) { v5 = v0; goto LABEL_400600; } v4 = v1; v1 += 1; } while (v4 <= 100); v5 = -1; LABEL_400600: return v5; }
e2fsprogs-1.46.5
angr_phoenix
static struct diff_block *process_diff(char const *filea, char const *fileb, struct diff_block **last_block, char **buf_to_free) { char *diff_contents; char *diff_limit; char *scan_diff; enum diff_type dt; lin i; struct diff_block *block_list; struct diff_block **block_list_end = &block_list; struct diff_block *bptr; size_t too_many_lines = ((9223372036854775807L) / ((sizeof *bptr->lines[1]) <= (sizeof *bptr->lengths[1]) ? (sizeof *bptr->lines[1]) : (sizeof *bptr->lengths[1]))); diff_limit = read_diff(filea, fileb, &diff_contents); *buf_to_free = diff_contents; scan_diff = diff_contents; while (scan_diff < diff_limit) { bptr = xmalloc(sizeof *bptr); bptr->lines[0] = bptr->lines[1] = 0; bptr->lengths[0] = bptr->lengths[1] = 0; dt = process_diff_control(&scan_diff, bptr); if (dt == ERROR || *scan_diff != '\n') { fprintf(stderr, gettext("%s: diff failed: "), program_name); do { putc_unlocked(*scan_diff, stderr); } while (*scan_diff++ != '\n'); exit(2); } scan_diff++; switch (dt) { case ADD: bptr->ranges[0][0]++; break; case DELETE: bptr->ranges[1][0]++; break; case CHANGE: break; default: fatal("internal error: invalid diff type in process_diff"); break; } if (dt != ADD) { lin numlines = (((bptr)->ranges[0][1]) - ((bptr)->ranges[0][0]) + 1); if (too_many_lines <= numlines) xalloc_die(); bptr->lines[0] = xmalloc(numlines * sizeof *bptr->lines[0]); bptr->lengths[0] = xmalloc(numlines * sizeof *bptr->lengths[0]); for (i = 0; i < numlines; i++) scan_diff = scan_diff_line(scan_diff, &(bptr->lines[0][i]), &(bptr->lengths[0][i]), diff_limit, '<'); } if (dt == CHANGE) { if (strncmp(scan_diff, "---\n", 4)) fatal("invalid diff format; invalid change separator"); scan_diff += 4; } if (dt != DELETE) { lin numlines = (((bptr)->ranges[1][1]) - ((bptr)->ranges[1][0]) + 1); if (too_many_lines <= numlines) xalloc_die(); bptr->lines[1] = xmalloc(numlines * sizeof *bptr->lines[1]); bptr->lengths[1] = xmalloc(numlines * sizeof *bptr->lengths[1]); for (i = 0; i < numlines; i++) scan_diff = scan_diff_line(scan_diff, &(bptr->lines[1][i]), &(bptr->lengths[1][i]), diff_limit, '>'); } *block_list_end = bptr; block_list_end = &bptr->next; } *block_list_end = ((void *)0); *last_block = bptr; return block_list; }
long process_diff(long a1, long a2, _QWORD *a3, char **a4) { long v4; char *v5; char *v6; unsigned int v10; char *v11; char *s1; long v13; long i; long *v15; long *v16; unsigned long v17; unsigned long v18; unsigned long v19; unsigned long v20; unsigned long v21; v21 = __readfsqword(0x28u); v15 = &v13; v17 = 0xFFFFFFFFFFFFFFFLL; v18 = read_diff(a1, a2, &v11); *a4 = v11; s1 = v11; while (v18 > (unsigned long)s1) { v16 = (long *)xmalloc(72LL); v16[5] = 0LL; v16[4] = v16[5]; v16[7] = 0LL; v16[6] = v16[7]; v10 = process_diff_control(&s1, v16); if (!v10 || *s1 != 10) { v4 = program_name; v5 = gettext("%s: diff failed: "); fprintf(stderr, v5, v4); do { putc_unlocked(*s1, stderr); v6 = s1++; } while (*v6 != 10); exit(2); } ++s1; if (v10 == 3) { ++v16[2]; } else { if (v10 > 3) fatal("internal error: invalid diff type in process_diff"); if (v10 == 1) ++*v16; } if (v10 != 1) { v19 = v16[1] - *v16 + 1; if (v17 <= v19) xalloc_die(); v16[4] = xmalloc(8 * v19); v16[6] = xmalloc(8 * v19); for (i = 0LL; i < (long)v19; ++i) s1 = scan_diff_line(s1, (_QWORD *)(v16[4] + 8 * i), (_QWORD *)(v16[6] + 8 * i), v18, 60); } if (v10 == 2) { if (strncmp(s1, "---\n", 4uLL)) fatal("invalid diff format; invalid change separator"); s1 += 4; } if (v10 != 3) { v20 = v16[3] - v16[2] + 1; if (v17 <= v20) xalloc_die(); v16[5] = xmalloc(8 * v20); v16[7] = xmalloc(8 * v20); for (i = 0LL; i < (long)v20; ++i) s1 = scan_diff_line(s1, (_QWORD *)(v16[5] + 8 * i), (_QWORD *)(v16[7] + 8 * i), v18, 62); } *v15 = (long)v16; v15 = v16 + 8; } *v15 = 0LL; *a3 = v16; return v13; }
diffutils
ida
void redirect(union node *redir, int flags) { union node *n; struct redirtab *sv; int i; int fd; int newfd; int *p; if (!redir) return; sv = ((void *)0); ({ suppressint++; ({ __asm__ __volatile__("" : : : "memory"); }); 0; }); if (__builtin_expect(!!(flags & 01), 1)) sv = redirlist; n = redir; do { newfd = openredirect(n); if (newfd < -1) continue; fd = n->nfile.fd; if (sv) { int closed; p = &sv->renamed[fd]; i = *p; closed = update_closed_redirs(fd, newfd); if (__builtin_expect(!!(i == -2), 1)) { i = -1; if (fd != newfd && !closed) { i = savefd(fd, fd); fd = -1; } } *p = i; } if (fd == newfd) continue; dupredirect(n, newfd); } while ((n = n->nfile.next)); ({ ({ __asm__ __volatile__("" : : : "memory"); }); if (--suppressint == 0 && intpending) onint(); 0; }); if (flags & 03 && sv->renamed[2] >= 0) preverrout.fd = sv->renamed[2]; }
void redirect(unsigned long long a0, unsigned long long a1, unsigned long a2, unsigned long long a3) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; struct_0 *v5; unsigned long long v6; unsigned int *v7; unsigned long long v9; unsigned long long v10; unsigned long long v11; v0 = a1; if (!a0) return; v6 = 0; suppressint = suppressint + 1; if ((v0 & 1)) v6 = 399668583475215753; v5 = a0; do { v3 = openredirect(v5, a1, v1, a3); if (v3 >= -1) { v2 = v5->field_10; if (v6) { v7 = v6 + v2 * 4 + 8; v1 = *(v7); v4 = update_closed_redirs(v2, v3); if (v1 == -2) { v1 = -1; if (v2 != v3 && !v4) { a1 = v2; v1 = savefd(v2, v2, v2, a3); v2 = -1; } } *(v7) = v1; } if (v2 != v3) dupredirect(v5, v3, v3, a3); } v5 = v5->field_8; } while (v5); suppressint = suppressint - 1; if (!suppressint && intpending) onint(); v9 = v0 & 3; if ((v0 & 3)) { v10 = *((v6 + 16)); if (*((v6 + 16)) >= 0) { v11 = *((v6 + 16)); dash_errno = *((v6 + 16)); } } return; }
dash-0.5.11+git20210903+057cd650a4ed
angr_sailr
void crypto_sign_ed25519_ref_fe25519_add( crypto_sign_ed25519_ref_fe25519 *r, const crypto_sign_ed25519_ref_fe25519 *x, const crypto_sign_ed25519_ref_fe25519 *y) { int i; for (i = 0; i < 32; i++) r->v[i] = x->v[i] + y->v[i]; reduce_add_sub(r); }
long long crypto_sign_ed25519_ref_fe25519_add(unsigned int *a0, unsigned int *a1, unsigned int *a2) { unsigned int v0; for (v0 = 0; v0 <= 31; v0 = __addvsi3(v0, 0x1, v0)) { a0[v0] = a1[v0] + a2[v0]; } return reduce_add_sub(a0); }
openssh-portable
angr_dream
void cu_installnew(int argc, void **argv) { struct fsys_namenode *namenode = argv[0]; struct stat stab; cleanup_pkg_failed++; cleanup_conflictor_failed++; debug(dbg_eachfile, "cu_installnew '%s' flags=%o", namenode->name, namenode->flags); setupfnamevbs(namenode->name); if (!(namenode->flags & FNNF_NEW_CONFF) && !lstat(fnametmpvb.buf, &stab)) { if (namenode->flags & FNNF_NO_ATOMIC_OVERWRITE) { debug(dbg_eachfiledetail, "cu_installnew restoring nonatomic"); if (secure_remove(fnamevb.buf) && (*__errno_location()) != 2 && (*__errno_location()) != 20) ohshite( gettext( "unable to remove newly-installed version of '%.250s' to allow" " reinstallation of backup copy"), namenode->name); } else { debug(dbg_eachfiledetail, "cu_installnew restoring atomic"); } if (rename(fnametmpvb.buf, fnamevb.buf)) ohshite(gettext("unable to restore backup version of '%.250s'"), namenode->name); else if (unlink(fnametmpvb.buf) && (*__errno_location()) != 2) ohshite(gettext("unable to remove backup copy of '%.250s'"), namenode->name); } else if (namenode->flags & FNNF_PLACED_ON_DISK) { debug(dbg_eachfiledetail, "cu_installnew removing new file"); if (secure_remove(fnamevb.buf) && (*__errno_location()) != 2 && (*__errno_location()) != 20) ohshite(gettext("unable to remove newly-installed version of '%.250s'"), namenode->name); } else { debug(dbg_eachfiledetail, "cu_installnew not restoring"); } if (secure_remove(fnamenewvb.buf) && (*__errno_location()) != 2 && (*__errno_location()) != 20) ohshite(gettext("unable to remove newly-extracted version of '%.250s'"), namenode->name); cleanup_pkg_failed--; cleanup_conflictor_failed--; }
long long cu_installnew(unsigned long a0, unsigned long long *a1) { unsigned int v0; struct_0 *v1; char v2; unsigned long long v4; unsigned long long v5; v0 = a0; v1 = *(a1); cleanup_pkg_failed = cleanup_pkg_failed + 1; cleanup_conflictor_failed = cleanup_conflictor_failed + 1; debug(0x8, "cu_installnew '%s' flags=%o", v1->field_8, v1->field_30); setupfnamevbs(v1->field_8); if ((v1->field_30 & 1)) { LABEL_4001f5: if ((v1->field_30 & 64)) { debug(0x40, "cu_installnew removing new file", v4, v5); if (!secure_remove(__errno_location)) goto LABEL_400287; if (*(__errno_location()) == 2) goto LABEL_400287; if (*(__errno_location()) == 20) goto LABEL_400287; ohshite(gettext("unable to remove newly-installed version of '%.250s'"), v1->field_8); } debug(0x40, "cu_installnew not restoring", v4, v5); } else { if (!(!lstat(fnamevb, &v2))) goto LABEL_4001f5; if ((v1->field_30 & 32)) { debug(0x40, "cu_installnew restoring nonatomic", v4, v5); if (!secure_remove(__errno_location)) goto LABEL_400163; if (*(__errno_location()) == 2) goto LABEL_400163; if (*(__errno_location()) == 20) goto LABEL_400163; ohshite(gettext("unable to remove newly-installed version of '%.250s' to " "allow reinstallation of backup copy"), v1->field_8); } debug(0x40, "cu_installnew restoring atomic", v4, v5); LABEL_400163: if (rename(fnamevb, __errno_location)) ohshite(gettext("unable to restore backup version of '%.250s'"), v1->field_8); if (unlink(fnamevb) && *(__errno_location()) != 2) { ohshite(gettext("unable to remove backup copy of '%.250s'"), v1->field_8); goto LABEL_4001f5; } } LABEL_400287: if (secure_remove(versiondescribe) && *(__errno_location()) != 2 && *(__errno_location()) != 20) ohshite(gettext("unable to remove newly-extracted version of '%.250s'"), v1->field_8); cleanup_pkg_failed = cleanup_pkg_failed - 1; cleanup_conflictor_failed = cleanup_conflictor_failed - 1; return 0; }
dpkg
angr_phoenix
int tnl_prl_ioctl(int cmd, const char *name, void *p) { return tnl_gen_ioctl(cmd, name, p, -1); }
void tnl_prl_ioctl(undefined4 param_1, undefined8 param_2, undefined8 param_3) { tnl_gen_ioctl(param_1, param_2, param_3, 0xffffffff); return; }
iproute2-6.0.0
ghidra
static _Bool parse_ok(const struct parser_table *entry, char **argv, int *arg_ptr) { return insert_exec_ok("-ok", entry, argv, arg_ptr); }
long long parse_ok(unsigned long long a0, unsigned long long a1, unsigned long long a2) { return insert_exec_ok("-ok", a0, a1, a2); }
findutils
angr_sailr
void *Pcompile(char *pattern, idx_t size, reg_syntax_t ignored, _Bool exact) { size_t e; int ec; int flags = 0x00000010u | (match_icase ? 0x00000008u : 0); char *patlim = pattern + size; struct pcre_comp *pc = ximalloc(sizeof *pc); pcre2_general_context_8 *gcontext = pc->gcontext = pcre2_general_context_create_8(private_malloc, private_free, ((void *)0)); pcre2_compile_context_8 *ccontext = pcre2_compile_context_create_8(gcontext); if (localeinfo.multibyte) { if (!localeinfo.using_utf8) ((!!sizeof(struct { _Static_assert(EXIT_TROUBLE, "verify_expr (" "EXIT_TROUBLE" ", " "(error (EXIT_TROUBLE, 0, gettext(\"-P supports only " "unibyte and UTF-8 locales\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(EXIT_TROUBLE, 0, gettext("-P supports only unibyte and UTF-8 locales")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(EXIT_TROUBLE, 0, gettext("-P supports only unibyte and UTF-8 locales")), ((0) ? (void)0 : __builtin_unreachable())))); flags |= 0x00080000u; flags |= 0x04000000u; } if (rawmemchr(pattern, '\n') != patlim) ((!!sizeof(struct { _Static_assert(EXIT_TROUBLE, "verify_expr (" "EXIT_TROUBLE" ", " "(error (EXIT_TROUBLE, 0, gettext(\"the -P option only " "supports a single pattern\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(EXIT_TROUBLE, 0, gettext("the -P option only supports a single pattern")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(EXIT_TROUBLE, 0, gettext("the -P option only supports a single pattern")), ((0) ? (void)0 : __builtin_unreachable())))); void *re_storage = ((void *)0); if (match_lines) { pcre2_set_compile_extra_options_8(ccontext, 0x00000008u); } else if (match_words) { static char const wprefix[10] = "(?<!\\w)(?:", wsuffix[7] = ")(?!\\w)"; idx_t re_size = size + sizeof wprefix + sizeof wsuffix; char *re = re_storage = ximalloc(re_size); char *rez = mempcpy(re, wprefix, sizeof wprefix); rez = mempcpy(rez, pattern, size); memcpy(rez, wsuffix, sizeof wsuffix); pattern = re; size = re_size; } pcre2_set_character_tables_8(ccontext, pcre2_maketables_8(gcontext)); pc->cre = pcre2_compile_8((PCRE2_SPTR8)pattern, size, flags, &ec, &e, ccontext); if (!pc->cre) { enum { ERRBUFSIZ = 256 }; PCRE2_UCHAR8 ep[ERRBUFSIZ]; pcre2_get_error_message_8(ec, ep, sizeof ep); ((!!sizeof(struct { _Static_assert(EXIT_TROUBLE, "verify_expr (" "EXIT_TROUBLE" ", " "(error (EXIT_TROUBLE, 0, \"%s\", ep), assume (false))" ")"); int _gl_dummy; })) ? ((error(EXIT_TROUBLE, 0, "%s", ep), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(EXIT_TROUBLE, 0, "%s", ep), ((0) ? (void)0 : __builtin_unreachable())))); } free(re_storage); pcre2_compile_context_free_8(ccontext); pc->mcontext = ((void *)0); pc->data = pcre2_match_data_create_from_pattern_8(pc->cre, gcontext); ec = pcre2_jit_compile_8(pc->cre, 0x00000001u); if (ec && ec != (-45) && ec != (-48)) ((!!sizeof(struct { _Static_assert(EXIT_TROUBLE, "verify_expr (" "EXIT_TROUBLE" ", " "(error (EXIT_TROUBLE, 0, gettext(\"JIT " "internal error: %d\"), ec), assume (false))" ")"); int _gl_dummy; })) ? ((error(EXIT_TROUBLE, 0, gettext("JIT internal error: %d"), ec), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(EXIT_TROUBLE, 0, gettext("JIT internal error: %d"), ec), ((0) ? (void)0 : __builtin_unreachable())))); pc->jit_stack = ((void *)0); pc->jit_stack_size = 32 << 10; pc->empty_match[0] = jit_exec(pc, "", 0, 0, 0x00000001u); pc->empty_match[1] = jit_exec(pc, "", 0, 0, 0); return pc; }
long long Pcompile(void *a0, unsigned long a1, unsigned long a2, unsigned long a3) { char v0; unsigned long v1; unsigned long v2; void *v3; char v4; unsigned int v5; char v6; void *v7; unsigned long v8; struct_0 *v9; unsigned long long v10; unsigned long long v11; unsigned long v12; void *v13; void *v14; char v15; unsigned int v17; unsigned long long v19; v3 = a0; v2 = a1; v1 = a2; v0 = a3; if (match_icase) v17 = 24; else v17 = 16; v5 = v17; v8 = v3 + v2; v9 = ximalloc(0x38); v9->field_0 = pcre2_general_context_create_8(private_malloc, private_free, 0x0); v10 = v9->field_0; v11 = pcre2_compile_context_create_8(v10); if (localeinfo) { if ((g_500072 ^ 1)) error(0x2, 0x0, gettext("-P supports only unibyte and UTF-8 locales")); v5 |= 0x80000; v5 |= 0x4000000; } if (!localeinfo || !(g_500072 ^ 1)) { if (v8 != rawmemchr(v3, 0xa)) error(0x2, 0x0, gettext("the -P option only supports a single pattern")); v7 = 0; if (match_lines) { pcre2_set_compile_extra_options_8(v11, 0x8); } else if (match_words) { v12 = v2 + 17; v7 = ximalloc(v12); v13 = v7; v14 = mempcpy(v13, "(?<!\\w)(?:", 0xa); v14 = mempcpy(v14, v3, v2); memcpy(v14, ")(?!\\w)", 0x7); v3 = v13; v2 = v12; } v19 = pcre2_maketables_8(v10); pcre2_set_character_tables_8(v11, v19, v19); v9->field_8 = pcre2_compile_8(v3, v2, v5, &v4, &v6, v11); if (!v9->field_8) { pcre2_get_error_message_8(*(&v4), &v15, 0x100, &v15); error(0x2, 0x0, "%s"); } free(v7); pcre2_compile_context_free_8(v11); v9->field_10 = 0; v9->field_18 = pcre2_match_data_create_from_pattern_8(v9->field_8, v10, v10); v4 = pcre2_jit_compile_8(v9->field_8, 0x1, v9); if (v4 && v4 != -45 && v4 != -48) error(0x2, 0x0, gettext("JIT internal error: %d")); if (!v4 || v4 == -45 || v4 == -48) { v9->field_20 = 0; v9->field_28 = 0x8000; v9->field_30 = jit_exec(v9, &g_400c47, 0x0, 0x0, 0x1); v9->field_34 = jit_exec(v9, &g_400c47, 0x0, 0x0, 0x0); return v9; } } }
grep
angr_dream
char *authorized_principals_file(struct passwd *pw) { if (options.authorized_principals_file == ((void *)0)) return ((void *)0); return expand_authorized_keys(options.authorized_principals_file, pw); }
long long authorized_principals_file(void *a0) { void *v1; if (!*(5250664)) { v1 = 0; return v1; } v1 = expand_authorized_keys(*(5250664), a0); return v1; }
openssh-portable
angr_sailr
void verify_pkcs7(common_info_st *cinfo, const char *purpose, unsigned display_data) { gnutls_pkcs7_t pkcs7; int ret, ecode; size_t size; gnutls_datum_t data, detached = {((void *)0), 0}; gnutls_datum_t tmp = {((void *)0), 0}; int i; gnutls_pkcs7_signature_info_st info; gnutls_x509_trust_list_t tl = ((void *)0); gnutls_typed_vdata_st vdata[2]; unsigned vdata_size = 0; gnutls_x509_crt_t signer = ((void *)0); unsigned flags = 0; ret = gnutls_pkcs7_init(&pkcs7); if (ret < 0) { fprintf(stderr, "p7_init: %s\n", gnutls_strerror(ret)); app_exit(1); } data.data = (void *)_gnutls_fread_file(infile, 0, &size); data.size = size; if (!data.data) { fprintf(stderr, "%s", infile ? "file" : "standard input"); app_exit(1); } ret = gnutls_pkcs7_import(pkcs7, &data, cinfo->incert_format); free(data.data); if (ret < 0) { fprintf(stderr, "import error: %s\n", gnutls_strerror(ret)); app_exit(1); } if (cinfo->cert != ((void *)0)) { signer = load_cert(1, cinfo); } else { tl = load_tl(cinfo); if (tl == ((void *)0)) { fprintf(stderr, "error loading trust list\n"); } } if (cinfo->data_file) load_data(cinfo, &detached); if (purpose) { vdata[vdata_size].type = GNUTLS_DT_KEY_PURPOSE_OID; vdata[vdata_size].data = (void *)purpose; vdata[vdata_size].size = strlen(purpose); vdata_size++; } ecode = 1; for (i = 0;; i++) { ret = gnutls_pkcs7_get_signature_info(pkcs7, i, &info); if (ret < 0) break; if (!display_data) { if (i == 0) { fprintf(outfile, "eContent Type: %s\n", gnutls_pkcs7_get_embedded_data_oid(pkcs7)); fprintf(outfile, "Signers:\n"); } print_pkcs7_sig_info(&info, cinfo); } else if (i == 0) { if (!detached.data) { ret = gnutls_pkcs7_get_embedded_data(pkcs7, 0, &tmp); if (ret < 0) { fprintf(stderr, "error getting embedded data: %s\n", gnutls_strerror(ret)); app_exit(1); } fwrite(tmp.data, 1, tmp.size, outfile); gnutls_free((void *)(tmp.data)), tmp.data = ((void *)0); tmp.data = ((void *)0); } else { fwrite(detached.data, 1, detached.size, outfile); } } gnutls_pkcs7_signature_info_deinit(&info); if (certtool_options.present.verify_allow_broken) flags |= (GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2 | GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5); if (signer) { ret = gnutls_pkcs7_verify_direct( pkcs7, signer, i, detached.data != ((void *)0) ? &detached : ((void *)0), flags); if (ret >= 0 && purpose) { unsigned res = gnutls_x509_crt_check_key_purpose(signer, purpose, 0); if (res == 0) ret = -101; } } else { ((void)sizeof((tl != ((void *)0)) ? 1 : 0), __extension__({ if (tl != ((void *)0)) ; else __assert_fail("tl != NULL", "certtool.c", 2756, __extension__ __PRETTY_FUNCTION__); })); ret = gnutls_pkcs7_verify( pkcs7, tl, vdata, vdata_size, i, detached.data != ((void *)0) ? &detached : ((void *)0), flags); } if (ret < 0) { fprintf(stderr, "\tSignature status: verification failed: %s\n", gnutls_strerror(ret)); ecode = 1; } else { fprintf(stderr, "\tSignature status: ok\n"); ecode = 0; } } gnutls_pkcs7_deinit(pkcs7); if (signer) gnutls_x509_crt_deinit(signer); else gnutls_x509_trust_list_deinit(tl, 1); free(detached.data); app_exit(ecode); }
void verify_pkcs7(long a1, const char *a2, int a3) { const char *v3; const char *v4; const char *v5; long v6; const char *embedded_data_oid; const char *v8; void **v9; void **v10; const char *v11; int v14; int v15; int embedded_data; int v17; int v18; unsigned int i; unsigned int v20; unsigned int v21; long v22; long v23; long tl; long cert; void *ptr; int v27; void *v28; size_t v29; void *v30; size_t n; int v32; const char *v33; int v34; char v35[168]; unsigned long v36; v36 = __readfsqword(0x28u); v28 = 0LL; LODWORD(v29) = 0; v30 = 0LL; LODWORD(n) = 0; tl = 0LL; v20 = 0; cert = 0LL; v21 = 0; v14 = gnutls_pkcs7_init(&v22); if (v14 < 0) { v3 = (const char *)gnutls_strerror((unsigned int)v14); fprintf(stderr, "p7_init: %s\n", v3); app_exit(1); } ptr = (void *)gnutls_fread_file(infile, 0LL, &v23); v27 = v23; if (!ptr) { if (infile) v4 = "file"; else v4 = "standard input"; fprintf(stderr, "%s", v4); app_exit(1); } v15 = gnutls_pkcs7_import(v22, &ptr, *(unsigned int *)(a1 + 28)); free(ptr); if (v15 < 0) { v5 = (const char *)gnutls_strerror((unsigned int)v15); fprintf(stderr, "import error: %s\n", v5); app_exit(1); } if (*(_QWORD *)(a1 + 40)) { cert = load_cert(1LL, a1); } else { tl = load_tl(a1); if (!tl) fprintf(stderr, "error loading trust list\n"); } if (*(_QWORD *)(a1 + 72)) load_data(a1, (long)&v28); if (a2) { v32 = 2; v33 = a2; v34 = strlen(a2); v20 = 1; } v18 = 1; for (i = 0;; ++i) { v6 = i; if ((int)gnutls_pkcs7_get_signature_info(v22, i, v35) < 0) break; if (a3) { if (!i) { if (v28) { v6 = 1LL; fwrite(v28, 1uLL, (unsigned int)v29, outfile); } else { embedded_data = gnutls_pkcs7_get_embedded_data(v22, 0LL, &v30); if (embedded_data < 0) { v8 = (const char *)gnutls_strerror((unsigned int)embedded_data); fprintf(stderr, "error getting embedded data: %s\n", v8); app_exit(1); } v6 = 1LL; fwrite(v30, 1uLL, (unsigned int)n, outfile); gnutls_free(v30); v30 = 0LL; } } } else { if (!i) { embedded_data_oid = (const char *)gnutls_pkcs7_get_embedded_data_oid(v22); fprintf(outfile, "eContent Type: %s\n", embedded_data_oid); fprintf(outfile, "Signers:\n"); } v6 = a1; print_pkcs7_sig_info((long)v35); } gnutls_pkcs7_signature_info_deinit(v35, v6); if (certtool_options[42]) v21 |= 0x30u; if (cert) { if (v28) v9 = &v28; else v9 = 0LL; v17 = gnutls_pkcs7_verify_direct(v22, cert, i, v9, v21); if (v17 >= 0 && a2 && !(unsigned int)gnutls_x509_crt_check_key_purpose(cert, a2, 0LL)) v17 = -101; } else { if (!tl) _assert_fail("tl != NULL", "certtool.c", 0xAC4u, "verify_pkcs7"); if (v28) v10 = &v28; else v10 = 0LL; v17 = gnutls_pkcs7_verify(v22, tl, &v32, v20, i, v10, v21); } if (v17 >= 0) { fprintf(stderr, "\tSignature status: ok\n"); v18 = 0; } else { v11 = (const char *)gnutls_strerror((unsigned int)v17); fprintf(stderr, "\tSignature status: verification failed: %s\n", v11); v18 = 1; } } gnutls_pkcs7_deinit(v22); if (cert) gnutls_x509_crt_deinit(cert); else gnutls_x509_trust_list_deinit(tl, 1LL); free(v28); app_exit(v18); }
gnutls
ida
static char **array_concat(arr1, arr2) char **arr1, **arr2; { register int i, j, len, len1, len2; register char **result; if (arr1 == 0) return (arr2); if (arr2 == 0) return (arr1); if (arr1[0] && arr1[0][0] == 0 && arr1[1] == 0) { strvec_dispose(arr1); return (arr2); } if (arr2[0] && arr2[0][0] == 0 && arr2[1] == 0) return (arr1); len1 = strvec_len(arr1); len2 = strvec_len(arr2); result = (char **)sh_malloc(((1 + (len1 * len2)) * sizeof(char *)), "braces.c", 759); if (result == 0) return (result); len = 0; for (i = 0; i < len1; i++) { int strlen_1 = strlen(arr1[i]); for (j = 0; j < len2; j++) { result[len] = (char *)sh_xmalloc((1 + strlen_1 + strlen(arr2[j])), "braces.c", 770); strcpy(result[len], arr1[i]); strcpy(result[len] + strlen_1, arr2[j]); len++; } sh_xfree((arr1[i]), "braces.c", 775); } sh_xfree((arr1), "braces.c", 777); result[len] = (char *)((void *)0); return (result); }
int array_concat(unsigned long long a0, void *a1) { unsigned int v0; int tmp_0; unsigned long v1; unsigned long long v2; unsigned int v3; unsigned int v5; unsigned int v6; void *v7; void *v9; void *v10; unsigned long long v11; v2 = a0; if (!v2) { v5 = a1; } else if (!a1) { v5 = v2; } else { if (*(v2) && !*(*(v2)) && !*((v2 + 8))) { strvec_dispose(v2); v5 = a1; goto LABEL_401e31; } if (*(a1) && !*(*(a1)) && !a1[8]) { v5 = v2; goto LABEL_401e31; } v6 = strvec_len(v2); v0 = strvec_len(a1); v7 = sh_malloc((v6 * v0 + 1) * 8, "braces.c", 0x2f7); if (!v7) { v5 = 0; } else { v9 = 0; for (v11 = 0; v11 < v6; v11 = 1) { v3 = strlen(*((v2 + v11 * 8))); for (v10 = 0; v10 < v0; v10 = v10 + 1) { v1 = v3 + 1; v5 = strlen(*((a1 + 0x8 * v10))); tmp_0 = v5 + v1; v1 = v7 + 0x8 * v9; *(v1) = sh_xmalloc(tmp_0, "braces.c", 0x302); strcpy(*((0x8 * v9 + v7)), *(v2)); strcpy(v3 + *((0x8 * v9 + v7)), *((a1 + 0x8 * v10))); v9 = v9 + 1; } sh_xfree(*(v2), "braces.c", 0x307); } sh_xfree(v2, "braces.c", 0x309); *((0x8 * v9 + v7)) = 0; v5 = v7; } } LABEL_401e31: return v5; }
bash
angr_phoenix
int zcatfd(fd, ofd, fn) int fd, ofd; char *fn; { ssize_t nr; int rval; char lbuf[4096]; rval = 0; while (1) { nr = zread(fd, lbuf, sizeof(lbuf)); if (nr == 0) break; else if (nr < 0) { rval = -1; break; } else if (zwrite(ofd, lbuf, nr) < 0) { rval = -1; break; } } return rval; }
long zcatfd(unsigned int a1, unsigned int a2) { unsigned int v3; long v4; char v5[16]; unsigned long v6; v6 = __readfsqword(0x28u); v3 = 0; while (1) { v4 = zread(a1, v5, 4096LL); if (!v4) break; if (v4 < 0) return (unsigned int)-1; if ((int)zwrite(a2, v5, v4) < 0) return (unsigned int)-1; } return v3; }
bash
ida
void bash_add_history(line) char *line; { int add_it, offset, curlen, is_comment; HIST_ENTRY *current, *old; char *chars_to_add, *new_line; add_it = 1; if (command_oriented_history && current_command_line_count > 1) { is_comment = shell_comment(line); if ((parser_state & 0x020000) && here_doc_first_line == 0 && line[strlen(line) - 1] == '\n') chars_to_add = ""; else if (current_command_line_count == current_command_line_comment + 1) chars_to_add = "\n"; else if (literal_history) chars_to_add = "\n"; else chars_to_add = history_delimiting_chars(line); using_history(); current = previous_history(); current_command_line_comment = is_comment ? current_command_line_count : -2; if (current) { curlen = strlen(current->line); if (dstack.delimiter_depth == 0 && current->line[curlen - 1] == '\\' && current->line[curlen - 2] != '\\') { current->line[curlen - 1] = '\0'; curlen--; chars_to_add = ""; } if (dstack.delimiter_depth == 0 && current->line[curlen - 1] == '\n' && *chars_to_add == ';') chars_to_add++; new_line = (char *)sh_xmalloc( (1 + curlen + strlen(line) + strlen(chars_to_add)), "bashhist.c", 931) ; sprintf(new_line, "%s%s%s", current->line, chars_to_add, line); offset = where_history(); old = replace_history_entry(offset, new_line, current->data); sh_xfree((new_line), "bashhist.c", 938); if (old) free_history_entry(old); add_it = 0; } } if (add_it && history_is_stifled() && history_length == 0 && history_length == history_max_entries) add_it = 0; if (add_it) really_add_history(line); using_history(); }
void bash_add_history(char *param_1) { bool bVar1; int iVar2; undefined4 uVar3; size_t sVar4; char **ppcVar5; size_t sVar6; char *__s; long lVar7; int local_44; char *local_38; bVar1 = true; if ((command_oriented_history != 0) && (1 < current_command_line_count)) { iVar2 = shell_comment(param_1); if (((parser_state & 0x20000) == 0) || ((here_doc_first_line != 0 || (sVar4 = strlen(param_1), param_1[sVar4 - 1] != '\n')))) { if (current_command_line_comment + 1 == current_command_line_count) { local_38 = "\n"; } else if (literal_history == 0) { local_38 = (char *)history_delimiting_chars(param_1); } else { local_38 = "\n"; } } else { local_38 = ""; } using_history(); ppcVar5 = (char **)previous_history(); current_command_line_comment = current_command_line_count; if (iVar2 == 0) { current_command_line_comment = -2; } if (ppcVar5 != (char **)0x0) { sVar4 = strlen(*ppcVar5); local_44 = (int)sVar4; if (((parser_state == 0) && ((*ppcVar5)[(long)local_44 + -1] == '\\')) && ((*ppcVar5)[(long)local_44 + -2] != '\\')) { (*ppcVar5)[(long)local_44 + -1] = '\0'; local_44 = local_44 + -1; local_38 = ""; } if (((parser_state == 0) && ((*ppcVar5)[(long)local_44 + -1] == '\n')) && (*local_38 == ';')) { local_38 = local_38 + 1; } sVar4 = strlen(param_1); sVar6 = strlen(local_38); __s = (char *)sh_xmalloc(sVar6 + (long)(local_44 + 1) + sVar4, "bashhist.c", 0x3a3); sprintf(__s, "%s%s%s", *ppcVar5, local_38, param_1); uVar3 = where_history(); lVar7 = replace_history_entry(uVar3, __s, ppcVar5[2]); sh_xfree(__s, "bashhist.c", 0x3aa); if (lVar7 != 0) { free_history_entry(lVar7); } bVar1 = false; } } if (((bVar1) && (iVar2 = history_is_stifled(), iVar2 != 0)) && ((history_length == 0 && (history_max_entries == 0)))) { bVar1 = false; } if (bVar1) { really_add_history(param_1); } using_history(); return; }
bash
ghidra
int progcomp_insert(cmd, cs) char *cmd; COMPSPEC *cs; { register BUCKET_CONTENTS *item; if (cs == ((void *)0)) programming_error(gettext("progcomp_insert: %s: NULL COMPSPEC"), cmd); if (prog_completes == 0) progcomp_create(); cs->refcount++; item = hash_insert(cmd, prog_completes, 0); if (item->data) free_progcomp(item->data); else item->key = (char *)strcpy(sh_xmalloc((1 + strlen(cmd)), "pcomplib.c", 192), (cmd)); item->data = cs; return 1; }
long long progcomp_insert(char *a0, unsigned int *a1) { unsigned long long v1; unsigned long long v2[3]; if (!a1) { v1 = gettext("progcomp_insert: %s: NULL COMPSPEC"); programming_error(v1, a0, v1); } if (!prog_completes) progcomp_create(); *(a1) = *(a1) + 1; v2 = hash_insert(a0, prog_completes, 0x0, prog_completes); if (!v2[2]) v2[1] = strcpy(sh_xmalloc(strlen(a0) + 1, "pcomplib.c", 0xc0), a0); else free_progcomp(v2[2]); v2[2] = a1; return 1; }
bash
angr_sailr
static void process_extended_statvfs(u_int32_t id) { char *path; struct statvfs st; int r; if ((r = sshbuf_get_cstring(iqueue, &path, ((void *)0))) != 0) sshfatal("sftp-server.c", __func__, 1399, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse"); sshlog("sftp-server.c", __func__, 1400, 0, SYSLOG_LEVEL_DEBUG3, ((void *)0), "request %u: statvfs", id); sshlog("sftp-server.c", __func__, 1401, 0, SYSLOG_LEVEL_INFO, ((void *)0), "statvfs \"%s\"", path); if (statvfs(path, &st) != 0) send_status(id, errno_to_portable((*__errno_location()))); else send_statvfs(id, &st); free(path); }
long long process_extended_statvfs(unsigned long a0) { unsigned long long v0; unsigned int v1; char v2; char v3; unsigned long long v4; unsigned long v5; char v6; unsigned long long v7; v1 = sshbuf_get_cstring(0xe87d894820ec8348, &v2, 0x0, &v2); if (v1) { v0 = "parse"; sshfatal("sftp-server.c", "process_extended_statvfs", 0x577, 0x1, 0x1, ssh_err(v1)); } v5 = a0; v4 = "request %u: statvfs"; sshlog("sftp-server.c", "process_extended_statvfs", 0x578, 0x0, 0x7, 0x0, *(&v6)); v7 = *(&v2); v6 = "statvfs \"%s\""; sshlog("sftp-server.c", "process_extended_statvfs", 0x579, 0x0, 0x3, 0x0, "statvfs \"%s\""); if (!statvfs(*(&v2), &v3, &v3)) send_statvfs(a0, &v3); else send_status(a0, errno_to_portable(*(__errno_location()))); free(*(&v2)); return 0; }
openssh-portable
angr_sailr
static _Bool sparse_scan_file(struct tar_sparse_file *file) { if (sparse_scan_file_wholesparse(file)) return 1; switch (hole_detection) { case HOLE_DETECTION_DEFAULT: case HOLE_DETECTION_SEEK: if (sparse_scan_file_seek(file)) return 1; __attribute__((__fallthrough__)); case HOLE_DETECTION_RAW: if (sparse_scan_file_raw(file)) return 1; } return 0; }
int sparse_scan_file(void *a0) { unsigned int v1; if (sparse_scan_file_wholesparse(a0)) { v1 = 1; return v1; } switch (hole_detection) { case 0: case 2: if (sparse_scan_file_seek(a0)) { v1 = 1; return v1; } case 1: if (!sparse_scan_file_raw(a0)) { v1 = 0; return v1; } v1 = 1; return v1; default: v1 = 0; return v1; } }
tar
angr_sailr
struct sshauthopt *sshauthopt_copy(const struct sshauthopt *orig) { struct sshauthopt *ret; if ((ret = sshauthopt_new()) == ((void *)0)) return ((void *)0); ret->permit_port_forwarding_flag = orig->permit_port_forwarding_flag; ret->permit_agent_forwarding_flag = orig->permit_agent_forwarding_flag; ret->permit_x11_forwarding_flag = orig->permit_x11_forwarding_flag; ret->permit_pty_flag = orig->permit_pty_flag; ret->permit_user_rc = orig->permit_user_rc; ret->restricted = orig->restricted; ret->cert_authority = orig->cert_authority; ret->force_tun_device = orig->force_tun_device; ret->valid_before = orig->valid_before; ret->no_require_user_presence = orig->no_require_user_presence; ret->require_verify = orig->require_verify; do { if (orig->cert_principals != ((void *)0) && (ret->cert_principals = strdup(orig->cert_principals)) == ((void *)0)) { sshauthopt_free(ret); return ((void *)0); } } while (0); do { if (orig->force_command != ((void *)0) && (ret->force_command = strdup(orig->force_command)) == ((void *)0)) { sshauthopt_free(ret); return ((void *)0); } } while (0); do { if (orig->required_from_host_cert != ((void *)0) && (ret->required_from_host_cert = strdup(orig->required_from_host_cert)) == ((void *)0)) { sshauthopt_free(ret); return ((void *)0); } } while (0); do { if (orig->required_from_host_keys != ((void *)0) && (ret->required_from_host_keys = strdup(orig->required_from_host_keys)) == ((void *)0)) { sshauthopt_free(ret); return ((void *)0); } } while (0); if (dup_strings(&ret->env, &ret->nenv, orig->env, orig->nenv) != 0 || dup_strings(&ret->permitopen, &ret->npermitopen, orig->permitopen, orig->npermitopen) != 0 || dup_strings(&ret->permitlisten, &ret->npermitlisten, orig->permitlisten, orig->npermitlisten) != 0) { sshauthopt_free(ret); return ((void *)0); } return ret; }
long long sshauthopt_copy(struct_0 *a0) { void *v0; void *v2; v0 = sshauthopt_new(); if (!v0) { v2 = 0; return v2; } *(v0) = a0->field_0; *(&v0[4]) = a0->field_4; *(&v0[8]) = a0->field_8; *(&v0[12]) = a0->field_c; *(&v0[16]) = a0->field_10; *(&v0[20]) = a0->field_14; *(&v0[32]) = a0->field_20; *(&v0[48]) = a0->field_30; *(&v0[24]) = a0->field_18; *(&v0[128]) = a0->field_80; *(&v0[132]) = a0->field_84; if (a0->field_28) { *(&v0[40]) = strdup(a0->field_28); if (!v0[40]) { sshauthopt_free(v0); v2 = 0; return v2; } } if (a0->field_38) { *(&v0[56]) = strdup(a0->field_38); if (!v0[56]) { sshauthopt_free(v0); v2 = 0; return v2; } } if (a0->field_70) { *(&v0[112]) = strdup(a0->field_70); if (!v0[112]) { sshauthopt_free(v0); v2 = 0; return v2; } } if (a0->field_78) { *(&v0[120]) = strdup(a0->field_78); if (!v0[120]) { sshauthopt_free(v0); v2 = 0; return v2; } } if (!dup_strings(v0 + 72, v0 + 64, a0->field_48, a0->field_40) && !dup_strings(v0 + 88, v0 + 80, a0->field_58, a0->field_50) && !dup_strings(v0 + 104, v0 + 96, a0->field_68, a0->field_60)) { v2 = v0; return v2; } sshauthopt_free(v0); v2 = 0; return v2; }
openssh-portable
angr_sailr
intmax_t evalexp(expr, flags, validp) char *expr; int flags; int *validp; { intmax_t val; int c; sigjmp_buf oevalbuf; val = 0; noeval = 0; already_expanded = (flags & 0x01); __builtin_memcpy((oevalbuf), (evalbuf), (sizeof(evalbuf))); c = __sigsetjmp((evalbuf), 0); if (c) { do { if (tokstr) sh_xfree((tokstr), "expr.c", 425); } while (0); do { if (expression) sh_xfree((expression), "expr.c", 426); } while (0); tokstr = expression = (char *)((void *)0); expr_unwind(); expr_depth = 0; __builtin_memcpy((evalbuf), (oevalbuf), (sizeof(evalbuf))); if (validp) *validp = 0; return (0); } val = subexpr(expr); if (validp) *validp = 1; __builtin_memcpy((evalbuf), (oevalbuf), (sizeof(evalbuf))); return (val); }
undefined8 evalexp(undefined8 param_1, uint param_2, undefined4 *param_3) { long lVar1; undefined8 uVar2; undefined8 uVar3; undefined8 uVar4; undefined8 uVar5; undefined8 uVar6; undefined8 uVar7; undefined8 uVar8; undefined8 uVar9; undefined8 uVar10; undefined8 uVar11; undefined8 uVar12; undefined8 uVar13; undefined8 uVar14; undefined8 uVar15; undefined8 uVar16; undefined8 uVar17; undefined8 uVar18; undefined8 uVar19; undefined8 uVar20; undefined8 uVar21; undefined8 uVar22; undefined8 uVar23; undefined8 uVar24; undefined8 uVar25; undefined8 uVar26; int iVar27; undefined8 uVar28; long in_FS_OFFSET; uVar26 = evalbuf._192_8_; uVar25 = evalbuf._184_8_; uVar24 = evalbuf._176_8_; uVar23 = evalbuf._168_8_; uVar22 = evalbuf._160_8_; uVar21 = evalbuf._152_8_; uVar20 = evalbuf._144_8_; uVar19 = evalbuf._136_8_; uVar18 = evalbuf._128_8_; uVar17 = evalbuf._120_8_; uVar16 = evalbuf._112_8_; uVar15 = evalbuf._104_8_; uVar14 = evalbuf._96_8_; uVar13 = evalbuf._88_8_; uVar12 = evalbuf._80_8_; uVar11 = evalbuf._72_8_; uVar10 = evalbuf._64_8_; uVar9 = evalbuf._56_8_; uVar8 = evalbuf._48_8_; uVar7 = evalbuf._40_8_; uVar6 = evalbuf._32_8_; uVar5 = evalbuf._24_8_; uVar4 = evalbuf._16_8_; uVar3 = evalbuf._8_8_; uVar2 = evalbuf._0_8_; lVar1 = *(long *)(in_FS_OFFSET + 0x28); noeval = 0; already_expanded = param_2 & 1; iVar27 = __sigsetjmp(evalbuf, 0); if (iVar27 == 0) { uVar28 = subexpr(param_1); evalbuf._0_8_ = uVar2; evalbuf._8_8_ = uVar3; evalbuf._16_8_ = uVar4; evalbuf._24_8_ = uVar5; evalbuf._32_8_ = uVar6; evalbuf._40_8_ = uVar7; evalbuf._48_8_ = uVar8; evalbuf._56_8_ = uVar9; evalbuf._64_8_ = uVar10; evalbuf._72_8_ = uVar11; evalbuf._80_8_ = uVar12; evalbuf._88_8_ = uVar13; evalbuf._96_8_ = uVar14; evalbuf._104_8_ = uVar15; evalbuf._112_8_ = uVar16; evalbuf._120_8_ = uVar17; evalbuf._128_8_ = uVar18; evalbuf._136_8_ = uVar19; evalbuf._144_8_ = uVar20; evalbuf._152_8_ = uVar21; evalbuf._160_8_ = uVar22; evalbuf._168_8_ = uVar23; evalbuf._176_8_ = uVar24; evalbuf._184_8_ = uVar25; evalbuf._192_8_ = uVar26; if (param_3 != (undefined4 *)0x0) { *param_3 = 1; } } else { if (tokstr != 0) { sh_xfree(tokstr, "expr.c", 0x1a9); } if (expression != 0) { sh_xfree(expression, "expr.c", 0x1aa); } expression = 0; tokstr = 0; expr_unwind(); expr_depth = 0; evalbuf._0_8_ = uVar2; evalbuf._8_8_ = uVar3; evalbuf._16_8_ = uVar4; evalbuf._24_8_ = uVar5; evalbuf._32_8_ = uVar6; evalbuf._40_8_ = uVar7; evalbuf._48_8_ = uVar8; evalbuf._56_8_ = uVar9; evalbuf._64_8_ = uVar10; evalbuf._72_8_ = uVar11; evalbuf._80_8_ = uVar12; evalbuf._88_8_ = uVar13; evalbuf._96_8_ = uVar14; evalbuf._104_8_ = uVar15; evalbuf._112_8_ = uVar16; evalbuf._120_8_ = uVar17; evalbuf._128_8_ = uVar18; evalbuf._136_8_ = uVar19; evalbuf._144_8_ = uVar20; evalbuf._152_8_ = uVar21; evalbuf._160_8_ = uVar22; evalbuf._168_8_ = uVar23; evalbuf._176_8_ = uVar24; evalbuf._184_8_ = uVar25; evalbuf._192_8_ = uVar26; if (param_3 != (undefined4 *)0x0) { *param_3 = 0; } uVar28 = 0; } if (lVar1 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar28; } __stack_chk_fail(); }
bash
ghidra
static int check_rfwd_permission(struct ssh *ssh, struct Forward *fwd) { struct ssh_channels *sc = ssh->chanctxt; struct permission_set *pset = &sc->remote_perms; u_int i, permit, permit_adm = 1; struct permission *perm; permit = pset->all_permitted; if (!permit) { for (i = 0; i < pset->num_permitted_user; i++) { perm = &pset->permitted_user[i]; if (remote_open_match(perm, fwd)) { permit = 1; break; } } } if (pset->num_permitted_admin > 0) { permit_adm = 0; for (i = 0; i < pset->num_permitted_admin; i++) { perm = &pset->permitted_admin[i]; if (remote_open_match(perm, fwd)) { permit_adm = 1; break; } } } return permit && permit_adm; }
int check_rfwd_permission(struct_0 *a0, void *a1) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned long v3; struct_1 *v4; void *v5; unsigned int v7; v3 = a0->field_868; v4 = v3 + 72; v2 = 1; v1 = v4->field_20; if (!v1) { v0 = 0; while (true) { if (v0 >= v4->field_0) break; v5 = v0 * 48 + v4->field_8; if (!remote_open_match(v5, a1)) { v0 += 1; } else { v1 = 1; break; } } } if (v4->field_10) { v2 = 0; v0 = 0; while (true) { if (v0 >= v4->field_10) break; v5 = v0 * 48 + v4->field_18; if (!remote_open_match(v5, a1)) { v0 += 1; } else { v2 = 1; break; } } } if (v1 && v2) { v7 = 1; goto LABEL_40d6e5; } v7 = 0; LABEL_40d6e5: return v7; }
openssh-portable
angr_phoenix
static void gname_coder(struct tar_stat_info const *st, char const *keyword, struct xheader *xhdr, void const *data __attribute__((unused))) { code_string(st->gname, keyword, xhdr); }
long long gname_coder(struct_0 *a0, unsigned long long a1, unsigned long long a2, unsigned long a3) { unsigned long v0; v0 = a3; return code_string(a0->field_28, a1, a2); }
tar
angr_dream
static SHELL_VAR *find_variable_nameref_context(v, vc, nvcp) SHELL_VAR *v; VAR_CONTEXT *vc; VAR_CONTEXT **nvcp; { SHELL_VAR *nv, *nv2; VAR_CONTEXT *nvc; for (nv = v, nvc = vc; nvc; nvc = nvc->down) { nv2 = find_nameref_at_context(nv, nvc); if (nv2 == &nameref_maxloop_value) return (nv2); if (nv2 == 0) continue; nv = nv2; if (*nvcp) *nvcp = nvc; if (((((nv)->attributes) & (0x0000800))) == 0) break; } return (((((nv)->attributes) & (0x0000800))) ? (SHELL_VAR *)((void *)0) : nv); }
int find_variable_nameref_context(unsigned int a0, void *a1, unsigned long long *a2) { struct_0 *v0; struct_1 *v1; unsigned int v2; unsigned int v4; *(&v0) = a0; v1 = a1; while (true) { if (!v1) { LABEL_4036fe: if ((v0->field_28 & 0x800)) { v4 = 0; break; } else { v4 = v0; break; } } else { *(&v2) = find_nameref_at_context(v0, v1); if (*(&v2) == 4241760) { v4 = *(&v2); break; } if (*(&v2)) { v0 = *(&v2); if (*(a2)) *(a2) = v1; if (!(v0->field_28 & 0x800)) goto LABEL_4036fe; } v1 = v1->field_18; } } return v4; }
bash
angr_phoenix
static int ssh_proxy_connect(struct ssh *ssh, const char *host, const char *host_arg, u_short port, const char *proxy_command) { char *command_string; int pin[2], pout[2]; pid_t pid; char *shell; if ((shell = getenv("SHELL")) == ((void *)0) || *shell == '\0') shell = "/bin/sh"; if (pipe(pin) == -1 || pipe(pout) == -1) sshfatal("sshconnect.c", __func__, 209, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "Could not create pipes to communicate with the proxy: %.100s", strerror((*__errno_location()))); command_string = expand_proxy_command(proxy_command, options.user, host, host_arg, port); sshlog("sshconnect.c", __func__, 214, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "Executing proxy command: %.500s", command_string); if ((pid = fork()) == 0) { char *argv[10]; close(pin[1]); if (pin[0] != 0) { if (dup2(pin[0], 0) == -1) perror("dup2 stdin"); close(pin[0]); } close(pout[0]); if (dup2(pout[1], 1) == -1) perror("dup2 stdout"); close(pout[1]); if (!debug_flag && options.control_path != ((void *)0) && options.control_persist && stdfd_devnull(0, 0, 1) == -1) sshlog("sshconnect.c", __func__, 239, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "stdfd_devnull failed"); argv[0] = shell; argv[1] = "-c"; argv[2] = command_string; argv[3] = ((void *)0); ssh_signal(13, ((__sighandler_t)0)); execv(argv[0], argv); perror(argv[0]); exit(1); } if (pid == -1) sshfatal("sshconnect.c", __func__, 257, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "fork failed: %.100s", strerror((*__errno_location()))); else proxy_command_pid = pid; close(pin[0]); close(pout[1]); free(command_string); if (ssh_packet_set_connection(ssh, pout[0], pin[1]) == ((void *)0)) return -1; return 0; }
long ssh_proxy_connect(long a1, long a2, long a3, unsigned short a4, const char *a5) { int *v5; char *v6; int *v7; char *v8; __pid_t v13; const char *v14; char *ptr; int pipedes[2]; int v17[2]; char *path[12]; path[11] = (char *)__readfsqword(0x28u); v14 = getenv("SHELL"); if (!v14 || !*v14) v14 = "/bin/sh"; if (pipe(pipedes) == -1 || pipe(v17) == -1) { v5 = _errno_location(); v6 = strerror(*v5); sshfatal("sshconnect.c", "ssh_proxy_connect", 209LL, 0LL, 1LL, 0LL, "Could not create pipes to communicate with the proxy: %.100s", v6); } ptr = (char *)expand_proxy_command(a5, *(_QWORD *)&options[56], a2, a3, a4); sshlog("sshconnect.c", "ssh_proxy_connect", 214LL, 0LL, 5LL, 0LL, "Executing proxy command: %.500s", ptr); v13 = fork(); if (!v13) { close(pipedes[1]); if (pipedes[0]) { if (dup2(pipedes[0], 0) == -1) perror("dup2 stdin"); close(pipedes[0]); } close(v17[0]); if (dup2(v17[1], 1) == -1) perror("dup2 stdout"); close(v17[1]); if (!debug_flag && *(_QWORD *)&options[1240] && options[1243] && (unsigned int)stdfd_devnull(0LL, 0LL, 1LL) == -1) sshlog("sshconnect.c", "ssh_proxy_connect", 239LL, 1LL, 2LL, 0LL, "stdfd_devnull failed"); path[0] = (char *)v14; path[1] = "-c"; path[2] = ptr; path[3] = 0LL; ssh_signal(13LL, 0LL); execv(path[0], path); perror(path[0]); exit(1); } if (v13 == -1) { v7 = _errno_location(); v8 = strerror(*v7); sshfatal("sshconnect.c", "ssh_proxy_connect", 257LL, 0LL, 1LL, 0LL, "fork failed: %.100s", v8); } proxy_command_pid = v13; close(pipedes[0]); close(v17[1]); free(ptr); if (ssh_packet_set_connection(a1, (unsigned int)v17[0], (unsigned int)pipedes[1])) return 0LL; else return 0xFFFFFFFFLL; }
openssh-portable
ida
static int input_userauth_passwd_changereq(int type, u_int32_t seqnr, struct ssh *ssh) { Authctxt *authctxt = ssh->authctxt; char *info = ((void *)0), *lang = ((void *)0), *password = ((void *)0), *retype = ((void *)0); char prompt[256]; const char *host; int r; sshlog("sshconnect2.c", __func__, 1117, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "input_userauth_passwd_changereq"); if (authctxt == ((void *)0)) sshfatal("sshconnect2.c", __func__, 1120, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "input_userauth_passwd_changereq: " "no authentication context"); host = options.host_key_alias ? options.host_key_alias : authctxt->host; if ((r = sshpkt_get_cstring(ssh, &info, ((void *)0))) != 0 || (r = sshpkt_get_cstring(ssh, &lang, ((void *)0))) != 0) goto out; if (strlen(info) > 0) sshlog("sshconnect2.c", __func__, 1128, 0, SYSLOG_LEVEL_INFO, ((void *)0), "%s", info); if ((r = sshpkt_start(ssh, 50)) != 0 || (r = sshpkt_put_cstring(ssh, authctxt->server_user)) != 0 || (r = sshpkt_put_cstring(ssh, authctxt->service)) != 0 || (r = sshpkt_put_cstring(ssh, authctxt->method->name)) != 0 || (r = sshpkt_put_u8(ssh, 1)) != 0) goto out; snprintf(prompt, sizeof(prompt), "Enter %.30s@%.128s's old password: ", authctxt->server_user, host); password = read_passphrase(prompt, 0); if ((r = sshpkt_put_cstring(ssh, password)) != 0) goto out; freezero(password, strlen(password)); password = ((void *)0); while (password == ((void *)0)) { snprintf(prompt, sizeof(prompt), "Enter %.30s@%.128s's new password: ", authctxt->server_user, host); password = read_passphrase(prompt, 0x0004); if (password == ((void *)0)) { r = 0; goto out; } snprintf(prompt, sizeof(prompt), "Retype %.30s@%.128s's new password: ", authctxt->server_user, host); retype = read_passphrase(prompt, 0); if (strcmp(password, retype) != 0) { freezero(password, strlen(password)); sshlog("sshconnect2.c", __func__, 1161, 0, SYSLOG_LEVEL_INFO, ((void *)0), "Mismatch; try again, EOF to quit."); password = ((void *)0); } freezero(retype, strlen(retype)); } if ((r = sshpkt_put_cstring(ssh, password)) != 0 || (r = sshpkt_add_padding(ssh, 64)) != 0 || (r = sshpkt_send(ssh)) != 0) goto out; ssh_dispatch_set(ssh, 60, &input_userauth_passwd_changereq); r = 0; out: if (password) freezero(password, strlen(password)); free(info); free(lang); return r; }
int input_userauth_passwd_changereq(undefined4 param_1, undefined4 param_2, long param_3) { undefined8 uVar1; long lVar2; int iVar3; size_t sVar4; char **ppcVar5; long in_FS_OFFSET; char *apcStack376[2]; long local_168; undefined4 local_160; undefined4 local_15c; int local_14c; char *local_148; void *local_140; char *local_138; undefined8 *local_130; char *local_128; long local_120; char local_118[264]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_130 = *(undefined8 **)(param_3 + 0x860); local_148 = (char *)0x0; local_140 = (void *)0x0; local_138 = (char *)0x0; local_128 = (char *)0x0; apcStack376[0] = "input_userauth_passwd_changereq"; local_168 = param_3; local_160 = param_2; local_15c = param_1; sshlog("sshconnect2.c", "input_userauth_passwd_changereq", 0x45d, 0, 6, 0); ppcVar5 = (char **)&local_168; if (local_130 == (undefined8 *)0x0) { ppcVar5 = apcStack376; apcStack376[0] = "input_userauth_passwd_changereq: no authentication context"; sshfatal("sshconnect2.c", "input_userauth_passwd_changereq", 0x460, 0, 1, 0); } lVar2 = local_168; local_120 = _sshkey_alg_list; if (_sshkey_alg_list == 0) { local_120 = local_130[2]; } *(undefined8 *)((long)ppcVar5 + -8) = 0x102261; local_14c = sshpkt_get_cstring(lVar2, &local_148, 0); lVar2 = local_168; if (local_14c == 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x102292; local_14c = sshpkt_get_cstring(lVar2, &local_140, 0); if (local_14c == 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x1022b4; sVar4 = strlen(local_148); if (sVar4 != 0) { *(char **)((long)ppcVar5 + -8) = local_148; *(undefined **)((long)ppcVar5 + -0x10) = &DAT_00107e34; *(undefined8 *)((long)ppcVar5 + -0x18) = 0x1022f7; sshlog("sshconnect2.c", "input_userauth_passwd_changereq", 0x468, 0, 3, 0); } lVar2 = local_168; *(undefined8 *)((long)ppcVar5 + -8) = 0x10230f; local_14c = sshpkt_start(lVar2, 0x32); lVar2 = local_168; if (local_14c == 0) { uVar1 = *local_130; *(undefined8 *)((long)ppcVar5 + -8) = 0x10233e; local_14c = sshpkt_put_cstring(lVar2, uVar1); lVar2 = local_168; if (local_14c == 0) { uVar1 = local_130[3]; *(undefined8 *)((long)ppcVar5 + -8) = 0x10236e; local_14c = sshpkt_put_cstring(lVar2, uVar1); lVar2 = local_168; if (local_14c == 0) { uVar1 = *(undefined8 *)local_130[4]; *(undefined8 *)((long)ppcVar5 + -8) = 0x1023a1; local_14c = sshpkt_put_cstring(lVar2, uVar1); lVar2 = local_168; if (local_14c == 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x1023c8; local_14c = sshpkt_put_u8(lVar2, 1); if (local_14c == 0) { uVar1 = *local_130; *(undefined8 *)((long)ppcVar5 + -8) = 0x102412; snprintf(local_118, 0x100, "Enter %.30s@%.128s\'s old password: ", uVar1, local_120); *(undefined8 *)((long)ppcVar5 + -8) = 0x102426; local_138 = (char *)read_passphrase(local_118, 0); lVar2 = local_168; *(undefined8 *)((long)ppcVar5 + -8) = 0x102446; local_14c = sshpkt_put_cstring(lVar2, local_138); if (local_14c == 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x102468; sVar4 = strlen(local_138); *(undefined8 *)((long)ppcVar5 + -8) = 0x10247d; freezero(local_138, sVar4); local_138 = (char *)0x0; while (lVar2 = local_168, local_138 == (char *)0x0) { uVar1 = *local_130; *(undefined8 *)((long)ppcVar5 + -8) = 0x1024c4; snprintf(local_118, 0x100, "Enter %.30s@%.128s\'s new password: ", uVar1, local_120); *(undefined8 *)((long)ppcVar5 + -8) = 0x1024d8; local_138 = (char *)read_passphrase(local_118, 4); if (local_138 == (char *)0x0) { local_14c = 0; goto LAB_001026a0; } uVar1 = *local_130; *(undefined8 *)((long)ppcVar5 + -8) = 0x10252f; snprintf(local_118, 0x100, "Retype %.30s@%.128s\'s new password: ", uVar1, local_120); *(undefined8 *)((long)ppcVar5 + -8) = 0x102543; local_128 = (char *)read_passphrase(local_118, 0); *(undefined8 *)((long)ppcVar5 + -8) = 0x102563; iVar3 = strcmp(local_138, local_128); if (iVar3 != 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x102576; sVar4 = strlen(local_138); *(undefined8 *)((long)ppcVar5 + -8) = 0x10258b; freezero(local_138, sVar4); *(char **)((long)ppcVar5 + -0x10) = "Mismatch; try again, EOF to quit."; *(undefined8 *)((long)ppcVar5 + -0x18) = 0x1025c5; sshlog("sshconnect2.c", "input_userauth_passwd_changereq", 0x489, 0, 3, 0); local_138 = (char *)0x0; } *(undefined8 *)((long)ppcVar5 + -8) = 0x1025e3; sVar4 = strlen(local_128); *(undefined8 *)((long)ppcVar5 + -8) = 0x1025f8; freezero(local_128, sVar4); } *(undefined8 *)((long)ppcVar5 + -8) = 0x10261f; local_14c = sshpkt_put_cstring(lVar2, local_138); lVar2 = local_168; if (local_14c == 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x102642; local_14c = sshpkt_add_padding(lVar2, 0x40); lVar2 = local_168; if (local_14c == 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x102660; local_14c = sshpkt_send(lVar2); lVar2 = local_168; if (local_14c == 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x10268a; ssh_dispatch_set(lVar2, 0x3c, input_userauth_passwd_changereq); local_14c = 0; } } } } } } } } } } } LAB_001026a0: if (local_138 != (char *)0x0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x1026b9; sVar4 = strlen(local_138); *(undefined8 *)((long)ppcVar5 + -8) = 0x1026ce; freezero(local_138, sVar4); } *(undefined8 *)((long)ppcVar5 + -8) = 0x1026dd; free(local_148); *(undefined8 *)((long)ppcVar5 + -8) = 0x1026ec; free(local_140); if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return local_14c; } *(undefined8 *)((long)ppcVar5 + -8) = 0x102706; __stack_chk_fail(); }
openssh-portable
ghidra
static int parse_ch_flags(const char *cmd, char **argv, int argc, int *hflag) { int ch; BSDoptind = BSDoptreset = 1; BSDopterr = 0; *hflag = 0; while ((ch = BSDgetopt(argc, argv, "h")) != -1) { switch (ch) { case 'h': *hflag = 1; break; default: sshlog("sftp.c", __func__, 578, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "%s: Invalid flag -%c", cmd, BSDoptopt); return -1; } } return BSDoptind; }
int parse_ch_flags(unsigned long long a0, unsigned long long a1, unsigned long a2, unsigned int *a3) { unsigned long v0; unsigned int v1; unsigned int v3; BSDoptreset = 1; BSDoptind = BSDoptreset; BSDopterr = 0; *(a3) = 0; while (true) { v1 = BSDgetopt(a2, a1, "h", a1); if (v1 == -1) { v3 = BSDoptind; return v3; } else if (v1 == 104) { *(a3) = 1; } else { v0 = BSDoptopt; sshlog("sftp.c", "parse_ch_flags", 0x242, 0x0, 0x2, 0x0, "%s: Invalid flag -%c", a0); v3 = -1; return v3; } } }
openssh-portable
angr_sailr
void sshpkt_fatal(struct ssh *ssh, int r, const char *fmt, ...) { va_list ap; __builtin_va_start(ap, fmt); sshpkt_vfatal(ssh, r, fmt, ap); __builtin_va_end(ap); sshlogdie("packet.c", __func__, 1923, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "should have exited"); }
undefined4 sshpkt_fatal(undefined4 param_1, undefined8 param_2, undefined4 param_3, undefined8 param_4, undefined8 param_5, undefined8 param_6, undefined8 param_7) { int iVar1; int __fd; char *__format; char in_AL; undefined4 uVar2; void *__buf; ssize_t sVar3; int *piVar4; undefined8 extraout_RDX; undefined8 unaff_RBX; char **ppcVar5; undefined8 uVar6; long in_FS_OFFSET; char *apcStack2064[2]; char *pcStack2048; char *pcStack2040; int iStack2028; undefined4 uStack2024; undefined4 uStack2020; undefined8 *puStack2016; undefined *puStack2008; undefined auStack2000[512]; char acStack1488[1032]; undefined8 uStack456; undefined auStack448[16]; undefined8 uStack432; undefined8 uStack424; undefined8 uStack416; undefined8 uStack408; code *pcStack272; char *pcStack264; undefined8 auStack256[2]; undefined8 local_f0; undefined4 local_e4; undefined8 local_e0; undefined4 local_d8; undefined4 local_d4; undefined *local_d0; undefined *local_c8; undefined8 local_c0; undefined local_b8[24]; undefined8 local_a0; undefined8 local_98; undefined8 local_90; undefined4 local_88; if (in_AL != '\0') { local_88 = param_1; } local_c0 = *(undefined8 *)(in_FS_OFFSET + 0x28); local_d8 = 0x18; local_d4 = 0x30; local_d0 = &stack0x00000008; local_c8 = local_b8; auStack256[0] = 0x104d48; local_f0 = param_4; local_e4 = param_3; local_e0 = param_2; local_a0 = param_5; local_98 = param_6; local_90 = param_7; sshpkt_vfatal(param_2, param_3, param_4, &local_d8); pcStack264 = "should have exited"; uStack408 = 0; uStack416 = 2; uStack424 = 1; pcStack2048 = "sshpkt_fatal"; pcStack2040 = "packet.c"; pcStack272 = ssh_packet_disconnect; sshlogdie("packet.c", "sshpkt_fatal", 0x783); ppcVar5 = &pcStack2048; uStack456 = *(undefined8 *)(in_FS_OFFSET + 0x28); uStack432 = extraout_RDX; pcStack272 = (code *)&stack0xfffffffffffffff8; if (disconnecting_20275 != 0) { ppcVar5 = apcStack2064; apcStack2064[0] = "packet_disconnect called recursively."; pcStack272 = (code *)&stack0xfffffffffffffff8; sshfatal("packet.c", "ssh_packet_disconnect", 0x795, 0, 1, 0); } disconnecting_20275 = 1; *(undefined8 *)((long)ppcVar5 + -8) = 0x104e5d; sshpkt_fmt_connection_id(pcStack2040, auStack2000, 0x200); __format = pcStack2048; uStack2024 = 0x10; uStack2020 = 0x30; puStack2016 = auStack256; puStack2008 = auStack448; *(undefined8 *)((long)ppcVar5 + -8) = 0x104eac; vsnprintf(acStack1488, 0x400, __format, &uStack2024); *(char **)((long)ppcVar5 + -0x10) = acStack1488; *(undefined **)((long)ppcVar5 + -0x18) = auStack2000; *(char **)((long)ppcVar5 + -0x20) = "Disconnecting %s: %.100s"; *(undefined8 *)((long)ppcVar5 + -0x28) = 0x104ef6; sshlog("packet.c", "ssh_packet_disconnect", 0x7a2, 0, 3, 0); *(undefined8 *)((long)ppcVar5 + -8) = 0x104f1c; iStack2028 = sshpkt_disconnect(pcStack2040, &DAT_001075cf, acStack1488); if (iStack2028 != 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x104f53; sshpkt_fatal(pcStack2040, iStack2028, &DAT_001075cf, "ssh_packet_disconnect"); } *(undefined8 *)((long)ppcVar5 + -8) = 0x104f62; iStack2028 = ssh_packet_write_wait(pcStack2040); if (iStack2028 != 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x104f99; sshpkt_fatal(pcStack2040, iStack2028, &DAT_001075cf, "ssh_packet_disconnect"); } *(undefined8 *)((long)ppcVar5 + -8) = 0x104fa8; ssh_packet_close(pcStack2040); uVar6 = 0xff; *(code **)((long)ppcVar5 + -8) = ssh_packet_write_poll; cleanup_exit(); *(code ***)((long)ppcVar5 + -8) = &pcStack272; *(undefined8 *)((long)ppcVar5 + -0x10) = unaff_RBX; *(undefined8 *)((long)ppcVar5 + -0x30) = uVar6; *(undefined8 *)((long)ppcVar5 + -0x20) = **(undefined8 **)((long)ppcVar5 + -0x30); uVar6 = *(undefined8 *)(*(long *)((long)ppcVar5 + -0x20) + 0x28); *(undefined8 *)((long)ppcVar5 + -0x40) = 0x104fde; uVar2 = sshbuf_len(uVar6); *(undefined4 *)((long)ppcVar5 + -0x28) = uVar2; if (0 < *(int *)((long)ppcVar5 + -0x28)) { iVar1 = *(int *)((long)ppcVar5 + -0x28); *(undefined8 *)((long)ppcVar5 + -0x40) = 0x105001; __buf = (void *)sshbuf_ptr(); __fd = *(int *)(*(long *)((long)ppcVar5 + -0x20) + 4); *(undefined8 *)((long)ppcVar5 + -0x40) = 0x105018; sVar3 = write(__fd, __buf, (long)iVar1); *(int *)((long)ppcVar5 + -0x28) = (int)sVar3; if (*(int *)((long)ppcVar5 + -0x28) == -1) { *(undefined8 *)((long)ppcVar5 + -0x40) = 0x105026; piVar4 = __errno_location(); if (*piVar4 != 4) { *(undefined8 *)((long)ppcVar5 + -0x40) = 0x105032; piVar4 = __errno_location(); if (*piVar4 != 0xb) { *(undefined8 *)((long)ppcVar5 + -0x40) = 0x10503e; piVar4 = __errno_location(); if (*piVar4 != 0xb) { return 0xffffffe8; } } } return 0; } if (*(int *)((long)ppcVar5 + -0x28) == 0) { return 0xffffffcc; } uVar6 = *(undefined8 *)(*(long *)((long)ppcVar5 + -0x20) + 0x28); *(undefined8 *)((long)ppcVar5 + -0x40) = 0x105079; uVar2 = sshbuf_consume(uVar6, (long)*(int *)((long)ppcVar5 + -0x28)); *(undefined4 *)((long)ppcVar5 + -0x24) = uVar2; if (*(int *)((long)ppcVar5 + -0x24) != 0) { return *(undefined4 *)((long)ppcVar5 + -0x24); } } return 0; }
openssh-portable
ghidra
static _Bool grepdesc(int desc, _Bool command_line) { intmax_t count; _Bool status = 1; _Bool ineof = 0; struct stat st; if (fstat(desc, &st) != 0) { suppressible_error((*__errno_location())); goto closeout; } if (desc != 0 && skip_devices(command_line) && is_device_mode(st.st_mode)) goto closeout; if (desc != 0 && command_line && skipped_file(filename, 1, ((((st.st_mode)) & 0170000) == (0040000)) != 0)) goto closeout; if (out_file < 0) out_file = !!((((st.st_mode)) & 0170000) == (0040000)); if (desc != 0 && directories == RECURSE_DIRECTORIES && ((((st.st_mode)) & 0170000) == (0040000))) { FTS *fts; FTSENT *ent; int opts = fts_options & ~(command_line ? 0 : 0x0001); char *fts_arg[2]; if (close(desc) != 0) suppressible_error((*__errno_location())); fts_arg[0] = (char *)filename; fts_arg[1] = ((void *)0); fts = rpl_fts_open(fts_arg, opts, ((void *)0)); if (!fts) xalloc_die(); while ((ent = rpl_fts_read(fts))) status &= grepdirent(fts, ent, command_line); if ((*__errno_location())) suppressible_error((*__errno_location())); if (rpl_fts_close(fts) != 0) suppressible_error((*__errno_location())); return status; } if (desc != 0 && ((directories == SKIP_DIRECTORIES && ((((st.st_mode)) & 0170000) == (0040000))) || ((devices == SKIP_DEVICES || (devices == READ_COMMAND_LINE_DEVICES && !command_line)) && is_device_mode(st.st_mode)))) goto closeout; if (!out_quiet && list_files == LISTFILES_NONE && 1 < max_count && ((((st.st_mode)) & 0170000) == (0100000)) && ((st).st_ino == (out_stat).st_ino && (st).st_dev == (out_stat).st_dev)) { if (!suppress_errors) error(0, 0, gettext("%s: input file is also the output"), input_filename()); errseen = 1; goto closeout; } count = grep(desc, &st, &ineof); if (count_matches) { if (out_file) { print_filename(); if (filename_mask) print_sep(SEP_CHAR_SELECTED); else putchar_errno(0); } printf_errno("%" "l" "d" "\n", count); if (line_buffered) fflush_errno(); } status = !count; if (list_files == LISTFILES_NONE) finalize_input(desc, &st, ineof); else if (list_files == (status ? LISTFILES_NONMATCHING : LISTFILES_MATCHING)) { print_filename(); putchar_errno('\n' & filename_mask); if (line_buffered) fflush_errno(); } closeout: if (desc != 0 && close(desc) != 0) suppressible_error((*__errno_location())); return status; }
_BOOL8 grepdesc(int a1, unsigned char a2) { int *v2; int *v3; int *v4; int *v5; long v7; char *v8; long v9; long v10; long v11; long v12; int v13; int *v14; char v15; unsigned char v16; unsigned int v17; long v18; long v19; long v20; long v21[2]; struct stat v22; unsigned long v23; v23 = __readfsqword(0x28u); v16 = 1; v15 = 0; if (fstat(a1, &v22)) { v2 = _errno_location(); suppressible_error(*v2); goto LABEL_56; } if (a1 && skip_devices(a2) && is_device_mode(v22.st_mode) || a1 && a2 && skipped_file(filename, 1u, (v22.st_mode & 0xF000) == 0x4000)) { LABEL_56: if (a1) { if (close(a1)) { v14 = _errno_location(); suppressible_error(*v14); } } return v16; } if (out_file < 0) out_file = (v22.st_mode & 0xF000) == 0x4000; if (!a1 || directories != 3 || (v22.st_mode & 0xF000) != 0x4000) { if (!a1 || (directories != 4 || (v22.st_mode & 0xF000) != 0x4000) && (devices != 2 && (devices || a2 == 1) || !is_device_mode(v22.st_mode))) { if (out_quiet != 1 && !list_files && max_count > 1 && (v22.st_mode & 0xF000) == 0x8000 && v22.st_ino == *(_QWORD *)&out_stat[8] && v22.st_dev == *(_QWORD *)out_stat) { if (suppress_errors != 1) { v7 = input_filename(); v8 = gettext("%s: input file is also the output"); error(0, 0, v8, v7); } errseen = 1; } else { v20 = grep(a1, (long)&v22, &v15); if (count_matches) { if (out_file) { print_filename(); if (filename_mask) print_sep(58); else putchar_errno(0); } printf_errno("%ld\n", v20, v9, v10, v11, v12); if (line_buffered) fflush_errno(); } v16 = v20 == 0; if (list_files) { if (v16) v13 = 2; else v13 = 1; if (v13 == list_files) { print_filename(); putchar_errno(filename_mask & 0xA); if (line_buffered) fflush_errno(); } } else { finalize_input(a1, (long)&v22, v15); } } } goto LABEL_56; } v17 = ~(a2 ^ 1) & fts_options; if (close(a1)) { v3 = _errno_location(); suppressible_error(*v3); } v21[0] = filename; v21[1] = 0LL; v18 = rpl_fts_open(v21, v17, 0LL); if (v18) goto LABEL_19; xalloc_die(); do { v16 &= grepdirent(v18, v19, a2); LABEL_19: v19 = rpl_fts_read(v18); } while (v19); if (*_errno_location()) { v4 = _errno_location(); suppressible_error(*v4); } if ((unsigned int)rpl_fts_close(v18)) { v5 = _errno_location(); suppressible_error(*v5); } return v16; }
grep
ida
gl_linked_previous_node(gl_list_t list, gl_list_node_t node) { return (node->prev != &list->root ? node->prev : ((void *)0)); }
long long gl_linked_previous_node(unsigned long a0, struct_0 *a1) { void *v1; if (a1->field_8 != a0 + 40) v1 = a1->field_8; else v1 = 0; return v1; }
gnutls
angr_dream
static int confirm(const char *prompt, const char *fingerprint) { const char *msg, *again = "Please type 'yes' or 'no': "; const char *again_fp = "Please type 'yes', 'no' or the fingerprint: "; char *p, *cp; int ret = -1; if (options.batch_mode) return 0; for (msg = prompt;; msg = fingerprint ? again_fp : again) { cp = p = read_passphrase(msg, 0x0001); if (p == ((void *)0)) return 0; p += strspn(p, " \t"); p[strcspn(p, " \t\n")] = '\0'; if (p[0] == '\0' || strcasecmp(p, "no") == 0) ret = 0; else if (strcasecmp(p, "yes") == 0 || (fingerprint != ((void *)0) && strcmp(p, fingerprint) == 0)) ret = 1; free(cp); if (ret != -1) return ret; } }
int confirm(unsigned long long a0, char *a1) { unsigned int v0; unsigned long v1; unsigned long long v2; unsigned long long v3; char *v4; void *v5; unsigned long v7; v2 = "Please type 'yes' or 'no': "; v3 = "Please type 'yes', 'no' or the fingerprint: "; v0 = -1; if (sshlog) { v7 = 0; } else { v1 = a0; while (true) { v4 = read_passphrase(v1, 0x1); v5 = v4; if (!v4) { *(&v7) = 0; break; } else { v4 = v4 + strspn(v4, " \t"); v4[strcspn(v4, " \t\n")] = 0; if (*(v4)) { v7 = strcasecmp(v4, "no"); if (v7) { v7 = strcasecmp(v4, "yes"); if (v7 && a1) v7 = strcmp(v4, a1); if (!v7 || !v7 && a1) v0 = 1; } } if (!*(v4) || !v7) v0 = 0; free(v5); if (v0 != -1) { *(&v7) = v0; break; } else { if (a1) v7 = v3; else v7 = v2; v1 = v7; } } } } return v7; }
openssh-portable
angr_dream
void load_hostkeys_command(struct hostkeys *hostkeys, const char *command_template, const char *invocation, const struct ssh_conn_info *cinfo, const struct sshkey *host_key, const char *hostfile_hostname) { int r, i, ac = 0; char *key_fp = ((void *)0), *keytext = ((void *)0), *tmp; char *command = ((void *)0), *tag = ((void *)0), **av = ((void *)0); FILE *f = ((void *)0); pid_t pid; void (*osigchld)(int); xasprintf(&tag, "KnownHostsCommand-%s", invocation); if (host_key != ((void *)0)) { if ((key_fp = sshkey_fingerprint(host_key, options.fingerprint_hash, SSH_FP_DEFAULT)) == ((void *)0)) sshfatal("sshconnect.c", __func__, 857, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshkey_fingerprint failed"); if ((r = sshkey_to_base64(host_key, &keytext)) != 0) sshfatal("sshconnect.c", __func__, 859, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "sshkey_to_base64 failed"); } osigchld = ssh_signal(17, ((__sighandler_t)0)); if (argv_split(command_template, &ac, &av, 0) != 0) { sshlog("sshconnect.c", __func__, 869, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "%s \"%s\" contains invalid quotes", tag, command_template); goto out; } if (ac == 0) { sshlog("sshconnect.c", __func__, 874, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "%s \"%s\" yielded no arguments", tag, command_template); goto out; } for (i = 1; i < ac; i++) { tmp = percent_dollar_expand( av[i], "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, "H", hostfile_hostname, "I", invocation, "t", host_key == ((void *)0) ? "NONE" : sshkey_ssh_name(host_key), "f", key_fp == ((void *)0) ? "NONE" : key_fp, "K", keytext == ((void *)0) ? "NONE" : keytext, (char *)((void *)0)); if (tmp == ((void *)0)) sshfatal("sshconnect.c", __func__, 888, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "percent_expand failed"); free(av[i]); av[i] = tmp; } command = argv_assemble(ac, av); if ((pid = subprocess(tag, command, ac, av, &f, (1 << 1) | (1 << 3) | (1 << 4), ((void *)0), ((void *)0), ((void *)0))) == 0) goto out; load_hostkeys_file(hostkeys, hostfile_hostname, tag, f, 1); if (exited_cleanly(pid, tag, command, 0) != 0) sshfatal("sshconnect.c", __func__, 903, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "KnownHostsCommand failed"); out: if (f != ((void *)0)) fclose(f); ssh_signal(17, osigchld); for (i = 0; i < ac; i++) free(av[i]); free(av); free(tag); free(command); free(key_fp); free(keytext); }
void load_hostkeys_command(undefined8 param_1, undefined8 param_2, undefined8 param_3, undefined8 *param_4, long param_5, undefined8 param_6) { undefined8 uVar1; undefined8 uVar2; undefined8 uVar3; undefined8 uVar4; undefined8 uVar5; undefined8 uVar6; undefined8 uVar7; undefined8 uVar8; void *pvVar9; FILE *__stream; int iVar10; undefined8 uVar11; undefined *puVar12; undefined *puVar13; char **ppcVar14; undefined *puVar15; undefined *puVar16; long in_FS_OFFSET; char *apcStack304[2]; void *apvStack288[5]; char *pcStack248; undefined8 uStack240; undefined auStack232[8]; undefined8 local_e0; undefined8 local_d8; undefined8 local_d0; undefined8 local_c8; long local_c0; undefined8 *local_b8; undefined8 local_b0; undefined8 local_a8; undefined8 local_a0; int local_90; int local_8c; int local_88; int local_84; undefined *local_80; void *local_78; void *local_70; FILE *local_68; undefined *local_60; void *local_58; undefined8 local_50; long local_48; long local_40; ppcVar14 = (char **)auStack232; local_40 = *(long *)(in_FS_OFFSET + 0x28); local_90 = 0; local_60 = (undefined *)0x0; local_80 = (undefined *)0x0; local_58 = (void *)0x0; local_78 = (void *)0x0; local_70 = (void *)0x0; local_68 = (FILE *)0x0; uStack240 = 0x102416; local_c8 = param_6; local_c0 = param_5; local_b8 = param_4; local_b0 = param_3; local_a8 = param_2; local_a0 = param_1; xasprintf(&local_78, "KnownHostsCommand-%s", param_3); puVar15 = auStack232; if (local_c0 != 0) { uStack240 = 0x102440; local_60 = (undefined *)sshkey_fingerprint(local_c0, _DAT_001096d8, 0); if (local_60 == (undefined *)0x0) { ppcVar14 = &pcStack248; pcStack248 = "sshkey_fingerprint failed"; sshfatal("sshconnect.c", "load_hostkeys_command", 0x359, 1, 1, 0); } *(undefined8 *)((long)ppcVar14 + -8) = 0x10249b; local_88 = sshkey_to_base64(local_c0, &local_80); puVar15 = (undefined *)ppcVar14; if (local_88 != 0) { *(undefined8 *)((long)ppcVar14 + -8) = 0x1024ae; uVar11 = ssh_err(local_88); puVar15 = (undefined *)((long)ppcVar14 + -0x10); *(char **)((long)ppcVar14 + -0x10) = "sshkey_to_base64 failed"; *(undefined8 *)((long)ppcVar14 + -0x18) = 0x1024e5; sshfatal("sshconnect.c", "load_hostkeys_command", 0x35b, 1, 1, uVar11); } } *(undefined8 *)(puVar15 + -8) = 0x1024f4; local_50 = ssh_signal(0x11, 0); *(undefined8 *)(puVar15 + -8) = 0x102517; iVar10 = argv_split(local_a8, &local_90, &local_70, 0); puVar13 = puVar15; if (iVar10 == 0) { if (local_90 == 0) { *(undefined8 *)(puVar15 + -0x10) = local_a8; *(void **)(puVar15 + -0x18) = local_78; *(char **)(puVar15 + -0x20) = "%s \"%s\" yielded no arguments"; *(undefined8 *)(puVar15 + -0x28) = 0x1025b8; sshlog("sshconnect.c", "load_hostkeys_command", 0x36a, 0, 2, 0); } else { for (local_8c = 1; local_8c < local_90; local_8c = __addvsi3(local_8c, 1)) { puVar13 = local_80; if (local_80 == (undefined *)0x0) { puVar13 = &DAT_0010602d; } puVar16 = local_60; if (local_60 == (undefined *)0x0) { puVar16 = &DAT_0010602d; } if (local_c0 == 0) { puVar12 = &DAT_0010602d; } else { *(undefined8 *)(puVar15 + -8) = 0x102613; puVar12 = (undefined *)sshkey_ssh_name(local_c0); } local_d0 = local_b8[10]; local_d8 = local_b8[8]; uVar11 = local_b8[7]; uVar1 = local_b8[9]; uVar2 = local_b8[6]; uVar3 = local_b8[5]; uVar4 = local_b8[4]; uVar5 = local_b8[3]; uVar6 = local_b8[2]; local_e0 = local_b8[1]; uVar7 = *local_b8; uVar8 = *(undefined8 *)((long)local_8c * 8 + (long)local_70); *(undefined8 *)(puVar15 + -8) = 0; *(undefined **)(puVar15 + -0x10) = puVar13; *(undefined **)(puVar15 + -0x18) = &DAT_00106038; *(undefined **)(puVar15 + -0x20) = puVar16; *(undefined **)(puVar15 + -0x28) = &DAT_0010603a; *(undefined **)(puVar15 + -0x30) = puVar12; *(undefined **)(puVar15 + -0x38) = &DAT_0010603c; *(undefined8 *)(puVar15 + -0x40) = local_b0; *(undefined **)(puVar15 + -0x48) = &DAT_0010603e; *(undefined8 *)(puVar15 + -0x50) = local_c8; *(undefined **)(puVar15 + -0x58) = &DAT_00106040; *(undefined8 *)(puVar15 + -0x60) = local_d0; *(undefined **)(puVar15 + -0x68) = &DAT_00106042; *(undefined8 *)(puVar15 + -0x70) = local_d8; *(undefined **)(puVar15 + -0x78) = &DAT_00105a81; *(undefined8 *)(puVar15 + -0x80) = uVar11; *(undefined **)(puVar15 + -0x88) = &DAT_00105a7f; *(undefined8 *)(puVar15 + -0x90) = uVar1; *(undefined **)(puVar15 + -0x98) = &DAT_00106044; *(undefined8 *)(puVar15 + -0xa0) = uVar2; *(undefined **)(puVar15 + -0xa8) = &DAT_00105a83; *(undefined8 *)(puVar15 + -0xb0) = uVar3; *(undefined **)(puVar15 + -0xb8) = &DAT_00105a7b; *(undefined8 *)(puVar15 + -0xc0) = uVar4; *(undefined **)(puVar15 + -200) = &DAT_00106046; *(undefined8 *)(puVar15 + -0xd0) = uVar5; *(undefined **)(puVar15 + -0xd8) = &DAT_00105a7d; *(undefined8 *)(puVar15 + -0xe0) = uVar6; *(undefined8 *)(puVar15 + -0xe8) = 0x10277f; local_48 = percent_dollar_expand(uVar8, &DAT_00106036, uVar7, &DAT_00106034, local_e0, &DAT_00106032); if (local_48 == 0) { *(char **)(puVar15 + -0x10) = "percent_expand failed"; *(undefined8 *)(puVar15 + -0x18) = 0x1027cb; sshfatal("sshconnect.c", "load_hostkeys_command", 0x378, 1, 1, 0); puVar15 = puVar15 + -0x10; } pvVar9 = *(void **)((long)local_70 + (long)local_8c * 8); *(undefined8 *)(puVar15 + -8) = 0x1027ea; free(pvVar9); *(long *)((long)local_8c * 8 + (long)local_70) = local_48; *(undefined8 *)(puVar15 + -8) = 0x102815; } *(undefined8 *)(puVar15 + -8) = 0x102841; local_58 = (void *)argv_assemble(local_90, local_70); *(undefined8 *)(puVar15 + -0x10) = 0; *(undefined8 *)(puVar15 + -0x18) = 0; *(undefined8 *)(puVar15 + -0x20) = 0; *(undefined8 *)(puVar15 + -0x28) = 0x102876; local_84 = subprocess(local_78, local_58, local_90, local_70, &local_68, 0x1a); puVar13 = puVar15; if (local_84 != 0) { *(undefined8 *)(puVar15 + -8) = 0x1028a7; load_hostkeys_file(local_a0, local_c8, local_78, local_68, 1); *(undefined8 *)(puVar15 + -8) = 0x1028be; iVar10 = exited_cleanly(local_84, local_78, local_58, 0); if (iVar10 != 0) { puVar13 = puVar15 + -0x10; *(char **)(puVar15 + -0x10) = "KnownHostsCommand failed"; *(undefined8 *)(puVar15 + -0x18) = 0x1028fc; sshfatal("sshconnect.c", "load_hostkeys_command", 0x387, 0, 1, 0); } } } } else { *(undefined8 *)(puVar15 + -0x10) = local_a8; *(void **)(puVar15 + -0x18) = local_78; *(char **)(puVar15 + -0x20) = "%s \"%s\" contains invalid quotes"; *(undefined8 *)(puVar15 + -0x28) = 0x102560; sshlog("sshconnect.c", "load_hostkeys_command", 0x365, 0, 2, 0); } __stream = local_68; if (local_68 != (FILE *)0x0) { *(undefined8 *)(puVar13 + -8) = 0x102915; fclose(__stream); } uVar11 = local_50; *(undefined8 *)(puVar13 + -8) = 0x102926; ssh_signal(0x11, uVar11); local_8c = 0; while (pvVar9 = local_70, local_8c < local_90) { pvVar9 = *(void **)((long)local_70 + (long)local_8c * 8); *(undefined8 *)(puVar13 + -8) = 0x102951; free(pvVar9); iVar10 = local_8c; *(undefined8 *)(puVar13 + -8) = 0x102961; local_8c = __addvsi3(iVar10, 1); } *(undefined8 *)(puVar13 + -8) = 0x102981; free(pvVar9); pvVar9 = local_78; *(undefined8 *)(puVar13 + -8) = 0x10298d; free(pvVar9); pvVar9 = local_58; *(undefined8 *)(puVar13 + -8) = 0x102999; free(pvVar9); puVar15 = local_60; *(undefined8 *)(puVar13 + -8) = 0x1029a5; free(puVar15); puVar15 = local_80; *(undefined8 *)(puVar13 + -8) = 0x1029b1; free(puVar15); if (local_40 == *(long *)(in_FS_OFFSET + 0x28)) { return; } *(undefined8 *)(puVar13 + -8) = 0x1029c6; __stack_chk_fail(); }
openssh-portable
ghidra
char **env_init(void) { char **p = (char **)malloc(sizeof(char *)); if (p != ((void *)0)) p[0] = ((void *)0); return (p); }
undefined8 *env_init(void) { undefined8 *puVar1; puVar1 = (undefined8 *)malloc(8); if (puVar1 != (undefined8 *)0x0) { *puVar1 = 0; } return puVar1; }
cronie
ghidra
static int ipstats_req_add_filters(struct ipstats_req *req, void *data) { struct ipstats_stat_dump_filters dump_filters = {}; struct ipstats_stat_enabled *enabled = data; _Bool get_filters = 0; int i; for (i = 0; i < enabled->nenabled; i++) enabled->enabled[i].desc->pack(&dump_filters, enabled->enabled[i].desc); for (i = 1; i < (sizeof(dump_filters.mask) / sizeof((dump_filters.mask)[0])); i++) { if (ipstats_req_should_filter_at(&dump_filters, i)) { get_filters = 1; break; } } req->ifsm.filter_mask = dump_filters.mask[0]; if (get_filters) { struct rtattr *nest; nest = addattr_nest(&req->nlh, sizeof(*req), IFLA_STATS_GET_FILTERS | (1 << 15)); for (i = 1; i < (sizeof(dump_filters.mask) / sizeof((dump_filters.mask)[0])); i++) { if (ipstats_req_should_filter_at(&dump_filters, i)) addattr32(&req->nlh, sizeof(*req), i, dump_filters.mask[i]); } addattr_nest_end(&req->nlh, nest); } return 0; }
void ipstats_req_add_filters(struct_1 *a0, unsigned long long a1[2]) { char v0; unsigned int v1; unsigned long long v2; void *v3; void *v4; void *v5; void *v7; v3 = 0; v4 = 0; v5 = 0; v0 = 0; for (v1 = 0; v1 < a1[1]; v1 += 1) { *((*((a1[0] + v1 * 32)) + 16))(&v3, *((a1[0] + v1 * 32)), *((a1[0] + v1 * 32)), *((*((a1[0] + v1 * 32)) + 16))); } v1 = 1; while (true) { if (v1 > 5) break; if (!ipstats_req_should_filter_at(&v3, v1)) { v1 += 1; } else { v0 = 1; break; } } a0->field_18 = v3; if (v0) { v2 = addattr_nest(a0, 0x9c, 0x8001); for (v1 = 1; v1 <= 5; v1 += 1) { if (ipstats_req_should_filter_at(&v3, v1)) addattr32(a0, 0x9c, v1, *((&v3 + 4 * v1))); } addattr_nest_end(a0, v2, v2); } v7 = 0; return; }
iproute2-6.0.0
angr_sailr
static int unbind_command(name) char *name; { rl_command_func_t *function; function = rl_named_function(name); if (function == 0) { builtin_error(gettext("`%s': unknown function name"), name); return 1; } rl_unbind_function_in_map(function, rl_get_keymap()); return 0; }
long unbind_command(long a1) { char *v1; long keymap; long v4; v4 = rl_named_function(a1); if (v4) { keymap = rl_get_keymap(); rl_unbind_function_in_map(v4, keymap); return 0LL; } else { v1 = gettext("`%s': unknown function name"); builtin_error(v1, a1, v1); return 1LL; } }
bash
ida
em_exchange_mark(EditLine *el, wint_t c __attribute__((__unused__))) { wchar_t *cp; cp = el->el_line.cursor; el->el_line.cursor = el->el_chared.c_kill.mark; el->el_chared.c_kill.mark = cp; return 5; }
long long em_exchange_mark(unsigned long long a0[115], unsigned long a1) { unsigned int v0; unsigned long v1; v0 = a1; v1 = a0[11]; a0[11] = a0[114]; a0[114] = v1; return 5; }
libedit
angr_sailr
static int flush_addrlabel(struct nlmsghdr *n, void *arg) { struct rtnl_handle rth2; struct rtmsg *r = ((void *)(((char *)n) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))))); int len = n->nlmsg_len; struct rtattr *tb[(__IFAL_MAX - 1) + 1]; len -= ((sizeof(*r)) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1)))); if (len < 0) return -1; parse_rtattr( tb, (__IFAL_MAX - 1), ((struct rtattr *)(((char *)(r)) + (((sizeof(struct rtmsg)) + 4U - 1) & ~(4U - 1)))), len); if (tb[IFAL_ADDRESS]) { n->nlmsg_type = RTM_DELADDRLABEL; n->nlmsg_flags = 0x01; if (rtnl_open(&rth2, 0) < 0) return -1; if (rtnl_talk(&rth2, n, ((void *)0)) < 0) return -2; rtnl_close(&rth2); } return 0; }
undefined8 flush_addrlabel(int *param_1, undefined8 param_2, undefined8 param_3, undefined8 param_4, undefined8 param_5, undefined8 param_6) { int iVar1; undefined8 uVar2; long in_FS_OFFSET; undefined local_68[64]; undefined local_28[8]; long local_20; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); if (*param_1 + -0x1c < 0) { uVar2 = 0xffffffff; goto LAB_00100870; } parse_rtattr(local_28, 2, param_1 + 7, *param_1 + -0x1c, param_5, param_6, param_2); if (local_20 != 0) { *(undefined2 *)(param_1 + 1) = 0x49; *(undefined2 *)((long)param_1 + 6) = 1; iVar1 = rtnl_open(local_68, 0); if (iVar1 < 0) { uVar2 = 0xffffffff; goto LAB_00100870; } iVar1 = rtnl_talk(local_68, param_1, 0); if (iVar1 < 0) { uVar2 = 0xfffffffe; goto LAB_00100870; } rtnl_close(local_68); } uVar2 = 0; LAB_00100870: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return uVar2; }
iproute2-6.0.0
ghidra
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 *param_1) { FILE *__stream; int iVar1; char *pcVar2; char *pcVar3; long in_FS_OFFSET; char *local_b8; char **local_b0; char *local_98; char *local_90; char *local_88; char *local_80; char *local_78; char *local_70; char *local_68; char *local_60; char *local_58; char *local_50; char *local_48; char *local_40; undefined8 local_38; undefined8 local_30; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_98 = "["; local_90 = "test invocation"; local_88 = "coreutils"; local_80 = "Multi-call invocation"; local_78 = "sha224sum"; local_70 = "sha2 utilities"; local_68 = "sha256sum"; local_60 = "sha2 utilities"; local_58 = "sha384sum"; local_50 = "sha2 utilities"; local_48 = "sha512sum"; local_40 = "sha2 utilities"; local_38 = 0; local_30 = 0; local_b0 = &local_98; while ((*local_b0 != (char *)0x0 && (iVar1 = strcmp(param_1, *local_b0), iVar1 != 0))) { local_b0 = local_b0 + 2; } local_b8 = param_1; if (local_b0[1] != (char *)0x0) { local_b8 = local_b0[1]; } pcVar2 = (char *)gettext("\n%s online help: <%s>\n"); printf(pcVar2,"GNU coreutils","https: pcVar2 = setlocale(5,(char *)0x0); if ((pcVar2 != (char *)0x0) && (iVar1 = strncmp(pcVar2,"en_",3), __stream = stdout, iVar1 != 0)) { pcVar2 = (char *)gettext("Report any translation bugs to <https: ); fputs_unlocked(pcVar2, __stream); } iVar1 = strcmp(param_1,"["); pcVar2 = param_1; if (iVar1 == 0) { pcVar2 = "test"; } pcVar3 = (char *)gettext("Full documentation <%s%s>\n"); printf(pcVar3,"https: if (local_b8 == param_1) { pcVar2 = " invocation"; } else { pcVar2 = ""; } pcVar3 = (char *)gettext("or available locally via: info \'(coreutils) %s%s\'\n"); printf(pcVar3,local_b8,pcVar2); if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return; } __stack_chk_fail(); }
coreutils
ghidra
static inline void emit_ancillary_info(char const *program) { struct infomap { char const *program; char const *node; } const infomap[] = { {"[", "test invocation"}, {"coreutils", "Multi-call invocation"}, {"sha224sum", "sha2 utilities"}, {"sha256sum", "sha2 utilities"}, {"sha384sum", "sha2 utilities"}, {"sha512sum", "sha2 utilities"}, {((void *)0), ((void *)0)}}; char const *node = program; struct infomap const *map_prog = infomap; while (map_prog->program && !(strcmp(program, map_prog->program) == 0)) map_prog++; if (map_prog->node) node = map_prog->node; printf (gettext ("\n%s online help: <%s>\n"), "GNU coreutils", "https: char const *lc_messages = setlocale ( 5 , ((void *)0) ); if (lc_messages && strncmp (lc_messages, "" "en_" "", sizeof ("en_") - 1)) { fputs_unlocked (gettext ("Report any translation bugs to " "<https: stdout ) ; } char const *url_program = (strcmp (program, "[") == 0) ? "test" : program; printf (gettext ("Full documentation <%s%s>\n"), "https: printf (gettext ("or available locally via: info '(coreutils) %s%s'\n"), node, node == program ? " invocation" : ""); }
unsigned long emit_ancillary_info(const char *a1) { char *v1; FILE *v2; char *v3; const char *v4; char *v5; const char *v6; char *v7; const char *v9; long *i; const char *v11; const char *v12; long v13[15]; unsigned long v14; v14 = __readfsqword(0x28u); v13[0] = (long)"["; v13[1] = (long)"test invocation"; v13[2] = (long)"coreutils"; v13[3] = (long)"Multi-call invocation"; v13[4] = (long)"sha224sum"; v13[5] = (long)"sha2 utilities"; v13[6] = (long)"sha256sum"; v13[7] = (long)"sha2 utilities"; v13[8] = (long)"sha384sum"; v13[9] = (long)"sha2 utilities"; v13[10] = (long)"sha512sum"; v13[11] = (long)"sha2 utilities"; v13[12] = 0LL; v13[13] = 0LL; v9 = a1; for (i = v13; *i && strcmp(a1, (const char *)*i); i += 2) ; if (i[1]) v9 = (const char *)i[1]; v1 = gettext("\n%s online help: <%s>\n"); printf(v1, "GNU coreutils", "https: v11 = setlocale(5, 0LL); if ( v11 && strncmp(v11, "en_", 3uLL) ) { v2 = stdout; v3 = gettext("Report any translation bugs to <https: fputs_unlocked(v3, v2); } if ( !strcmp(a1, "[") ) v4 = "test"; else v4 = a1; v12 = v4; v5 = gettext("Full documentation <%s%s>\n"); printf(v5, "https: if ( v9 == a1 ) v6 = " invocation"; else v6 = locale; v7 = gettext("or available locally via: info '(coreutils) %s%s'\n"); printf(v7, v9, v6); return __readfsqword(0x28u) ^ v14; }
coreutils
ida
static char **glob_dir_to_array(dir, array, flags) char *dir, **array; int flags; { register unsigned int i, l; int add_slash; char **result, *new; struct stat sb; l = strlen(dir); if (l == 0) { if (flags & 0x001) for (i = 0; array[i]; i++) { if ((stat(array[i], &sb) == 0) && ((((sb.st_mode)) & 0170000) == (0040000))) { l = strlen(array[i]); new = (char *)realloc(array[i], l + 2); if (new == 0) return ((void *)0); new[l] = '/'; new[l + 1] = '\0'; array[i] = new; } } return (array); } add_slash = dir[l - 1] != '/'; i = 0; while (array[i] != ((void *)0)) ++i; result = (char **)sh_malloc(((i + 1) * sizeof(char *)), "glob.c", 1097); if (result == ((void *)0)) return (((void *)0)); for (i = 0; array[i] != ((void *)0); i++) { result[i] = (char *)sh_malloc((l + strlen(array[i]) + 3), "glob.c", 1104); if (result[i] == ((void *)0)) { int ind; for (ind = 0; ind < i; ind++) sh_xfree((result[ind]), "glob.c", 1110); sh_xfree((result), "glob.c", 1111); return (((void *)0)); } strcpy(result[i], dir); if (add_slash) result[i][l] = '/'; if (array[i][0]) { strcpy(result[i] + l + add_slash, array[i]); if (flags & 0x001) { if ((stat(result[i], &sb) == 0) && ((((sb.st_mode)) & 0170000) == (0040000))) { size_t rlen; rlen = strlen(result[i]); result[i][rlen] = '/'; result[i][rlen + 1] = '\0'; } } } else result[i][l + add_slash] = '\0'; } result[i] = ((void *)0); for (i = 0; array[i] != ((void *)0); i++) sh_xfree((array[i]), "glob.c", 1139); sh_xfree(((char *)array), "glob.c", 1140); return (result); }
long glob_dir_to_array(const char *a1, long a2, char a3) { unsigned int v3; unsigned int n; int v5; unsigned int i; unsigned int j; size_t v9; size_t v10; unsigned int k; unsigned int m; _BOOL4 v14; long v15; _BYTE *v16; struct stat v17; unsigned long v18; v18 = __readfsqword(0x28u); v3 = strlen(a1); if (v3) { v14 = a1[v3 - 1] != 47; for (i = 0; *(_QWORD *)(8LL * i + a2); ++i) ; v15 = sh_malloc(8LL * (i + 1), "glob.c", 1097LL); if (v15) { for (j = 0;; ++j) { if (!*(_QWORD *)(8LL * j + a2)) { *(_QWORD *)(8LL * j + v15) = 0LL; for (k = 0; *(_QWORD *)(8LL * k + a2); ++k) sh_xfree(*(_QWORD *)(8LL * k + a2), "glob.c", 1139LL); sh_xfree(a2, "glob.c", 1140LL); return v15; } v9 = strlen(*(const char **)(8LL * j + a2)); *(_QWORD *)(8LL * j + v15) = sh_malloc(v3 + v9 + 3, "glob.c", 1104LL); if (!*(_QWORD *)(8LL * j + v15)) break; strcpy(*(char **)(8LL * j + v15), a1); if (v14) *(_BYTE *)(v3 + *(_QWORD *)(8LL * j + v15)) = 47; if (**(_BYTE **)(8LL * j + a2)) { strcpy((char *)(v3 + (long)v14 + *(_QWORD *)(8LL * j + v15)), *(const char **)(8LL * j + a2)); if ((a3 & 1) != 0 && !stat(*(const char **)(8LL * j + v15), &v17) && (v17.st_mode & 0xF000) == 0x4000) { v10 = strlen(*(const char **)(8LL * j + v15)); *(_BYTE *)(*(_QWORD *)(8LL * j + v15) + v10) = 47; *(_BYTE *)(v10 + 1 + *(_QWORD *)(8LL * j + v15)) = 0; } } else { *(_BYTE *)(v3 + v14 + *(_QWORD *)(8LL * j + v15)) = 0; } } for (m = 0; j > m; ++m) sh_xfree(*(_QWORD *)(8LL * (int)m + v15), "glob.c", 1110LL); sh_xfree(v15, "glob.c", 1111LL); return 0LL; } else { return 0LL; } } else { if ((a3 & 1) != 0) { for (n = 0; *(_QWORD *)(8LL * n + a2); ++n) { if (!stat(*(const char **)(8LL * n + a2), &v17) && (v17.st_mode & 0xF000) == 0x4000) { v5 = strlen(*(const char **)(8LL * n + a2)); v16 = realloc(*(void **)(8LL * n + a2), (unsigned int)(v5 + 2)); if (!v16) return 0LL; v16[v5] = 47; v16[v5 + 1] = 0; *(_QWORD *)(a2 + 8LL * n) = v16; } } } return a2; } }
bash
ida
void set_stat_placeholders(struct stat *p) { (void)p; (void)p; }
void set_stat_placeholders(unsigned long a0) { unsigned long v0; char v1; unsigned long long v3; v0 = a0; v3 = *(&v1); return; }
findutils
angr_phoenix
char *sftp_realpath(const char *path, char *resolved) { struct stat sb; char *p, *q, *s; size_t left_len, resolved_len; unsigned symlinks; int serrno, slen, mem_allocated; char left[4096], next_token[4096], symlink[4096]; if (path[0] == '\0') { (*__errno_location()) = 2; return (((void *)0)); } serrno = (*__errno_location()); if (resolved == ((void *)0)) { resolved = malloc(4096); if (resolved == ((void *)0)) return (((void *)0)); mem_allocated = 1; } else mem_allocated = 0; symlinks = 0; if (path[0] == '/') { resolved[0] = '/'; resolved[1] = '\0'; if (path[1] == '\0') return (resolved); resolved_len = 1; left_len = strlcpy(left, path + 1, sizeof(left)); } else { if (getcwd(resolved, 4096) == ((void *)0)) { if (mem_allocated) free(resolved); else strlcpy(resolved, ".", 4096); return (((void *)0)); } resolved_len = strlen(resolved); left_len = strlcpy(left, path, sizeof(left)); } if (left_len >= sizeof(left) || resolved_len >= 4096) { (*__errno_location()) = 36; goto err; } while (left_len != 0) { p = strchr(left, '/'); s = p ? p : left + left_len; if (s - left >= (ptrdiff_t)sizeof(next_token)) { (*__errno_location()) = 36; goto err; } memcpy(next_token, left, s - left); next_token[s - left] = '\0'; left_len -= s - left; if (p != ((void *)0)) memmove(left, s + 1, left_len + 1); if (resolved[resolved_len - 1] != '/') { if (resolved_len + 1 >= 4096) { (*__errno_location()) = 36; goto err; } resolved[resolved_len++] = '/'; resolved[resolved_len] = '\0'; } if (next_token[0] == '\0') continue; else if (strcmp(next_token, ".") == 0) continue; else if (strcmp(next_token, "..") == 0) { if (resolved_len > 1) { resolved[resolved_len - 1] = '\0'; q = strrchr(resolved, '/') + 1; *q = '\0'; resolved_len = q - resolved; } continue; } resolved_len = strlcat(resolved, next_token, 4096); if (resolved_len >= 4096) { (*__errno_location()) = 36; goto err; } if (lstat(resolved, &sb) != 0) { if ((*__errno_location()) == 2 && p == ((void *)0)) { (*__errno_location()) = serrno; return (resolved); } goto err; } if (((((sb.st_mode)) & 0170000) == (0120000))) { if (symlinks++ > 32) { (*__errno_location()) = 40; goto err; } slen = readlink(resolved, symlink, sizeof(symlink) - 1); if (slen < 0) goto err; symlink[slen] = '\0'; if (symlink[0] == '/') { resolved[1] = 0; resolved_len = 1; } else if (resolved_len > 1) { resolved[resolved_len - 1] = '\0'; q = strrchr(resolved, '/') + 1; *q = '\0'; resolved_len = q - resolved; } if (p != ((void *)0)) { if (symlink[slen - 1] != '/') { if (slen + 1 >= (ptrdiff_t)sizeof(symlink)) { (*__errno_location()) = 36; goto err; } symlink[slen] = '/'; symlink[slen + 1] = 0; } left_len = strlcat(symlink, left, sizeof(symlink)); if (left_len >= sizeof(symlink)) { (*__errno_location()) = 36; goto err; } } left_len = strlcpy(left, symlink, sizeof(left)); } } if (resolved_len > 1 && resolved[resolved_len - 1] == '/') resolved[resolved_len - 1] = '\0'; return (resolved); err: if (mem_allocated) free(resolved); return (((void *)0)); }
char *sftp_realpath(_BYTE *a1, char *a2) { char *v3; size_t v4; unsigned int v5; char *buf; unsigned int v7; int v8; int v9; int v10; unsigned long v11; size_t v12; char *v13; char *v14; char *v15; char *v16; struct stat v17; char s[16]; char dest[16]; char v20[16]; unsigned long v21; buf = a2; v21 = __readfsqword(0x28u); if (!*a1) { *_errno_location() = 2; return 0LL; } v9 = *_errno_location(); if (a2) { v8 = 0; } else { buf = (char *)malloc(0x1000uLL); if (!buf) return 0LL; v8 = 1; } v7 = 0; if (*a1 == 47) { *buf = 47; buf[1] = 0; if (!a1[1]) return buf; v12 = 1LL; v11 = strlcpy(s, a1 + 1, 4096LL); } else { if (!getcwd(buf, 0x1000uLL)) { if (v8) free(buf); else strlcpy(buf, ".", 4096LL); return 0LL; } v12 = strlen(buf); v11 = strlcpy(s, a1, 4096LL); } if (v11 <= 0xFFF && v12 <= 0xFFF) { while (1) { while (1) { do { if (!v11) { if (v12 > 1 && buf[v12 - 1] == 47) buf[v12 - 1] = 0; return buf; } v13 = strchr(s, 47); if (v13) v3 = v13; else v3 = &s[v11]; v14 = v3; if (v3 - s > 4095) goto LABEL_55; memcpy(dest, s, v3 - s); dest[v14 - s] = 0; v11 -= v14 - s; if (v13) memmove(s, v14 + 1, v11 + 1); if (buf[v12 - 1] != 47) { if (v12 + 1 > 0xFFF) goto LABEL_55; v4 = v12++; buf[v4] = 47; buf[v12] = 0; } } while (!dest[0] || !strcmp(dest, ".")); if (strcmp(dest, "..")) break; if (v12 > 1) { buf[v12 - 1] = 0; v15 = strrchr(buf, 47) + 1; *v15 = 0; v12 = v15 - buf; } } v12 = strlcat(buf, dest, 4096LL); if (v12 > 0xFFF) goto LABEL_55; if (lstat(buf, &v17)) break; if ((v17.st_mode & 0xF000) == 40960) { v5 = v7++; if (v5 > 0x20) { *_errno_location() = 40; goto LABEL_62; } v10 = readlink(buf, v20, 0xFFFuLL); if (v10 < 0) goto LABEL_62; v20[v10] = 0; if (v20[0] == 47) { buf[1] = 0; v12 = 1LL; } else if (v12 > 1) { buf[v12 - 1] = 0; v16 = strrchr(buf, 47) + 1; *v16 = 0; v12 = v16 - buf; } if (v13) { if (v20[v10 - 1] != 47) { if (v10 + 1 > 4095) goto LABEL_55; v20[v10] = 47; v20[v10 + 1] = 0; } if ((unsigned long)strlcat(v20, s, 4096LL) > 0xFFF) { LABEL_55: *_errno_location() = 36; goto LABEL_62; } } v11 = strlcpy(s, v20, 4096LL); } } if (*_errno_location() == 2 && !v13) { *_errno_location() = v9; return buf; } } else { *_errno_location() = 36; } LABEL_62: if (v8) free(buf); return 0LL; }
openssh-portable
ida
int auth2_method_allowed(Authctxt *authctxt, const char *method, const char *submethod) { u_int i; if (options.num_auth_methods == 0) return 1; for (i = 0; i < authctxt->num_auth_methods; i++) { if (list_starts_with(authctxt->auth_methods[i], method, submethod) != 0) return 1; } return 0; }
int auth2_method_allowed(struct_0 *a0, unsigned long long a1, unsigned long long a2) { unsigned int v0; unsigned int v2; if (!*(5250712)) { v2 = 1; } else { v0 = 0; while (true) { if (v0 < a0->field_48) { v2 = list_starts_with(*((a0->field_40 + v0 * 8)), a1, a2); if (v2) { v2 = 1; break; } else { v0 += 1; } } else { v2 = 0; break; } } } return v2; }
openssh-portable
angr_dream
ce__isword(wint_t p) { return iswalnum(p) || wcschr(L"*?_-.[]~=", p) != ((void *)0); }
_BOOL8 ce__isword(wint_t a1) { return iswalnum(a1) || wcschr(U"*?_-.[]~=", a1); }
libedit
ida
char *bash_tilde_find_word(s, flags, lenp) const char *s; int flags, *lenp; { const char *r; char *ret; int l; for (r = s; *r && *r != '/'; r++) { if (*r == '\\' || *r == '\'' || *r == '"') { ret = (char *)strcpy(sh_xmalloc((1 + strlen(s)), "general.c", 1184), (s)); if (lenp) *lenp = 0; return ret; } else if (flags && *r == ':') break; } l = r - s; ret = sh_xmalloc((l + 1), "general.c", 1193); strncpy(ret, s, l); ret[l] = '\0'; if (lenp) *lenp = l; return ret; }
char *bash_tilde_find_word(char *param_1, int param_2, int *param_3) { int iVar1; size_t sVar2; char *pcVar3; char *local_18; for (local_18 = param_1; (*local_18 != '\0' && (*local_18 != '/')); local_18 = local_18 + 1) { if ((*local_18 == '\\') || ((*local_18 == '\'' || (*local_18 == '\"')))) { sVar2 = strlen(param_1); pcVar3 = (char *)sh_xmalloc(sVar2 + 1, "general.c", 0x4a0); pcVar3 = strcpy(pcVar3, param_1); if (param_3 == (int *)0x0) { return pcVar3; } *param_3 = 0; return pcVar3; } if ((param_2 != 0) && (*local_18 == ':')) break; } iVar1 = (int)local_18 - (int)param_1; pcVar3 = (char *)sh_xmalloc((long)(iVar1 + 1), "general.c", 0x4a9); strncpy(pcVar3, param_1, (long)iVar1); pcVar3[iVar1] = '\0'; if (param_3 != (int *)0x0) { *param_3 = iVar1; } return pcVar3; }
bash
ghidra
void print_error_perarchive(const char *emsg, const void *data) { const char *filename = data; notice(gettext("error processing archive %s (--%s):\n %s"), filename, cipaction->olong, emsg); statusfd_send("status: %s : %s : %s", filename, "error", emsg); enqueue_error_report(filename); }
void print_error_perarchive(undefined8 param_1, undefined8 param_2) { undefined8 uVar1; undefined8 uVar2; uVar1 = *cipaction; uVar2 = gettext("error processing archive %s (--%s):\n %s"); notice(uVar2, param_2, uVar1, param_1); statusfd_send("status: %s : %s : %s", param_2, "error", param_1); enqueue_error_report(param_2); return; }
dpkg
ghidra
void discard_unwind_frame(tag) char *tag; { if (unwind_protect_list) without_interrupts(unwind_frame_discard_internal, tag, (char *)((void *)0)); }
long long discard_unwind_frame(unsigned long long a0) { unsigned long long v1; v1 = unwind_protect_list; if (unwind_protect_list) v1 = without_interrupts(unwind_frame_discard_internal, a0, 0x0); return v1; }
bash
angr_dream
static int get_sci(__u64 *sci, const char *arg) { return get_be64(sci, arg, 16); }
void get_sci(undefined8 param_1, undefined8 param_2) { get_be64(param_1, param_2, 0x10); return; }
iproute2-6.0.0
ghidra
int rl_undo_command(int count, int key) { if (count < 0) return 0; while (count) { if (rl_do_undo()) count--; else { rl_ding(); break; } } return 0; }
long rl_undo_command(int a1) { int v2; v2 = a1; if (a1 < 0) return 0LL; while (v2) { if (!(unsigned int)rl_do_undo()) { rl_ding(); return 0LL; } --v2; } return 0LL; }
bash
ida
static errcode_t scan_callback(ext2_filsys fs, ext2_inode_scan scan __attribute__((unused)), dgrp_t group, void *priv_data) { struct scan_callback_struct *scan_struct; e2fsck_t ctx; scan_struct = (struct scan_callback_struct *)priv_data; ctx = scan_struct->ctx; process_inodes((e2fsck_t)fs->priv_data, scan_struct->block_buf); if (ctx->progress) if ((ctx->progress)(ctx, 1, group + 1, ctx->fs->group_desc_count)) return (2133571409L); return 0; }
long long scan_callback(struct_0 *a0, unsigned long a1, unsigned long a2, unsigned long long a3[2]) { unsigned long v0; struct_1 *v1; unsigned long long v3; v0 = a1; v1 = a3[0]; process_inodes(a0->field_e0, a3[1]); if (v1->field_160 && v1->field_160(v1, 1, a2 + 1, v1->field_0->field_30, v1->field_160)) { v3 = 2133571409; goto LABEL_405d6d; } v3 = 0; LABEL_405d6d: return v3; }
e2fsprogs-1.46.5
angr_phoenix
void channel_send_window_changes(struct ssh *ssh) { struct ssh_channels *sc = ssh->chanctxt; struct winsize ws; int r; u_int i; for (i = 0; i < sc->channels_alloc; i++) { if (sc->channels[i] == ((void *)0) || !sc->channels[i]->client_tty || sc->channels[i]->type != 4) continue; if (ioctl(sc->channels[i]->rfd, 0x5413, &ws) == -1) continue; channel_request_start(ssh, i, "window-change", 0); if ((r = sshpkt_put_u32(ssh, (u_int)ws.ws_col)) != 0 || (r = sshpkt_put_u32(ssh, (u_int)ws.ws_row)) != 0 || (r = sshpkt_put_u32(ssh, (u_int)ws.ws_xpixel)) != 0 || (r = sshpkt_put_u32(ssh, (u_int)ws.ws_ypixel)) != 0 || (r = sshpkt_send(ssh)) != 0) sshfatal("channels.c", __func__, 4726, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "channel %u; send window-change", i); } }
long long channel_send_window_changes(struct_2 *a0) { unsigned int v0; unsigned int v1; struct_3 *v2; char v3; char v4; char v5; char v6; unsigned long long v7; unsigned long v8; unsigned long long v10; v2 = a0->field_868; for (v1 = 0; v1 < v2->field_8; v1 += 1) { if (*((v2->field_0 + (v1 << 3))) && *((*((v2->field_0 + (v1 << 3))) + 76)) && *(*((v2->field_0 + (v1 << 3)))) == 4) { v10 = ioctl(*((*((v2->field_0 + v1 * 8)) + 28)), 0x5413); if (v10 != -1) { channel_request_start(a0, v1, "window-change", 0x0); v0 = sshpkt_put_u32(a0, *(&v4), *(&v4)); if (!v0) { v0 = sshpkt_put_u32(a0, *(&v3), *(&v3)); if (!v0) { v0 = sshpkt_put_u32(a0, *(&v5), *(&v5)); if (!v0) { v0 = sshpkt_put_u32(a0, *(&v6), *(&v6)); if (!v0) v0 = sshpkt_send(a0); } } } } } if (...) { v8 = v1; v7 = "channel %u; send window-change"; sshfatal("channels.c", "channel_send_window_changes", 0x1276, 0x1, 0x1, ssh_err(v0)); } } return 0; }
openssh-portable
angr_dream
static uchar *getDfltTpl(void) { if (loadModConf != ((void *)0) && loadModConf->tplName != ((void *)0)) return loadModConf->tplName; else if (cs.pszTplName == ((void *)0)) return (uchar *)"RSYSLOG_TraditionalForwardFormat"; else return cs.pszTplName; }
int getDfltTpl() { unsigned int v1; if (loadModConf && *((loadModConf + 8))) v1 = *((loadModConf + 8)); if (!*((loadModConf + 8)) || !loadModConf) { if (!cs) v1 = &g_405ea8; else v1 = cs; } return v1; }
rsyslog-8.2210.0
angr_dream
static void prep_non_filename_text(void) { if (color_indicator[C_END].string != ((void *)0)) put_indicator(&color_indicator[C_END]); else { put_indicator(&color_indicator[C_LEFT]); put_indicator(&color_indicator[C_RESET]); put_indicator(&color_indicator[C_RIGHT]); } }
void prep_non_filename_text() { unsigned long long v1; unsigned long long v2; if (g_410728) { v1 = put_indicator(&g_410720); return; } put_indicator(&color_indicator); put_indicator(&g_410730); v2 = put_indicator(&g_410710); return; }
coreutils
angr_sailr
static inline __u32 rta_getattr_u32(const struct rtattr *rta) { return *(__u32 *)(( void *)(((char *)(rta)) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))); }
int rta_getattr_u32(struct_0 *a0) { return a0->field_4; }
iproute2-6.0.0
angr_phoenix
static void usage(void) { char const *const *p; printf(gettext("Usage: %s [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]]\n"), program_name); printf("%s\n", gettext("Compare two files byte by byte.")); printf( "\n%s\n\n", gettext( "The optional SKIP1 and SKIP2 specify the number of bytes to skip\n" "at the beginning of each file (zero by default).")); fputs_unlocked(gettext("Mandatory arguments to long options are mandatory " "for short options too.\n"), stdout) ; for (p = option_help_msgid; *p; p++) printf(" %s\n", gettext(*p)); printf("\n%s\n\n%s\n%s\n", gettext("SKIP values may be followed by the following multiplicative " "suffixes:\nkB 1000, K 1024, MB 1,000,000, M 1,048,576,\nGB " "1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y.") , gettext("If a FILE is '-' or missing, read standard input."), gettext("Exit status is 0 if inputs are the same, 1 if different, 2 " "if trouble.")); emit_bug_reporting_address(); }
void usage(void) { FILE *__stream; char *pcVar1; undefined8 uVar2; undefined8 uVar3; undefined8 uVar4; undefined1 *local_20; uVar2 = program_name; pcVar1 = (char *)gettext("Usage: %s [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]]\n"); printf(pcVar1, uVar2); uVar2 = gettext("Compare two files byte by byte."); printf("%s\n", uVar2); uVar2 = gettext("The optional SKIP1 and SKIP2 specify the number of bytes to " "skip\nat the beginning of each file (zero by default)."); printf("\n%s\n\n", uVar2); __stream = stdout; pcVar1 = (char *)gettext("Mandatory arguments to long options are mandatory " "for short options too.\n"); fputs_unlocked(pcVar1, __stream); for (local_20 = option_help_msgid; *(long *)local_20 != 0; local_20 = (undefined1 *)((long)local_20 + 8)) { uVar2 = gettext(*(long *)local_20); printf(" %s\n", uVar2); } uVar2 = gettext( "Exit status is 0 if inputs are the same, 1 if different, 2 if trouble."); uVar3 = gettext("If a FILE is \'-\' or missing, read standard input."); uVar4 = gettext("SKIP values may be followed by the following multiplicative " "suffixes:\nkB 1000, K 1024, MB 1,000,000, M 1,048,576,\nGB " "1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y."); printf("\n%s\n\n%s\n%s\n", uVar4, uVar3, uVar2); emit_bug_reporting_address(); return; }
diffutils
ghidra
static void ck_fclose(FILE *f) { if (fclose(f)) perror_fatal("fclose"); }
void ck_fclose(FILE *param_1) { int iVar1; iVar1 = fclose(param_1); if (iVar1 != 0) { perror_fatal("fclose"); } return; }
diffutils
ghidra
static error_t parse_opt(int key, char *arg, struct argp_state *state) { struct tar_args *args = state->input; switch (key) { case 0x1000003: if (state->root_argp->children) { int i; for (i = 0; state->root_argp->children[i].argp; i++) state->child_inputs[i] = state->input; } break; case 0: name_add_name(arg); break; case 'A': set_subcommand_option(CAT_SUBCOMMAND); break; case 'a': args->compress_autodetect = 1; break; case NO_AUTO_COMPRESS_OPTION: args->compress_autodetect = 0; break; case 'b': { uintmax_t u; if (!(xstrtoumax(arg, 0, 10, &u, "") == LONGINT_OK && u == (blocking_factor = u) && 0 < blocking_factor && u == (record_size = u * 512) / 512)) do { if (error_hook) error_hook(); error(0, 0, "%s: %s", quotearg_colon(arg), gettext("Invalid blocking factor")); usage(2); } while (0); } break; case 'B': read_full_records_option = 1; break; case 'c': set_subcommand_option(CREATE_SUBCOMMAND); break; case CLAMP_MTIME_OPTION: set_mtime_option = CLAMP_MTIME; break; case 'd': set_subcommand_option(DIFF_SUBCOMMAND); break; case 'F': info_script_option = arg; multi_volume_option = 1; break; case 'f': if (archive_names == allocated_archive_names) archive_name_array = x2nrealloc(archive_name_array, &allocated_archive_names, sizeof(archive_name_array[0])); archive_name_array[archive_names++] = arg; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': argp_error(state, gettext("Options '-[0-7][lmh]' not supported by *this* tar")); exit(64); break; case FULL_TIME_OPTION: full_time_option = 1; break; case 'g': optloc_save(OC_LISTED_INCREMENTAL, args->loc); listed_incremental_option = arg; after_date_option = 1; __attribute__((__fallthrough__)); case 'G': incremental_option = 1; break; case 'h': dereference_option = 1; break; case HARD_DEREFERENCE_OPTION: hard_dereference_option = 1; break; case 'i': ignore_zeros_option = 1; break; case 'j': set_use_compress_program_option("bzip2", args->loc); break; case 'J': set_use_compress_program_option("xz", args->loc); break; case 'k': set_old_files_option(KEEP_OLD_FILES, args->loc); break; case 'K': optloc_save(OC_STARTING_FILE, args->loc); add_starting_file(arg); break; case ONE_FILE_SYSTEM_OPTION: one_file_system_option = 1; break; case ONE_TOP_LEVEL_OPTION: optloc_save(OC_ONE_TOP_LEVEL, args->loc); one_top_level_option = 1; one_top_level_dir = arg; break; case 'l': check_links_option = 1; break; case 'L': { uintmax_t u; char *p; if (xstrtoumax(arg, &p, 10, &u, "bBcGgkKMmPTtw") != LONGINT_OK) do { if (error_hook) error_hook(); error(0, 0, "%s: %s", quotearg_colon(arg), gettext("Invalid tape length")); usage(2); } while (0); if (p > arg && !strchr("bBcGgkKMmPTtw", p[-1])) tape_length_option = 1024 * (tarlong)u; else tape_length_option = (tarlong)u; multi_volume_option = 1; } break; case LEVEL_OPTION: { char *p; incremental_level = strtoul(arg, &p, 10); if (*p) do { if (error_hook) error_hook(); error(0, 0, gettext("Invalid incremental level value")); usage(2); } while (0); } break; case LZIP_OPTION: set_use_compress_program_option("lzip", args->loc); break; case LZMA_OPTION: set_use_compress_program_option("lzma", args->loc); break; case LZOP_OPTION: set_use_compress_program_option("lzop", args->loc); break; case 'm': touch_option = 1; break; case 'M': multi_volume_option = 1; break; case MTIME_OPTION: get_date_or_file(args, "--mtime", arg, &mtime_option); if (set_mtime_option == USE_FILE_MTIME) set_mtime_option = FORCE_MTIME; break; case 'n': seek_option = 1; break; case NO_SEEK_OPTION: seek_option = 0; break; case 'N': after_date_option = 1; __attribute__((__fallthrough__)); case NEWER_MTIME_OPTION: if ((0 <= (newer_mtime_option).tv_nsec)) do { if (error_hook) error_hook(); error(0, 0, gettext("More than one threshold date")); usage(2); } while (0); get_date_or_file( args, key == NEWER_MTIME_OPTION ? "--newer-mtime" : "--after-date", arg, &newer_mtime_option); optloc_save(OC_NEWER, args->loc); break; case 'o': args->o_option = 1; break; case 'O': to_stdout_option = 1; break; case 'p': same_permissions_option = 1; break; case 'P': optloc_save(OC_ABSOLUTE_NAMES, args->loc); absolute_names_option = 1; break; case 'r': set_subcommand_option(APPEND_SUBCOMMAND); break; case 'R': block_number_option = 1; break; case 's': optloc_save(OC_SAME_ORDER, args->loc); same_order_option = 1; break; case 'S': sparse_option = 1; break; case SKIP_OLD_FILES_OPTION: set_old_files_option(SKIP_OLD_FILES, args->loc); break; case HOLE_DETECTION_OPTION: hole_detection = ((hole_detection_types)[__xargmatch_internal( "--hole-detection", arg, hole_detection_args, (void const *)(hole_detection_types), sizeof *(hole_detection_types), argmatch_die)]); sparse_option = 1; break; case SPARSE_VERSION_OPTION: sparse_option = 1; { char *p; tar_sparse_major = strtoul(arg, &p, 10); if (*p) { if (*p != '.') do { if (error_hook) error_hook(); error(0, 0, gettext("Invalid sparse version value")); usage(2); } while (0); tar_sparse_minor = strtoul(p + 1, &p, 10); if (*p) do { if (error_hook) error_hook(); error(0, 0, gettext("Invalid sparse version value")); usage(2); } while (0); } } break; case 't': set_subcommand_option(LIST_SUBCOMMAND); verbose_option++; break; case TEST_LABEL_OPTION: set_subcommand_option(TEST_LABEL_SUBCOMMAND); break; case TRANSFORM_OPTION: set_transform_expr(arg); break; case 'u': set_subcommand_option(UPDATE_SUBCOMMAND); break; case 'U': set_old_files_option(UNLINK_FIRST_OLD_FILES, args->loc); break; case UTC_OPTION: utc_option = 1; break; case 'V': volume_label_option = arg; break; case 'v': verbose_option++; warning_option |= (0x00002000 | 0x00001000 | 0x00080000 | 0x00100000 | 0x00400000); break; case 'w': interactive_option = 1; break; case 'W': optloc_save(OC_VERIFY, args->loc); verify_option = 1; break; case WARNING_OPTION: set_warning_option(arg); break; case 'x': set_subcommand_option(EXTRACT_SUBCOMMAND); break; case 'z': set_use_compress_program_option("gzip", args->loc); break; case 'Z': set_use_compress_program_option("compress", args->loc); break; case ZSTD_OPTION: set_use_compress_program_option("zstd", args->loc); break; case ATIME_PRESERVE_OPTION: atime_preserve_option = (arg ? ((atime_preserve_types)[__xargmatch_internal( "--atime-preserve", arg, atime_preserve_args, (void const *)(atime_preserve_types), sizeof *(atime_preserve_types), argmatch_die)]) : replace_atime_preserve); if (!01000000 && atime_preserve_option == system_atime_preserve) do { if (error_hook) error_hook(); error(0, 0, gettext("--atime-preserve='system' is not supported" " on this platform")); fatal_exit(); } while (0) ; break; case CHECK_DEVICE_OPTION: check_device_option = 1; break; case NO_CHECK_DEVICE_OPTION: check_device_option = 0; break; case CHECKPOINT_OPTION: if (arg) { char *p; if (*arg == '.') { checkpoint_compile_action("."); arg++; } checkpoint_option = strtoul(arg, &p, 0); if (*p) do { if (error_hook) error_hook(); error(0, 0, gettext("--checkpoint value is not an integer")); fatal_exit(); } while (0); } else checkpoint_option = 10; break; case CHECKPOINT_ACTION_OPTION: checkpoint_compile_action(arg); break; case BACKUP_OPTION: backup_option = 1; if (arg) args->version_control_string = arg; break; case DELAY_DIRECTORY_RESTORE_OPTION: delay_directory_restore_option = 1; break; case NO_DELAY_DIRECTORY_RESTORE_OPTION: delay_directory_restore_option = 0; break; case DELETE_OPTION: set_subcommand_option(DELETE_SUBCOMMAND); break; case FORCE_LOCAL_OPTION: force_local_option = 1; break; case 'H': set_archive_format(arg); break; case INDEX_FILE_OPTION: index_file_name = arg; break; case IGNORE_COMMAND_ERROR_OPTION: ignore_command_error_option = 1; break; case IGNORE_FAILED_READ_OPTION: ignore_failed_read_option = 1; break; case KEEP_DIRECTORY_SYMLINK_OPTION: keep_directory_symlink_option = 1; break; case KEEP_NEWER_FILES_OPTION: set_old_files_option(KEEP_NEWER_FILES, args->loc); break; case GROUP_OPTION: { uintmax_t u = parse_owner_group( arg, ((gid_t)(!(!((gid_t)0 < (gid_t)-1)) ? (gid_t)-1 : ((((gid_t)1 << ((sizeof(gid_t) * 8) - 2)) - 1) * 2 + 1))), &group_name_option); if (u == (18446744073709551615UL)) { group_option = -1; if (group_name_option) gname_to_gid(group_name_option, &group_option); } else group_option = u; } break; case GROUP_MAP_OPTION: group_map_read(arg); break; case MODE_OPTION: mode_option = mode_compile(arg); if (!mode_option) do { if (error_hook) error_hook(); error(0, 0, gettext("Invalid mode given on option")); fatal_exit(); } while (0); initial_umask = umask(0); umask(initial_umask); break; case NO_IGNORE_COMMAND_ERROR_OPTION: ignore_command_error_option = 0; break; case NO_OVERWRITE_DIR_OPTION: set_old_files_option(NO_OVERWRITE_DIR_OLD_FILES, args->loc); break; case NO_QUOTE_CHARS_OPTION: for (; *arg; arg++) set_char_quoting(((void *)0), *arg, 0); break; case NUMERIC_OWNER_OPTION: numeric_owner_option = 1; break; case OCCURRENCE_OPTION: optloc_save(OC_OCCURRENCE, args->loc); if (!arg) occurrence_option = 1; else { uintmax_t u; if (xstrtoumax(arg, 0, 10, &u, "") == LONGINT_OK) occurrence_option = u; else do { if (error_hook) error_hook(); error(0, 0, "%s: %s", quotearg_colon(arg), gettext("Invalid number")); fatal_exit(); } while (0); } break; case OLD_ARCHIVE_OPTION: set_archive_format("v7"); break; case OVERWRITE_DIR_OPTION: set_old_files_option(DEFAULT_OLD_FILES, args->loc); break; case OVERWRITE_OPTION: set_old_files_option(OVERWRITE_OLD_FILES, args->loc); break; case OWNER_OPTION: { uintmax_t u = parse_owner_group( arg, ((uid_t)(!(!((uid_t)0 < (uid_t)-1)) ? (uid_t)-1 : ((((uid_t)1 << ((sizeof(uid_t) * 8) - 2)) - 1) * 2 + 1))), &owner_name_option); if (u == (18446744073709551615UL)) { owner_option = -1; if (owner_name_option) uname_to_uid(owner_name_option, &owner_option); } else owner_option = u; } break; case OWNER_MAP_OPTION: owner_map_read(arg); break; case QUOTE_CHARS_OPTION: for (; *arg; arg++) set_char_quoting(((void *)0), *arg, 1); break; case QUOTING_STYLE_OPTION: tar_set_quoting_style(arg); break; case PAX_OPTION: { char *tmp = expand_pax_option(args, arg); args->pax_option = 1; xheader_set_option(tmp); free(tmp); } break; case POSIX_OPTION: set_archive_format("posix"); break; case RECORD_SIZE_OPTION: { uintmax_t u; if (!(xstrtoumax(arg, ((void *)0), 10, &u, "bBcGgkKMmPTtw") == LONGINT_OK && u == (size_t)u)) do { if (error_hook) error_hook(); error(0, 0, "%s: %s", quotearg_colon(arg), gettext("Invalid record size")); usage(2); } while (0); record_size = u; if (record_size % 512 != 0) do { if (error_hook) error_hook(); error(0, 0, gettext("Record size must be a multiple of %d."), 512); usage(2); } while (0); blocking_factor = record_size / 512; } break; case RECURSIVE_UNLINK_OPTION: recursive_unlink_option = 1; break; case REMOVE_FILES_OPTION: remove_files_option = 1; break; case RESTRICT_OPTION: restrict_option = 1; break; case RMT_COMMAND_OPTION: rmt_command = arg; break; case RSH_COMMAND_OPTION: rsh_command_option = arg; break; case SHOW_DEFAULTS_OPTION: { char *s = format_default_settings(); printf("%s\n", s); close_stdout(); free(s); exit(0); } case SHOW_SNAPSHOT_FIELD_RANGES_OPTION: show_snapshot_field_ranges(); close_stdout(); exit(0); case STRIP_COMPONENTS_OPTION: { uintmax_t u; if (!(xstrtoumax(arg, 0, 10, &u, "") == LONGINT_OK && u == (size_t)u)) do { if (error_hook) error_hook(); error(0, 0, "%s: %s", quotearg_colon(arg), gettext("Invalid number of elements")); usage(2); } while (0); strip_name_components = u; } break; case SHOW_OMITTED_DIRS_OPTION: show_omitted_dirs_option = 1; break; case SHOW_TRANSFORMED_NAMES_OPTION: show_transformed_names_option = 1; break; case SORT_OPTION: savedir_sort_order = ((sort_mode_flag)[__xargmatch_internal( "--sort", arg, sort_mode_arg, (void const *)(sort_mode_flag), sizeof *(sort_mode_flag), argmatch_die)]); break; case SUFFIX_OPTION: backup_option = 1; args->backup_suffix_string = arg; break; case TO_COMMAND_OPTION: if (to_command_option) do { if (error_hook) error_hook(); error(0, 0, gettext("Only one --to-command option allowed")); usage(2); } while (0); to_command_option = arg; break; case TOTALS_OPTION: if (arg) set_stat_signal(arg); else totals_option = 1; break; case 'I': set_use_compress_program_option(arg, args->loc); break; case VOLNO_FILE_OPTION: volno_file_option = arg; break; case NO_SAME_OWNER_OPTION: same_owner_option = -1; break; case NO_SAME_PERMISSIONS_OPTION: same_permissions_option = -1; break; case ACLS_OPTION: set_archive_format("posix"); acls_option = 1; break; case NO_ACLS_OPTION: acls_option = -1; break; case SELINUX_CONTEXT_OPTION: set_archive_format("posix"); selinux_context_option = 1; break; case NO_SELINUX_CONTEXT_OPTION: selinux_context_option = -1; break; case XATTR_OPTION: set_xattr_option(1); break; case NO_XATTR_OPTION: set_xattr_option(-1); break; case XATTR_INCLUDE: case XATTR_EXCLUDE: set_xattr_option(1); xattrs_mask_add(arg, (key == XATTR_INCLUDE)); break; case SAME_OWNER_OPTION: same_owner_option = 1; break; case 0x1000005: if (args->loc->source == OPTS_FILE) error(0, 0, gettext("%s:%lu: location of the error"), args->loc->name, (unsigned long)args->loc->line); else if (args->loc->source == OPTS_ENVIRON) error(0, 0, gettext("error parsing %s"), args->loc->name); exit(64); default: return 7; } return 0; }
long parse_opt(long a1, char *a2, const struct argp_state *a3) { char *v3; const char *v4; long v5; char *v6; char *v7; const char *v8; double v9; double v10; char *v11; char *v12; const char *v13; char *v14; char *v15; char *v16; int v17; char *v18; char *v19; char *v20; const char *v21; char *v22; const char *v23; char *v24; char *v25; const char *v26; char *v27; long v28; long v29; char *v30; long v31; char *v32; char *nptr; int i; unsigned long v37; char *endptr; long *input; void *v40; void *ptr; unsigned long v42; unsigned long v43; unsigned long v44; nptr = a2; v44 = __readfsqword(0x28u); input = (long *)a3->input; if ((_DWORD)a1 == 16777221) { if (*(_DWORD *)*input == 2) { v28 = *(_QWORD *)(*input + 16); v29 = *(_QWORD *)(*input + 8); v30 = gettext("%s:%lu: location of the error"); error(0, 0, v30, v29, v28); } else if (!*(_DWORD *)*input) { v31 = *(_QWORD *)(*input + 8); v32 = gettext("error parsing %s"); error(0, 0, v32, v31); } exit(64); } if ((int)a1 > 16777221) return 7LL; if ((int)a1 > 207) { if ((_DWORD)a1 == 16777219) { if (a3->root_argp->children) { for (i = 0; a3->root_argp->children[i].argp; ++i) a3->child_inputs[i] = a3->input; } return 0LL; } return 7LL; } if ((int)a1 < 0) return 7LL; switch ((int)a1) { case 0: name_add_name(a2); return 0LL; case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: v6 = gettext("Options '-[0-7][lmh]' not supported by *this* tar"); argp_error(a3, v6); exit(64); case 65: set_subcommand_option(2LL); return 0LL; case 66: read_full_records_option = 1; return 0LL; case 70: info_script_option = (long)a2; multi_volume_option = 1; return 0LL; case 71: goto LABEL_34; case 72: set_archive_format(a2); return 0LL; case 73: set_use_compress_program_option(a2, *input); return 0LL; case 74: set_use_compress_program_option("xz", *input); return 0LL; case 75: optloc_save(5u, *input); add_starting_file(a2); return 0LL; case 76: if ((unsigned int)xstrtoumax(a2, &endptr, 10LL, &v37, "bBcGgkKMmPTtw")) { if (error_hook) error_hook(a2); v7 = gettext("Invalid tape length"); v8 = (const char *)quotearg_colon(a2); error(0, 0, "%s: %s", v8, v7); usage(2); } if (a2 >= endptr || strchr("bBcGgkKMmPTtw", *(endptr - 1))) { if ((v37 & 0x8000000000000000LL) != 0LL) v10 = (double)(int)(v37 & 1 | (v37 >> 1)) + (double)(int)(v37 & 1 | (v37 >> 1)); else v10 = (double)(int)v37; tape_length_option = *(_QWORD *)&v10; } else { if ((v37 & 0x8000000000000000LL) != 0LL) v9 = (double)(int)(v37 & 1 | (v37 >> 1)) + (double)(int)(v37 & 1 | (v37 >> 1)); else v9 = (double)(int)v37; *(double *)&tape_length_option = v9 * 1024.0; } multi_volume_option = 1; return 0LL; case 77: multi_volume_option = 1; return 0LL; case 78: after_date_option = 1; goto LABEL_74; case 79: to_stdout_option = 1; return 0LL; case 80: optloc_save(8u, *input); absolute_names_option = 1; return 0LL; case 82: block_number_option = 1; return 0LL; case 83: sparse_option = 1; return 0LL; case 85: set_old_files_option(3, *input); return 0LL; case 86: volume_label_option = a2; return 0LL; case 87: optloc_save(4u, *input); verify_option = 1; return 0LL; case 90: set_use_compress_program_option("compress", *input); return 0LL; case 97: *((_BYTE *)input + 18) = 1; return 0LL; case 98: if ((unsigned int)xstrtoumax(a2, 0LL, 10LL, &endptr, &locale) || (blocking_factor = (int)endptr, (char *)(int)endptr != endptr) || blocking_factor <= 0 || (record_size = (_QWORD)endptr << 9, (char *)((unsigned long)endptr & 0x7FFFFFFFFFFFFFLL) != endptr)) { if (error_hook) error_hook(a2); v3 = gettext("Invalid blocking factor"); v4 = (const char *)quotearg_colon(a2); error(0, 0, "%s: %s", v4, v3); usage(2); } return 0LL; case 99: set_subcommand_option(3LL); return 0LL; case 100: set_subcommand_option(5LL); return 0LL; case 102: if (archive_names == allocated_archive_names) archive_name_array = (void *)x2nrealloc(archive_name_array, &allocated_archive_names, 8LL); v5 = archive_names++; *((_QWORD *)archive_name_array + v5) = a2; return 0LL; case 103: optloc_save(2u, *input); listed_incremental_option = (long)a2; after_date_option = 1; LABEL_34: incremental_option = 1; return 0LL; case 104: dereference_option = 1; return 0LL; case 105: ignore_zeros_option = 1; return 0LL; case 106: set_use_compress_program_option("bzip2", *input); return 0LL; case 107: set_old_files_option(4, *input); return 0LL; case 108: check_links_option = 1; return 0LL; case 109: touch_option = 1; return 0LL; case 110: seek_option = 1; return 0LL; case 111: *((_BYTE *)input + 16) = 1; return 0LL; case 112: same_permissions_option = 1; return 0LL; case 114: set_subcommand_option(1LL); return 0LL; case 115: optloc_save(6u, *input); same_order_option = 1; return 0LL; case 116: set_subcommand_option(7LL); ++verbose_option; return 0LL; case 117: set_subcommand_option(8LL); return 0LL; case 118: ++verbose_option; warning_option |= 0x583000u; return 0LL; case 119: interactive_option = 1; return 0LL; case 120: set_subcommand_option(6LL); return 0LL; case 122: set_use_compress_program_option("gzip", *input); return 0LL; case 128: set_archive_format("posix"); acls_option = 1; return 0LL; case 129: if (a2) v17 = atime_preserve_types[_xargmatch_internal( "--atime-preserve", a2, atime_preserve_args, atime_preserve_types, 4LL, argmatch_die)]; else v17 = 1; atime_preserve_option = v17; return 0LL; case 130: backup_option = 1; if (a2) input[4] = (long)a2; return 0LL; case 131: check_device_option = 1; return 0LL; case 132: if (!a2) goto LABEL_129; if (*a2 == 46) { checkpoint_compile_action("."); nptr = a2 + 1; } checkpoint_option = strtoul(nptr, &endptr, 0); if (*endptr) { if (error_hook) error_hook(nptr); v18 = gettext("--checkpoint value is not an integer"); error(0, 0, v18); fatal_exit(); LABEL_129: checkpoint_option = 10; } break; case 133: checkpoint_compile_action(a2); return 0LL; case 134: set_mtime_option = 2; return 0LL; case 135: delay_directory_restore_option = 1; return 0LL; case 136: hard_dereference_option = 1; return 0LL; case 137: set_subcommand_option(4LL); return 0LL; case 138: force_local_option = 1; return 0LL; case 139: full_time_option = 1; return 0LL; case 140: v43 = parse_owner_group(a2, 0xFFFFFFFFuLL, (const char **)&group_name_option); if (v43 == -1LL) { group_option = -1; if (group_name_option) gname_to_gid(group_name_option, &group_option); } else { group_option = v43; } return 0LL; case 141: group_map_read(a2); return 0LL; case 142: ignore_command_error_option = 1; return 0LL; case 143: ignore_failed_read_option = 1; return 0LL; case 144: index_file_name = a2; return 0LL; case 145: keep_directory_symlink_option = 1; return 0LL; case 146: set_old_files_option(6, *input); return 0LL; case 147: incremental_level = strtoul(a2, &endptr, 10); if (*endptr) { if (error_hook) error_hook(a2); v11 = gettext("Invalid incremental level value"); error(0, 0, v11); usage(2); } return 0LL; case 148: set_use_compress_program_option("lzip", *input); return 0LL; case 149: set_use_compress_program_option("lzma", *input); return 0LL; case 150: set_use_compress_program_option("lzop", *input); return 0LL; case 151: mode_option = mode_compile(a2); if (!mode_option) { if (error_hook) error_hook(a2); v19 = gettext("Invalid mode given on option"); error(0, 0, v19); fatal_exit(); } initial_umask = umask(0); umask(initial_umask); return 0LL; case 152: get_date_or_file((long)input, (long)"--mtime", a2, mtime_option); if (!set_mtime_option) set_mtime_option = 1; return 0LL; case 153: LABEL_74: if (newer_mtime_option[1] >= 0) { if (error_hook) error_hook(a1); v12 = gettext("More than one threshold date"); error(0, 0, v12); usage(2); } if ((_DWORD)a1 == 153) v13 = "--newer-mtime"; else v13 = "--after-date"; get_date_or_file((long)input, (long)v13, a2, newer_mtime_option); optloc_save(3u, *input); return 0LL; case 154: acls_option = -1; return 0LL; case 155: *((_BYTE *)input + 18) = 0; return 0LL; case 156: check_device_option = 0; return 0LL; case 157: delay_directory_restore_option = 0; return 0LL; case 158: ignore_command_error_option = 0; return 0LL; case 159: set_old_files_option(1, *input); return 0LL; case 160: while (*nptr) set_char_quoting(0LL, (unsigned int)*nptr++, 0LL); return 0LL; case 161: same_owner_option = -1; return 0LL; case 162: same_permissions_option = -1; return 0LL; case 163: seek_option = 0; return 0LL; case 164: selinux_context_option = -1; return 0LL; case 165: set_xattr_option(-1); return 0LL; case 166: numeric_owner_option = 1; return 0LL; case 167: optloc_save(1u, *input); if (a2) { if ((unsigned int)xstrtoumax(a2, 0LL, 10LL, &endptr, &locale)) { if (error_hook) error_hook(a2); v20 = gettext("Invalid number"); v21 = (const char *)quotearg_colon(a2); error(0, 0, "%s: %s", v21, v20); fatal_exit(); LABEL_166: set_archive_format("v7"); } else { occurrence_option = (long)endptr; } } else { occurrence_option = 1LL; } break; case 168: goto LABEL_166; case 169: one_file_system_option = 1; return 0LL; case 170: optloc_save(7u, *input); one_top_level_option = 1; one_top_level_dir = (long)a2; return 0LL; case 171: set_old_files_option(0, *input); return 0LL; case 172: set_old_files_option(2, *input); return 0LL; case 173: v42 = parse_owner_group(a2, 0xFFFFFFFFuLL, (const char **)&owner_name_option); if (v42 == -1LL) { owner_option = -1; if (owner_name_option) uname_to_uid(owner_name_option, &owner_option); } else { owner_option = v42; } return 0LL; case 174: owner_map_read(a2); return 0LL; case 175: ptr = (void *)expand_pax_option((long)input, a2); *((_BYTE *)input + 17) = 1; xheader_set_option(ptr); free(ptr); return 0LL; case 176: set_archive_format("posix"); return 0LL; case 177: while (*nptr) set_char_quoting(0LL, (unsigned int)*nptr++, 1LL); return 0LL; case 178: tar_set_quoting_style(a2); return 0LL; case 179: if ((unsigned int)xstrtoumax(a2, 0LL, 10LL, &endptr, "bBcGgkKMmPTtw")) { if (error_hook) error_hook(a2); v22 = gettext("Invalid record size"); v23 = (const char *)quotearg_colon(a2); error(0, 0, "%s: %s", v23, v22); usage(2); } record_size = (long)endptr; if (((unsigned short)endptr & 0x1FF) != 0) { if (error_hook) error_hook(a2); v24 = gettext("Record size must be a multiple of %d."); error(0, 0, v24, 512LL); usage(2); } blocking_factor = (unsigned long)record_size >> 9; return 0LL; case 180: recursive_unlink_option = 1; return 0LL; case 181: remove_files_option = 1; return 0LL; case 182: restrict_option = 1; return 0LL; case 183: rmt_command = a2; return 0LL; case 184: rsh_command_option = (long)a2; return 0LL; case 185: same_owner_option = 1; return 0LL; case 186: set_archive_format("posix"); selinux_context_option = 1; return 0LL; case 187: v40 = (void *)format_default_settings(); printf("%s\n", (const char *)v40); close_stdout(); free(v40); exit(0); case 188: show_omitted_dirs_option = 1; return 0LL; case 189: show_snapshot_field_ranges(); close_stdout(); exit(0); case 190: show_transformed_names_option = 1; return 0LL; case 191: set_old_files_option(5, *input); return 0LL; case 192: savedir_sort_order = sort_mode_flag[_xargmatch_internal( "--sort", a2, sort_mode_arg, sort_mode_flag, 4LL, argmatch_die)]; return 0LL; case 193: hole_detection = hole_detection_types[_xargmatch_internal( "--hole-detection", a2, hole_detection_args, hole_detection_types, 4LL, argmatch_die)]; sparse_option = 1; return 0LL; case 194: sparse_option = 1; tar_sparse_major = strtoul(a2, &endptr, 10); if (*endptr) { if (*endptr != 46) { if (error_hook) error_hook(a2); v14 = gettext("Invalid sparse version value"); error(0, 0, v14); usage(2); } v15 = endptr + 1; tar_sparse_minor = strtoul(endptr + 1, &endptr, 10); if (*endptr) { if (error_hook) error_hook(v15); v16 = gettext("Invalid sparse version value"); error(0, 0, v16); usage(2); } } return 0LL; case 195: if ((unsigned int)xstrtoumax(a2, 0LL, 10LL, &endptr, &locale)) { if (error_hook) error_hook(a2); v25 = gettext("Invalid number of elements"); v26 = (const char *)quotearg_colon(a2); error(0, 0, "%s: %s", v26, v25); usage(2); } strip_name_components = (long)endptr; return 0LL; case 196: backup_option = 1; input[3] = (long)a2; return 0LL; case 197: set_subcommand_option(9LL); return 0LL; case 198: if (a2) set_stat_signal(a2); else totals_option = 1; return 0LL; case 199: if (to_command_option) { if (error_hook) error_hook(a1); v27 = gettext("Only one --to-command option allowed"); error(0, 0, v27); usage(2); } to_command_option = (long)a2; return 0LL; case 200: set_transform_expr(a2); return 0LL; case 201: utc_option = 1; return 0LL; case 202: volno_file_option = (long)a2; return 0LL; case 203: set_warning_option(a2); return 0LL; case 204: set_xattr_option(1); return 0LL; case 205: case 206: set_xattr_option(1); xattrs_mask_add(a2, (_DWORD)a1 == 206); return 0LL; case 207: set_use_compress_program_option("zstd", *input); return 0LL; default: return 7LL; } return 0LL; }
tar
ida
static void wait_proc(pid_t pid) { if (delete_proc(pid)) reap(pid); }
void wait_proc(unsigned long a0) { unsigned long long v2; if (delete_proc(a0)) { v2 = reap(a0); return; } return; }
coreutils
angr_sailr
static void chopslash(char *str) { char *p = str + strlen(str) - 1; while (p > str && ((*p) == '/')) *p-- = '\0'; }
long long chopslash(char *a0) { char *v0; char *v3; char *v4; v0 = &a0[1 + strlen(a0)]; while (true) { v3 = v0; if (v0 <= a0) break; v3 = *(v0); if (*(v0) != 47) break; v4 = v0; v0 += 1; *(v4) = 0; } return v3; }
tar
angr_phoenix
(r = sshpkt_put_string(ssh, sig, siglen)) != 0 || (r = sshpkt_send(ssh)) != 0) { sshlog("sshconnect2.c", __func__, 2275, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "packet error"); goto out; }
void sshpkt_put_string(void) { halt_baddata(); }
openssh-portable
ghidra
char *ansicstr(string, len, flags, sawc, rlen) char *string; int len, flags, *sawc, *rlen; { int c, temp; char *ret, *r, *s; unsigned long v; size_t clen; int b, mb_cur_max; wchar_t wc; if (string == 0 || *string == '\0') return ((char *)((void *)0)); mb_cur_max = (__ctype_get_mb_cur_max()); temp = 4 * len + 4; if (temp < 12) temp = 12; ret = (char *)sh_xmalloc((temp), "strtrans.c", 72); for (r = ret, s = string; s && *s;) { c = *s++; if (c != '\\' || *s == '\0') { clen = 1; if ((locale_utf8locale && (c & 0x80)) || (locale_utf8locale == 0 && mb_cur_max > 0 && is_basic(c) == 0)) { clen = mbrtowc(&wc, s - 1, mb_cur_max, 0); if (((clen) == (size_t)-1 || (clen) == (size_t)-2)) clen = 1; } *r++ = c; for (--clen; clen > 0; clen--) *r++ = *s++; } else { switch (c = *s++) { case 'a': c = '\a'; break; case 'v': c = '\v'; break; case 'b': c = '\b'; break; case 'e': case 'E': c = '\033'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': if (flags & 1) { *r++ = '\\'; break; } case '0': temp = 2 + ((flags & 1) && (c == '0')); for (c -= '0'; ((*s) >= '0' && (*s) <= '7') && temp--; s++) c = (c * 8) + ((*s) - '0'); c &= 0xFF; break; case 'x': if ((flags & 2) && *s == '{') { flags |= 16; s++; } for (temp = 2, c = 0; (1 && ((*__ctype_b_loc())[(int)(((unsigned char)(unsigned char)*s))] & (unsigned short int)_ISxdigit)) && temp--; s++) c = (c * 16) + (((*s) >= 'a' && (*s) <= 'f') ? (*s) - 'a' + 10 : (*s) >= 'A' && (*s) <= 'F' ? (*s) - 'A' + 10 : (*s) - '0'); if (flags & 16) { for (; (1 && ((*__ctype_b_loc())[(int)(((unsigned char)(unsigned char)*s))] & (unsigned short int)_ISxdigit)); s++) c = (c * 16) + (((*s) >= 'a' && (*s) <= 'f') ? (*s) - 'a' + 10 : (*s) >= 'A' && (*s) <= 'F' ? (*s) - 'A' + 10 : (*s) - '0'); flags &= ~16; if (*s == '}') s++; } else if (temp == 2) { *r++ = '\\'; c = 'x'; } c &= 0xFF; break; case 'u': case 'U': temp = (c == 'u') ? 4 : 8; for (v = 0; (1 && ((*__ctype_b_loc())[(int)(((unsigned char)(unsigned char)*s))] & (unsigned short int)_ISxdigit)) && temp--; s++) v = (v * 16) + (((*s) >= 'a' && (*s) <= 'f') ? (*s) - 'a' + 10 : (*s) >= 'A' && (*s) <= 'F' ? (*s) - 'A' + 10 : (*s) - '0'); if (temp == ((c == 'u') ? 4 : 8)) { *r++ = '\\'; break; } else if (v <= 0x7f) { c = v; break; } else { temp = u32cconv(v, r); r += temp; continue; } case '\\': break; case '\'': case '"': case '?': if (flags & 1) *r++ = '\\'; break; case 'c': if (sawc) { *sawc = 1; *r = '\0'; if (rlen) *rlen = r - ret; return ret; } else if ((flags & 1) == 0 && *s == 0) ; else if ((flags & 1) == 0 && (c = *s)) { s++; if ((flags & 2) && c == '\\' && c == *s) s++; c = ((c) == '?' ? 0x7f : (((1 && ((*__ctype_b_loc())[(int)(((unsigned char)c))] & (unsigned short int)_ISlower)) ? toupper(c) : (c)) & 0x1f)); break; } default: if ((flags & 4) == 0) *r++ = '\\'; break; } if ((flags & 2) && (c == '\001' || c == '\177')) *r++ = '\001'; *r++ = c; } } *r = '\0'; if (rlen) *rlen = r - ret; return ret; }
char *ansicstr(char *a1, int a2, int a3, _DWORD *a4, _DWORD *a5) { char *v6; char *v7; char *v8; char *v9; char *v10; char *v11; _BOOL4 v12; int v14; int v16; char *v17; int v18; long v19; int v21; char *v22; char *v23; int v24; char *v25; char *v26; char *v27; wchar_t pwc; int c; int v33; int mb_cur_max; char *v35; char *v36; unsigned long v37; size_t v38; char *v39; unsigned long v40; v40 = __readfsqword(0x28u); if (!a1 || !*a1) return 0LL; mb_cur_max = _ctype_get_mb_cur_max(); v33 = 4 * (a2 + 1); if (v33 <= 11) v33 = 12; v39 = (char *)sh_xmalloc(v33, "strtrans.c", 72LL); v35 = v39; v36 = a1; while (1) { LABEL_120: if (!v36 || !*v36) { *v35 = 0; if (a5) *a5 = (_DWORD)v35 - (_DWORD)v39; return v39; } v6 = v36++; c = *v6; if (c == 92) { if (*v36) break; } v38 = 1LL; if (locale_utf8locale && (c & 0x80) != 0 || !locale_utf8locale && mb_cur_max > 0 && !(unsigned int)is_basic(c)) { v38 = mbrtowc(&pwc, v36 - 1, mb_cur_max, 0LL); if (v38 >= 0xFFFFFFFFFFFFFFFELL) v38 = 1LL; } v7 = v35++; *v7 = c; --v38; while (v38) { v8 = v36++; v9 = v35++; *v9 = *v8; --v38; } } v10 = v36++; c = *v10; switch (c) { case '"': case '\'': case '?': if ((a3 & 1) != 0) { v23 = v35++; *v23 = 92; } goto LABEL_115; case '0': goto LABEL_31; case '1': case '2': case '3': case '4': case '5': case '6': case '7': if ((a3 & 1) != 0) { v11 = v35++; *v11 = 92; } else { LABEL_31: v12 = (a3 & 1) != 0 && c == 48; v33 = v12 + 2; c -= 48; while (*v36 > 47) { if (*v36 > 55) break; if (!v33--) break; c = 8 * c + *v36++ - 48; } c = (unsigned char)c; } goto LABEL_115; case 'E': case 'e': c = 27; goto LABEL_115; case 'U': case 'u': if (c == 117) v18 = 4; else v18 = 8; v33 = v18; v37 = 0LL; while (((*_ctype_b_loc())[(unsigned char)*v36] & 0x1000) != 0) { if (!v33--) break; if (*v36 <= 96 || *v36 > 102) { if (*v36 <= 64 || *v36 > 70) v19 = *v36 - 48; else v19 = *v36 - 55; } else { v19 = *v36 - 87; } v37 = 16 * v37 + v19; ++v36; } if (c == 117) v21 = 4; else v21 = 8; if (v21 == v33) { v22 = v35++; *v22 = 92; goto LABEL_115; } if (v37 <= 0x7F) { c = v37; goto LABEL_115; } v33 = u32cconv(v37, v35); v35 += v33; goto LABEL_120; case '\\': goto LABEL_115; case 'a': c = 7; goto LABEL_115; case 'b': c = 8; goto LABEL_115; case 'c': if (!a4) { if (((a3 & 1) != 0 || *v36) && (a3 & 1) == 0 && (c = *v36) != 0) { ++v36; if ((a3 & 2) != 0 && c == 92 && *v36 == 92) ++v36; if (c == 63) { v24 = 127; } else if (((*_ctype_b_loc())[(unsigned char)c] & 0x200) != 0) { v24 = toupper(c) & 0x1F; } else { v24 = c & 0x1F; } c = v24; } else { LABEL_113: if ((a3 & 4) == 0) { v25 = v35++; *v25 = 92; } } LABEL_115: if ((a3 & 2) != 0 && (c == 1 || c == 127)) { v26 = v35++; *v26 = 1; } v27 = v35++; *v27 = c; goto LABEL_120; } *a4 = 1; *v35 = 0; if (a5) *a5 = (_DWORD)v35 - (_DWORD)v39; return v39; case 'f': c = 12; goto LABEL_115; case 'n': c = 10; goto LABEL_115; case 'r': c = 13; goto LABEL_115; case 't': c = 9; goto LABEL_115; case 'v': c = 11; goto LABEL_115; case 'x': if ((a3 & 2) != 0 && *v36 == 123) { a3 |= 0x10u; ++v36; } v33 = 2; c = 0; while (((*_ctype_b_loc())[(unsigned char)*v36] & 0x1000) != 0) { if (!v33--) break; if (*v36 <= 96 || *v36 > 102) { if (*v36 <= 64 || *v36 > 70) v14 = *v36 - 48; else v14 = *v36 - 55; } else { v14 = *v36 - 87; } c = 16 * c + v14; ++v36; } if ((a3 & 0x10) != 0) { while (((*_ctype_b_loc())[(unsigned char)*v36] & 0x1000) != 0) { if (*v36 <= 96 || *v36 > 102) { if (*v36 <= 64 || *v36 > 70) v16 = *v36 - 48; else v16 = *v36 - 55; } else { v16 = *v36 - 87; } c = 16 * c + v16; ++v36; } a3 &= ~0x10u; if (*v36 == 125) ++v36; } else if (v33 == 2) { v17 = v35++; *v17 = 92; c = 120; } c = (unsigned char)c; goto LABEL_115; default: goto LABEL_113; } }
bash
ida
int inflateBack(strm, in, in_desc, out, out_desc) z_streamp strm; in_func in; void *in_desc; out_func out; void *out_desc; { struct inflate_state *state; unsigned char *next; unsigned char *put; unsigned have, left; unsigned long hold; unsigned bits; unsigned copy; unsigned char *from; code here; code last; unsigned len; int ret; static const unsigned short order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; if (strm == 0 || strm->state == 0) return (-2); state = (struct inflate_state *)strm->state; strm->msg = 0; state->mode = TYPE; state->last = 0; state->whave = 0; next = strm->next_in; have = next != 0 ? strm->avail_in : 0; hold = 0; bits = 0; put = state->window; left = state->wsize; for (;;) switch (state->mode) { case TYPE: if (state->last) { do { hold >>= bits & 7; bits -= bits & 7; } while (0); state->mode = DONE; break; } do { while (bits < (unsigned)(3)) do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } while (0); state->last = ((unsigned)hold & ((1U << (1)) - 1)); do { hold >>= (1); bits -= (unsigned)(1); } while (0); switch (((unsigned)hold & ((1U << (2)) - 1))) { case 0: ; state->mode = STORED; break; case 1: fixedtables(state); ; state->mode = LEN; break; case 2: ; state->mode = TABLE; break; case 3: strm->msg = (char *)"invalid block type"; state->mode = BAD; } do { hold >>= (2); bits -= (unsigned)(2); } while (0); break; case STORED: do { hold >>= bits & 7; bits -= bits & 7; } while (0); do { while (bits < (unsigned)(32)) do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } while (0); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { strm->msg = (char *)"invalid stored block lengths"; state->mode = BAD; break; } state->length = (unsigned)hold & 0xffff; ; do { hold = 0; bits = 0; } while (0); while (state->length != 0) { copy = state->length; do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); do { if (left == 0) { put = state->window; left = state->wsize; state->whave = left; if (out(out_desc, put, left)) { ret = (-5); goto inf_leave; } } } while (0); if (copy > have) copy = have; if (copy > left) copy = left; memcpy(put, next, copy); have -= copy; next += copy; left -= copy; put += copy; state->length -= copy; }; state->mode = TYPE; break; case TABLE: do { while (bits < (unsigned)(14)) do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } while (0); state->nlen = ((unsigned)hold & ((1U << (5)) - 1)) + 257; do { hold >>= (5); bits -= (unsigned)(5); } while (0); state->ndist = ((unsigned)hold & ((1U << (5)) - 1)) + 1; do { hold >>= (5); bits -= (unsigned)(5); } while (0); state->ncode = ((unsigned)hold & ((1U << (4)) - 1)) + 4; do { hold >>= (4); bits -= (unsigned)(4); } while (0); if (state->nlen > 286 || state->ndist > 30) { strm->msg = (char *)"too many length or distance symbols"; state->mode = BAD; break; } ; state->have = 0; while (state->have < state->ncode) { do { while (bits < (unsigned)(3)) do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } while (0); state->lens[order[state->have++]] = (unsigned short)((unsigned)hold & ((1U << (3)) - 1)); do { hold >>= (3); bits -= (unsigned)(3); } while (0); } while (state->have < 19) state->lens[order[state->have++]] = 0; state->next = state->codes; state->lencode = (code const *)(state->next); state->lenbits = 7; ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid code lengths set"; state->mode = BAD; break; }; state->have = 0; while (state->have < state->nlen + state->ndist) { for (;;) { here = state->lencode[((unsigned)hold & ((1U << (state->lenbits)) - 1))]; if ((unsigned)(here.bits) <= bits) break; do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } if (here.val < 16) { do { hold >>= (here.bits); bits -= (unsigned)(here.bits); } while (0); state->lens[state->have++] = here.val; } else { if (here.val == 16) { do { while (bits < (unsigned)(here.bits + 2)) do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } while (0); do { hold >>= (here.bits); bits -= (unsigned)(here.bits); } while (0); if (state->have == 0) { strm->msg = (char *)"invalid bit length repeat"; state->mode = BAD; break; } len = (unsigned)(state->lens[state->have - 1]); copy = 3 + ((unsigned)hold & ((1U << (2)) - 1)); do { hold >>= (2); bits -= (unsigned)(2); } while (0); } else if (here.val == 17) { do { while (bits < (unsigned)(here.bits + 3)) do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } while (0); do { hold >>= (here.bits); bits -= (unsigned)(here.bits); } while (0); len = 0; copy = 3 + ((unsigned)hold & ((1U << (3)) - 1)); do { hold >>= (3); bits -= (unsigned)(3); } while (0); } else { do { while (bits < (unsigned)(here.bits + 7)) do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } while (0); do { hold >>= (here.bits); bits -= (unsigned)(here.bits); } while (0); len = 0; copy = 11 + ((unsigned)hold & ((1U << (7)) - 1)); do { hold >>= (7); bits -= (unsigned)(7); } while (0); } if (state->have + copy > state->nlen + state->ndist) { strm->msg = (char *)"invalid bit length repeat"; state->mode = BAD; break; } while (copy--) state->lens[state->have++] = (unsigned short)len; } } if (state->mode == BAD) break; if (state->lens[256] == 0) { strm->msg = (char *)"invalid code -- missing end-of-block"; state->mode = BAD; break; } state->next = state->codes; state->lencode = (code const *)(state->next); state->lenbits = 9; ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid literal/lengths set"; state->mode = BAD; break; } state->distcode = (code const *)(state->next); state->distbits = 6; ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); if (ret) { strm->msg = (char *)"invalid distances set"; state->mode = BAD; break; }; state->mode = LEN; case LEN: if (have >= 6 && left >= 258) { do { strm->next_out = put; strm->avail_out = left; strm->next_in = next; strm->avail_in = have; state->hold = hold; state->bits = bits; } while (0); if (state->whave < state->wsize) state->whave = state->wsize - left; inflate_fast(strm, state->wsize); do { put = strm->next_out; left = strm->avail_out; next = strm->next_in; have = strm->avail_in; hold = state->hold; bits = state->bits; } while (0); break; } for (;;) { here = state->lencode[((unsigned)hold & ((1U << (state->lenbits)) - 1))]; if ((unsigned)(here.bits) <= bits) break; do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } if (here.op && (here.op & 0xf0) == 0) { last = here; for (;;) { here = state ->lencode[last.val + (((unsigned)hold & ((1U << (last.bits + last.op)) - 1)) >> last.bits)]; if ((unsigned)(last.bits + here.bits) <= bits) break; do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } do { hold >>= (last.bits); bits -= (unsigned)(last.bits); } while (0); } do { hold >>= (here.bits); bits -= (unsigned)(here.bits); } while (0); state->length = (unsigned)here.val; if (here.op == 0) { ; do { if (left == 0) { put = state->window; left = state->wsize; state->whave = left; if (out(out_desc, put, left)) { ret = (-5); goto inf_leave; } } } while (0); *put++ = (unsigned char)(state->length); left--; state->mode = LEN; break; } if (here.op & 32) { ; state->mode = TYPE; break; } if (here.op & 64) { strm->msg = (char *)"invalid literal/length code"; state->mode = BAD; break; } state->extra = (unsigned)(here.op) & 15; if (state->extra != 0) { do { while (bits < (unsigned)(state->extra)) do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } while (0); state->length += ((unsigned)hold & ((1U << (state->extra)) - 1)); do { hold >>= (state->extra); bits -= (unsigned)(state->extra); } while (0); }; for (;;) { here = state->distcode[((unsigned)hold & ((1U << (state->distbits)) - 1))]; if ((unsigned)(here.bits) <= bits) break; do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } if ((here.op & 0xf0) == 0) { last = here; for (;;) { here = state->distcode[last.val + (((unsigned)hold & ((1U << (last.bits + last.op)) - 1)) >> last.bits)]; if ((unsigned)(last.bits + here.bits) <= bits) break; do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } do { hold >>= (last.bits); bits -= (unsigned)(last.bits); } while (0); } do { hold >>= (here.bits); bits -= (unsigned)(here.bits); } while (0); if (here.op & 64) { strm->msg = (char *)"invalid distance code"; state->mode = BAD; break; } state->offset = (unsigned)here.val; state->extra = (unsigned)(here.op) & 15; if (state->extra != 0) { do { while (bits < (unsigned)(state->extra)) do { do { if (have == 0) { have = in(in_desc, &next); if (have == 0) { next = 0; ret = (-5); goto inf_leave; } } } while (0); have--; hold += (unsigned long)(*next++) << bits; bits += 8; } while (0); } while (0); state->offset += ((unsigned)hold & ((1U << (state->extra)) - 1)); do { hold >>= (state->extra); bits -= (unsigned)(state->extra); } while (0); } if (state->offset > state->wsize - (state->whave < state->wsize ? left : 0)) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; }; do { do { if (left == 0) { put = state->window; left = state->wsize; state->whave = left; if (out(out_desc, put, left)) { ret = (-5); goto inf_leave; } } } while (0); copy = state->wsize - state->offset; if (copy < left) { from = put + copy; copy = left - copy; } else { from = put - state->offset; copy = left; } if (copy > state->length) copy = state->length; state->length -= copy; left -= copy; do { *put++ = *from++; } while (--copy); } while (state->length != 0); break; case DONE: ret = 1; goto inf_leave; case BAD: ret = (-3); goto inf_leave; default: ret = (-2); goto inf_leave; } inf_leave: if (left < state->wsize) { if (out(out_desc, state->window, state->wsize - left) && ret == 1) ret = (-5); } strm->next_in = next; strm->avail_in = have; return ret; }
long long inflateBack(struct_0 *a0, unsigned long long a1, unsigned long long a2, unsigned long long a3, unsigned long long a4) { unsigned int v0; int tmp_30; int tmp_40; int tmp_18; int tmp_68; int tmp_16; int tmp_21; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned int v5; unsigned int v6; unsigned int v7; void *v8; char *v9; void *v10; char *v11; struct_2 *v12; unsigned long long v14; unsigned long v15; unsigned long v18; unsigned long v20; unsigned long v22; unsigned long long v23; unsigned long v29; unsigned long v31; unsigned long long v32; unsigned long v34; unsigned long v36; unsigned long v38; unsigned long v40; void *v41; unsigned long long v42; char *v43; if (a0 && a0->field_38) { v12 = a0->field_38; a0->field_30 = 0; v12->field_8 = 16191; v12->field_c = 0; v12->field_40 = 0; v8 = a0->field_0; if (v8) v15 = a0->field_8; else v15 = 0; v0 = v15; v10 = 0; v2 = 0; v9 = v12->field_48; v1 = v12->field_3c; while (true) { switch (v12->field_8) { case 16191: if (v12->field_c) { v10 >>= (v2 & 7) & 63; v2 &= -8; v12->field_8 = 16208; } else { while (true) { if (v2 <= 2) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v18 = *(tmp_30) << (v2 & 63); v10 += v18; v2 += 8; } } else { v12->field_c = v10 & 1; v10 >>= 1; v2 -= 1; if ((v10 & 3) == 3) { a0->field_30 = "invalid block type"; v12->field_8 = 16209; break; } else if ((v10 & 3) == 2) { v12->field_8 = 16196; break; } else if ((v10 & 3) <= 2) { if (!(v10 & 3)) { v12->field_8 = 16193; break; } else if ((v10 & 3) == 1) { fixedtables(v12); v12->field_8 = 16200; break; } } v10 >>= 2; v2 -= 2; break; } } } case 16193: v10 >>= (v2 & 7) & 63; v2 &= -8; while (true) { if (v2 <= 31) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v20 = *(tmp_30) << (v2 & 63); v10 += v20; v2 += 8; } } else if (v10 != (v10 >> 16 ^ 65535)) { a0->field_30 = "invalid stored block lengths"; v12->field_8 = 16209; break; } else { v12->field_5c = v10; v10 = 0; v2 = 0; while (true) { if (v12->field_5c) { v3 = v12->field_5c; if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { if (!v1) { v9 = v12->field_48; v1 = v12->field_3c; v12->field_40 = v1; v23 = (stack_base)[120](a4, v9, v1, v9, a3); if (v23) { v5 = -5; break; } } if (!v23 || v1) { if (v3 > v0) v3 = v0; if (v3 > v1) v3 = v1; memcpy(v9, v8, v3); v0 -= v3; v8 = v3 + v8; v1 -= v3; v9 = &v9[v3]; v12->field_5c = v12->field_5c - v3; } } } else { v12->field_8 = 16191; break; } } break; } } case 16196: while (true) { if (v2 <= 13) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v15 = *(tmp_30) << (v2 & 63); v10 += v15; v2 += 8; } } else { v12->field_84 = (v10 & 31) + 257; v10 >>= 5; v2 -= 5; v12->field_88 = (v10 & 31) + 1; v10 >>= 5; v2 -= 5; v12->field_80 = (v10 & 15) + 4; v10 >>= 4; v2 -= 4; if (v12->field_84 <= 286 && v12->field_88 <= 30) { while (true) { if (v12->field_8c < v12->field_80) { while (true) { if (v2 <= 2) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v22 = *(tmp_30) << (v2 & 63); v10 += v22; v2 += 8; } } else { tmp_40 = v12->field_8c; v12->field_8c = v12->field_8c + 1; v15 = *((2 * tmp_40 + &order.3299)); *(&v12->padding_98[2 * v15]) = v10 & 7; v10 >>= 3; v2 -= 3; break; } } if (!v0 && !v0 && v2 <= 2) break; } else { for (v12->field_8c = 0; v12->field_8c <= 18; *(&v12->padding_98[2 * v15]) = 0) { tmp_18 = v12->field_8c; v12->field_8c = v12->field_8c + 1; v15 = *((2 * tmp_18 + &order.3299)); } v12->field_90 = &v12[2].padding_10[20]; v12->field_68 = v12->field_90; v12->field_78 = 7; v5 = inflate_table(0x0, &v12->padding_98, 0x13, &v12->field_90, &v12->field_78, &v12[1].field_7c + 2); if (v5) { a0->field_30 = "invalid code lengths set"; v12->field_8 = 16209; break; } else { v12->field_8c = 0; while (true) { if (v12->field_8c < v12->field_88 + v12->field_84) { while (true) { v6 = *( ((!((4294967295 << (v12->field_78 & 31))) & v10) * 4 + v12->field_68)); if (v2 < *(&v6 + 1)) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v15 = *(tmp_30) << (v2 & 63); v10 += v15; v2 += 8; } } else if (*((&v6 + 2)) <= 15) { v10 >>= *(&v6 + 1) & 63; v2 -= *(&v6 + 1); tmp_68 = v12->field_8c; v12->field_8c = v12->field_8c + 1; *(&v12->padding_98[2 * tmp_68]) = *((&v6 + 2)); break; } else { if (*((&v6 + 2)) == 16) { while (true) { if (v2 < *(&v6 + 1) + 2) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v15 = *(tmp_30) << (v2 & 63); v10 += v15; v2 += 8; } } else { v10 >>= *(&v6 + 1) & 63; v2 -= *(&v6 + 1); if (!v12->field_8c) { a0->field_30 = "invalid bit length repeat"; v12->field_8 = 16209; break; } else { v4 = *(&v12->padding_0[2 * v12->field_8c + 150]); *(&v3) = (v10 & 3) + 3; v10 >>= 2; v2 -= 2; break; } } } if (!v12->field_8c || v2 < *(&v6 + 1) + 2 || !v0 && !v0) break; } else if (*((&v6 + 2)) == 17) { while (true) { if (v2 < *(&v6 + 1) + 3) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v15 = *(tmp_30) << (v2 & 63); v10 += v15; v2 += 8; } } else { v10 >>= *(&v6 + 1) & 63; v2 -= *(&v6 + 1); v4 = 0; *(&v3) = (v10 & 7) + 3; v10 >>= 3; v2 -= 3; break; } } if (!v0 && v2 < *(&v6 + 1) + 3 && !v0) break; } else { while (true) { if (v2 < *(&v6 + 1) + 7) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v15 = *(tmp_30) << (v2 & 63); v10 += v15; v2 += 8; } } else { v10 >>= *(&v6 + 1) & 63; v2 -= *(&v6 + 1); v4 = 0; *(&v3) = (v10 & 127) + 11; v10 >>= 7; v2 -= 7; break; } } if (!v0 && !v0 && v2 < *(&v6 + 1) + 7) break; } if (v12->field_8c && v2 >= *(&v6 + 1) + 2) { if (v12->field_8c + v3 > v12->field_88 + v12->field_84) { a0->field_30 = "invalid bit length repeat"; v12->field_8 = 16209; break; } else { while (true) { *(&v15) = v3; *(&v3) = v3 - 1; if (!v15) break; tmp_16 = v12->field_8c; v12->field_8c = v12->field_8c + 1; *(&v12->padding_98[2 * tmp_16]) = v4; } } } } } if (*((&v6 + 2)) == 17 && *((&v6 + 2)) > 15 && v2 >= *(&v6 + 1) && !v0 && v2 < *(&v6 + 1) + 3 && !v0 || *((&v6 + 2)) != 16 && *((&v6 + 2)) > 15 && *((&v6 + 2)) != 17 && v2 >= *(&v6 + 1) && !v0 && !v0 && v2 < *(&v6 + 1) + 7 || !v0 && v2 < *(&v6 + 1) && !v0 || *((&v6 + 2)) == 16 && *((&v6 + 2)) > 15 && v2 >= *(&v6 + 1) && !v0 && !v0) break; if (*((&v6 + 2)) == 17 && *((&v6 + 2)) > 15 && v2 >= *(&v6 + 1) && !v0 && v2 < *(&v6 + 1) + 3 && !v0 || *((&v6 + 2)) != 16 && *((&v6 + 2)) > 15 && *((&v6 + 2)) != 17 && v2 >= *(&v6 + 1) && !v0 && !v0 && v2 < *(&v6 + 1) + 7 || !v0 && v2 < *(&v6 + 1) && !v0 || *((&v6 + 2)) == 16 && *((&v6 + 2)) > 15 && v2 >= *(&v6 + 1) && !v0 && !v0) continue; } if (v12->field_8 == 16209) break; if (v12->field_8 != 16209) { if (!v12->field_298) { a0->field_30 = "invalid code -- missing end-of-block"; v12->field_8 = 16209; break; } else { v12->field_90 = &v12[2].padding_10[20]; v12->field_68 = v12->field_90; v12->field_78 = 9; v5 = inflate_table(0x1, &v12->padding_98, v12->field_84, &v12->field_90, &v12->field_78, &v12[1].field_7c + 2); if (v5) { a0->field_30 = "invalid literal/lengths set"; v12->field_8 = 16209; break; } else { v12->field_70 = v12->field_90; v12->field_7c = 6; v5 = inflate_table( 0x2, &v12->padding_98[2 * v12->field_84], v12->field_88, &v12->field_90, &v12->field_7c, &v12[1].field_7c + 2); if (v5) { a0->field_30 = "invalid distances set"; v12->field_8 = 16209; break; } else { v12->field_8 = 16200; break; } } } } } if (*((&v6 + 2)) == 17 && *((&v6 + 2)) > 15 && v2 >= *(&v6 + 1) && !v0 && v2 < *(&v6 + 1) + 3 && !v0 || *((&v6 + 2)) != 16 && *((&v6 + 2)) > 15 && *((&v6 + 2)) != 17 && v2 >= *(&v6 + 1) && !v0 && !v0 && v2 < *(&v6 + 1) + 7 || !v0 && v2 < *(&v6 + 1) && !v0 || *((&v6 + 2)) == 16 && *((&v6 + 2)) > 15 && v2 >= *(&v6 + 1) && !v0 && !v0) break; if ((!(*((&v6 + 2)) == 17) || !(*((&v6 + 2)) > 15) || !(v2 >= *(&v6 + 1)) || !(!v0) || !(v2 < *(&v6 + 1) + 3) || !(!v0)) && (!(*((&v6 + 2)) != 16) || !(*((&v6 + 2)) > 15) || !(*((&v6 + 2)) != 17) || !(v2 >= *(&v6 + 1)) || !(!v0) || !(!v0) || !(v2 < *(&v6 + 1) + 7)) && (!(!v0) || !(v2 < *(&v6 + 1)) || !(!v0)) && (!(*((&v6 + 2)) == 16) || !(*((&v6 + 2)) > 15) || !(v2 >= *(&v6 + 1)) || !(!v0) || !(!v0))) break; } } } if (v12->field_8c < v12->field_80 && !v0 && !v0 && v2 <= 2 || !v5 && v12->field_8c >= v12->field_80 && (*((&v6 + 2)) == 17 && *((&v6 + 2)) > 15 && v2 >= *(&v6 + 1) && !v0 && v2 < *(&v6 + 1) + 3 && !v0 || *((&v6 + 2)) != 16 && *((&v6 + 2)) > 15 && *((&v6 + 2)) != 17 && v2 >= *(&v6 + 1) && !v0 && !v0 && v2 < *(&v6 + 1) + 7 || !v0 && v2 < *(&v6 + 1) && !v0 || *((&v6 + 2)) == 16 && *((&v6 + 2)) > 15 && v2 >= *(&v6 + 1) && !v0 && !v0)) break; if ((!(v12->field_8c < v12->field_80) || !(!v0) || !(!v0) || !(v2 <= 2)) && (!(!v5) || !(v12->field_8c >= v12->field_80) || (!(*((&v6 + 2)) == 17) || !(*((&v6 + 2)) > 15) || !(v2 >= *(&v6 + 1)) || !(!v0) || !(v2 < *(&v6 + 1) + 3) || !(!v0)) && (!(*((&v6 + 2)) != 16) || !(*((&v6 + 2)) > 15) || !(*((&v6 + 2)) != 17) || !(v2 >= *(&v6 + 1)) || !(!v0) || !(!v0) || !(v2 < *(&v6 + 1) + 7)) && (!(!v0) || !(v2 < *(&v6 + 1)) || !(!v0)) && (!(*((&v6 + 2)) == 16) || !(*((&v6 + 2)) > 15) || !(v2 >= *(&v6 + 1)) || !(!v0) || !(!v0)))) break; } if (v12->field_84 > 286 || v12->field_88 > 30) { a0->field_30 = "too many length or distance symbols"; v12->field_8 = 16209; break; } } } case 16200: if (v0 > 5 && v1 > 257) { a0->field_18 = v9; a0->field_20 = v1; a0->field_0 = v8; a0->field_8 = v0; v12->field_50 = v10; v12->field_58 = v2; if (v12->field_40 < v12->field_3c) v12->field_40 = v12->field_3c - v1; inflate_fast(a0, v12->field_3c, v12->field_3c); v9 = a0->field_18; v1 = a0->field_20; v8 = a0->field_0; v0 = a0->field_8; v10 = v12->field_50; v2 = v12->field_58; } if (v0 <= 5 || v1 <= 257) { while (true) { v6 = *(((!((4294967295 << (v12->field_78 & 31))) & v10) * 4 + v12->field_68)); if (v2 < *(&v6 + 1)) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v29 = *(tmp_30) << (v2 & 63); v10 += v29; v2 += 8; } } else { if (v6 && !(v6 & 240)) { v7 = v6; while (true) { v6 = *(((((v10 & !((4294967295 << (v7 + *(&v7 + 1) & 31)))) >> (*(&v7 + 1) & 31)) + *((&v7 + 2))) * 4 + v12->field_68)); if (v2 < *(&v6 + 1) + *(&v7 + 1)) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v31 = *(tmp_30) << (v2 & 63); v10 += v31; v2 += 8; } } else { v10 >>= *(&v7 + 1) & 63; v2 -= *(&v7 + 1); break; } } if (v2 < *(&v6 + 1) + *(&v7 + 1) && !v0 && !v0) break; } if (v0 || v0 || v2 >= *(&v6 + 1) + *(&v7 + 1)) { v10 >>= *(&v6 + 1) & 63; v2 -= *(&v6 + 1); v12->field_5c = *((&v6 + 2)); if (!v6) { if (!v1) { v9 = v12->field_48; v1 = v12->field_3c; v12->field_40 = v1; v32 = (stack_base)[120](a4, v9, v1, v9, a3); if (v32) { v5 = -5; break; } } if (!v32 || v1) { tmp_21 = v9; v9 += 1; *(tmp_21) = v12->field_5c; v1 -= 1; v12->field_8 = 16200; break; } } else if ((v6 & 32)) { v12->field_8 = 16191; break; } else if ((v6 & 64)) { a0->field_30 = "invalid literal/length code"; v12->field_8 = 16209; break; } else { v12->field_64 = v6 & 15; if (v12->field_64) { while (true) { if (v2 < v12->field_64) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v34 = *(tmp_30) << (v2 & 63); v10 += v34; v2 += 8; } } else { v12->field_5c = v12->field_5c + (!((4294967295 << (v12->field_64 & 31))) & v10); v10 >>= v12->field_64 & 63; v2 -= v12->field_64; break; } } if (!v0 && v2 < v12->field_64 && !v0) break; } if (v2 >= v12->field_64 || v0 || v0) { while (true) { v6 = *( ((!((4294967295 << (v12->field_7c & 31))) & v10) * 4 + v12->field_70)); if (v2 < *(&v6 + 1)) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v36 = *(tmp_30) << (v2 & 63); v10 += v36; v2 += 8; } } else { if (!(v6 & 240)) { v7 = v6; while (true) { v6 = *(((((v10 & !((4294967295 << (v7 + *(&v7 + 1) & 31)))) >> (*(&v7 + 1) & 31)) + *((&v7 + 2))) * 4 + v12->field_70)); if (v2 < *(&v6 + 1) + *(&v7 + 1)) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v38 = *(tmp_30) << (v2 & 63); v10 += v38; v2 += 8; } } else { v10 >>= *(&v7 + 1) & 63; v2 -= *(&v7 + 1); break; } } if (!v0 && !v0 && v2 < *(&v6 + 1) + *(&v7 + 1)) break; } if (v0 || v2 >= *(&v6 + 1) + *(&v7 + 1) || v0) { v10 >>= *(&v6 + 1) & 63; v2 -= *(&v6 + 1); if ((v6 & 64)) { a0->field_30 = "invalid distance code"; v12->field_8 = 16209; break; } else { v12->field_60 = *((&v6 + 2)); v12->field_64 = v6 & 15; if (v12->field_64) { while (true) { if (v2 < v12->field_64) { if (!v0) { v0 = (stack_base)[104](a2, &v8, &v8, a1); if (!v0) { v8 = 0; v5 = -5; break; } } if (v0 || v0) { v0 -= 1; tmp_30 = v8; v8 += 1; v40 = *(tmp_30) << (v2 & 63); v10 += v40; v2 += 8; } } else { v12->field_60 = v12->field_60 + (!((4294967295 << (v12->field_64 & 31))) & v10); v10 >>= v12->field_64 & 63; v2 -= v12->field_64; break; } } if (!v0 && !v0) break; } if (v0 || v0) { if (v12->field_40 < v12->field_3c) v41 = v1; else v41 = 0; if (v12->field_60 > (v12->field_3c - v41)) { a0->field_30 = "invalid distance too far back"; v12->field_8 = 16209; break; } else { while (true) { if (!v1) { v9 = v12->field_48; v1 = v12->field_3c; v12->field_40 = v1; v42 = (stack_base)[120](a4, v9, v1, v9, a3); if (v42) { v5 = -5; break; } } if (!v42 || v1) { v3 = v12->field_3c - v12->field_60; if (v3 < v1) { v11 = &v9[v3]; v3 = v1 - v3; } else { v11 = &v9[-(v12->field_60)]; v3 = v1; } if (v3 > v12->field_5c) v3 = v12->field_5c; v12->field_5c = v12->field_5c - v3; v1 -= v3; do { tmp_18 = v11; v11 += 1; v43 = v9; v9 += 1; *(v43) = *(tmp_18); v3 = v3 - 1; } while (v3); if (!v12->field_5c) break; } } break; } } } } } } break; } } } } } } case 16208: v5 = 1; case 16209: v5 = -3; default: v5 = -2; } } if (v1 < v12->field_3c && (stack_base)[120](a4, v12->field_48, v12->field_3c - v1, v12->field_48, a3) && v5 == 1) v5 = -5; a0->field_0 = v8; a0->field_8 = v0; v14 = v5; } if (!a0 || !a0->field_38) v14 = 4294967294; return v14; }
zlib
angr_dream
static int R3_recip(small *out, const small *in) { small f[761 + 1], g[761 + 1], v[761 + 1], r[761 + 1]; int i, loop, delta; int sign, swap, t; for (i = 0; i < 761 + 1; ++i) v[i] = 0; for (i = 0; i < 761 + 1; ++i) r[i] = 0; r[0] = 1; for (i = 0; i < 761; ++i) f[i] = 0; f[0] = 1; f[761 - 1] = f[761] = -1; for (i = 0; i < 761; ++i) g[761 - 1 - i] = in[i]; g[761] = 0; delta = 1; for (loop = 0; loop < 2 * 761 - 1; ++loop) { for (i = 761; i > 0; --i) v[i] = v[i - 1]; v[0] = 0; sign = -g[0] * f[0]; swap = int16_negative_mask(-delta) & int16_nonzero_mask(g[0]); delta ^= swap & (delta ^ -delta); delta += 1; for (i = 0; i < 761 + 1; ++i) { t = swap & (f[i] ^ g[i]); f[i] ^= t; g[i] ^= t; t = swap & (v[i] ^ r[i]); v[i] ^= t; r[i] ^= t; } for (i = 0; i < 761 + 1; ++i) g[i] = F3_freeze(g[i] + sign * f[i]); for (i = 0; i < 761 + 1; ++i) r[i] = F3_freeze(r[i] + sign * v[i]); for (i = 0; i < 761; ++i) g[i] = g[i + 1]; g[761] = 0; } sign = f[0]; for (i = 0; i < 761; ++i) out[i] = sign * v[761 - 1 - i]; return int16_nonzero_mask(delta); }
void R3_recip(long param_1, long param_2) { byte bVar1; byte bVar2; undefined4 uVar3; uint uVar4; uint uVar5; uint uVar6; int iVar7; long in_FS_OFFSET; int local_c40; int local_c3c; uint local_c38; byte local_c28[760]; undefined local_930; undefined local_92f; byte local_928[761]; undefined local_62f; byte local_628[768]; byte local_328[776]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); for (local_c40 = 0; local_c40 < 0x2fa; local_c40 = __addvsi3(local_c40, 1)) { local_628[local_c40] = 0; } for (local_c40 = 0; local_c40 < 0x2fa; local_c40 = __addvsi3(local_c40, 1)) { local_328[local_c40] = 0; } local_328[0] = 1; for (local_c40 = 0; local_c40 < 0x2f9; local_c40 = __addvsi3(local_c40, 1)) { local_c28[local_c40] = 0; } local_c28[0] = 1; local_92f = 0xff; local_930 = 0xff; for (local_c40 = 0; local_c40 < 0x2f9; local_c40 = __addvsi3(local_c40)) { iVar7 = __subvsi3(0x2f8, local_c40); local_928[iVar7] = *(byte *)(local_c40 + param_2); } local_62f = 0; local_c38 = 1; for (local_c3c = 0; bVar2 = local_c28[0], local_c3c < 0x5f1; local_c3c = __addvsi3(local_c3c)) { for (local_c40 = 0x2f9; 0 < local_c40; local_c40 = __addvsi3(local_c40, 0xffffffff)) { iVar7 = __addvsi3(local_c40, 0xffffffff); local_628[local_c40] = local_628[iVar7]; } local_628[0] = 0; uVar3 = __negvsi2(); __mulvsi3(uVar3, (int)(char)local_c28[0]); uVar4 = int16_negative_mask(); uVar5 = int16_nonzero_mask(); uVar6 = __negvsi2(); local_c38 = __addvsi3(local_c38 ^ (uVar6 ^ local_c38) & uVar5 & uVar4, 1); for (local_c40 = 0; local_c40 < 0x2fa; local_c40 = __addvsi3(local_c40, 1)) { bVar1 = (byte)(uVar5 & uVar4); bVar2 = (local_928[local_c40] ^ local_c28[local_c40]) & bVar1; local_c28[local_c40] = bVar2 ^ local_c28[local_c40]; local_928[local_c40] = bVar2 ^ local_928[local_c40]; bVar1 = (local_328[local_c40] ^ local_628[local_c40]) & bVar1; local_628[local_c40] = bVar1 ^ local_628[local_c40]; local_328[local_c40] = bVar1 ^ local_328[local_c40]; } for (local_c40 = 0; local_c40 < 0x2fa; local_c40 = __addvsi3(local_c40, 1)) { bVar2 = F3_freeze(); local_928[local_c40] = bVar2; } for (local_c40 = 0; local_c40 < 0x2fa; local_c40 = __addvsi3(local_c40, 1)) { bVar2 = F3_freeze(); local_328[local_c40] = bVar2; } for (local_c40 = 0; local_c40 < 0x2f9; local_c40 = __addvsi3(local_c40, 1)) { iVar7 = __addvsi3(local_c40, 1); local_928[local_c40] = local_928[iVar7]; } local_62f = 0; } for (local_c40 = 0; local_c40 < 0x2f9; local_c40 = __addvsi3(local_c40)) { iVar7 = __subvsi3(0x2f8, local_c40); *(byte *)(param_1 + local_c40) = local_628[iVar7] * bVar2; } int16_nonzero_mask((int)(short)local_c38); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return; }
openssh-portable
ghidra
static WORD_LIST *expand_word_internal(word, quoted, isexp, contains_dollar_at, expanded_something) WORD_DESC *word; int quoted, isexp; int *contains_dollar_at; int *expanded_something; { WORD_LIST *list; WORD_DESC *tword; char *istring; size_t istring_size; size_t istring_index; char *temp, *temp1; register char *string; size_t string_size; int sindex; int quoted_dollar_at; int quoted_state; int had_quoted_null; int has_quoted_ifs; int has_dollar_at, temp_has_dollar_at; int internal_tilde; int split_on_spaces; int local_expanded; int tflag; int pflags; int mb_cur_max; int assignoff; register unsigned char c; int t_index; char twochars[2]; mbstate_t state; memset(&state, '\0', sizeof(mbstate_t)); if (((word->word)[0] == ("\"$@\"")[0] && strcmp(word->word, "\"$@\"") == 0) && (word->flags == ((1 << 0) | (1 << 1))) && dollar_vars[1]) { if (contains_dollar_at) *contains_dollar_at = 1; if (expanded_something) *expanded_something = 1; if (cached_quoted_dollar_at) return (copy_word_list(cached_quoted_dollar_at)); list = list_rest_of_args(); list = quote_list(list); cached_quoted_dollar_at = copy_word_list(list); return (list); } istring = (char *)sh_xmalloc((istring_size = 112), "subst.c", 10988); istring[istring_index = 0] = '\0'; quoted_dollar_at = had_quoted_null = has_dollar_at = 0; has_quoted_ifs = 0; split_on_spaces = 0; internal_tilde = 0; quoted_state = 0; string = word->word; if (string == 0) goto finished_with_string; mb_cur_max = (__ctype_get_mb_cur_max()); string_size = (mb_cur_max > 1) ? strlen(string) : 1; if (contains_dollar_at) *contains_dollar_at = 0; assignoff = -1; for (sindex = 0;;) { c = string[sindex]; switch (c) { case '\0': goto finished_with_string; case '\001': sindex++; if (mb_cur_max > 1 && string[sindex]) { int i; mbstate_t state_bak; size_t mblength; i = is_basic(*((string) + (sindex))); if (i) mblength = 1; else if (locale_utf8locale && (((string)[sindex] & 0x80) == 0)) mblength = (string)[sindex] != 0; else { state_bak = state; mblength = mbrlen((string) + (sindex), (string_size) - (sindex), &state); } if (mblength == (size_t)-1 || mblength == (size_t)-2) { state = state_bak; mblength = 1; } if (mblength < 1) mblength = 1; (temp) = (char *)sh_xmalloc((mblength + 2), "subst.c", 11027); (temp)[0] = '\001'; for (i = 0; i < mblength; i++) (temp)[i + 1] = (string)[(sindex)++]; (temp)[mblength + 1] = '\0'; goto add_string; } else { temp = (char *)sh_xmalloc((3), "subst.c", 11032); temp[0] = '\001'; temp[1] = c = string[sindex]; temp[2] = '\0'; } dollar_add_string: if (string[sindex]) sindex++; add_string: if (temp) { istring = sub_append_string(temp, istring, &istring_index, &istring_size); temp = (char *)0; } break; case '<': case '>': { if (string[++sindex] != '(' || (quoted & (0x002 | 0x001)) || (word->flags & (1 << 20))) { sindex--; goto add_character; } else t_index = sindex + 1; temp1 = extract_process_subst(string, (c == '<') ? "<(" : ">(", &t_index, 0); sindex = t_index; temp = temp1 ? process_substitute(temp1, (c == '>')) : (char *)0; do { if (temp1) sh_xfree((temp1), "subst.c", 11075); } while (0); goto dollar_add_string; } case '[': if ((quoted & 0x100) == 0 || shell_compatibility_level <= 51) { if (isexp == 0 && (word->flags & ((1 << 4) | (1 << 6))) == 0 && (ifs_cmap[(unsigned char)(c)] != 0) && (quoted & (0x001 | 0x002)) == 0) goto add_ifs_character; else goto add_character; } else { temp = expand_array_subscript(string, &sindex, quoted, word->flags); goto add_string; } case '=': if (word->flags & ((1 << 11) | (1 << 12))) { if (isexp == 0 && (word->flags & ((1 << 4) | (1 << 6))) == 0 && (ifs_cmap[(unsigned char)(c)] != 0)) goto add_ifs_character; else goto add_character; } if ((word->flags & (1 << 2)) && (posixly_correct == 0 || (word->flags & (1 << 7))) && assignoff == -1 && sindex > 0) assignoff = sindex; if (sindex == assignoff && string[sindex + 1] == '~') internal_tilde = 1; if (word->flags & (1 << 17)) word->flags |= (1 << 11); if (isexp == 0 && (word->flags & ((1 << 4) | (1 << 6))) == 0 && (ifs_cmap[(unsigned char)(c)] != 0)) { has_quoted_ifs++; goto add_ifs_character; } else goto add_character; case ':': if (word->flags & ((1 << 12) | (1 << 13))) { if (isexp == 0 && (word->flags & ((1 << 4) | (1 << 6))) == 0 && (ifs_cmap[(unsigned char)(c)] != 0)) goto add_ifs_character; else goto add_character; } if ((word->flags & ((1 << 2) | (1 << 11))) && (posixly_correct == 0 || (word->flags & (1 << 7))) && string[sindex + 1] == '~') internal_tilde = 1; if (isexp == 0 && (word->flags & ((1 << 4) | (1 << 6))) == 0 && (ifs_cmap[(unsigned char)(c)] != 0)) goto add_ifs_character; else goto add_character; case '~': if ((word->flags & (1 << 12)) || (sindex > 0 && (internal_tilde == 0)) || (quoted & (0x001 | 0x002))) { internal_tilde = 0; if (isexp == 0 && (word->flags & ((1 << 4) | (1 << 6))) == 0 && (ifs_cmap[(unsigned char)(c)] != 0) && (quoted & (0x001 | 0x002)) == 0) goto add_ifs_character; else goto add_character; } if (word->flags & (1 << 11)) tflag = 2; else if (word->flags & ((1 << 2) | (1 << 7))) tflag = 1; else tflag = 0; temp = bash_tilde_find_word(string + sindex, tflag, &t_index); internal_tilde = 0; if (temp && *temp && t_index > 0) { temp1 = bash_tilde_expand(temp, tflag); if (temp1 && *temp1 == '~' && ((temp)[0] == (temp1)[0] && strcmp(temp, temp1) == 0)) { do { if (temp) sh_xfree((temp), "subst.c", 11190); } while (0); do { if (temp1) sh_xfree((temp1), "subst.c", 11191); } while (0); goto add_character; } sh_xfree((temp), "subst.c", 11194); temp = temp1; sindex += t_index; goto add_quoted_string; } else { do { if (temp) sh_xfree((temp), "subst.c", 11201); } while (0); goto add_character; } case '$': if (expanded_something) *expanded_something = 1; local_expanded = 1; temp_has_dollar_at = 0; pflags = (word->flags & (1 << 10)) ? 0x01 : 0; if (word->flags & (1 << 6)) pflags |= 0x04; if (word->flags & (1 << 11)) pflags |= 0x08; if (word->flags & (1 << 27)) pflags |= 0x10; tword = param_expand(string, &sindex, quoted, expanded_something, &temp_has_dollar_at, &quoted_dollar_at, &had_quoted_null, pflags); has_dollar_at += temp_has_dollar_at; split_on_spaces += (tword->flags & (1 << 3)); if (tword == &expand_wdesc_error || tword == &expand_wdesc_fatal) { sh_xfree((string), "subst.c", 11227); sh_xfree((istring), "subst.c", 11228); return ((tword == &expand_wdesc_error) ? &expand_word_error : &expand_word_fatal); } if (contains_dollar_at && has_dollar_at) *contains_dollar_at = 1; if (tword && (tword->flags & (1 << 18))) had_quoted_null = 1; if (tword && (tword->flags & (1 << 21))) had_quoted_null = 1; temp = tword ? tword->word : (char *)((void *)0); dispose_word_desc(tword); if (had_quoted_null && temp && ((temp)[0] == '\177' && (temp)[1] == '\0')) { do { if (temp) sh_xfree((temp), "subst.c", 11247); } while (0); temp = (char *)((void *)0); } goto add_string; break; case '`': { t_index = sindex++; temp = string_extract(string, &sindex, "`", (word->flags & (1 << 27)) ? 0x0400 : 0x0004); if (temp == &extract_string_error || temp == &extract_string_fatal) { if (sindex - 1 == t_index) { sindex = t_index; goto add_character; } set_exit_status(1); report_error(gettext("bad substitution: no closing \"`\" in %s"), string + t_index); sh_xfree((string), "subst.c", 11270); sh_xfree((istring), "subst.c", 11271); return ((temp == &extract_string_error) ? &expand_word_error : &expand_word_fatal); } if (expanded_something) *expanded_something = 1; local_expanded = 1; if (word->flags & (1 << 10)) temp1 = substring(string, t_index, sindex + 1); else { de_backslash(temp); tword = command_substitute(temp, quoted, 0); temp1 = tword ? tword->word : (char *)((void *)0); if (tword) dispose_word_desc(tword); } do { if (temp) sh_xfree((temp), "subst.c", 11291); } while (0); temp = temp1; goto dollar_add_string; } case '\\': if (string[sindex + 1] == '\n') { sindex += 2; continue; } c = string[++sindex]; if ((quoted & 0x002) && (quoted & 0x080) && c == '"') tflag = 0x0040; else if (quoted & 0x002) tflag = 0x0080; else if (quoted & 0x001) tflag = 0x0040; else tflag = 0; if ((quoted & 0x080) && c == '}') { do { if (locale_mb_cur_max > 1) { mbstate_t state_bak; size_t mblength; int _i; _i = is_basic((string)[(sindex)]); if (_i) mblength = 1; else if (locale_utf8locale && ((string)[(sindex)] & 0x80) == 0) mblength = (string)[(sindex)] != 0; else { state_bak = state; mblength = mbrlen((string) + (sindex), (string_size) - (sindex), &state); } if (mblength == (size_t)-2 || mblength == (size_t)-1) { state = state_bak; mblength = 1; } else mblength = (mblength < 1) ? 1 : mblength; temp = sh_xmalloc((mblength + 2), "subst.c", 11321); temp[0] = '\001'; for (_i = 0; _i < mblength; _i++) temp[_i + 1] = string[sindex++]; temp[mblength + 1] = '\0'; goto add_string; } else { twochars[0] = '\001'; twochars[1] = c; } } while (0); } else if ((quoted & (0x002 | 0x001)) && ((sh_syntaxtab[c] & tflag) == 0) && isexp == 0 && (ifs_cmap[(unsigned char)(c)] != 0)) { do { if ((istring_index) + (2) >= istring_size) { while ((istring_index) + (2) >= istring_size) istring_size += (128); istring = sh_xrealloc((istring), (istring_size), "subst.c", 11326); } } while (0); istring[istring_index++] = '\001'; istring[istring_index++] = '\\'; istring[istring_index] = '\0'; do { if (locale_mb_cur_max > 1) { mbstate_t state_bak; size_t mblength; int _i; _i = is_basic((string)[(sindex)]); if (_i) mblength = 1; else if (locale_utf8locale && ((string)[(sindex)] & 0x80) == 0) mblength = (string)[(sindex)] != 0; else { state_bak = state; mblength = mbrlen((string) + (sindex), (string_size) - (sindex), &state); } if (mblength == (size_t)-2 || mblength == (size_t)-1) { state = state_bak; mblength = 1; } else mblength = (mblength < 1) ? 1 : mblength; temp = sh_xmalloc((mblength + 2), "subst.c", 11332); temp[0] = '\001'; for (_i = 0; _i < mblength; _i++) temp[_i + 1] = string[sindex++]; temp[mblength + 1] = '\0'; goto add_string; } else { twochars[0] = '\001'; twochars[1] = c; } } while (0); } else if ((quoted & (0x002 | 0x001)) && c == 0) { do { if ((istring_index) + (2) >= istring_size) { while ((istring_index) + (2) >= istring_size) istring_size += (128); istring = sh_xrealloc((istring), (istring_size), "subst.c", 11336); } } while (0); istring[istring_index++] = '\001'; istring[istring_index++] = '\\'; istring[istring_index] = '\0'; break; } else if ((quoted & (0x002 | 0x001)) && ((sh_syntaxtab[c] & tflag) == 0)) { do { if (locale_mb_cur_max > 1) { mbstate_t state_bak; size_t mblength; int _i; _i = is_basic((string)[(sindex)]); if (_i) mblength = 1; else if (locale_utf8locale && ((string)[(sindex)] & 0x80) == 0) mblength = (string)[(sindex)] != 0; else { state_bak = state; mblength = mbrlen((string) + (sindex), (string_size) - (sindex), &state); } if (mblength == (size_t)-2 || mblength == (size_t)-1) { state = state_bak; mblength = 1; } else mblength = (mblength < 1) ? 1 : mblength; temp = sh_xmalloc((mblength + 2), "subst.c", 11345); temp[0] = '\\'; for (_i = 0; _i < mblength; _i++) temp[_i + 1] = string[sindex++]; temp[mblength + 1] = '\0'; goto add_string; } else { twochars[0] = '\\'; twochars[1] = c; } } while (0); } else if (c == 0) { c = '\177'; sindex--; goto add_character; } else { do { if (locale_mb_cur_max > 1) { mbstate_t state_bak; size_t mblength; int _i; _i = is_basic((string)[(sindex)]); if (_i) mblength = 1; else if (locale_utf8locale && ((string)[(sindex)] & 0x80) == 0) mblength = (string)[(sindex)] != 0; else { state_bak = state; mblength = mbrlen((string) + (sindex), (string_size) - (sindex), &state); } if (mblength == (size_t)-2 || mblength == (size_t)-1) { state = state_bak; mblength = 1; } else mblength = (mblength < 1) ? 1 : mblength; temp = sh_xmalloc((mblength + 2), "subst.c", 11355); temp[0] = '\001'; for (_i = 0; _i < mblength; _i++) temp[_i + 1] = string[sindex++]; temp[mblength + 1] = '\0'; goto add_string; } else { twochars[0] = '\001'; twochars[1] = c; } } while (0); } sindex++; add_twochars: do { if ((istring_index) + (2) >= istring_size) { while ((istring_index) + (2) >= istring_size) istring_size += (128); istring = sh_xrealloc((istring), (istring_size), "subst.c", 11361); } } while (0); istring[istring_index++] = twochars[0]; istring[istring_index++] = twochars[1]; istring[istring_index] = '\0'; break; case '"': if ((quoted & (0x001 | 0x002)) && ((quoted & 0x100) == 0)) goto add_character; t_index = ++sindex; temp = string_extract_double_quoted( string, &sindex, (word->flags & (1 << 27)) ? 0x0400 : 0); quoted_state = (t_index == 1 && string[sindex] == '\0') ? 2 : 1; if (temp && *temp) { tword = alloc_word_desc(); tword->word = temp; if (word->flags & (1 << 17)) tword->flags |= word->flags & ((1 << 17) | (1 << 11)); if (word->flags & (1 << 27)) tword->flags |= (1 << 27); if (word->flags & (1 << 10)) tword->flags |= (1 << 10); if (word->flags & (1 << 20)) tword->flags |= (1 << 20); if (word->flags & (1 << 11)) tword->flags |= (1 << 11); temp = (char *)((void *)0); temp_has_dollar_at = 0; list = expand_word_internal(tword, 0x001 | (quoted & 0x100), 0, &temp_has_dollar_at, (int *)((void *)0)); has_dollar_at += temp_has_dollar_at; if (list == &expand_word_error || list == &expand_word_fatal) { sh_xfree((istring), "subst.c", 11410); sh_xfree((string), "subst.c", 11411); tword->word = (char *)((void *)0); dispose_word(tword); return list; } dispose_word(tword); if (list == 0 && temp_has_dollar_at) { quoted_dollar_at++; break; } if (list && list->word && list->next == 0 && (list->word->flags & (1 << 18))) { if (had_quoted_null && temp_has_dollar_at) quoted_dollar_at++; had_quoted_null = 1; } if (list) dequote_list(list); if (temp_has_dollar_at) { quoted_dollar_at++; if (contains_dollar_at) *contains_dollar_at = 1; if (expanded_something) *expanded_something = 1; local_expanded = 1; } } else { do { if (temp) sh_xfree((temp), "subst.c", 11466); } while (0); list = (WORD_LIST *)((void *)0); had_quoted_null = 1; } if (list) { if (list->next) { temp = quoted_dollar_at ? string_list_dollar_at(list, 0x001, 0) : string_list(quote_list(list)); dispose_words(list); goto add_string; } else { temp = (char *)strcpy( sh_xmalloc((1 + strlen(list->word->word)), "subst.c", 11493), (list->word->word)); tflag = list->word->flags; dispose_words(list); if ((tflag & (1 << 18)) && ((temp)[0] == '\177' && (temp)[1] == '\0') == 0) remove_quoted_nulls(temp); } } else temp = (char *)((void *)0); if (temp == 0 && quoted_state == 1) had_quoted_null = 1; if (temp == 0 && quoted_state == 1 && quoted == 0 && (word->flags & ((1 << 4) | (1 << 14) | (1 << 11))) == (1 << 14)) { c = '\177'; sindex--; had_quoted_null = 1; goto add_character; } if (temp == 0 && quoted_state == 1 && (word->flags & ((1 << 4) | (1 << 6)))) continue; add_quoted_string: if (temp) { temp1 = temp; temp = quote_string(temp); sh_xfree((temp1), "subst.c", 11541); goto add_string; } else { c = '\177'; sindex--; had_quoted_null = 1; goto add_character; } case '\'': if ((quoted & (0x001 | 0x002))) goto add_character; t_index = ++sindex; temp = string_extract_single_quoted(string, &sindex, 0); quoted_state = (t_index == 1 && string[sindex] == '\0') ? 2 : 1; if (*temp == '\0') { sh_xfree((temp), "subst.c", 11571); temp = (char *)((void *)0); } else remove_quoted_escapes(temp); if (temp == 0 && quoted_state == 1) had_quoted_null = 1; if (temp == 0 && quoted_state == 1 && quoted == 0 && (word->flags & ((1 << 4) | (1 << 14) | (1 << 11))) == (1 << 14)) { c = '\177'; sindex--; goto add_character; } if (temp == 0 && (quoted_state == 1) && (word->flags & ((1 << 4) | (1 << 6)))) continue; if (temp == 0) { c = '\177'; sindex--; goto add_character; } else goto add_quoted_string; case ' ': if (ifs_is_null || split_on_spaces || ((word->flags & ((1 << 4) | (1 << 6) | (1 << 11))) && (word->flags & (1 << 14)) == 0)) { if (string[sindex]) sindex++; twochars[0] = '\001'; twochars[1] = c; goto add_twochars; } default: add_ifs_character: if ((quoted & (0x002 | 0x001)) || (isexp == 0 && (ifs_cmap[(unsigned char)(c)] != 0) && (word->flags & ((1 << 4) | (1 << 6))) == 0)) { if ((quoted & (0x002 | 0x001)) == 0) has_quoted_ifs++; add_quoted_character: if (string[sindex]) sindex++; if (c == 0) { c = '\177'; goto add_character; } else { if (mb_cur_max > 1) sindex--; if (mb_cur_max > 1) { int i; mbstate_t state_bak; size_t mblength; i = is_basic(*((string) + (sindex))); if (i) mblength = 1; else if (locale_utf8locale && (((string)[sindex] & 0x80) == 0)) mblength = (string)[sindex] != 0; else { state_bak = state; mblength = mbrlen((string) + (sindex), (string_size) - (sindex), &state); } if (mblength == (size_t)-1 || mblength == (size_t)-2) { state = state_bak; mblength = 1; } if (mblength < 1) mblength = 1; (temp) = (char *)sh_xmalloc((mblength + 2), "subst.c", 11647); (temp)[0] = '\001'; for (i = 0; i < mblength; i++) (temp)[i + 1] = (string)[(sindex)++]; (temp)[mblength + 1] = '\0'; goto add_string; } else { twochars[0] = '\001'; twochars[1] = c; goto add_twochars; } } } do { if (locale_mb_cur_max > 1) { int i; mbstate_t state_bak; size_t mblength; i = is_basic(*((string) + (sindex))); if (i) mblength = 1; else if (locale_utf8locale && (((string)[sindex] & 0x80) == 0)) mblength = (string)[sindex] != 0; else { state_bak = state; mblength = mbrlen((string) + (sindex), (string_size) - (sindex), &state); } if (mblength == (size_t)-1 || mblength == (size_t)-2) { state = state_bak; mblength = 1; } if (mblength < 1) mblength = 1; temp = (char *)sh_xmalloc((mblength + 1), "subst.c", 11659); for (i = 0; i < mblength; i++) (temp)[i] = (string)[(sindex)++]; (temp)[mblength] = '\0'; goto add_string; } } while (0); add_character: do { if ((istring_index) + (1) >= istring_size) { while ((istring_index) + (1) >= istring_size) istring_size += (128); istring = sh_xrealloc((istring), (istring_size), "subst.c", 11662); } } while (0); istring[istring_index++] = c; istring[istring_index] = '\0'; sindex++; } }
long **expand_word_internal(long a1, unsigned int a2, int a3, _DWORD *a4, _DWORD *a5) { long **v6; const char *v7; size_t v8; unsigned char v9; int v10; const char *v11; char *v12; int v13; char *v14; int v15; char v16; const char *v17; char *v18; char *v19; unsigned char v20; long v21; int v22; long v23; long v24; long v25; int v26; long v27; long v28; long v29; int v30; long v31; int v32; long v33; long v34; int v35; int v36; int v37; char *v38; long **v39; const char *v40; size_t v41; char *v42; int v44; int v45; int v46; long v47; int v48; int v49; char *v50; const char *v51; char *v52; const char *v53; long v54; int v55; int v56; int v60; int v61; int v62; _BOOL4 v63; unsigned int v64; int v65; int v66; int v67; int v68; int v69; unsigned int v70; int v71; int v72; int i; int j; int n; int m; int k; int jj; int ii; int mb_cur_max; int v81; unsigned long v82; long v83; long **word_list; long *v85; char *appended; char *s1; char *s2; unsigned long v89; unsigned long v90; unsigned long v91; unsigned long v92; unsigned long v93; unsigned long v94; unsigned long v95; size_t v96; char *v97; long s; long v99; char v100; unsigned char v101; unsigned long v102; v102 = __readfsqword(0x28u); memset(&s, 0, sizeof(s)); if (**(_BYTE **)a1 != 34 || strcmp(*(const char **)a1, "\"$@\"") || *(_DWORD *)(a1 + 8) != 3 || !dollar_vars[1]) { v82 = 112LL; appended = (char *)sh_xmalloc(112LL, "subst.c", 10988LL); v83 = 0LL; *appended = 0; v67 = 0; v62 = 0; v61 = 0; v66 = 0; v69 = 0; v68 = 0; v65 = 0; v7 = *(const char **)a1; if (*(_QWORD *)a1) { mb_cur_max = _ctype_get_mb_cur_max(); if (mb_cur_max <= 1) v8 = 1LL; else v8 = strlen(v7); v96 = v8; if (a4) *a4 = 0; v72 = -1; v60 = 0; while (1) { while (1) { while (1) { v9 = v7[v60]; if (v9 > 0x60u) break; switch (v9) { case 0u: goto LABEL_438; case 1u: ++v60; if (mb_cur_max <= 1 || !v7[v60]) { s1 = (char *)sh_xmalloc(3LL, "subst.c", 11032LL); *s1 = 1; *(_WORD *)(s1 + 1) = (unsigned char)v7[v60]; goto LABEL_40; } i = is_basic(v7[v60]); if (i) { v89 = 1LL; } else if (locale_utf8locale && v7[v60] >= 0) { v89 = v7[v60] != 0; } else { v99 = s; v89 = mbrlen(&v7[v60], v96 - v60, (mbstate_t *)&s); } if (v89 >= 0xFFFFFFFFFFFFFFFELL) { s = v99; v89 = 1LL; } if (!v89) v89 = 1LL; s1 = (char *)sh_xmalloc(v89 + 2, "subst.c", 11027LL); *s1 = 1; for (i = 0; v89 > i; ++i) { v10 = v60++; s1[i + 1] = v7[v10]; } s1[v89 + 1] = 0; goto LABEL_42; case 0x20u: if (!ifs_is_null && !v69 && ((*(_DWORD *)(a1 + 8) & 0x850) == 0 || (*(_DWORD *)(a1 + 8) & 0x4000) != 0)) goto LABEL_388; if (v7[v60]) ++v60; v100 = 1; v101 = v9; goto LABEL_283; case 0x22u: if ((a2 & 3) != 0 && (a2 & 0x100) == 0) goto LABEL_429; v64 = ++v60; s1 = (char *)string_extract_double_quoted( (long)v7, &v60, (*(int *)(a1 + 8) >> 17) & 0x400); if (v64 != 1 || v7[v60]) v35 = 1; else v35 = 2; v65 = v35; if (s1 && *s1) { v85 = (long *)alloc_word_desc(); *v85 = (long)s1; if ((*(_DWORD *)(a1 + 8) & 0x20000) != 0) *((_DWORD *)v85 + 2) |= *(_DWORD *)(a1 + 8) & 0x20800; if ((*(_DWORD *)(a1 + 8) & 0x8000000) != 0) *((_DWORD *)v85 + 2) |= 0x8000000u; if ((*(_DWORD *)(a1 + 8) & 0x400) != 0) { v36 = *((_DWORD *)v85 + 2); BYTE1(v36) |= 4u; *((_DWORD *)v85 + 2) = v36; } if ((*(_DWORD *)(a1 + 8) & 0x100000) != 0) *((_DWORD *)v85 + 2) |= 0x100000u; if ((*(_DWORD *)(a1 + 8) & 0x800) != 0) { v37 = *((_DWORD *)v85 + 2); BYTE1(v37) |= 8u; *((_DWORD *)v85 + 2) = v37; } s1 = 0LL; v63 = 0; word_list = expand_word_internal((long)v85, a2 & 0x100 | 1, 0, &v63, 0LL); v67 += v63; if (word_list == (long **)&expand_word_error || word_list == (long **)&expand_word_fatal) { sh_xfree(appended, "subst.c", 11410LL); sh_xfree(v7, "subst.c", 11411LL); *v85 = 0LL; dispose_word(v85); return word_list; } dispose_word(v85); if (!word_list && v63) { ++v61; continue; } if (word_list && word_list[1] && !*word_list && (word_list[1][1] & 0x40000) != 0) { if (v62 && v63) ++v61; v62 = 1; } if (word_list) dequote_list(word_list); if (v63) { ++v61; if (a4) *a4 = 1; if (a5) *a5 = 1; v81 = 1; } } else { if (s1) sh_xfree(s1, "subst.c", 11466LL); word_list = 0LL; v62 = 1; } if (word_list) { if (*word_list) { if (v61) { v38 = string_list_dollar_at(word_list, 1, 0); } else { v39 = quote_list(word_list); v38 = string_list(v39); } s1 = v38; dispose_words(word_list); goto LABEL_42; } v40 = (const char *)*word_list[1]; v41 = strlen(v40); v42 = (char *)sh_xmalloc(v41 + 1, "subst.c", 11493LL); s1 = strcpy(v42, v40); v70 = *((_DWORD *)word_list[1] + 2); dispose_words(word_list); if ((v70 & 0x40000) != 0 && (*s1 != 127 || s1[1])) remove_quoted_nulls(s1); } else { s1 = 0LL; } if (!s1 && v65 == 1) v62 = 1; if (!s1 && v65 == 1 && !a2 && (*(_DWORD *)(a1 + 8) & 0x4810) == 0x4000) { v9 = 127; --v60; v62 = 1; goto LABEL_429; } if (s1 || v65 != 1 || (*(_DWORD *)(a1 + 8) & 0x50) == 0) goto LABEL_357; continue; case 0x24u: if (a5) *a5 = 1; v81 = 1; v63 = 0; v71 = (*(int *)(a1 + 8) >> 10) & 1; if ((*(_DWORD *)(a1 + 8) & 0x40) != 0) v71 |= 4u; if ((*(_DWORD *)(a1 + 8) & 0x800) != 0) v71 |= 8u; if ((*(_DWORD *)(a1 + 8) & 0x8000000) != 0) v71 |= 0x10u; v85 = (long *)param_expand(v7, &v60, a2, a5, &v63, &v61, &v62, v71); v67 += v63; v69 += v85[1] & 8; if (v85 == (long *)&expand_wdesc_error || v85 == (long *)&expand_wdesc_fatal) { sh_xfree(v7, "subst.c", 11227LL); sh_xfree(appended, "subst.c", 11228LL); if (v85 == (long *)&expand_wdesc_error) return (long **)&expand_word_error; else return (long **)&expand_word_fatal; } if (a4 && v67) *a4 = 1; if (v85 && (v85[1] & 0x40000) != 0) v62 = 1; if (v85 && (v85[1] & 0x200000) != 0) v62 = 1; if (v85) v14 = (char *)*v85; else v14 = 0LL; s1 = v14; dispose_word_desc(v85); if (v62 && s1 && *s1 == 127 && !s1[1]) { sh_xfree(s1, "subst.c", 11247LL); s1 = 0LL; } goto LABEL_42; case 0x27u: if ((a2 & 3) != 0) goto LABEL_429; v64 = ++v60; s1 = (char *)string_extract_single_quoted((long)v7, &v60, 0); if (v64 != 1 || v7[v60]) v44 = 1; else v44 = 2; v65 = v44; if (*s1) { remove_quoted_escapes(s1); } else { sh_xfree(s1, "subst.c", 11571LL); s1 = 0LL; } if (!s1 && v65 == 1) v62 = 1; if (!s1 && v65 == 1 && !a2 && (*(_DWORD *)(a1 + 8) & 0x4810) == 0x4000) { v9 = 127; --v60; goto LABEL_429; } if (!s1 && v65 == 1 && (*(_DWORD *)(a1 + 8) & 0x50) != 0) continue; if (s1) goto LABEL_357; v9 = 127; --v60; goto LABEL_429; case 0x3Au: if ((*(_DWORD *)(a1 + 8) & 0x3000) != 0) { if (a3 || (*(_DWORD *)(a1 + 8) & 0x50) != 0 || !ifs_cmap[v9]) goto LABEL_429; } else { if ((*(_DWORD *)(a1 + 8) & 0x804) != 0 && (!posixly_correct || (*(_DWORD *)(a1 + 8) & 0x80) != 0) && v7[v60 + 1] == 126) { v68 = 1; } if (a3 || (*(_DWORD *)(a1 + 8) & 0x50) != 0 || !ifs_cmap[v9]) goto LABEL_429; } goto LABEL_388; case 0x3Cu: case 0x3Eu: if (v7[++v60] != 40 || (a2 & 3) != 0 || (*(_DWORD *)(a1 + 8) & 0x100000) != 0) { --v60; goto LABEL_429; } v64 = v60 + 1; if (v9 == 60) v11 = "<("; else v11 = ">("; s2 = (char *)extract_process_subst((long)v7, (long)v11, (int *)&v64, 0); v60 = v64; if (s2) v12 = process_substitute(s2, v9 == 62); else v12 = 0LL; s1 = v12; if (s2) sh_xfree(s2, "subst.c", 11075LL); goto LABEL_40; case 0x3Du: if ((*(_DWORD *)(a1 + 8) & 0x1800) == 0) { if ((*(_DWORD *)(a1 + 8) & 4) != 0 && (!posixly_correct || (*(_DWORD *)(a1 + 8) & 0x80) != 0) && v72 == -1 && v60 > 0) { v72 = v60; } if (v72 == v60 && v7[v60 + 1] == 126) v68 = 1; if ((*(_DWORD *)(a1 + 8) & 0x20000) != 0) { v13 = *(_DWORD *)(a1 + 8); BYTE1(v13) |= 8u; *(_DWORD *)(a1 + 8) = v13; } if (!a3 && (*(_DWORD *)(a1 + 8) & 0x50) == 0 && ifs_cmap[v9]) { ++v66; goto LABEL_388; } goto LABEL_429; } if (a3 || (*(_DWORD *)(a1 + 8) & 0x50) != 0 || !ifs_cmap[v9]) goto LABEL_429; goto LABEL_388; case 0x5Bu: if ((a2 & 0x100) != 0 && shell_compatibility_level > 51) { s1 = expand_array_subscript((long)v7, &v60, a2); goto LABEL_42; } if (!a3 && (*(_DWORD *)(a1 + 8) & 0x50) == 0 && ifs_cmap[v9] && (a2 & 3) == 0) goto LABEL_388; goto LABEL_429; case 0x5Cu: if (v7[v60 + 1] == 10) { v60 += 2; continue; } v20 = v7[++v60]; if ((a2 & 2) != 0 && (a2 & 0x80) != 0 && v20 == 34) { v70 = 64; } else if ((a2 & 2) != 0) { v70 = 128; } else if ((a2 & 1) != 0) { v70 = 64; } else { v70 = 0; } if ((a2 & 0x80) != 0 && v20 == 125) { if (locale_mb_cur_max <= 1) { v100 = 1; v101 = 125; LABEL_282: ++v60; goto LABEL_283; } j = is_basic(v7[v60]); if (j) { v90 = 1LL; } else if (locale_utf8locale && v7[v60] >= 0) { v90 = v7[v60] != 0; } else { v99 = s; v90 = mbrlen(&v7[v60], v96 - v60, (mbstate_t *)&s); } if (v90 < 0xFFFFFFFFFFFFFFFELL) { if (v90) v21 = v90; else v21 = 1LL; v90 = v21; } else { s = v99; v90 = 1LL; } s1 = (char *)sh_xmalloc(v90 + 2, "subst.c", 11321LL); *s1 = 1; for (j = 0; v90 > j; ++j) { v22 = v60++; s1[j + 1] = v7[v22]; } s1[v90 + 1] = 0; } else if ((a2 & 3) == 0 || (v70 & sh_syntaxtab[v20]) != 0 || a3 || !ifs_cmap[v20]) { if ((a2 & 3) != 0 && !v20) { if (v83 + 2 >= v82) { while (v83 + 2 >= v82) v82 += 128LL; appended = (char *)sh_xrealloc(appended, v82, "subst.c", 11336LL); } v27 = v83++; appended[v27] = 1; v28 = v83++; appended[v28] = 92; appended[v83] = 0; continue; } if ((a2 & 3) == 0 || (v70 & sh_syntaxtab[v20]) != 0) { if (!v20) { v9 = 127; --v60; goto LABEL_429; } if (locale_mb_cur_max <= 1) { v100 = 1; v101 = v20; goto LABEL_282; } k = is_basic(v7[v60]); if (k) { v93 = 1LL; } else if (locale_utf8locale && v7[v60] >= 0) { v93 = v7[v60] != 0; } else { v99 = s; v93 = mbrlen(&v7[v60], v96 - v60, (mbstate_t *)&s); } if (v93 < 0xFFFFFFFFFFFFFFFELL) { if (v93) v31 = v93; else v31 = 1LL; v93 = v31; } else { s = v99; v93 = 1LL; } s1 = (char *)sh_xmalloc(v93 + 2, "subst.c", 11355LL); *s1 = 1; for (k = 0; v93 > k; ++k) { v32 = v60++; s1[k + 1] = v7[v32]; } s1[v93 + 1] = 0; } else { if (locale_mb_cur_max <= 1) { v100 = 92; v101 = v20; goto LABEL_282; } m = is_basic(v7[v60]); if (m) { v92 = 1LL; } else if (locale_utf8locale && v7[v60] >= 0) { v92 = v7[v60] != 0; } else { v99 = s; v92 = mbrlen(&v7[v60], v96 - v60, (mbstate_t *)&s); } if (v92 < 0xFFFFFFFFFFFFFFFELL) { if (v92) v29 = v92; else v29 = 1LL; v92 = v29; } else { s = v99; v92 = 1LL; } s1 = (char *)sh_xmalloc(v92 + 2, "subst.c", 11345LL); *s1 = 92; for (m = 0; v92 > m; ++m) { v30 = v60++; s1[m + 1] = v7[v30]; } s1[v92 + 1] = 0; } } else { if (v83 + 2 >= v82) { while (v83 + 2 >= v82) v82 += 128LL; appended = (char *)sh_xrealloc(appended, v82, "subst.c", 11326LL); } v23 = v83++; appended[v23] = 1; v24 = v83++; appended[v24] = 92; appended[v83] = 0; if (locale_mb_cur_max <= 1) { v100 = 1; v101 = v20; goto LABEL_282; } n = is_basic(v7[v60]); if (n) { v91 = 1LL; } else if (locale_utf8locale && v7[v60] >= 0) { v91 = v7[v60] != 0; } else { v99 = s; v91 = mbrlen(&v7[v60], v96 - v60, (mbstate_t *)&s); } if (v91 < 0xFFFFFFFFFFFFFFFELL) { if (v91) v25 = v91; else v25 = 1LL; v91 = v25; } else { s = v99; v91 = 1LL; } s1 = (char *)sh_xmalloc(v91 + 2, "subst.c", 11332LL); *s1 = 1; for (n = 0; v91 > n; ++n) { v26 = v60++; s1[n + 1] = v7[v26]; } s1[v91 + 1] = 0; } goto LABEL_42; case 0x60u: v15 = v60++; v64 = v15; if ((*(_DWORD *)(a1 + 8) & 0x8000000) != 0) v16 = 0; else v16 = 4; s1 = (char *)string_extract((long)v7, &v60, "`", v16); if (s1 != (char *)&extract_string_error && s1 != (char *)&extract_string_fatal) { if (a5) *a5 = 1; v81 = 1; if ((*(_DWORD *)(a1 + 8) & 0x400) != 0) { s2 = (char *)substring(v7, v64, (unsigned int)(v60 + 1)); } else { de_backslash(s1); v85 = (long *)command_substitute(s1, a2, 0); if (v85) v19 = (char *)*v85; else v19 = 0LL; s2 = v19; if (v85) dispose_word_desc(v85); } if (s1) sh_xfree(s1, "subst.c", 11291LL); s1 = s2; LABEL_40: if (v7[v60]) ++v60; goto LABEL_42; } if (v60 - 1 != v64) { set_exit_status(1LL); v17 = &v7[v64]; v18 = gettext("bad substitution: no closing \"`\" in %s"); report_error(v18, v17); sh_xfree(v7, "subst.c", 11270LL); sh_xfree(appended, "subst.c", 11271LL); if (s1 == (char *)&extract_string_error) return (long **)&expand_word_error; else return (long **)&expand_word_fatal; } v60 = v64; LABEL_429: if (v83 + 1 >= v82) { while (v83 + 1 >= v82) v82 += 128LL; appended = (char *)sh_xrealloc(appended, v82, "subst.c", 11662LL); } v47 = v83++; appended[v47] = v9; appended[v83] = 0; ++v60; break; default: goto LABEL_388; } } if (v9 == 126) break; LABEL_388: if ((a2 & 3) == 0 && (a3 || !ifs_cmap[v9] || (*(_DWORD *)(a1 + 8) & 0x50) != 0)) { if (locale_mb_cur_max <= 1) goto LABEL_429; ii = is_basic(v7[v60]); if (ii) { v95 = 1LL; } else if (locale_utf8locale && v7[v60] >= 0) { v95 = v7[v60] != 0; } else { v99 = s; v95 = mbrlen(&v7[v60], v96 - v60, (mbstate_t *)&s); } if (v95 >= 0xFFFFFFFFFFFFFFFELL) { s = v99; v95 = 1LL; } if (!v95) v95 = 1LL; s1 = (char *)sh_xmalloc(v95 + 1, "subst.c", 11659LL); for (ii = 0; v95 > ii; ++ii) { v46 = v60++; s1[ii] = v7[v46]; } s1[v95] = 0; goto LABEL_42; } if ((a2 & 3) == 0) ++v66; if (v7[v60]) ++v60; if (!v9) { v9 = 127; goto LABEL_429; } if (mb_cur_max > 1) { jj = is_basic(v7[--v60]); if (jj) { v94 = 1LL; } else if (locale_utf8locale && v7[v60] >= 0) { v94 = v7[v60] != 0; } else { v99 = s; v94 = mbrlen(&v7[v60], v96 - v60, (mbstate_t *)&s); } if (v94 >= 0xFFFFFFFFFFFFFFFELL) { s = v99; v94 = 1LL; } if (!v94) v94 = 1LL; s1 = (char *)sh_xmalloc(v94 + 2, "subst.c", 11647LL); *s1 = 1; for (jj = 0; v94 > jj; ++jj) { v45 = v60++; s1[jj + 1] = v7[v45]; } s1[v94 + 1] = 0; goto LABEL_42; } v100 = 1; v101 = v9; LABEL_283: if (v83 + 2 >= v82) { while (v83 + 2 >= v82) v82 += 128LL; appended = (char *)sh_xrealloc(appended, v82, "subst.c", 11361LL); } v33 = v83++; appended[v33] = v100; v34 = v83++; appended[v34] = v101; appended[v83] = 0; } if ((*(_DWORD *)(a1 + 8) & 0x1000) != 0 || v60 > 0 && !v68 || (a2 & 3) != 0) { v68 = 0; if (a3 || (*(_DWORD *)(a1 + 8) & 0x50) != 0 || !ifs_cmap[v9] || (a2 & 3) != 0) goto LABEL_429; goto LABEL_388; } if ((*(_DWORD *)(a1 + 8) & 0x800) != 0) v70 = 2; else v70 = (*(_DWORD *)(a1 + 8) & 0x84) != 0; s1 = (char *)bash_tilde_find_word(&v7[v60], v70, &v64); v68 = 0; if (!s1 || !*s1 || (int)v64 <= 0) { if (s1) sh_xfree(s1, "subst.c", 11201LL); goto LABEL_429; } s2 = (char *)bash_tilde_expand(s1, v70); if (s2 && *s2 == 126 && *s1 == *s2 && !strcmp(s1, s2)) { if (s1) sh_xfree(s1, "subst.c", 11190LL); if (s2) sh_xfree(s2, "subst.c", 11191LL); goto LABEL_429; } sh_xfree(s1, "subst.c", 11194LL); s1 = s2; v60 += v64; LABEL_357: if (!s1) { v9 = 127; --v60; v62 = 1; goto LABEL_429; } s2 = s1; s1 = quote_string(s1); sh_xfree(s2, "subst.c", 11541LL); LABEL_42: if (s1) { appended = (char *)sub_append_string((long)s1, (long)appended, &v83, &v82); s1 = 0LL; } } } LABEL_438: if (!*appended) { if (v62 || !v61 && v65 == 1) { *appended = 127; appended[1] = 0; v85 = (long *)alloc_word_desc(); *v85 = (long)appended; appended = 0LL; *((_DWORD *)v85 + 2) |= 0x40000u; word_list = (long **)make_word_list(v85, 0LL); if ((a2 & 3) != 0) *((_DWORD *)v85 + 2) |= 2u; } else if (v65 && !v61) { word_list = 0LL; } else { word_list = 0LL; } goto LABEL_533; } if ((*(_DWORD *)(a1 + 8) & 0x10) != 0) { v85 = (long *)alloc_word_desc(); *v85 = (long)appended; if (v62 && *appended == 127 && !appended[1]) *((_DWORD *)v85 + 2) |= 0x40000u; appended = 0LL; if ((*(_DWORD *)(a1 + 8) & 4) != 0) *((_DWORD *)v85 + 2) |= 4u; if ((*(_DWORD *)(a1 + 8) & 0x8000) != 0) { v48 = *((_DWORD *)v85 + 2); BYTE1(v48) |= 0x80u; *((_DWORD *)v85 + 2) = v48; } if ((*(_DWORD *)(a1 + 8) & 0x20) != 0) *((_DWORD *)v85 + 2) |= 0x20u; if ((*(_DWORD *)(a1 + 8) & 0x4000000) != 0) *((_DWORD *)v85 + 2) |= 0x4000000u; if ((*(_DWORD *)(a1 + 8) & 0x200) != 0) { v49 = *((_DWORD *)v85 + 2); BYTE1(v49) |= 2u; *((_DWORD *)v85 + 2) = v49; } if ((a2 & 3) != 0) *((_DWORD *)v85 + 2) |= 2u; } else { if ((*(_DWORD *)(a1 + 8) & 0x800) != 0) { word_list = (long **)list_string(appended, (long)&src, a2); v85 = word_list[1]; if (v62 && *appended == 127 && !appended[1]) *((_DWORD *)v85 + 2) |= 0x40000u; sh_xfree(word_list, "subst.c", 11754LL); sh_xfree(appended, "subst.c", 11755LL); appended = 0LL; } else { if (v61 || v67) v50 = ifs_value; else v50 = 0LL; v97 = v50; if (v69) { if (ifs_is_set) word_list = (long **)list_string(appended, (long)" ", 1); else word_list = (long **)list_string(appended, (long)" \t\n", 1); goto LABEL_533; } if (v67 && !v61 && v97 && !a2 && (*(_DWORD *)(a1 + 8) & 0x40) != 0) { v85 = (long *)alloc_word_desc(); if (!*v97 || *v97 == 32) { *v85 = (long)appended; } else { if (*v97) v51 = v97; else v51 = " "; word_list = (long **)list_string(appended, (long)v51, 1); v52 = string_list(word_list); *v85 = (long)v52; } if (v62 && *appended == 127 && !appended[1]) *((_DWORD *)v85 + 2) |= 0x40000u; if (appended != (char *)*v85) sh_xfree(appended, "subst.c", 11821LL); appended = 0LL; } else { if (v67 && v97) { if (*v97) v53 = v97; else v53 = " "; word_list = (long **)list_string(appended, (long)v53, 1); goto LABEL_533; } v85 = (long *)alloc_word_desc(); if (a5 && !*a5 && v66) { v54 = remove_quoted_ifs(appended); *v85 = v54; } else { *v85 = (long)appended; } if (v62 && *appended == 127 && !appended[1]) { *((_DWORD *)v85 + 2) |= 0x40000u; } else if (v62) { *((_DWORD *)v85 + 2) |= 0x200000u; } if (appended != (char *)*v85) sh_xfree(appended, "subst.c", 11839LL); appended = 0LL; } } if ((a2 & 3) != 0 || v65 == 2) *((_DWORD *)v85 + 2) |= 2u; if ((*(_DWORD *)(a1 + 8) & 4) != 0) *((_DWORD *)v85 + 2) |= 4u; if ((*(_DWORD *)(a1 + 8) & 0x8000) != 0) { v55 = *((_DWORD *)v85 + 2); BYTE1(v55) |= 0x80u; *((_DWORD *)v85 + 2) = v55; } if ((*(_DWORD *)(a1 + 8) & 0x20) != 0) *((_DWORD *)v85 + 2) |= 0x20u; if ((*(_DWORD *)(a1 + 8) & 0x4000000) != 0) *((_DWORD *)v85 + 2) |= 0x4000000u; if ((*(_DWORD *)(a1 + 8) & 0x200) != 0) { v56 = *((_DWORD *)v85 + 2); BYTE1(v56) |= 2u; *((_DWORD *)v85 + 2) = v56; } } word_list = (long **)make_word_list(v85, 0LL); LABEL_533: sh_xfree(appended, "subst.c", 11858LL); return word_list; } if (a4) *a4 = 1; if (a5) *a5 = 1; if (cached_quoted_dollar_at) return (long **)copy_word_list(cached_quoted_dollar_at); v6 = (long **)list_rest_of_args(); word_list = quote_list(v6); cached_quoted_dollar_at = copy_word_list(word_list); return word_list; }
bash
ida
static int ipnh_cache_process_nlmsg(const struct nlmsghdr *n, struct nh_entry *new_nhe) { struct nh_entry *nhe; nhe = ipnh_cache_get(new_nhe->nh_id); switch (n->nlmsg_type) { case RTM_DELNEXTHOP: if (nhe) ipnh_cache_del(nhe); ipnh_destroy_entry(new_nhe); break; case RTM_NEWNEXTHOP: if (!nhe) { nhe = malloc(sizeof(*nhe)); if (!nhe) { ipnh_destroy_entry(new_nhe); return -1; } } else { ipnh_cache_unlink_entry(nhe); ipnh_destroy_entry(nhe); } memcpy(nhe, new_nhe, sizeof(*nhe)); ipnh_cache_link_entry(nhe); break; } return 0; }
void ipnh_cache_process_nlmsg(struct_1 *a0, struct_0 *a1) { void *v0; unsigned long long v2; void *v3; v0 = ipnh_cache_get(a1->field_10); switch (a0->field_4) { case 104: if (v0) { ipnh_cache_unlink_entry(v0); ipnh_destroy_entry(v0); } else { v0 = malloc(0x70); if (!v0) { ipnh_destroy_entry(a1); v2 = 4294967295; return; } } memcpy(v0, a1, 0x70); ipnh_cache_link_entry(v0); break; case 105: if (v0) ipnh_cache_del(v0); ipnh_destroy_entry(a1); break; default: v3 = 0; return; } }
iproute2-6.0.0
angr_sailr
static int psk_callback(gnutls_session_t session, char **username, gnutls_datum_t *key) { const char *hint = gnutls_psk_client_get_hint(session); char *rawkey; char *passwd; int ret; size_t res_size; gnutls_datum_t tmp; log_msg(stdout, "- PSK client callback. "); if (hint) log_msg(stdout, "PSK hint '%s'\n", hint); else log_msg(stdout, "No PSK hint\n"); if (gnutls_cli_options.present.pskusername) *username = gnutls_strdup(gnutls_cli_options.arg.pskusername); else { char *p = ((void *)0); size_t n; log_msg(stdout, "Enter PSK identity: "); fflush(stdout); ret = getline(&p, &n, stdin); if (ret == -1 || p == ((void *)0)) { fprintf(stderr, "No username given, aborting...\n"); return -32; } if (p[strlen(p) - 1] == '\n') p[strlen(p) - 1] = '\0'; if (p[strlen(p) - 1] == '\r') p[strlen(p) - 1] = '\0'; *username = gnutls_strdup(p); free(p); } if (!*username) return -25; passwd = getpass("Enter key: "); if (passwd == ((void *)0)) { fprintf(stderr, "No key given, aborting...\n"); return -32; } tmp.data = (void *)passwd; tmp.size = strlen(passwd); res_size = tmp.size / 2 + 1; rawkey = gnutls_malloc(res_size); if (rawkey == ((void *)0)) return -25; ret = gnutls_hex_decode(&tmp, rawkey, &res_size); if (ret < 0) { fprintf(stderr, "Error deriving password: %s\n", gnutls_strerror(ret)); gnutls_free((void *)(rawkey)), rawkey = ((void *)0); gnutls_free((void *)(*username)), *username = ((void *)0); return ret; } key->data = (void *)rawkey; key->size = res_size; if (gnutls_cli_options.present.debug) { char hexkey[41]; res_size = sizeof(hexkey); ret = gnutls_hex_encode(key, hexkey, &res_size); if (ret < 0) { fprintf(stderr, "Error in hex encoding: %s\n", gnutls_strerror(ret)); exit(1); } fprintf(stderr, "PSK username: %s\n", *username); fprintf(stderr, "PSK hint: %s\n", hint); fprintf(stderr, "PSK key: %s\n", hexkey); } return 0; }
long psk_callback(long a1, const char **a2, long a3) { const char *v4; const char *v5; int v7; int v8; char *lineptr; const char *hint; char *s; long v12; size_t n; unsigned int v14; char v15[56]; unsigned long v16; v16 = __readfsqword(0x28u); hint = (const char *)gnutls_psk_client_get_hint(a1); log_msg(stdout, "- PSK client callback. "); if (hint) log_msg(stdout, "PSK hint '%s'\n", hint); else log_msg(stdout, "No PSK hint\n"); if (gnutls_cli_options[36]) { *a2 = (const char *)gnutls_strdup(*(_QWORD *)&gnutls_cli_options[240]); } else { lineptr = 0LL; log_msg(stdout, "Enter PSK identity: "); fflush(stdout); if ((unsigned int)getline(&lineptr, &n, stdin) == -1 || !lineptr) { fprintf(stderr, "No username given, aborting...\n"); return 4294967264LL; } if (lineptr[strlen(lineptr) - 1] == 10) lineptr[strlen(lineptr) - 1] = 0; if (lineptr[strlen(lineptr) - 1] == 13) lineptr[strlen(lineptr) - 1] = 0; *a2 = (const char *)gnutls_strdup(lineptr); free(lineptr); } if (!*a2) return 4294967271LL; s = getpass("Enter key: "); if (s) { n = (size_t)s; v14 = strlen(s); lineptr = (char *)((v14 >> 1) + 1); v12 = gnutls_malloc(lineptr); if (v12) { v7 = gnutls_hex_decode(&n, v12, &lineptr); if (v7 >= 0) { *(_QWORD *)a3 = v12; *(_DWORD *)(a3 + 8) = (_DWORD)lineptr; if (gnutls_cli_options[0]) { lineptr = (_BYTE *)(&loc_27 + 2); v8 = gnutls_hex_encode(a3, v15, &lineptr); if (v8 < 0) { v5 = (const char *)gnutls_strerror((unsigned int)v8); fprintf(stderr, "Error in hex encoding: %s\n", v5); exit(1); } fprintf(stderr, "PSK username: %s\n", *a2); fprintf(stderr, "PSK hint: %s\n", hint); fprintf(stderr, "PSK key: %s\n", v15); } return 0LL; } else { v4 = (const char *)gnutls_strerror((unsigned int)v7); fprintf(stderr, "Error deriving password: %s\n", v4); gnutls_free(v12); v12 = 0LL; gnutls_free(*a2); *a2 = 0LL; return (unsigned int)v7; } } else { return 4294967271LL; } } else { fprintf(stderr, "No key given, aborting...\n"); return 4294967264LL; } }
gnutls
ida
size_t atomiciov(ssize_t (*f)(int, const struct iovec *, int), int fd, const struct iovec *_iov, int iovcnt) { return atomiciov6(f, fd, _iov, iovcnt, ((void *)0), ((void *)0)); }
void atomiciov(undefined8 param_1, undefined4 param_2, undefined8 param_3, undefined4 param_4) { atomiciov6(param_1, param_2, param_3, param_4, 0, 0); return; }
openssh-portable
ghidra
test_code_t test_md5(gnutls_session_t session) { int ret; if (gnutls_fips140_mode_enabled()) return TEST_IGNORE; sprintf(prio_str, "NONE:" "+CIPHER-ALL:+ARCFOUR-128:+3DES-CBC" ":+GOST28147-TC26Z-CNT" ":" "+COMP-NULL" ":%s:+MD5:" "+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+ECDHE-RSA:+ECDHE-ECDSA:+ANON-ECDH" ":+VKO-GOST-12" ":%s", protocol_str, rest); { int _ret; if ((_ret = __gnutls_priority_set_direct(session, prio_str, 870)) != TEST_SUCCEED) { return _ret; } }; gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred); ret = test_do_handshake(session); return ret; }
long long test_md5(unsigned long long a0) { unsigned int v0; unsigned int v1; unsigned long long v3; if (gnutls_fips140_mode_enabled()) { v3 = 3; return v3; } sprintf(&prio_str, "NONE:+CIPHER-ALL:+ARCFOUR-128:+3DES-CBC:+GOST28147-TC26Z-CNT:+COMP-" "NULL:%s:+MD5:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+ECDHE-RSA:+ECDHE-" "ECDSA:+ANON-ECDH:+VKO-GOST-12:%s", &protocol_str, &rest); v0 = __gnutls_priority_set_direct(a0, &prio_str, 0x366); if (v0) { v3 = v0; return v3; } gnutls_credentials_set(a0, 0x1, xcred); v1 = test_do_handshake(a0); v3 = v1; return v3; }
gnutls
angr_sailr
static const char *validate_to_str(__u8 validate) { if (validate >= (sizeof(validate_str) / sizeof((validate_str)[0]))) return "(unknown)"; return validate_str[validate]; }
int validate_to_str(unsigned long a0) { unsigned int v1; if (a0 > 2) v1 = &g_40464c; else v1 = (&validate_str)[a0]; return v1; }
iproute2-6.0.0
angr_dream
test_code_t test_3des(gnutls_session_t session) { int ret; sprintf(prio_str, "NONE:" "+3DES-CBC:" "+COMP-NULL" ":%s:" "+MAC-ALL:+MD5:+SHA1" ":+GOST28147-TC26Z-IMIT" ":" "+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+ECDHE-RSA:+ECDHE-ECDSA:+ANON-ECDH" ":+VKO-GOST-12" ":%s", protocol_str, rest); { int _ret; if ((_ret = __gnutls_priority_set_direct(session, prio_str, 935)) != TEST_SUCCEED) { return _ret; } }; gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred); ret = test_do_handshake(session); return ret; }
long test_3des(long a1) { unsigned int v2; sprintf(prio_str, "NONE:+3DES-CBC:+COMP-NULL:%s:+MAC-ALL:+MD5:+SHA1:+GOST28147-TC26Z-" "IMIT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+ECDHE-RSA:+E" "CDHE-ECDSA:+ANON-ECDH:+VKO-GOST-12:%s", protocol_str, rest); v2 = _gnutls_priority_set_direct(a1, prio_str, 0x3A7u); if (v2) return v2; gnutls_credentials_set(a1, 1LL, xcred); return (unsigned int)test_do_handshake(a1); }
gnutls
ida
void pushstring(char *s, void *ap) { struct strpush *sp; size_t len; len = strlen(s); ({ suppressint++; ({ __asm__ __volatile__("" : : : "memory"); }); 0; }); if ((unsigned long)parsefile->strpush | (unsigned long)parsefile->spfree) { sp = ckmalloc(sizeof(struct strpush)); sp->prev = parsefile->strpush; parsefile->strpush = sp; } else sp = parsefile->strpush = &(parsefile->basestrpush); sp->prevstring = parsefile->nextc; sp->prevnleft = parsefile->nleft; sp->unget = parsefile->unget; sp->spfree = parsefile->spfree; memcpy(sp->lastc, parsefile->lastc, sizeof(sp->lastc)); sp->ap = (struct alias *)ap; if (ap) { ((struct alias *)ap)->flag |= 1; sp->string = s; } parsefile->nextc = s; parsefile->nleft = len; parsefile->unget = 0; parsefile->spfree = ((void *)0); ({ ({ __asm__ __volatile__("" : : : "memory"); }); if (--suppressint == 0 && intpending) onint(); 0; }); }
void pushstring(char *param_1, long param_2) { undefined *puVar1; size_t sVar2; undefined8 *local_18; sVar2 = strlen(param_1); puVar1 = parsefile; suppressint = suppressint + 1; if ((*(ulong *)(parsefile + 0x70) | *(ulong *)(parsefile + 0x28)) == 0) { *(undefined **)(parsefile + 0x28) = parsefile + 0x30; local_18 = *(undefined8 **)(puVar1 + 0x28); } else { local_18 = (undefined8 *)ckmalloc(0x40); *local_18 = *(undefined8 *)(parsefile + 0x28); *(undefined8 **)(parsefile + 0x28) = local_18; } local_18[1] = *(undefined8 *)(parsefile + 0x18); *(undefined4 *)(local_18 + 2) = *(undefined4 *)(parsefile + 0x10); *(undefined4 *)(local_18 + 7) = *(undefined4 *)(parsefile + 0x80); local_18[5] = *(undefined8 *)(parsefile + 0x70); memcpy(local_18 + 6, parsefile + 0x78, 8); local_18[3] = param_2; if (param_2 != 0) { *(uint *)(param_2 + 0x18) = *(uint *)(param_2 + 0x18) | 1; local_18[4] = param_1; } *(char **)(parsefile + 0x18) = param_1; *(int *)(parsefile + 0x10) = (int)sVar2; *(undefined4 *)(parsefile + 0x80) = 0; *(undefined8 *)(parsefile + 0x70) = 0; suppressint = suppressint + -1; if ((suppressint == 0) && (intpending != 0)) { onint(); } return; }
dash-0.5.11+git20210903+057cd650a4ed
ghidra
static int newerf(const char *f1, const char *f2) { struct stat64 b1, b2; return (stat64(f1, &b1) == 0 && stat64(f2, &b2) == 0 && (b1.st_mtim.tv_sec > b2.st_mtim.tv_sec || (b1.st_mtim.tv_sec == b2.st_mtim.tv_sec && (b1.st_mtim.tv_nsec > b2.st_mtim.tv_nsec)))); }
void newerf(char *a0, char *a1) { char v0; char v1; char v2; char v3; char v4; char v5; void *v7; unsigned long long v8; if (!stat64(a0, &v0) && !stat64(a1, &v3) && (!(*(&v1) <= *(&v4)) || !(*(&v1) != *(&v4)) && !(*(&v2) <= *(&v5)))) { v8 = 1; return; } v7 = 0; return; }
dash-0.5.11+git20210903+057cd650a4ed
angr_sailr
static void die(int killed) { static struct termios sgtty; if (killed != 0) { tcsetattr(0, 0, &sgtty); } else { tcgetattr(0, &sgtty); } if (killed != 0) { _exit(128 + killed); } }
void die(int a1) { if (a1) tcsetattr(0, 0, &sgtty_5650); else tcgetattr(0, &sgtty_5650); if (a1) exit(a1 + 128); }
shadow
ida
const char *tar_dirname(void) { return wd[chdir_current].name; }
long tar_dirname() { return *(_QWORD *)(wd + 24LL * chdir_current); }
tar
ida
static _Bool decode_record(struct xheader *xhdr, char **ptr, void (*handler)(void *, char const *, char const *, size_t), void *data) { char *start = *ptr; char *p = start; size_t len; char *len_lim; char const *keyword; char *nextp; size_t len_max = xhdr->buffer + xhdr->size - start; while (*p == ' ' || *p == '\t') p++; if (!((unsigned)(*p) - '0' <= 9)) { if (*p) do { if (error_hook) error_hook(); error(0, 0, gettext("Malformed extended header: missing length")); exit_status = 2; } while (0); return 0; } len = strtoumax(p, &len_lim, 10); if (len_max < len) { int len_len = len_lim - p; do { if (error_hook) error_hook(); error(0, 0, gettext("Extended header length %*s is out of range"), len_len, p); exit_status = 2; } while (0); return 0; } nextp = start + len; for (p = len_lim; *p == ' ' || *p == '\t'; p++) continue; if (p == len_lim) { do { if (error_hook) error_hook(); error(0, 0, gettext("Malformed extended header: missing blank after length")); exit_status = 2; } while (0); return 0; } keyword = p; p = strchr(p, '='); if (!(p && p < nextp)) { do { if (error_hook) error_hook(); error(0, 0, gettext("Malformed extended header: missing equal sign")); exit_status = 2; } while (0); return 0; } if (nextp[-1] != '\n') { do { if (error_hook) error_hook(); error(0, 0, gettext("Malformed extended header: missing newline")); exit_status = 2; } while (0); return 0; } *p = nextp[-1] = '\0'; handler(data, keyword, p + 1, nextp - p - 2); *p = '='; nextp[-1] = '\n'; *ptr = nextp; return 1; }
int decode_record(unsigned long long a0[3], unsigned long long *a1, unsigned long long a2, unsigned long long a3) { unsigned int v0; char v1; char *v2; char *v3; unsigned long v4; unsigned long v5; unsigned long v6; unsigned long long v7; unsigned int v9; v3 = *(a1); v2 = v3; v4 = a0[1] + a0[2] + -0x1 * v3; while (true) { if (*(v2) != 32 && *(v2) != 9) break; v2 += 1; } if (*(v2)-48 > 9) { if (*(v2)) { if (*(&error_hook)) *(5242936)(); error(0x0, 0x0, gettext("Malformed extended header: missing length")); exit_status = 2; } v9 = 0; } else { v5 = strtoumax(v2, &v1, 0xa); if (v4 < v5) { v0 = (*(&v1) + -0x1 * v2); if (*(&error_hook)) *(5242936)(); error(0x0, 0x0, gettext("Extended header length %*s is out of range")); exit_status = 2; v9 = 0; } else { v6 = &v3[v5]; v2 = *(&v1); while (true) { if (*(v2) != 32 && *(v2) != 9) break; v2 += 1; } if (v2 == *(&v1)) { if (*(&error_hook)) *(5242936)(); error(0x0, 0x0, gettext("Malformed extended header: missing blank after length")); exit_status = 2; v9 = 0; } else { v7 = v2; v2 = strchr(v2, 0x3d); if (!v2) { LABEL_401816: if (*(&error_hook)) *(5242936)(); error(0x0, 0x0, gettext("Malformed extended header: missing equal sign")); exit_status = 2; v9 = 0; } else { if (!(v2 < v6)) goto LABEL_401816; if (*((v6 - 1)) == 10) { *((v6 - 1)) = 0; *(v2) = *((v6 - 1)); (stack_base)[112](a3, v7, v2 + 1, -2 + v6 + -0x1 * v2, a2); *(v2) = 61; *((v6 - 1)) = 10; *(a1) = v6; v9 = 1; } else { if (*(&error_hook)) *(5242936)(); error(0x0, 0x0, gettext("Malformed extended header: missing newline")); exit_status = 2; v9 = 0; } } } } } return v9; }
tar
angr_phoenix
, "getnameinfo failed: %.100s", ssh_gai_strerror(ret)) ; continue; } listen_sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (listen_sock == -1) { sshlog("sshd.c", __func__, 1053, 0, SYSLOG_LEVEL_VERBOSE, ((void *)0), "socket: %.100s", strerror((*__errno_location()))); continue; }
void ssh_gai_strerror(void) { halt_baddata(); }
openssh-portable
ghidra
static int history_tokenize_word(const char *string, int ind) { register int i, j; int delimiter, nestdelim, delimopen; i = ind; delimiter = nestdelim = 0; if (((string[i]) ? ((char *)strchr(("()\n"), (string[i])) != (char *)((void *)0)) : 0)) { i++; return i; } if ((1 && ((*__ctype_b_loc())[(int)(((unsigned char)string[i]))] & (unsigned short int)_ISdigit))) { j = i; while (string[j] && (1 && ((*__ctype_b_loc())[(int)(((unsigned char)string[j]))] & (unsigned short int)_ISdigit))) j++; if (string[j] == 0) return (j); if (string[j] == '<' || string[j] == '>') i = j; else { i = j; goto get_word; } } if (((string[i]) ? ((char *)strchr(("<>;&|"), (string[i])) != (char *)((void *)0)) : 0)) { int peek = string[i + 1]; if (peek == string[i]) { if (peek == '<' && string[i + 2] == '-') i++; else if (peek == '<' && string[i + 2] == '<') i++; i += 2; return i; } else if (peek == '&' && (string[i] == '>' || string[i] == '<')) { j = i + 2; while (string[j] && (1 && ((*__ctype_b_loc())[(int)(((unsigned char)string[j]))] & (unsigned short int)_ISdigit))) j++; if (string[j] == '-') j++; return j; } else if ((peek == '>' && string[i] == '&') || (peek == '|' && string[i] == '>')) { i += 2; return i; } else if (peek == '(' && (string[i] == '>' || string[i] == '<')) { i += 2; delimopen = '('; delimiter = ')'; nestdelim = 1; goto get_word; } i++; return i; } get_word: if (delimiter == 0 && ((string[i]) ? ((char *)strchr(("\"'`"), (string[i])) != (char *)((void *)0)) : 0)) delimiter = string[i++]; for (; string[i]; i++) { if (string[i] == '\\' && string[i + 1] == '\n') { i++; continue; } if (string[i] == '\\' && delimiter != '\'' && (delimiter != '"' || ((string[i]) ? ((char *)strchr(("\\`\"$"), (string[i])) != (char *)((void *)0)) : 0))) { i++; continue; } if (nestdelim && string[i] == delimopen) { nestdelim++; continue; } if (nestdelim && string[i] == delimiter) { nestdelim--; if (nestdelim == 0) delimiter = 0; continue; } if (delimiter && string[i] == delimiter) { delimiter = 0; continue; } if (nestdelim == 0 && delimiter == 0 && ((string[i]) ? ((char *)strchr(("<>$!@?+*"), (string[i])) != (char *)((void *)0)) : 0) && string[i + 1] == '(') { i += 2; delimopen = '('; delimiter = ')'; nestdelim = 1; continue; } if (delimiter == 0 && (((string[i]) ? ((char *)strchr((history_word_delimiters), (string[i])) != (char *)((void *)0)) : 0))) break; if (delimiter == 0 && ((string[i]) ? ((char *)strchr(("\"'`"), (string[i])) != (char *)((void *)0)) : 0)) delimiter = string[i]; } return i; }
int history_tokenize_word(char *a0, unsigned long a1) { unsigned int v0; int tmp_7; unsigned int v1; unsigned int v2; unsigned int v3; char *v5; unsigned int v6; unsigned int v8; char *v9; unsigned int v10; v5 = a1; v1 = 0; v0 = v1; if (a0[a1] && strchr("()\n", a0[a1])) { v6 = a1 + 1; goto LABEL_403753; } v8 = *((*(__ctype_b_loc()) + a0[a1] * 2)) & 0x800; if (v8) { while (true) { if (!*((a0 + v5))) break; *(&v8) = *((*(__ctype_b_loc()) + *((a0 + v5)) * 2)); v8 = v8 & 0x800; if (!v8) break; v5 = v5 + 1; } if (!*((a0 + v5))) { v6 = v5; goto LABEL_403753; } } if (*((a0 + v5)) && strchr("<>;&|", *((a0 + v5)))) { v3 = *((a0 + v5 + 1)); if (v3 == *((a0 + v5))) { if (v3 == 60 && *((a0 + v5 + 2)) == 45) goto LABEL_4033b1; LABEL_4033b1: *(&v5) = a1 + 2; v6 = *(&v5); goto LABEL_403753; } if (v3 != 38) { LABEL_403448: if (v3 == 62 && *((a0 + v5)) == 38) goto LABEL_403476; if (v3 != 124) { LABEL_403480: if (v3 != 40) { LABEL_4034c2: *(&v5) = v5 + 1; v6 = *(&v5); goto LABEL_403753; } else { if (*((a0 + v5)) != 62 && !(*((a0 + v5)) == 60)) goto LABEL_4034c2; v5 = v5 + 2; v2 = 40; v0 = 41; v1 = 1; } } else if (!(*((a0 + v5)) == 62)) { goto LABEL_403480; } LABEL_403476: *(&v5) = v5 + 2; v6 = *(&v5); goto LABEL_403753; } else { if (*((a0 + v5)) != 62 && !(*((a0 + v5)) == 60)) goto LABEL_403448; v9 = v5 + 2; while (true) { if (!*((a0 + v9))) break; *(&v8) = *((*(__ctype_b_loc()) + *((a0 + v9)) * 2)); v10 = v8 & 0x800; if (!v10) break; v9 = v9 + 1; } if (*((a0 + v9)) == 45) *(&v9) = v9 + 1; v6 = v9; goto LABEL_403753; } } if (!v0 && *((a0 + v5)) && strchr("\"\'`", *((a0 + v5)))) { tmp_7 = v5; v5 += 1; v0 = a0[tmp_7]; } while (true) { if (!*((a0 + v5))) break; if (*((a0 + v5)) == 92 && *((a0 + v5 + 1)) == 10) goto LABEL_403736; if (*((a0 + v5)) == 92 && v0 != 39) { if (v0 != 34) { LABEL_4035af: goto LABEL_403736; } else if (*((a0 + v5))) { if (!strchr("\\`\"$", *((a0 + v5)))) goto LABEL_4035b7; goto LABEL_4035af; } } LABEL_4035b7: if (v1 && v2 == *((a0 + v5))) { v1 += 1; goto LABEL_403736; } if (v1 && v0 == *((a0 + v5))) { v1 -= 1; if (!v1) v0 = 0; goto LABEL_403736; } if (v0 && v0 == *((a0 + v5))) { v0 = 0; goto LABEL_403736; } if (!v1 && !v0 && *((a0 + v5)) && strchr("<>$!@?+*", *((a0 + v5))) && *((a0 + v5 + 1)) == 40) { v2 = 40; v0 = 41; v1 = 1; goto LABEL_403736; } if (!v0 && *((a0 + v5)) && strchr(history_word_delimiters, *((a0 + v5)))) break; if (!v0 && *((a0 + v5)) && strchr("\"\'`", *((a0 + v5)))) v0 = *((a0 + v5)); LABEL_403736: v5 = a1 + 1; } v6 = v5; LABEL_403753: return v6; }
bash
angr_phoenix
static _Bool parse_time(const struct parser_table *entry, char *argv[], int *arg_ptr) { struct predicate *our_pred; struct time_val tval; enum comparison_type comp; const char *timearg, *orig_timearg; const char *errmsg = gettext("arithmetic overflow while converting %s " "days to a number of seconds"); struct timespec origin; const int saved_argc = *arg_ptr; if (!collect_arg(argv, arg_ptr, &timearg)) return 0; orig_timearg = timearg; origin = options.cur_day_start; if (get_comp_type(&timearg, &comp)) { if (COMP_LT == comp) { uintmax_t expected = origin.tv_sec + (86400 - 1); origin.tv_sec += (86400 - 1); if (expected != (uintmax_t)origin.tv_sec) { ((!!sizeof(struct { _Static_assert( 1, "verify_expr (" "1" ", " "(error (1, 0, gettext (\"arithmetic overflow when trying to " "calculate the end of today\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, 0, gettext("arithmetic overflow when trying to calculate " "the end of today")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, 0, gettext("arithmetic overflow when trying to calculate " "the end of today")), ((0) ? (void)0 : __builtin_unreachable())))); } } } timearg = orig_timearg; if (!get_relative_timestamp(timearg, &tval, origin, 86400, errmsg)) { *arg_ptr = saved_argc; return 0; } our_pred = insert_primary(entry, orig_timearg); our_pred->args.reftime = tval; our_pred->est_success_rate = estimate_timestamp_success_rate(tval.ts.tv_sec); if (options.debug_options & DebugExpressionTree) { time_t t; fprintf(stderr, "inserting %s\n", our_pred->p_name); fprintf(stderr, " type: %s %s ", (tval.kind == COMP_GT) ? "gt" : ((tval.kind == COMP_LT) ? "lt" : ((tval.kind == COMP_EQ) ? "eq" : "?")), (tval.kind == COMP_GT) ? " >" : ((tval.kind == COMP_LT) ? " <" : ((tval.kind == COMP_EQ) ? ">=" : " ?"))); t = our_pred->args.reftime.ts.tv_sec; fprintf(stderr, "%" "l" "u" " %s", (uintmax_t)our_pred->args.reftime.ts.tv_sec, ctime(&t)); if (tval.kind == COMP_EQ) { t = our_pred->args.reftime.ts.tv_sec + 86400; fprintf(stderr, " < %" "l" "u" " %s", (uintmax_t)t, ctime(&t)); } } return 1; }
undefined8 parse_time(undefined8 param_1, undefined8 param_2, undefined4 *param_3) { char cVar1; undefined8 uVar2; undefined *puVar3; char *pcVar4; undefined *puVar5; long in_FS_OFFSET; undefined4 extraout_XMM0_Da; int local_70; undefined4 local_6c; undefined8 local_68; long local_60; undefined8 local_58; undefined8 local_50; long local_48; long local_40; long local_38; undefined8 local_30; undefined4 local_28; int iStack36; undefined8 local_20; undefined8 local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_58 = gettext( "arithmetic overflow while converting %s days to a number of seconds"); local_6c = *param_3; cVar1 = collect_arg(param_2, param_3, &local_68); if (cVar1 == '\x01') { local_50 = local_68; local_38 = _getfileconat; local_30 = _GLOBAL_OFFSET_TABLE_; cVar1 = get_comp_type(&local_68, &local_70); if ((cVar1 != '\0') && (local_70 == 1)) { local_48 = local_38 + 0x1517f; local_38 = local_38 + 0x1517f; } local_68 = local_50; cVar1 = get_relative_timestamp(DAT_00106e80, local_50, &local_28, local_38, local_30, local_58); if (cVar1 == '\x01') { local_40 = insert_primary(param_1, local_50); *(ulong *)(local_40 + 0x38) = CONCAT44(iStack36, local_28); *(undefined8 *)(local_40 + 0x40) = local_20; *(undefined8 *)(local_40 + 0x48) = local_18; estimate_timestamp_success_rate(local_20); *(undefined4 *)(local_40 + 0x24) = extraout_XMM0_Da; if ((_error & 1) != 0) { fprintf(stderr, "inserting %s\n", *(undefined8 *)(local_40 + 8)); if (iStack36 == 0) { puVar5 = &DAT_00106d45; } else if (iStack36 == 1) { puVar5 = &DAT_00106d42; } else if (iStack36 == 2) { puVar5 = &DAT_00106d3c; } else { puVar5 = &DAT_00106d3f; } if (iStack36 == 0) { puVar3 = &DAT_00106d50; } else if (iStack36 == 1) { puVar3 = &DAT_00106d4d; } else if (iStack36 == 2) { puVar3 = &DAT_00106d48; } else { puVar3 = &DAT_00106d4b; } fprintf(stderr, " type: %s %s ", puVar3, puVar5); local_60 = *(long *)(local_40 + 0x40); pcVar4 = ctime(&local_60); fprintf(stderr, "%lu %s", *(undefined8 *)(local_40 + 0x40), pcVar4); if (iStack36 == 2) { local_60 = *(long *)(local_40 + 0x40) + 0x15180; pcVar4 = ctime(&local_60); fprintf(stderr, " < %lu %s", local_60, pcVar4); } } uVar2 = 1; } else { *param_3 = local_6c; uVar2 = 0; } } else { uVar2 = 0; } if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar2; } __stack_chk_fail(); }
findutils
ghidra
static void delete_chars(int count) { if (count > _rl_screenwidth) return; if (_rl_term_DC && *_rl_term_DC) { char *buffer; buffer = tgoto(_rl_term_DC, count, count); tputs(buffer, count, _rl_output_character_function); } else { if (_rl_term_dc && *_rl_term_dc) while (count--) tputs(_rl_term_dc, 1, _rl_output_character_function); } }
int delete_chars(int a1) { int result; int v2; const char *v3; v2 = a1; result = rl_screenwidth; if (a1 <= rl_screenwidth) { if (rl_term_DC && *rl_term_DC) { v3 = tgoto(rl_term_DC, a1, a1); return tputs(v3, a1, (int (*)(int))&rl_output_character_function); } else { result = (int)rl_term_dc; if (rl_term_dc) { result = (unsigned char)*rl_term_dc; if ((_BYTE)result) { while (1) { result = v2--; if (!result) break; tputs(rl_term_dc, 1, (int (*)(int))&rl_output_character_function); } } } } } return result; }
bash
ida
int bridge_parse_xstats(struct link_util *lu, int argc, char **argv) { while (argc > 0) { if (strcmp(*argv, "igmp") == 0 || strcmp(*argv, "mcast") == 0) { xstats_print_attr = BRIDGE_XSTATS_MCAST; } else if (strcmp(*argv, "stp") == 0) { xstats_print_attr = BRIDGE_XSTATS_STP; } else if (strcmp(*argv, "dev") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); filter_index = ll_name_to_index(*argv); if (!filter_index) return nodev(*argv); } else if (strcmp(*argv, "help") == 0) { bridge_print_xstats_help(lu, stdout); exit(0); } else { invarg("unknown attribute", *argv); } argc--; argv++; } return 0; }
long long bridge_parse_xstats(unsigned long long a0, unsigned long a1, unsigned long a2) { unsigned long long *v0; unsigned int v1; void *v3; v1 = a1; v0 = a2; while (true) { if (v1 <= 0) { v3 = 0; break; } if (!strcmp(*(v0), "igmp")) { LABEL_402d9a: xstats_print_attr = 2; goto LABEL_402e80; } else { if (!strcmp(*(v0), "mcast")) goto LABEL_402d9a; if (!strcmp(*(v0), "stp")) { xstats_print_attr = 4; } else if (!strcmp(*(v0), "dev")) { v0 += 1; v1 -= 1; if (v1 <= 0) incomplete_command(); filter_index = ll_name_to_index(*(v0)); if (!filter_index) { v3 = nodev(*(v0)); break; } } else if (strcmp(*(v0), "help")) { invarg("unknown attribute", *(v0)); } else { bridge_print_xstats_help(a0, stdout); exit(0x0); } LABEL_402e80: v1 -= 1; v0 += 1; } } return v3; }
iproute2-6.0.0
angr_phoenix
int rl_vi_append_mode(int count, int key) { _rl_vi_append_forward(key); rl_vi_start_inserting(key, 1, rl_arg_sign); return (0); }
undefined8 rl_vi_append_mode(undefined8 param_1, undefined4 param_2) { _rl_vi_append_forward(param_2); rl_vi_start_inserting(param_2, 1, rl_arg_sign); return 0; }
bash
ghidra
static void merge_lists(struct predlist lists[], int nlists, struct predlist *name_list, struct predlist *regex_list, struct predicate **last) { int i; static void (*mergefn)(struct predlist *, struct predicate **); mergefn = predlist_merge_sort; mergefn(name_list, last); mergefn(regex_list, last); for (i = 0; i < nlists; i++) mergefn(&lists[i], last); }
long merge_lists(long a1, int a2, long *a3, long a4, _QWORD *a5) { long result; int i; mergefn_5804 = (long (*)(_QWORD, _QWORD))predlist_merge_sort; predlist_merge_sort(a3, a5); mergefn_5804(a4, a5); for (i = 0;; ++i) { result = (unsigned int)i; if (i >= a2) break; mergefn_5804(a1 + 16LL * i, a5); } return result; }
findutils
ida
static int pkcs11_fetch_keys(struct pkcs11_provider *p, CK_ULONG slotidx, struct sshkey ***keysp, char ***labelsp, int *nkeys) { struct sshkey *key = ((void *)0); CK_OBJECT_CLASS key_class; CK_ATTRIBUTE key_attr[2]; CK_SESSION_HANDLE session; CK_FUNCTION_LIST *f = ((void *)0); CK_RV rv; CK_OBJECT_HANDLE obj; CK_ULONG n = 0; int ret = -1; memset(&key_attr, 0, sizeof(key_attr)); memset(&obj, 0, sizeof(obj)); key_class = (2); key_attr[0].type = (0); key_attr[0].pValue = &key_class; key_attr[0].ulValueLen = sizeof(key_class); session = p->slotinfo[slotidx].session; f = p->function_list; rv = f->C_FindObjectsInit(session, key_attr, 1); if (rv != (0)) { sshlog("ssh-pkcs11.c", __func__, 1236, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "C_FindObjectsInit failed: %lu", rv); goto fail; } while (1) { CK_KEY_TYPE ck_key_type; CK_UTF8CHAR label[256]; rv = f->C_FindObjects(session, &obj, 1, &n); if (rv != (0)) { sshlog("ssh-pkcs11.c", __func__, 1246, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "C_FindObjects failed: %lu", rv); goto fail; } if (n == 0) break; memset(&ck_key_type, 0, sizeof(ck_key_type)); memset(&key_attr, 0, sizeof(key_attr)); key_attr[0].type = (0x100); key_attr[0].pValue = &ck_key_type; key_attr[0].ulValueLen = sizeof(ck_key_type); key_attr[1].type = (3); key_attr[1].pValue = &label; key_attr[1].ulValueLen = sizeof(label) - 1; rv = f->C_GetAttributeValue(session, obj, key_attr, 2); if (rv != (0)) { sshlog("ssh-pkcs11.c", __func__, 1263, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "C_GetAttributeValue failed: %lu", rv); goto fail; } label[key_attr[1].ulValueLen] = '\0'; switch (ck_key_type) { case (0): key = pkcs11_fetch_rsa_pubkey(p, slotidx, &obj); break; case (3): key = pkcs11_fetch_ecdsa_pubkey(p, slotidx, &obj); break; default: key = ((void *)0); sshlog("ssh-pkcs11.c", __func__, 1281, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "skipping unsupported key type"); } if (key == ((void *)0)) { sshlog("ssh-pkcs11.c", __func__, 1285, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "failed to fetch key"); continue; } note_key(p, slotidx, __func__, key); if (pkcs11_key_included(keysp, nkeys, key)) { sshlog("ssh-pkcs11.c", __func__, 1290, 1, SYSLOG_LEVEL_DEBUG2, ((void *)0), "key already included"); ; sshkey_free(key); } else { *keysp = xrecallocarray(*keysp, *nkeys, *nkeys + 1, sizeof(struct sshkey *)); (*keysp)[*nkeys] = key; if (labelsp != ((void *)0)) { *labelsp = xrecallocarray(*labelsp, *nkeys, *nkeys + 1, sizeof(char *)); (*labelsp)[*nkeys] = xstrdup((char *)label); } *nkeys = *nkeys + 1; sshlog("ssh-pkcs11.c", __func__, 1303, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "have %d keys", *nkeys); } } ret = 0; fail: rv = f->C_FindObjectsFinal(session); if (rv != (0)) { sshlog("ssh-pkcs11.c", __func__, 1311, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "C_FindObjectsFinal failed: %lu", rv); ret = -1; } return (ret); }
void pkcs11_fetch_keys(unsigned long long a0[17], unsigned int a1, unsigned long long *a2, unsigned long long *a3, unsigned int *a4) { unsigned long v0; unsigned int v1; unsigned long long v2; char v3; void *v4; char v5; void *v6; void *v7; unsigned long long v8; unsigned long v9; unsigned long long v10; unsigned long v11; unsigned long long v12; unsigned long long v13; unsigned long long v14; unsigned long long v15; char v16; unsigned long long v20; v6 = 0; v7 = 0; v4 = 0; v1 = -1; memset(&v10, 0x0, 0x30); memset(&v3, 0x0, 0x8); v2 = 2; v10 = 0; v11 = &v2; v12 = 8; v8 = *((a1 * 224 + a0[16] + 208)); v7[0] = a0[2]; v9 = v7[27](v8, &v10, 1, &v10, v7[27]); if (v9) { v0 = v9; sshlog("ssh-pkcs11.c", "pkcs11_fetch_keys", 0x4d4, 0x0, 0x2, 0x0, "C_FindObjectsInit failed: %lu"); } else { while (true) { v9 = v7[28](v8, &v3, 1, &v4, v7[28]); if (v9) { v0 = v9; sshlog("ssh-pkcs11.c", "pkcs11_fetch_keys", 0x4de, 0x0, 0x2, 0x0, "C_FindObjects failed: %lu"); break; } else if (!v4) { v1 = 0; break; } else { memset(&v5, 0x0, 0x8); memset(&v10, 0x0, 0x30); v10 = 0x100; v11 = &v5; v12 = 8; v13 = 3; v14 = &v16; v15 = 255; v9 = v7[25](v8, *(&v3), &v10, 2, v7[25]); if (v9) { v0 = v9; sshlog("ssh-pkcs11.c", "pkcs11_fetch_keys", 0x4ef, 0x0, 0x2, 0x0, "C_GetAttributeValue failed: %lu"); break; } else { (&v16)[v15] = 0; if (!*(&v5)) { v6 = pkcs11_fetch_rsa_pubkey(a0, a1, &v3); } else if (*(&v5) == 3) { v6 = pkcs11_fetch_ecdsa_pubkey(a0, a1, &v3); } else { v6 = 0; sshlog("ssh-pkcs11.c", "pkcs11_fetch_keys", 0x501, 0x0, 0x2, 0x0, "skipping unsupported key type"); } if (!v6) { sshlog("ssh-pkcs11.c", "pkcs11_fetch_keys", 0x505, 0x0, 0x2, 0x0, "failed to fetch key"); } else { note_key(a0, a1, "pkcs11_fetch_keys", v6); if (pkcs11_key_included(a2, a4, v6)) { sshlog("ssh-pkcs11.c", "pkcs11_fetch_keys", 0x50a, 0x1, 0x6, 0x0, "key already included"); sshkey_free(v6); } else { *(a2) = xrecallocarray(*(a2), *(a4), __addvsi3(*(a4), 0x1), 0x8); *((*(a2) + *(a4) * 8)) = v6; if (a3) { *(a3) = xrecallocarray(*(a3), *(a4), __addvsi3(*(a4), 0x1), 0x8); *((*(a3) + *(a4) * 8)) = xstrdup(&v16); } *(a4) = __addvsi3(*(a4), 0x1); v0 = *(a4); sshlog("ssh-pkcs11.c", "pkcs11_fetch_keys", 0x517, 0x0, 0x5, 0x0, "have %d keys"); } } } } } } v9 = *(((stack_base)[368] + 232))(v8); if (v9) { v0 = v9; sshlog("ssh-pkcs11.c", "pkcs11_fetch_keys", 0x51f, 0x0, 0x2, 0x0, "C_FindObjectsFinal failed: %lu"); v1 = -1; } v20 = v1; return; }
openssh-portable
angr_dream