input
stringlengths
26
172k
output
stringlengths
18
318k
repo_name
stringclasses
23 values
decompiler
stringclasses
5 values
static char *strduplicate(char *from) { char *new = stralloc(strlen(from)); strcpy(new, from); return new; }
char *strduplicate(char *param_1) { size_t sVar1; char *__dest; sVar1 = strlen(param_1); __dest = (char *)stralloc(sVar1 & 0xffffffff); strcpy(__dest, param_1); return __dest; }
bash
ghidra
static int convert_libcrypto_error(void) { if (translate_libcrypto_error(ERR_peek_error()) == -43) return -43; return translate_libcrypto_error(ERR_peek_last_error()); }
long convert_libcrypto_error() { unsigned long v0; unsigned long error; v0 = ERR_peek_error(); if ((unsigned int)translate_libcrypto_error(v0) == -43) return 4294967253LL; error = ERR_peek_last_error(); return translate_libcrypto_error(error); }
openssh-portable
ida
void sshfatal(const char *file, const char *func, int line, int showfunc, LogLevel level, const char *suffix, const char *fmt, ...) { va_list args; __builtin_va_start(args, fmt); sshlogv(file, func, line, showfunc, level, suffix, fmt, args); __builtin_va_end(args); cleanup_exit(255); }
void sshfatal(unsigned long long a0, unsigned long long a1, unsigned long a2, unsigned long a3, unsigned long a4, unsigned long long a5, unsigned long long v16) { unsigned long v0; unsigned long long v1; unsigned int v2; unsigned int v3; unsigned long v4; unsigned long v5; unsigned long v6; char v7; int v8; int v9; int v10; int v11; int v12; int v13; int v14; int v15; char v17; char v18; int v19; int v20; int v21; int v22; int v23; int v24; int v25; int v26; unsigned long long *v27; if (v18) { v8 = v19; v9 = v20; v10 = v21; v11 = v22; v12 = v23; v13 = v24; v14 = v25; v15 = v26; } v1 = v16; v6 = v27[5]; v2 = 48; v3 = 48; v4 = &v17; v5 = &v7; v0 = &v2; sshlogv(a0, a1, a2, a3, a4, a5, v1); cleanup_exit(0xff); }
openssh-portable
angr_phoenix
static inline void emit_mandatory_arg_note(void) { fputs_unlocked(gettext("\nMandatory arguments to long options are mandatory " "for short options too.\n"), stdout) ; }
void emit_mandatory_arg_note(void) { char *__s; FILE *__stream; __stream = stdout; __s = (char *)gettext("\nMandatory arguments to long options are mandatory " "for short options too.\n"); fputs_unlocked(__s, __stream); return; }
coreutils
ghidra
int sh_open(const char *pathname, int flags, int mayfail) { int fd; int e; do { fd = open64(pathname, flags, 0666); e = (*dash_errno); } while (fd < 0 && e == 4 && !pending_sig); if (mayfail || fd >= 0) return fd; sh_open_fail(pathname, flags, e); }
int sh_open(char *a0, unsigned long a1, unsigned long a2) { unsigned int v0; unsigned int v1; while (true) { v0 = open64(a0, a1, 0x1b6); v1 = *(dash_errno); if (v0 >= 0) break; if (v1 != 4) break; if (pending_sig) break; } if (!a2 && v0 < 0) sh_open_fail(a0, a1, v1); return v0; }
dash-0.5.11+git20210903+057cd650a4ed
angr_phoenix
static void Encap(unsigned char *c, unsigned char *k, const unsigned char *pk) { Inputs r; unsigned char r_enc[((761 + 3) / 4)]; unsigned char cache[32]; Hash_prefix(cache, 4, pk, 1158); Short_random(r); Hide(c, r_enc, r, pk, cache); HashSession(k, 1, r_enc, c); }
void Encap(char *a0, char *a1, unsigned long a2) { char v0; char v1; char v2; char v3; unsigned long long *v5; unsigned long long v6; Hash_prefix(&v0, 0x4, a2, 0x486); Short_random(&v2); Hide(a0, &v1, &v2, a2, &v0); HashSession(a1, 0x1, &v1, a0); v6 = *(&v3) ^ v5[5]; return; }
openssh-portable
angr_sailr
static void memory_error_and_abort(char *fname) { fprintf(stderr, "%s: out of virtual memory\n", fname); exit(2); }
void memory_error_and_abort(const char *a1) { fprintf(stderr, "%s: out of virtual memory\n", a1); exit(2); }
bash
ida
static void delete_local_contexts(vcxt) VAR_CONTEXT *vcxt; { VAR_CONTEXT *v, *t; for (v = vcxt; v != global_variables; v = t) { t = v->down; dispose_var_context(v); } }
void delete_local_contexts(void *a0) { struct_0 *v0; void *v1; unsigned long long v3; v0 = a0; while (true) { v3 = global_variables; if (v0 == global_variables) break; v1 = v0->field_18; dispose_var_context(v0); v0 = v1; } return; }
bash
angr_dream
static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb) { __u32 table = r->rtm_table; if (tb[RTA_TABLE]) table = rta_getattr_u32(tb[RTA_TABLE]); return table; }
int rtm_get_table(struct_1 *a0, struct_0 *a1) { unsigned int v0; v0 = a0->field_4; if (a1->field_78) v0 = rta_getattr_u32(a1->field_78); return v0; }
iproute2-6.0.0
angr_phoenix
static void announce_mkdir(char const *dir, void *options) { struct mkdir_options const *o = options; if (o->created_directory_format) prog_fprintf(stdout, o->created_directory_format, quotearg_style(shell_escape_always_quoting_style, dir)); }
void announce_mkdir(unsigned long long a0, struct_0 *a1) { unsigned long long v1; unsigned long long v2; v1 = a1->field_20; if (a1->field_20) { v2 = prog_fprintf(stdout, a1->field_20, quotearg_style(0x4, a0), a1->field_20); return; } return; }
coreutils
angr_sailr
void crypto_sign_ed25519_ref_fe25519_cmov( crypto_sign_ed25519_ref_fe25519 *r, const crypto_sign_ed25519_ref_fe25519 *x, unsigned char b) { int i; crypto_uint32 mask = b; mask = -mask; for (i = 0; i < 32; i++) r->v[i] ^= mask & (x->v[i] ^ r->v[i]); }
long long crypto_sign_ed25519_ref_fe25519_cmov(unsigned int *a0, unsigned int *a1, unsigned long a2) { char v0; unsigned int v1; unsigned int v2; unsigned long long v4; v0 = a2; v4 = v0; v2 = v0; v2 = -(v2); for (v1 = 0; v1 <= 31; v1 = v4) { a0[v1] = a0[v1] ^ (a0[v1] ^ a1[v1]) & v2; v4 = __addvsi3(v1, 0x1, v1); } return v4; }
openssh-portable
angr_sailr
static void listen_on_addrs(struct listenaddr *la) { int ret, listen_sock; struct addrinfo *ai; char ntop[1025], strport[32]; for (ai = la->addrs; ai; ai = ai->ai_next) { if (ai->ai_family != 2 && ai->ai_family != 10) continue; if (num_listen_socks >= 16) sshfatal("sshd.c", __func__, 1039, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "Too many listen sockets. " "Enlarge MAX_LISTEN_SOCKS"); if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop, sizeof(ntop), strport, sizeof(strport), 1 | 2)) != 0) { sshlog("sshd.c", __func__, 1044, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "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; } if (set_nonblock(listen_sock) == -1) { close(listen_sock); continue; } if (fcntl(listen_sock, 2, 1) == -1) { sshlog("sshd.c", __func__, 1061, 0, SYSLOG_LEVEL_VERBOSE, ((void *)0), "socket: CLOEXEC: %s", strerror((*__errno_location()))); close(listen_sock); continue; } set_reuseaddr(listen_sock); if (la->rdomain != ((void *)0) && set_rdomain(listen_sock, la->rdomain) == -1) { close(listen_sock); continue; } if (ai->ai_family == 10) sock_set_v6only(listen_sock); sshlog("sshd.c", __func__, 1077, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "Bind to port %s on %s.", strport, ntop); if (bind(listen_sock, ai->ai_addr, ai->ai_addrlen) == -1) { sshlog("sshd.c", __func__, 1081, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Bind to port %s on %s failed: %.200s.", strport, ntop, strerror((*__errno_location()))); close(listen_sock); continue; } listen_socks[num_listen_socks] = listen_sock; num_listen_socks++; if (listen(listen_sock, 128) == -1) sshfatal("sshd.c", __func__, 1091, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "listen on [%s]:%s: %.100s", ntop, strport, strerror((*__errno_location()))); sshlog("sshd.c", __func__, 1093, 0, SYSLOG_LEVEL_INFO, ((void *)0), "Server listening on %s port %s%s%s.", ntop, strport, la->rdomain == ((void *)0) ? "" : " rdomain ", la->rdomain == ((void *)0) ? "" : la->rdomain) ; } }
void listen_on_addrs(unsigned long long a0[2]) { unsigned int v0; unsigned int v1; struct_0 *v2; char v3; char v4; unsigned long long v5; unsigned long long v6; unsigned long long v7; unsigned long long v8; unsigned long long v9; unsigned long v10; unsigned long long v14; unsigned long long v17; unsigned long long v18; unsigned long long *v19; unsigned long long v20; for (v2 = a0[1]; v2; v2 = v2->field_28) { if (v2->field_4 == 2 || v2->field_4 == 10) { if (num_listen_socks > 15) { v9 = "Too many listen sockets. Enlarge MAX_LISTEN_SOCKS"; sshfatal("sshd.c"); } v9 = 3; v0 = getnameinfo(v2->field_18, v2->field_10, &v4, 0x401, &v3, 0x20); if (v0) { v10 = ssh_gai_strerror(v0); v9 = "getnameinfo failed: %.100s"; sshlog("sshd.c", "listen_on_addrs", 0x414, 0x0, 0x2, 0x0); } else { v1 = socket(v2->field_4, v2->field_8, v2->field_c); if (v1 == -1) { v10 = strerror(*(__errno_location())); v9 = "socket: %.100s"; sshlog("sshd.c", "listen_on_addrs", 0x41d, 0x0, 0x4, 0x0); } else if (set_nonblock(v1) == -1) { close(v1); } else if (fcntl(v1, 0x2) == -1) { v10 = strerror(*(__errno_location())); v9 = "socket: CLOEXEC: %s"; sshlog("sshd.c", "listen_on_addrs", 0x425, 0x0, 0x4, 0x0); close(v1); } else { set_reuseaddr(v1); if (a0[0]) { v14 = set_rdomain(v1, a0[0], a0[0]); if (v14 == -1) close(v1); } if (!a0[0] || v14 != -1) { if (v2->field_4 == 10) sock_set_v6only(v1); v9 = &v4; v8 = &v3; v7 = "Bind to port %s on %s."; sshlog("sshd.c", "listen_on_addrs", 0x435, 0x0, 0x5, 0x0); if (bind(v1, v2->field_18, v2->field_10) == -1) { v10 = strerror(*(__errno_location())); v9 = &v4; v8 = &v3; v7 = "Bind to port %s on %s failed: %.200s."; sshlog("sshd.c", "listen_on_addrs", 0x439, 0x0, 0x2, 0x0); close(v1); } else { *((4 * num_listen_socks + &listen_socks)) = v1; num_listen_socks = __addvsi3(num_listen_socks, 0x1); if (listen(v1, 0x80) == -1) { v10 = strerror(*(__errno_location())); v9 = &v3; v8 = &v4; v7 = "listen on [%s]:%s: %.100s"; sshfatal("sshd.c"); } if (a0[0]) v17 = a0[0]; else v17 = &g_40737c; if (!a0[0]) v18 = &g_40737c; else v18 = " rdomain "; v9 = v17; v8 = v18; v7 = &v3; v6 = &v4; v5 = "Server listening on %s port %s%s%s."; sshlog("sshd.c", "listen_on_addrs", 0x445, 0x0, 0x3, 0x0); } } } } } } v20 = v9 ^ v19[5]; return; }
openssh-portable
angr_dream
uLong adler32_combine(adler1, adler2, len2) uLong adler1; uLong adler2; off_t len2; { return adler32_combine_(adler1, adler2, len2); }
void adler32_combine(undefined8 param_1, undefined8 param_2, undefined8 param_3) { adler32_combine_(param_1, param_2, param_3); return; }
zlib
ghidra
static int input_userauth_success(int type, u_int32_t seq, struct ssh *ssh) { Authctxt *authctxt = ssh->authctxt; if (authctxt == ((void *)0)) sshfatal("sshconnect2.c", __func__, 621, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "no authentication context"); free(authctxt->authlist); authctxt->authlist = ((void *)0); if (authctxt->method != ((void *)0) && authctxt->method->cleanup != ((void *)0)) authctxt->method->cleanup(ssh); free(authctxt->methoddata); authctxt->methoddata = ((void *)0); authctxt->success = 1; return 0; }
undefined8 input_userauth_success(undefined4 param_1, undefined4 param_2, long param_3) { void *pvVar1; code *pcVar2; long lVar3; char **ppcVar4; char *apcStack56[2]; long local_28; undefined4 local_20; undefined4 local_1c; long local_10; ppcVar4 = (char **)&local_28; local_28 = param_3; local_10 = *(long *)(param_3 + 0x860); local_20 = param_2; local_1c = param_1; if (local_10 == 0) { ppcVar4 = apcStack56; apcStack56[0] = "no authentication context"; sshfatal("sshconnect2.c", "input_userauth_success", 0x26d, 1, 1, 0); } pvVar1 = *(void **)(local_10 + 0x30); *(undefined8 *)((long)ppcVar4 + -8) = 0x1015d1; free(pvVar1); lVar3 = local_28; *(undefined8 *)(local_10 + 0x30) = 0; if ((*(long *)(local_10 + 0x20) != 0) && (*(long *)(*(long *)(local_10 + 0x20) + 0x10) != 0)) { pcVar2 = *(code **)(*(long *)(local_10 + 0x20) + 0x10); *(undefined8 *)((long)ppcVar4 + -8) = 0x101610; (*pcVar2)(lVar3); } pvVar1 = *(void **)(local_10 + 0x80); *(undefined8 *)((long)ppcVar4 + -8) = 0x101623; free(pvVar1); *(undefined8 *)(local_10 + 0x80) = 0; *(undefined4 *)(local_10 + 0x28) = 1; return 0; }
openssh-portable
ghidra
void get_ocsp_issuer_set(gnutls_x509_crt_t crt) { int ret, i; gnutls_datum_t uri; if (batch) { if (!cfg.ocsp_uris) return; for (i = 0; cfg.ocsp_uris[i] != ((void *)0); i++) { uri.data = (void *)cfg.ocsp_uris[i]; uri.size = strlen(cfg.ocsp_uris[i]); ret = gnutls_x509_crt_set_authority_info_access(crt, GNUTLS_IA_OCSP_URI, &uri); if (ret < 0) { fprintf(stderr, "set OCSP URI (%s): %s\n", cfg.ocsp_uris[i], gnutls_strerror(ret)); exit(1); } } } }
long long get_ocsp_issuer_set(unsigned long long a0) { unsigned int v0; unsigned int v1; unsigned long v2; unsigned int v3; if (!*(got.batch)) { return 0; } else if (!*((got.cfg + 656))) { return 0; } else { for (v0 = 0; *((*((got.cfg + 656)) + (v0 << 3))); v0 += 1) { v2 = *((*((got.cfg + 656)) + v0 * 8)); v3 = strlen(*((*((got.cfg + 656)) + v0 * 8))); v1 = gnutls_x509_crt_set_authority_info_access(a0, 0x2716, &v2); if (v1 < 0) { fprintf(*(got.stderr), "set OCSP URI (%s): %s\n", *((*((got.cfg + 656)) + v0 * 8)), gnutls_strerror(v1)); exit(0x1); } } return 0; } }
gnutls
angr_sailr
static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv, const BIGNUM *rp, EC_KEY *ec) { struct pkcs11_key *k11; struct pkcs11_slotinfo *si; CK_FUNCTION_LIST *f; CK_ULONG siglen = 0, bnlen; CK_RV rv; ECDSA_SIG *ret = ((void *)0); u_char *sig; BIGNUM *r = ((void *)0), *s = ((void *)0); if ((k11 = EC_KEY_get_ex_data(ec, ec_key_idx)) == ((void *)0)) { ossl_error("EC_KEY_get_key_method_data failed for ec"); return (((void *)0)); } if (pkcs11_get_key(k11, (0x1041)) == -1) { sshlog("ssh-pkcs11.c", __func__, 531, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "pkcs11_get_key failed"); return (((void *)0)); } f = k11->provider->function_list; si = &k11->provider->slotinfo[k11->slotidx]; siglen = ECDSA_size(ec); sig = xmalloc(siglen); rv = f->C_Sign(si->session, (CK_BYTE *)dgst, dgst_len, sig, &siglen); if (rv != (0)) { sshlog("ssh-pkcs11.c", __func__, 544, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "C_Sign failed: %lu", rv); goto done; } if (siglen < 64 || siglen > 132 || siglen % 2) { ossl_error("d2i_ECDSA_SIG failed"); goto done; } bnlen = siglen / 2; if ((ret = ECDSA_SIG_new()) == ((void *)0)) { sshlog("ssh-pkcs11.c", __func__, 553, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "ECDSA_SIG_new failed"); goto done; } if ((r = BN_bin2bn(sig, bnlen, ((void *)0))) == ((void *)0) || (s = BN_bin2bn(sig + bnlen, bnlen, ((void *)0))) == ((void *)0)) { ossl_error("d2i_ECDSA_SIG failed"); ECDSA_SIG_free(ret); ret = ((void *)0); goto done; } if (!ECDSA_SIG_set0(ret, r, s)) { sshlog("ssh-pkcs11.c", __func__, 564, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "ECDSA_SIG_set0 failed"); ECDSA_SIG_free(ret); ret = ((void *)0); goto done; } r = s = ((void *)0); done: BN_free(r); BN_free(s); free(sig); return (ret); }
long long ecdsa_do_sign(unsigned long long a0, unsigned long a1, unsigned long a2, unsigned long a3, unsigned long long a4) { unsigned long v0; unsigned long v1; unsigned long v2; unsigned long long v3; void *v4; void *v5; void *v6; struct_2 *v7; struct_1 *v8; struct_0 *v9; void *v10; unsigned long v11; unsigned long long v12; void *v14; v2 = a2; v1 = a3; v3 = 0; v4 = 0; v5 = 0; v6 = 0; v7 = EC_KEY_get_ex_data(a4, ec_key_idx, ec_key_idx); if (!v7) { ossl_error("EC_KEY_get_key_method_data failed for ec"); v14 = 0; return v14; } else if (pkcs11_get_key(v7, 0x1041) != -1) { v8 = v7->field_0->field_10; v9 = v7->field_8 * 224 + v7->field_0->field_80; v3 = ECDSA_size(a4); v10 = xmalloc(v3); v11 = v8->field_160(v9->field_d0, a0, a1, v10, &v3, v8->field_160); if (v11) { v0 = v11; sshlog("ssh-pkcs11.c", "ecdsa_do_sign", 0x220, 0x0, 0x2, 0x0, "C_Sign failed: %lu"); } else if (v3 <= 63 || v3 > 132 || (v3 & 1)) { ossl_error("d2i_ECDSA_SIG failed"); } else { v12 = v3 >> 1; v4 = ECDSA_SIG_new(); if (v4) { v5 = BN_bin2bn(v10, v12, 0x0, v12); if (!v5 || (v6 = BN_bin2bn(v12 + v10, v12, 0x0, v12), !v6)) { ossl_error("d2i_ECDSA_SIG failed"); ECDSA_SIG_free(v4); v4 = 0; } else if (ECDSA_SIG_set0(v4, v5, v6, v5)) { v6 = 0; v5 = v6; } else { sshlog("ssh-pkcs11.c", "ecdsa_do_sign", 0x234, 0x1, 0x2, 0x0, "ECDSA_SIG_set0 failed"); ECDSA_SIG_free(v4); v4 = 0; } } else { sshlog("ssh-pkcs11.c", "ecdsa_do_sign", 0x229, 0x0, 0x2, 0x0, "ECDSA_SIG_new failed"); } } BN_free(v5); BN_free(v6); free(v10); v14 = v4; return v14; } else { sshlog("ssh-pkcs11.c", "ecdsa_do_sign", 0x213, 0x0, 0x2, 0x0, "pkcs11_get_key failed"); v14 = 0; return v14; } }
openssh-portable
angr_sailr
) { *ppData = ((void *)0); return RS_RET_OUT_OF_MEMORY; }
long long createWrkrInstance(unsigned long long *a0, unsigned long a1) { unsigned int v0; unsigned long long *v1; unsigned long long v3; v0 = 0; v1 = calloc(0x1, 0x8); if (!v1) { *(a0) = 0; v3 = 4294967290; } else { *(v1) = a1; *(a0) = v1; v3 = v0; } return v3; }
rsyslog-8.2210.0
angr_phoenix
static char *parameter_list_transform(xc, itype, quoted) int xc; int itype; int quoted; { char *ret; WORD_LIST *list; list = list_rest_of_args(); if (list == 0) return ((char *)((void *)0)); if (xc == 'A') ret = pos_params_assignment(list, itype, quoted); else ret = list_transform(xc, (SHELL_VAR *)0, list, itype, quoted); dispose_words(list); return (ret); }
char *parameter_list_transform(int a1, int a2, int a3) { char *v5; long ***v6; v6 = (long ***)list_rest_of_args(); if (!v6) return 0LL; if (a1 == 65) v5 = pos_params_assignment(v6, a2, a3); else v5 = list_transform(a1, 0LL, v6, a2, a3); dispose_words(v6); return v5; }
bash
ida
char *get_name_for_error() { char *name; SHELL_VAR *bash_source_v; ARRAY *bash_source_a; name = (char *)((void *)0); if (interactive_shell == 0) { bash_source_v = find_variable("BASH_SOURCE"); if (bash_source_v && ((((bash_source_v)->attributes) & (0x0000004))) && (bash_source_a = (ARRAY *)((bash_source_v)->value))) name = array_reference(bash_source_a, 0); if (name == 0 || *name == '\0') name = dollar_vars[0]; } if (name == 0 && shell_name && *shell_name) name = base_pathname(shell_name); if (name == 0) name = "bash"; return (name); }
const char *get_name_for_error() { _BYTE *v1; long variable; long v3; v1 = 0LL; if (!interactive_shell) { variable = find_variable("BASH_SOURCE"); if (variable) { if ((*(_DWORD *)(variable + 40) & 4) != 0) { v3 = *(_QWORD *)(variable + 8); if (v3) v1 = (_BYTE *)array_reference(v3, 0LL); } } if (!v1 || !*v1) v1 = (_BYTE *)dollar_vars; } if (!v1 && shell_name && *shell_name) v1 = (_BYTE *)base_pathname(shell_name); if (!v1) return "bash"; return v1; }
bash
ida
static _Bool advance_input_after_read_error(idx_t nbytes) { if (!input_seekable) { if (input_seek_errno == 29) return 1; (*__errno_location()) = input_seek_errno; } else { off_t offset; advance_input_offset(nbytes); if (input_offset < 0) { nl_error(0, 0, gettext("offset overflow while reading file %s"), quotearg_style(shell_escape_always_quoting_style, input_file)); return 0; } offset = lseek(0, 0, 1); if (0 <= offset) { off_t diff; if (offset == input_offset) return 1; diff = input_offset - offset; if (!(0 <= diff && diff <= nbytes) && status_level != STATUS_NONE) nl_error(0, 0, gettext("warning: invalid file offset after failed read")); if (0 <= lseek(0, diff, 1)) return 1; if ((*__errno_location()) == 0) nl_error(0, 0, gettext("cannot work around kernel bug after all")); } } nl_error(0, (*__errno_location()), gettext("%s: cannot seek"), quotearg_n_style_colon(0, shell_escape_quoting_style, input_file)); return 0; }
int advance_input_after_read_error(unsigned int a0, unsigned long a1, unsigned long a2, unsigned int a3, unsigned int a4, unsigned int a5) { unsigned long v0; unsigned int v1; unsigned int v3; if (!(input_seekable ^ 1)) { advance_input_offset(a0); if (input_offset < 0) { nl_error(0x0, 0x0, gettext("offset overflow while reading file %s"), quotearg_style(0x4, *(&input_file)), a4, a5); v3 = 0; return v3; } v0 = lseek(0x0, 0x0, 0x1); if (!((v0 - 0 >> 63))) { if (v0 == input_offset) { v3 = 1; return v3; } *(&v1) = input_offset - v0; if (((*(&v1) - 0 >> 63) || *(&v1) > a0) && status_level != 1) nl_error(0x0, 0x0, gettext("warning: invalid file offset after failed read"), a3, a4, a5); if (lseek(0x0, *(&v1), 0x1) >= 0) { v3 = 1; return v3; } if (!*(__errno_location())) nl_error(0x0, 0x0, gettext("cannot work around kernel bug after all"), a3, a4, a5); } } else if (input_seek_errno != 29) { *(__errno_location()) = input_seek_errno; } else { v3 = 1; return v3; } nl_error(0x0, *(__errno_location()), gettext("%s: cannot seek"), quotearg_n_style_colon(0x0, 0x3, *(&input_file)), a4, a5); v3 = 0; return v3; }
coreutils
angr_sailr
SHELL_VAR *bind_array_variable(name, ind, value, flags) char *name; arrayind_t ind; char *value; int flags; { SHELL_VAR *entry; entry = find_shell_variable(name); if (entry == (SHELL_VAR *)0) { entry = find_variable_nameref_for_create(name, 0); if (entry == (void *)&nameref_invalid_value) return ((SHELL_VAR *)0); if (entry && ((((entry)->attributes) & (0x0000800)))) entry = make_new_array_variable(((entry)->value)); } if (entry == (SHELL_VAR *)0) entry = make_new_array_variable(name); else if ((((((entry)->attributes) & (0x0000002))) && (flags & 0x0020) == 0) || ((((entry)->attributes) & (0x0004000)))) { if (((((entry)->attributes) & (0x0000002)))) err_readonly(name); return (entry); } else if (((((entry)->attributes) & (0x0000004))) == 0) entry = convert_var_to_array(entry); return (bind_array_var_internal(entry, ind, 0, value, flags)); }
int bind_array_variable(unsigned long long a0, unsigned long long a1, unsigned long long a2, unsigned long a3) { struct_0 *v0; unsigned int v2; v0 = find_shell_variable(a0); if (!v0) { v0 = find_variable_nameref_for_create(a0, 0x0); if (v0 == 5243008) { v2 = 0; } else if (v0 && (v0->field_28 & 0x800)) { v0 = make_new_array_variable(v0->field_8); } } if (v0 || v0 != 5243008) { if (!v0) { v0 = make_new_array_variable(a0); } else { if ((!(v0->field_28 & 2) || (a3 & 32)) && !(v0->field_28 & 0x4000) && !(v0->field_28 & 4)) v0 = convert_var_to_array(v0); if ((!(a3 & 32) || (v0->field_28 & 0x4000)) && ((v0->field_28 & 2) || (v0->field_28 & 0x4000))) { if ((v0->field_28 & 2)) err_readonly(a0); v2 = v0; } } if (!(v0->field_28 & 0x4000) || (a3 & 32)) v2 = bind_array_var_internal(v0, a1, 0x0, a2, a3); } return v2; }
bash
angr_dream
void assign_string_n(char **string, const char *value, size_t n) { free(*string); if (value) { size_t l = strnlen(value, n); char *p = xmalloc(l + 1); memcpy(p, value, l); p[l] = 0; *string = p; } }
void assign_string_n(void **a1, const char *a2, size_t a3) { size_t n; void *dest; free(*a1); if (a2) { n = strnlen(a2, a3); dest = (void *)xmalloc(n + 1); memcpy(dest, a2, n); *((_BYTE *)dest + n) = 0; *a1 = dest; } }
tar
ida
static int bash_history_inhibit_expansion(string, i) char *string; int i; { int t, si; char hx[2]; hx[0] = history_expansion_char; hx[1] = '\0'; if (i > 0 && (string[i - 1] == '[') && ((']') ? ((char *)mbschr((string + i + 1), (']')) != (char *)((void *)0)) : 0)) return (1); else if (i > 1 && string[i - 1] == '{' && string[i - 2] == '$' && (('}') ? ((char *)mbschr ((string + i + 1), ('}')) != (char *)
long long bash_history_inhibit_expansion(char *a0, unsigned long a1) { unsigned int v0; unsigned int v1; char v2; char v3; unsigned long long v5; unsigned long long v6; unsigned long long v7; unsigned long long v8; v2 = history_expansion_char; v3 = 0; if (a1 > 0 && a0[1 + a1] == 91) { v5 = mbschr(&a0[1 + a1], 0x5d, a1 + 1); if (v5) v6 = 1; } if (a1 <= 0 || !v5 || a0[1 + a1] != 91) { if (a1 > 1 && a0[1 + a1] == 123 && a0[2 + a1] == 36) { v7 = mbschr(&a0[1 + a1], 0x7d, a1 + 1); if (v7) v6 = 1; } if (a1 <= 1 || !v7 || a0[2 + a1] != 36 || a0[1 + a1] != 123) { if (a1 > 1 && a0[1 + a1] == 36 && a0[a1] == 33) v6 = 1; if (a1 <= 1 || a0[1 + a1] != 36 || a0[a1] != 33) { if (extended_glob && a1 > 1 && a0[1 + a1] == 40) { v8 = mbschr(&a0[2 + a1], 0x29, a1 + 2); if (v8) v6 = 1; } if (a1 <= 1 || !extended_glob || !v8 || a0[1 + a1] != 40) { v1 = 0; if (history_quoting_state == 39) { v1 = skip_to_delim(a0, 0x0, "'", 0x201); if (a0[v1] && v1 < a1) v1 += 1; if (!a0[v1] || v1 >= a1) v6 = 1; } if (history_quoting_state != 39 || v1 < a1 && a0[v1]) { v0 = skip_to_histexp(a0, v1, &v2, 0x201); if (v0 > 0) { while (true) { if (v0 < a1) { v0 = skip_to_histexp(a0, v0 + 1, &v2, 0x201); if (v0 > 0) continue; v6 = 0; break; } else { v6 = a1 < v0; break; } } } else { v6 = 0; } } } } } } return v6; }
bash
angr_dream
static int parse_rxsci_args(int *argcp, char ***argvp, struct rxsc_desc *rxsc) { int argc = *argcp; char **argv = *argvp; _Bool active_set = 0; while (argc > 0) { if (strcmp(*argv, "on") == 0) { if (active_set) duparg2("on/off", "on"); rxsc->active = 1; active_set = 1; } else if (strcmp(*argv, "off") == 0) { if (active_set) duparg2("on/off", "off"); rxsc->active = 0; active_set = 1; } else { fprintf(stderr, "macsec: unknown command \"%s\"?\n", *argv); ipmacsec_usage(); } argv++; argc--; } *argvp = argv; *argcp = argc; return 0; }
int parse_rxsci_args(unsigned int *a0, unsigned long long *a1, struct_0 *a2) { char v0; unsigned int v1; unsigned long long *v2; v1 = *(a0); v2 = *(a1); for (v0 = 0; v1 > 0; v1 -= 1) { if (!strcmp(*(v2), "on")) { if (v0) duparg2("on/off", "on"); a2->field_10 = 1; v0 = 1; } else { if (strcmp(*(v2), "off")) { fprintf(stderr, "macsec: unknown command \"%s\"?\n", *(v2)); ipmacsec_usage(); } if (v0) duparg2("on/off", "off"); a2->field_10 = 0; v0 = 1; } v2 += 1; } *(a1) = v2; *(a0) = v1; return 0; }
iproute2-6.0.0
angr_sailr
static int ssh_packet_enable_delayed_compress(struct ssh *ssh) { struct session_state *state = ssh->state; struct sshcomp *comp = ((void *)0); int r, mode; state->after_authentication = 1; for (mode = 0; mode < MODE_MAX; mode++) { if (state->newkeys[mode] == ((void *)0)) continue; comp = &state->newkeys[mode]->comp; if (comp && !comp->enabled && comp->type == 2) { if ((r = ssh_packet_init_compression(ssh)) != 0) return r; if (mode == MODE_OUT) { if ((r = start_compression_out(ssh, 6)) != 0) return r; } else { if ((r = start_compression_in(ssh)) != 0) return r; } comp->enabled = 1; } } return 0; }
int ssh_packet_enable_delayed_compress(unsigned long long *a0) { unsigned int v0; unsigned int v1; struct_1 *v2; void *v3; unsigned int v5; v2 = *(a0); v3 = 0; v2->field_148 = 1; v0 = 0; while (true) { if (v0 > 1) { v5 = 0; break; } else { if (*(&v2[1].padding_0[12 + 8 * v0])) { *(&v3[0]) = *(&v2[1].padding_0[12 + 8 * v0]) + 104; if (v3 && !v3[1] && v3[0] == 2) { v1 = ssh_packet_init_compression(a0); if (v1) { v5 = v1; break; } else { if (v0 == 1) { v1 = start_compression_out(a0, 0x6); if (v1) { v5 = v1; break; } } else { v1 = start_compression_in(a0); if (v1) { v5 = v1; break; } } v3[1] = 1; } } } v0 = __addvsi3(v0, 0x1); } } return v5; }
openssh-portable
angr_phoenix
static void dupredirect(redir, f) union node *redir; int f; { int fd = redir->nfile.fd; int err = 0; if (redir->nfile.type == 21 || redir->nfile.type == 22) { if (f >= 0) { if (dup2(f, fd) < 0) { err = (*dash_errno); goto err; } return; } f = fd; } else if (dup2(f, fd) < 0) err = (*dash_errno); close(f); if (err < 0) goto err; return; err: sh_error("%d: %s", f, strerror(err)); }
void dupredirect(unsigned int a0[5], unsigned long a1, unsigned long a2, unsigned long long a3) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned long long v6; unsigned long long v8; v0 = a1; v2 = a0[4]; v1 = 0; switch (a0[0]) { case 21: case 22: if (v0 < 0) { v0 = v2; break; } else if (dup2(v0, v2) >= 0) { return; } else { v1 = *(*(&dash_errno)); v8 = sh_error("%d: %s", v0, strerror(v1), a3); return; } default: if (dup2(v0, v2) < 0) { v1 = *(*(&dash_errno)); break; } } v6 = close(v0); if (v1 < 0) { v8 = sh_error("%d: %s", v0, strerror(v1), a3); return; } return; }
dash-0.5.11+git20210903+057cd650a4ed
angr_sailr
inline errcode_t ext2fs_get_array(unsigned long count, unsigned long size, void *ptr) { if (count && (~0UL) / count < size) return (2133571398L); return ext2fs_get_mem(count * size, ptr); }
void ext2fs_get_array(void) { halt_baddata(); }
e2fsprogs-1.46.5
ghidra
namebuf_t namebuf_create(const char *dir) { namebuf_t buf = xmalloc(sizeof(*buf)); buf->buffer_size = strlen(dir) + 2; buf->buffer = xmalloc(buf->buffer_size); strcpy(buf->buffer, dir); buf->dir_length = strlen(buf->buffer); if (!((buf->buffer[buf->dir_length - 1]) == '/')) buf->buffer[buf->dir_length++] = '/'; return buf; }
int namebuf_create(char *a0) { unsigned long long v0[3]; int tmp_20; char *v2; v0[0] = xmalloc(0x18); v0[1] = strlen(a0) + 2; v0[0] = xmalloc(v0[1]); strcpy(v0[0], a0); v0[2] = strlen(v0[0]); if (*((v0[2] - 1 + v0[0])) != 47) { v2 = v0[0]; tmp_20 = v0[2]; v0[2] = v0[2] + 1; v2[tmp_20] = 47; return v0; } return v0; }
tar
angr_sailr
static _Bool init_fps(int number_of_files, char **av) { COLUMN *p; total_files = 0; free(column_vector); column_vector = xnmalloc(columns, sizeof(COLUMN)); if (parallel_files) { int files_left = number_of_files; for (p = column_vector; files_left--; ++p, ++av) { if (!open_file(*av, p)) { --p; --columns; } } if (columns == 0) return 0; init_header("", -1); } else { p = column_vector; if (number_of_files > 0) { if (!open_file(*av, p)) return 0; init_header(*av, fileno(p->fp)); p->lines_stored = 0; } else { p->name = gettext("standard input"); p->fp = stdin; have_read_stdin = 1; p->status = OPEN; p->full_page_printed = 0; ++total_files; init_header("", -1); p->lines_stored = 0; } char const *firstname = p->name; FILE *firstfp = p->fp; int i; for (i = columns - 1, ++p; i; --i, ++p) { p->name = firstname; p->fp = firstfp; p->status = OPEN; p->full_page_printed = 0; p->lines_stored = 0; } } files_ready_to_read = total_files; return 1; }
int init_fps(unsigned long a0, unsigned long a1) { unsigned long long *v0; int tmp_9; unsigned int v1; unsigned int v2; unsigned long long v3; unsigned long v4; unsigned long v5; unsigned int v9; v0 = a1; total_files = 0; free(column_vector); column_vector = xnmalloc(columns, 0x40); if (parallel_files) { v1 = a0; v3 = column_vector; while (true) { tmp_9 = v1; v1 -= 1; if (!tmp_9) break; if ((open_file(*(v0), v3) ^ 1)) { v3 -= 64; columns = columns - 1; } v3 += 64; v0 += 1; } if (!columns) { v9 = 0; goto LABEL_4015f6; } else { init_header(&g_403efb, 0xffffffff); } } else { v3 = column_vector; if (a0 <= 0) { v3->field_8 = gettext("standard input"); v3->field_0 = stdin; have_read_stdin = 1; v3->field_10 = 0; v3->field_39 = 0; total_files = total_files + 1; init_header(&g_403efb, 0xffffffff); v3->field_2c = 0; } else if ((open_file(*(v0), v3) ^ 1)) { v9 = 0; goto LABEL_4015f6; } else { init_header(*(v0), fileno(v3->field_0)); v3->field_2c = 0; } v4 = v3->field_8; v5 = v3->field_0; v2 = columns - 1; for (v3 += 64; v2; v3 += 64) { v3->field_8 = v4; v3->field_0 = v5; v3->field_10 = 0; v3->field_39 = 0; v3->field_2c = 0; v2 -= 1; } } files_ready_to_read = total_files; v9 = 1; LABEL_4015f6: return v9; }
coreutils
angr_phoenix
static inline void emit_ancillary_info(char const *program) { struct infomap { char const *program; char const *node; } const infomap[] = { {"[", "test invocation"}, {"coreutils", "Multi-call invocation"}, {"sha224sum", "sha2 utilities"}, {"sha256sum", "sha2 utilities"}, {"sha384sum", "sha2 utilities"}, {"sha512sum", "sha2 utilities"}, {((void *)0), ((void *)0)}}; char const *node = program; struct infomap const *map_prog = infomap; while (map_prog->program && !(strcmp(program, map_prog->program) == 0)) map_prog++; if (map_prog->node) node = map_prog->node; printf (gettext ("\n%s online help: <%s>\n"), "GNU coreutils", "https: char const *lc_messages = setlocale ( 5 , ((void *)0) ); if (lc_messages && strncmp (lc_messages, "" "en_" "", sizeof ("en_") - 1)) { fputs_unlocked (gettext ("Report any translation bugs to " "<https: stdout ) ; } char const *url_program = (strcmp (program, "[") == 0) ? "test" : program; printf (gettext ("Full documentation <%s%s>\n"), "https: printf (gettext ("or available locally via: info '(coreutils) %s%s'\n"), node, node == program ? " invocation" : ""); }
void emit_ancillary_info(char *a0) { unsigned long long v0; unsigned long long v1[2]; char *v2; unsigned long long v3; unsigned long long v4; unsigned long long v5; unsigned long long v6; unsigned long long v7; unsigned long long v8; unsigned long long v9; unsigned long long v10; unsigned long long v11; unsigned long long v12; unsigned long long v13; unsigned long long v14; unsigned long long v15; void *v16; void *v17; char v18; unsigned long long v20; unsigned long long *v21; unsigned long long v22; v4 = "["; v5 = "test invocation"; v6 = "coreutils"; v7 = "Multi-call invocation"; v8 = "sha224sum"; v9 = "sha2 utilities"; v10 = "sha256sum"; v11 = "sha2 utilities"; v12 = "sha384sum"; v13 = "sha2 utilities"; v14 = "sha512sum"; v15 = "sha2 utilities"; v16 = 0; v17 = 0; v0 = a0; v1[0] = &v4; while (true) { if (!v1[0]) break; if (!strcmp(a0, v1[0])) break; v1[0] = v1 + 1; } if (v1[1]) v0 = v1[1]; printf(gettext("\n%s online help: <%s>\n")); v2 = setlocale(0x5, NULL); if (v2 && strncmp(v2, "en_", 0x3)) fputs_unlocked(gettext("Report any translation bugs to <https: if (!strcmp(a0, "[")) v20 = "test"; else v20 = a0; v3 = v20; printf(gettext("Full documentation <%s%s>\n")); printf(gettext("or available locally via: info '(coreutils) %s%s'\n")); v22 = *(&v18) ^ v21[5]; return; }
coreutils
angr_phoenix
static void store_columns(void) { int i, j; unsigned int line = 0; unsigned int buff_start; int last_col; COLUMN *p; buff_current = 0; buff_start = 0; if (balance_columns) last_col = columns; else last_col = columns - 1; for (i = 1, p = column_vector; i <= last_col; ++i, ++p) p->lines_stored = 0; for (i = 1, p = column_vector; i <= last_col && files_ready_to_read; ++i, ++p) { p->current_line = line; for (j = lines_per_body; j && files_ready_to_read; --j) if (p->status == OPEN) { input_position = 0; if (!read_line(p)) read_rest_of_line(p); if (p->status == OPEN || buff_start != buff_current) { ++p->lines_stored; line_vector[line] = buff_start; end_vector[line++] = input_position; buff_start = buff_current; } } } line_vector[line] = buff_start; if (balance_columns) balance(line); }
void store_columns(void) { char cVar1; int local_24; int local_20; uint local_1c; int local_18; int local_14; long local_10; local_1c = 0; buff_current = 0; local_18 = 0; if (balance_columns == '\0') { local_14 = columns + -1; } else { local_14 = columns; } local_10 = column_vector; for (local_24 = 1; local_24 <= local_14; local_24 = local_24 + 1) { *(undefined4 *)(local_10 + 0x2c) = 0; local_10 = local_10 + 0x40; } local_24 = 1; local_10 = column_vector; while ((local_24 <= local_14 && (files_ready_to_read != 0))) { *(uint *)(local_10 + 0x28) = local_1c; local_20 = lines_per_body; while ((local_20 != 0 && (files_ready_to_read != 0))) { if (*(int *)(local_10 + 0x10) == 0) { input_position = 0; cVar1 = read_line(local_10); if (cVar1 != '\x01') { read_rest_of_line(local_10); } if ((*(int *)(local_10 + 0x10) == 0) || (local_18 != buff_current)) { *(int *)(local_10 + 0x2c) = *(int *)(local_10 + 0x2c) + 1; *(int *)((ulong)local_1c * 4 + line_vector) = local_18; *(undefined4 *)(end_vector + (ulong)local_1c * 4) = input_position; local_18 = buff_current; local_1c = local_1c + 1; } } local_20 = local_20 + -1; } local_24 = local_24 + 1; local_10 = local_10 + 0x40; } *(int *)((ulong)local_1c * 4 + line_vector) = local_18; if (balance_columns != '\0') { balance(local_1c); } return; }
coreutils
ghidra
static enum simple_strtod_error parse_human_number(char const *str, long double *value, size_t *precision) { char *ptr = ((void *)0); enum simple_strtod_error e = simple_strtod_human(str, &ptr, value, precision, scale_from); if (e != SSE_OK && e != SSE_OK_PRECISION_LOSS) { simple_strtod_fatal(e, str); return e; } if (ptr && *ptr != '\0') { if (inval_style != inval_ignore) error(conv_exit_code, 0, gettext("invalid suffix in input %s: %s"), quote_n(0, str), quote_n(1, ptr)); e = SSE_INVALID_SUFFIX; } return e; }
int parse_human_number(unsigned long long a0, unsigned int a1, unsigned long long *a2) { unsigned int v0; void *v1; unsigned int v3; unsigned long long v4; unsigned long long v5; v1 = 0; v0 = simple_strtod_human(a0, &v1, a1, a2, scale_from); if (v0 && v0 != 1) { simple_strtod_fatal(v0, a0); v3 = v0; goto LABEL_4020a6; } if (v1 && *(v1)) { if (inval_style == 3) { v0 = 5; } else { v4 = quote_n(0x1, v1); v5 = quote_n(0x0, a0); error(conv_exit_code, 0x0, gettext("invalid suffix in input %s: %s")); } } v3 = v0; LABEL_4020a6: return v3; }
coreutils
angr_phoenix
static int get_nondigit_option(int argc, char *const *argv, intmax_t *default_context) { static int prev_digit_optind = -1; int this_digit_optind; _Bool was_digit; char buf[((((((sizeof(intmax_t) * 8) - (!((__typeof__(intmax_t))0 < (__typeof__(intmax_t))-1))) * 146 + 484) / 485) + (!((__typeof__(intmax_t))0 < (__typeof__(intmax_t))-1))) + 1) + 4]; char *p = buf; int opt; was_digit = 0; this_digit_optind = optind; while (1) { opt = getopt_long(argc, (char **)argv, short_options, long_options, ((void *)0)); if (!c_isdigit(opt)) break; if (prev_digit_optind != this_digit_optind || !was_digit) { p = buf; } else { p -= buf[0] == '0'; } if (p == buf + sizeof buf - 4) { strcpy(p, "..."); p += 3; break; } *p++ = opt; was_digit = 1; prev_digit_optind = this_digit_optind; this_digit_optind = optind; } if (p != buf) { *p = '\0'; context_length_arg(buf, default_context); } return opt; }
int get_nondigit_option(unsigned long a0, char **a1, unsigned long long *a2) { char v0; int tmp_12; unsigned int v1; unsigned int v2; char *v3; char v4; char v5; v3 = &v4; v0 = 0; v1 = optind; while (true) { v2 = getopt_long( a0, a1, "0123456789A:B:C:D:EFGHIPTUVX:abcd:e:f:hiLlm:noqRrsuvwxyZz", &long_options, NULL); if ((c_isdigit(v2) ^ 1)) break; if (v1 != prev_digit_optind.7695) { LABEL_4035a3: v3 = &v4; goto LABEL_4035c0; } else { if (!(!(v0 ^ 1))) goto LABEL_4035a3; v3 = &v3[-(v4 == 48)]; LABEL_4035c0: if (v3 != &v5) { tmp_12 = v3; v3 += 1; *(tmp_12) = v2; v0 = 1; prev_digit_optind.7695 = v1; v1 = optind; } else { strcpy(v3, "..."); v3 += 3; break; } } } if (v3 != &v4) { *(v3) = 0; context_length_arg(&v4, a2); } return v2; }
grep
angr_phoenix
static int parse_additional_groups(char const *groups, gid_t **pgids, size_t *pn_gids, _Bool show_errors) { gid_t *gids = ((void *)0); size_t n_gids_allocated = 0; size_t n_gids = 0; char *buffer = xstrdup(groups); char const *tmp; int ret = 0; for (tmp = strtok(buffer, ","); tmp; tmp = strtok(((void *)0), ",")) { struct group *g; uintmax_t value; if (xstrtoumax(tmp, ((void *)0), 10, &value, "") == LONGINT_OK && value <= ((gid_t)(!(!((gid_t)0 < (gid_t)-1)) ? (gid_t)-1 : ((((gid_t)1 << ((sizeof(gid_t) * 8) - 2)) - 1) * 2 + 1)))) { while (((*__ctype_b_loc())[(int)((to_uchar(*tmp)))] & (unsigned short int)_ISspace)) tmp++; if (*tmp != '+') { g = getgrnam(tmp); if (g != ((void *)0)) value = g->gr_gid; } g = (struct group *)(intptr_t)!((void *)0); } else { g = getgrnam(tmp); if (g != ((void *)0)) value = g->gr_gid; } if (g == ((void *)0)) { ret = -1; if (show_errors) { error(0, (*__errno_location()), gettext("invalid group %s"), quote(tmp)); continue; } break; } if (n_gids == n_gids_allocated) gids = ((!!sizeof(struct { _Static_assert(sizeof *(gids) != 1, "verify_expr (" "sizeof *(gids) != 1" ", " "x2nrealloc (gids, &n_gids_allocated, sizeof *(gids))" ")"); int _gl_dummy; })) ? (x2nrealloc(gids, &n_gids_allocated, sizeof *(gids))) : (x2nrealloc(gids, &n_gids_allocated, sizeof *(gids)))); gids[n_gids++] = value; } if (ret == 0 && n_gids == 0) { if (show_errors) error(0, 0, gettext("invalid group list %s"), quote(groups)); ret = -1; } *pgids = gids; if (ret == 0) *pn_gids = n_gids; free(buffer); return ret; }
int parse_additional_groups(undefined8 param_1, long *param_2, long *param_3, char param_4) { ushort *puVar1; byte bVar2; int iVar3; ushort **ppuVar4; group *pgVar5; int *piVar6; undefined8 uVar7; undefined8 uVar8; long in_FS_OFFSET; int local_5c; long local_58; ulong local_50; long local_48; long local_40; char *local_38; group *local_30; char *local_28; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_48 = 0; local_58 = 0; local_40 = 0; local_28 = (char *)xstrdup(param_1); local_5c = 0; local_38 = strtok(local_28, ","); while (local_38 != (char *)0x0) { iVar3 = xstrtoumax(local_38, 0, 10, &local_50, &DAT_001011db); if ((iVar3 == 0) && (local_50 < 0x100000000)) { while (true) { ppuVar4 = __ctype_b_loc(); puVar1 = *ppuVar4; bVar2 = to_uchar((int)*local_38); if ((puVar1[bVar2] & 0x2000) == 0) break; local_38 = local_38 + 1; } if ((*local_38 != '+') && (pgVar5 = getgrnam(local_38), pgVar5 != (group *)0x0)) { local_50 = (ulong)pgVar5->gr_gid; } local_30 = (group *)0x1; } else { local_30 = getgrnam(local_38); if (local_30 != (group *)0x0) { local_50 = (ulong)local_30->gr_gid; } } if (local_30 == (group *)0x0) { local_5c = -1; if (param_4 == '\0') break; uVar7 = quote(local_38); uVar8 = gettext("invalid group %s"); piVar6 = __errno_location(); error(0, *piVar6, uVar8, uVar7); } else { if (local_40 == local_58) { local_48 = x2nrealloc(local_48, &local_58, 4); } *(int *)(local_48 + local_40 * 4) = (int)local_50; local_40 = local_40 + 1; } local_38 = strtok((char *)0x0, ","); } if ((local_5c == 0) && (local_40 == 0)) { if (param_4 != '\0') { uVar7 = quote(param_1); uVar8 = gettext("invalid group list %s"); error(0, 0, uVar8, uVar7); } local_5c = -1; } *param_2 = local_48; if (local_5c == 0) { *param_3 = local_40; } free(local_28); if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return local_5c; } __stack_chk_fail(); }
coreutils
ghidra
static void check_order(struct linebuffer const *prev, struct linebuffer const *current, int whatfile) { if (check_input_order != CHECK_ORDER_DISABLED && ((check_input_order == CHECK_ORDER_ENABLED) || seen_unpairable)) { if (!issued_disorder_warning[whatfile - 1]) { int order; if (hard_LC_COLLATE) order = xmemcoll(prev->buffer, prev->length - 1, current->buffer, current->length - 1); else order = memcmp2(prev->buffer, prev->length - 1, current->buffer, current->length - 1); if (0 < order) { error((check_input_order == CHECK_ORDER_ENABLED ? 1 : 0), 0, gettext("file %d is not in sorted order"), whatfile); issued_disorder_warning[whatfile - 1] = 1; } } } }
void check_order(unsigned long long a0[3], unsigned long long a1[3], unsigned long a2) { unsigned int v0; unsigned long long v2; unsigned long long v3; unsigned long long v4; unsigned long long v7; v2 = check_input_order; if (check_input_order != 2) { if (check_input_order != 1) { v3 = seen_unpairable; if (!seen_unpairable) goto LABEL_4006d9; } v4 = *(a2 + &seen_unpairable) ^ 1; if ((*(a2 + &seen_unpairable) ^ 1)) { if (!hard_LC_COLLATE) v0 = memcmp2(a0[2], a0[1] - 1, a1[2], a1[1] - 1); else v0 = xmemcoll(a0[2], a0[1] - 1, a1[2], a1[1] - 1); if (v0 > 0) { error(check_input_order == 1, 0x0, gettext("file %d is not in sorted order")); v7 = a2 - 1; *(a2 + &seen_unpairable) = 1; } } } LABEL_4006d9: return; }
coreutils
angr_phoenix
static void initialize_regex(void) { int character; if (ignore_case) for (character = 0; character < 256; character++) folded_chars[character] = toupper(character); if (context_regex.string) { if (!*context_regex.string) context_regex.string = ((void *)0); } else if (gnu_extensions && !input_reference) context_regex.string = "[.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]*";
void initialize_regex() { unsigned int v0; char *v2; unsigned long long v3; unsigned long long v4; unsigned long long v5; unsigned long v6; char v7; unsigned long long v8; if (ignore_case) { for (v0 = 0; v0 <= 255; v0 += 1) { *(v0 + &folded_chars) = toupper(v0); } } if (!context_regex) { if (gnu_extensions && (input_reference ^ 1)) context_regex = "[.?!][]\"\')}]*\\($\\|\t\\| \\)[ \t\n]*"; if (!(input_reference ^ 1) || !gnu_extensions) context_regex = "\n"; } else if (!*(context_regex)) {
coreutils
angr_dream
void set_cron_uid(void) { if (setuid(0) < 0) { perror("setuid"); exit(1); } }
void set_cron_uid(void) { int iVar1; iVar1 = setuid(0); if (iVar1 < 0) { perror("setuid"); exit(1); } return; }
cronie
ghidra
void put_u64(void *vp, u_int64_t v) { u_char *p = (u_char *)vp; p[0] = (u_char)(v >> 56) & 0xff; p[1] = (u_char)(v >> 48) & 0xff; p[2] = (u_char)(v >> 40) & 0xff; p[3] = (u_char)(v >> 32) & 0xff; p[4] = (u_char)(v >> 24) & 0xff; p[5] = (u_char)(v >> 16) & 0xff; p[6] = (u_char)(v >> 8) & 0xff; p[7] = (u_char)v & 0xff; }
long long put_u64(char a0[8], unsigned long a1) { a0[0] = a1 / 0x100000000000000; a0[1] = a1 / 0x1000000000000; a0[2] = a1 / 0x10000000000; a0[3] = a1 / 0x100000000; a0[4] = a1 / 0x1000000; a0[5] = a1 / 0x10000; a0[6] = a1 / 0x100; a0[7] = a1; return &a0[7]; }
openssh-portable
angr_dream
static _Bool should_exclude_dir(const struct cfg *cfg, const char *name) { struct cfg_exclude *exc; if (name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) return 1; if ((strcmp((name), ("build")) == 0) || (strcmp((name), ("source")) == 0)) return 1; for (exc = cfg->excludes; exc != ((void *)0); exc = exc->next) { if ((strcmp((name), (exc->exclude_dir)) == 0)) return 1; } return 0; }
undefined8 should_exclude_dir(long param_1, char *param_2) { int iVar1; undefined8 *local_10; if ((((*param_2 != '.') || ((param_2[1] != '\0' && ((param_2[1] != '.' || (param_2[2] != '\0')))))) && (iVar1 = strcmp(param_2, "build"), iVar1 != 0)) && (iVar1 = strcmp(param_2, "source"), iVar1 != 0)) { local_10 = *(undefined8 **)(param_1 + 0x1030); while (true) { if (local_10 == (undefined8 *)0x0) { return 0; } iVar1 = strcmp(param_2, (char *)(local_10 + 1)); if (iVar1 == 0) break; local_10 = (undefined8 *)*local_10; } return 1; } return 1; }
kmod
ghidra
char *assoc_subrange(hash, start, nelem, starsub, quoted, pflags) HASH_TABLE *hash; arrayind_t start, nelem; int starsub, quoted, pflags; { WORD_LIST *l, *save, *h, *t; int i, j; char *ret; if (((hash)->nentries == 0)) return ((char *)((void *)0)); save = l = assoc_to_word_list(hash); if (save == 0) return ((char *)((void *)0)); for (i = 1; l && i < start; i++) l = l->next; if (l == 0) { dispose_words(save); return ((char *)((void *)0)); } for (j = 0, h = t = l; l && j < nelem; j++) { t = l; l = l->next; } t->next = (WORD_LIST *)((void *)0); ret = string_list_pos_params(starsub ? '*' : '@', h, quoted, pflags); if (t != l) t->next = l; dispose_words(save); return (ret); }
long long assoc_subrange(unsigned long long a0, unsigned long a1, unsigned long a2, unsigned long a3, unsigned long a4, unsigned long a5) { struct_0 *v0; unsigned int v1; unsigned int v2; unsigned long long *v3; unsigned long long *v4; unsigned long long *v5; unsigned long long *v6; unsigned long long v7; void *v9; v0 = a0; if (!v0->field_c) { v9 = 0; return v9; } v3 = assoc_to_word_list(v0); v5 = v3; if (!v5) { v9 = 0; return v9; } for (v1 = 1; v3 && a1 > v1; v1 += 1) { v3 = *(v3); } if (!v3) { dispose_words(v5); v9 = 0; return v9; } v2 = 0; v4 = v3; for (v6 = v4; v3 && a2 > v2; v2 += 1) { v4 = v3; v3 = *(v3); } *(v4) = 0; v7 = string_list_pos_params((!a3 ? 42 : 64), v6, a4, a5); if (v4 != v3) *(v4) = v3; dispose_words(v5); v9 = v7; return v9; }
bash
angr_sailr
static enum token t_lex(char **tp) { struct t_op const *op; char *s = *tp; if (s == 0) { t_wp_op = (struct t_op *)0; return EOI; } op = getop(s); if (op && !(op->op_type == UNOP && isoperand(tp)) && !(op->op_num == LPAREN && !tp[1])) { t_wp_op = op; return op->op_num; } t_wp_op = (struct t_op *)0; return OPERAND; }
int t_lex(unsigned long long a0[2]) { char *v0; unsigned short v1[6]; unsigned int v3; v0 = a0[0]; if (!v0) { t_wp_op = 0; v3 = 0; } else { *(&v1[0]) = getop(v0); if (v1) { if (!v1[5] && !(!isoperand(a0))) goto LABEL_400b6f; if (v1[4] != 37) { LABEL_400b59: t_wp_op = v1; v3 = v1[4]; goto LABEL_400b7f; } else if (!(!a0[1])) { goto LABEL_400b59; } } LABEL_400b6f: t_wp_op = 0; v3 = 39; } LABEL_400b7f: return v3; }
dash-0.5.11+git20210903+057cd650a4ed
angr_phoenix
void rl_reset_after_signal(void) { if (rl_prep_term_function) (*rl_prep_term_function)(); }
long long rl_reset_after_signal() { unsigned long long v1; v1 = *(got.rl_prep_term_function); if (*(got.rl_prep_term_function)) v1 = *(*(5243864))(); return v1; }
libedit
angr_sailr
ARRAY *array_remove_quoted_nulls(array) ARRAY *array; { ARRAY_ELEMENT *a; if (array == 0 || ((array)->head) == 0 || ((array)->num_elements == 0)) return (ARRAY *)((void *)0); for (a = ((array->head)->next); a != array->head; a = ((a)->next)) a->value = remove_quoted_nulls(a->value); return array; }
long long array_remove_quoted_nulls(void *a0) { unsigned long long v0[3]; void *v2; if (!a0) { v2 = 0; return v2; } else if (!a0[16]) { v2 = 0; return v2; } else if (!a0[8]) { v2 = 0; return v2; } else { for (v0[0] = *((a0[16] + 16)); v0 != a0[16]; v0[0] = v0[2]) { v0[1] = remove_quoted_nulls(v0[1]); } v2 = a0; return v2; } }
bash
angr_sailr
char *_rl_savestring(const char *s) { return (strcpy((char *)xmalloc(1 + (int)strlen(s)), (s))); }
void _rl_savestring(char *param_1) { size_t sVar1; char *__dest; sVar1 = strlen(param_1); __dest = (char *)xmalloc((long)((int)sVar1 + 1)); strcpy(__dest, param_1); return; }
bash
ghidra
static int import_dsa_dh(gnutls_dh_params_t dh_params, gnutls_datum_t *params, gnutls_x509_crt_fmt_t format) { gnutls_x509_privkey_t pkey; int ret; ret = gnutls_x509_privkey_init(&pkey); if (ret < 0) return ret; ret = gnutls_x509_privkey_import(pkey, params, format); if (ret < 0) return ret; ret = gnutls_dh_params_import_dsa(dh_params, pkey); gnutls_x509_privkey_deinit(pkey); return ret; }
long import_dsa_dh(long a1, long a2, unsigned int a3) { int v5; int v6; long v7[2]; v7[1] = __readfsqword(0x28u); v5 = gnutls_x509_privkey_init(v7); if (v5 < 0) return (unsigned int)v5; v6 = gnutls_x509_privkey_import(v7[0], a2, a3); if (v6 >= 0) { v6 = gnutls_dh_params_import_dsa(a1, v7[0]); gnutls_x509_privkey_deinit(v7[0]); } return (unsigned int)v6; }
gnutls
ida
int pidfile_write(struct pidfh *pfh) { char pidstr[16]; int error, fd; (*__errno_location()) = pidfile_verify(pfh); if ((*__errno_location()) != 0) { return (-1); } fd = pfh->pf_fd; if (ftruncate(fd, 0) == -1) { error = (*__errno_location()); _pidfile_remove(pfh, 0); (*__errno_location()) = error; return (-1); } snprintf(pidstr, sizeof(pidstr), "%u", getpid()); if (pwrite(fd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) { error = (*__errno_location()); _pidfile_remove(pfh, 0); (*__errno_location()) = error; return (-1); } return (0); }
long long pidfile_write(unsigned int *a0) { unsigned int v0; unsigned int v1; char v2; unsigned long long v5; *(__errno_location()) = pidfile_verify(a0); if (*(__errno_location())) { v5 = 4294967295; } else { v0 = *(a0); if (ftruncate(v0, 0x0) == -1) { v1 = *(__errno_location()); _pidfile_remove(a0, 0x0); *(__errno_location()) = v1; v5 = 4294967295; } else { snprintf(&v2, 0x10, "%u", getpid()); if (pwrite(v0, &v2, strlen(&v2), 0x0) == strlen(&v2)) { v5 = 0; } else { v1 = *(__errno_location()); _pidfile_remove(a0, 0x0); *(__errno_location()) = v1; v5 = 4294967295; } } } return v5; }
libbsd-0.11.7
angr_phoenix
static void xfrm_print_addr(FILE *fp, int family, xfrm_address_t *a) { fprintf(fp, "%s", rt_addr_n2a(family, sizeof(*a), a)); }
void xfrm_print_addr(void *a0, unsigned long a1, unsigned long long a2) { unsigned long long v1; v1 = fprintf(a0, "%s", rt_addr_n2a(a1, 0x10, a2)); return; }
iproute2-6.0.0
angr_sailr
static WORD_DESC *parameter_brace_expand(string, indexp, quoted, pflags, quoted_dollar_atp, contains_dollar_at) char *string; int *indexp, quoted, pflags, *quoted_dollar_atp, *contains_dollar_at; { int check_nullness, var_is_set, var_is_null, var_is_special; int want_substring, want_indir, want_patsub, want_casemod, want_attributes; char *name, *value, *temp, *temp1; WORD_DESC *tdesc, *ret; int t_index, sindex, c, tflag, modspec, local_pflags, all_element_arrayref; intmax_t number; array_eltstate_t es; temp = temp1 = value = (char *)((void *)0); var_is_set = var_is_null = var_is_special = check_nullness = 0; want_substring = want_indir = want_patsub = want_casemod = want_attributes = 0; local_pflags = 0; all_element_arrayref = 0; sindex = *indexp; t_index = ++sindex; if (string[t_index] == '#' && ((1 && ((*__ctype_b_loc())[(int)(((unsigned char)string[t_index + 1]))] & (unsigned short int)_ISalpha)) || (string[t_index + 1] == '_'))) name = string_extract(string, &t_index, "}", 0x0002);
int parameter_brace_expand(unsigned long long a0, unsigned int *a1, unsigned long long a2, unsigned long long a3, unsigned int *a4, unsigned int *a5) { unsigned int v0; int tmp_37; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned int v5; unsigned int v6; unsigned int v7; unsigned int v8; unsigned int v9; unsigned int v10; unsigned int v11; unsigned int v12; unsigned int v13; unsigned int v14; unsigned int v15; unsigned int v16; unsigned int v17; unsigned int v18; char v19; char v20[3]; void *v21; void *v22; void *v23; struct_0 *v24; char v25[2]; unsigned long v26; unsigned long long v27; void *v28; unsigned long long v29; char v30[3]; char v31; unsigned long long v32; unsigned int v35; char v36[3]; unsigned long long v37; unsigned long long v38; unsigned long long v39; v1 = a2; v0 = a3; v21 = 0; v25 = v21; v22 = v25; v4 = 0; v6 = v4; v5 = v6; v16 = v5; v17 = 0; v9 = v17; v8 = v9; v18 = v8; v7 = v18; v13 = 0; v14 = 0; v3 = *(a1); v3 += 1; v2 = v3; if (*((a0 + v2)) == 35) { v35 = *((*(__ctype_b_loc()) + *((a0 + v2 + 1)) * 2)) & 0x400; if (*((a0 + v2 + 1)) == 95 || v35) *(&v20) = string_extract(a0, &v2, "}", 0x2, a4, a5); }
bash
angr_dream
static int do_set(int argc, char **argv) { char *dev = ((void *)0); __u32 mask = 0; __u32 flags = 0; int qlen = -1; int mtu = -1; char *newaddr = ((void *)0); char *newbrd = ((void *)0); struct ifreq ifr0, ifr1; char *newname = ((void *)0); int htype, halen; while (argc > 0) { if (strcmp(*argv, "up") == 0) { mask |= IFF_UP; flags |= IFF_UP; } else if (strcmp(*argv, "down") == 0) { mask |= IFF_UP; flags &= ~IFF_UP; } else if (strcmp(*argv, "name") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); if (check_ifname(*argv)) invarg("\"name\" not a valid ifname", *argv); newname = *argv; } else if (matches(*argv, "address") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); newaddr = *argv; } else if (matches(*argv, "broadcast") == 0 || strcmp(*argv, "brd") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); newbrd = *argv; } else if (matches(*argv, "txqueuelen") == 0 || strcmp(*argv, "qlen") == 0 || matches(*argv, "txqlen") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); if (qlen != -1) duparg("txqueuelen", *argv); if (get_integer(&qlen, *argv, 0)) invarg("Invalid \"txqueuelen\" value\n", *argv); } else if (strcmp(*argv, "mtu") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); if (mtu != -1) duparg("mtu", *argv); if (get_integer(&mtu, *argv, 0)) invarg("Invalid \"mtu\" value\n", *argv); } else if (strcmp(*argv, "multicast") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); mask |= IFF_MULTICAST; if (strcmp(*argv, "on") == 0) flags |= IFF_MULTICAST; else if (strcmp(*argv, "off") == 0) flags &= ~IFF_MULTICAST; else return on_off("multicast", *argv); } else if (strcmp(*argv, "allmulticast") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); mask |= IFF_ALLMULTI; if (strcmp(*argv, "on") == 0) flags |= IFF_ALLMULTI; else if (strcmp(*argv, "off") == 0) flags &= ~IFF_ALLMULTI; else return on_off("allmulticast", *argv); } else if (strcmp(*argv, "promisc") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); mask |= IFF_PROMISC; if (strcmp(*argv, "on") == 0) flags |= IFF_PROMISC; else if (strcmp(*argv, "off") == 0) flags &= ~IFF_PROMISC; else return on_off("promisc", *argv); } else if (strcmp(*argv, "trailers") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); mask |= IFF_NOTRAILERS; if (strcmp(*argv, "off") == 0) flags |= IFF_NOTRAILERS; else if (strcmp(*argv, "on") == 0) flags &= ~IFF_NOTRAILERS; else return on_off("trailers", *argv); } else if (strcmp(*argv, "arp") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); mask |= IFF_NOARP; if (strcmp(*argv, "on") == 0) flags &= ~IFF_NOARP; else if (strcmp(*argv, "off") == 0) flags |= IFF_NOARP; else return on_off("arp", *argv); } else if (matches(*argv, "dynamic") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); mask |= IFF_DYNAMIC; if (strcmp(*argv, "on") == 0) flags |= IFF_DYNAMIC; else if (strcmp(*argv, "off") == 0) flags &= ~IFF_DYNAMIC; else return on_off("dynamic", *argv); } else { if (strcmp(*argv, "dev") == 0) do { argv++; if (--argc <= 0) incomplete_command(); } while (0); else if (matches(*argv, "help") == 0) usage(); if (dev) duparg2("dev", *argv); if (check_ifname(*argv)) invarg("\"dev\" not a valid ifname", *argv); dev = *argv; } argc--; argv++; } if (!dev) { fprintf(stderr, "Not enough of information: \"dev\" argument is required.\n"); exit(-1); } if (newaddr || newbrd) { halen = get_address(dev, &htype); if (halen < 0) return -1; if (newaddr) { if (parse_address(dev, htype, halen, newaddr, &ifr0) < 0) return -1; } if (newbrd) { if (parse_address(dev, htype, halen, newbrd, &ifr1) < 0) return -1; } } if (newname && strcmp(dev, newname)) { if (do_changename(dev, newname) < 0) return -1; dev = newname; } if (qlen != -1) { if (set_qlen(dev, qlen) < 0) return -1; } if (mtu != -1) { if (set_mtu(dev, mtu) < 0) return -1; } if (newaddr || newbrd) { if (newbrd) { if (set_address(&ifr1, 1) < 0) return -1; } if (newaddr) { if (set_address(&ifr0, 0) < 0) return -1; } } if (mask) return do_chflags(dev, flags, mask); return 0; }
void do_set(unsigned long a0, unsigned long a1) { unsigned long long *v0; unsigned int v1; unsigned int v2; unsigned int v3; char v4; unsigned int v5; unsigned int v6; unsigned int v7; void *v8; void *v9; void *v10; void *v11; char v12; char v13; unsigned long long v23; unsigned long long v24; unsigned long long v25; unsigned long long v26; unsigned long long v27; unsigned long long v28; unsigned long long v29; unsigned long long v30; unsigned long long v31; unsigned long long v32; unsigned long long v33; unsigned long long v34; unsigned long long v35; unsigned long long v36; void *v37; unsigned long long v38; v1 = a0; v0 = a1; v8 = 0; v5 = 0; v6 = 0; v2 = -1; v3 = -1; v9 = 0; v10 = 0; for (v11 = 0; true; v0 += 1) { if (v1 <= 0) break; if (!strcmp(*(v0), "up")) { v5 |= 1; v6 |= 1; v1 = v1 - 1; continue; } if (!strcmp(*(v0), "down")) { v5 |= 1; v6 &= -2; v1 = v1 - 1; continue; } if (!strcmp(*(v0), "name")) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); if (check_ifname(*(v0))) invarg("\"name\" not a valid ifname", *(v0)); v11 = *(v0); v1 = v1 - 1; continue; } if ((matches(*(v0), "address") ^ 1)) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); v9 = *(v0); v1 = v1 - 1; continue; } if ((matches(*(v0), "broadcast") ^ 1) || !strcmp(*(v0), "brd")) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); v10 = *(v0); v1 = v1 - 1; continue; } if (!(!(matches(*(v0), "txqueuelen") ^ 1)) || !(strcmp(*(v0), "qlen")) || !(!(matches(*(v0), "txqlen") ^ 1))) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); if (v2 != -1) duparg("txqueuelen", *(v0)); if (get_integer(&v2, *(v0), 0x0, *(v0))) { invarg("Invalid \"txqueuelen\" value\n", *(v0)); } else { v1 = v1 - 1; continue; } } if (!strcmp(*(v0), "mtu")) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); if (v3 != -1) duparg("mtu", *(v0)); if (get_integer(&v3, *(v0), 0x0, *(v0))) { invarg("Invalid \"mtu\" value\n", *(v0)); } else { v1 = v1 - 1; continue; } } if (!strcmp(*(v0), "multicast")) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); v5 |= 0x1000; if (strcmp(*(v0), "on")) { if (strcmp(*(v0), "off")) { v23 = on_off("multicast", *(v0)); return; } v6 &= -4097; v1 = v1 - 1; continue; } else { v6 |= 0x1000; v1 = v1 - 1; } continue; } if (!strcmp(*(v0), "allmulticast")) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); v5 |= 0x200; if (strcmp(*(v0), "on")) { if (strcmp(*(v0), "off")) { v24 = on_off("allmulticast", *(v0)); return; } v6 &= -513; v1 = v1 - 1; continue; } else { v6 |= 0x200; v1 = v1 - 1; } continue; } if (!strcmp(*(v0), "promisc")) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); v5 |= 0x100; if (strcmp(*(v0), "on")) { if (strcmp(*(v0), "off")) { v25 = on_off("promisc", *(v0)); return; } v6 &= -257; v1 = v1 - 1; continue; } else { v6 |= 0x100; v1 = v1 - 1; } continue; } if (!strcmp(*(v0), "trailers")) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); v5 |= 32; if (strcmp(*(v0), "off")) { if (strcmp(*(v0), "on")) { v26 = on_off("trailers", *(v0)); return; } v6 &= -33; v1 = v1 - 1; continue; } else { v6 |= 32; v1 = v1 - 1; } continue; } if (!strcmp(*(v0), "arp")) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); v5 |= 128; if (strcmp(*(v0), "on")) { if (strcmp(*(v0), "off")) { v27 = on_off("arp", *(v0)); return; } v6 |= 128; v1 = v1 - 1; continue; } else { v6 &= -129; v1 = v1 - 1; } continue; } if ((matches(*(v0), "dynamic") ^ 1)) { v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); v5 |= 0x8000; if (!strcmp(*(v0), "on")) { v6 |= 0x8000; v1 = v1 - 1; } else if (!strcmp(*(v0), "off")) { v6 &= -32769; v1 = v1 - 1; continue; } else { v28 = on_off("dynamic", *(v0)); return; } continue; } if (!strcmp(*(v0), "dev")) { v0 = v0 + 1; v1 = v1 - 1; if (!(v1 <= 0)) goto LABEL_405017; incomplete_command(); } if ((matches(*(v0), "help") ^ 1)) usage(); LABEL_405017: if (v8) duparg2("dev", *(v0)); if (check_ifname(*(v0))) invarg("\"dev\" not a valid ifname", *(v0)); v8 = *(v0); v1 = v1 - 1; } if (!v8) { fprintf(stderr, "Not enough of information: \"dev\" argument is required.\n"); exit(0xffffffff); } if (v9 || v10) { v7 = get_address(v8, &v4); if (v7 < 0) { v29 = 4294967295; return; } if (v9 && parse_address(v8, *(&v4), v7, v9, &v12) < 0) { v30 = 4294967295; return; } if (v10 && parse_address(v8, *(&v4), v7, v10, &v13) < 0) { v31 = 4294967295; return; } } if (v11 && strcmp(v8, v11)) { if (do_changename(v8, v11) >= 0) { v8 = v11; } else { v32 = 4294967295; return; } } if (v2 != -1 && set_qlen(v8, v2) < 0) { v33 = 4294967295; return; } if (v3 != -1 && set_mtu(v8, v3) < 0) { v34 = 4294967295; return; } if (v9 || v10) { if (v10 && set_address(&v13, 0x1) < 0) { v35 = 4294967295; return; } if (v9 && set_address(&v12, 0x0) < 0) { v36 = 4294967295; return; } } if (!v5) { v37 = 0; return; } v38 = do_chflags(v8, v6, v5); return; }
iproute2-6.0.0
angr_sailr
int addr_sa_to_xaddr(struct sockaddr *sa, socklen_t slen, struct xaddr *xa) { struct sockaddr_in *in4 = (struct sockaddr_in *)sa; struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)sa; memset(xa, '\0', sizeof(*xa)); switch (sa->sa_family) { case 2: if (slen < (socklen_t)sizeof(*in4)) return -1; xa->af = 2; memcpy(&xa->xa.v4, &in4->sin_addr, sizeof(xa->xa.v4)); break; case 10: if (slen < (socklen_t)sizeof(*in6)) return -1; xa->af = 10; memcpy(&xa->xa.v6, &in6->sin6_addr, sizeof(xa->xa.v6)); xa->scope_id = in6->sin6_scope_id; break; default: return -1; } return 0; }
int addr_sa_to_xaddr(struct_1 *a0, unsigned long a1, struct_0 *a2) { unsigned short *v0; struct_1 *v1; unsigned int v3; v0 = &a0->field_0; v1 = a0; memset(a2, 0x0, 0x18); if (a0->field_0 == 2) { if (a1 <= 15) { v3 = -1; goto LABEL_4002bd; } else { a2->field_0 = 2; memcpy(&a2->padding_2[2], v0 + 2, 0x4); } } else { if (a0->field_0 != 10) { v3 = -1; goto LABEL_4002bd; } else if (a1 <= 27) { v3 = -1; goto LABEL_4002bd; } else { a2->field_0 = 10; memcpy(&a2->padding_2[2], &v1->padding_2[6], 0x10); a2->field_14 = v1->field_18; } } v3 = 0; LABEL_4002bd: return v3; }
openssh-portable
angr_phoenix
static int cost_table_comparison(const void *p1, const void *p2) { const struct pred_cost_lookup *pc1 = p1; const struct pred_cost_lookup *pc2 = p2; union { PRED_FUNC pfn; char mem[sizeof(PRED_FUNC)]; } u1, u2; u1.pfn = pc1->fn; u2.pfn = pc2->fn; return memcmp(u1.mem, u2.mem, sizeof(u1.pfn)); }
int cost_table_comparison(long *a1, long *a2) { long s1; long s2[2]; s2[1] = __readfsqword(0x28u); s1 = *a1; s2[0] = *a2; return memcmp(&s1, s2, 8uLL); }
findutils
ida
static char *scanright(char *startp, char *rmesc, char *rmescend, char *str, int quotes, int zero) { int esc = 0; char *loc; char *loc2; for (loc = str - 1, loc2 = rmescend; loc >= startp; loc2--) { int match; char c = *loc2; const char *s = loc2; if (zero) { *loc2 = '\0'; s = rmesc; } match = !fnmatch((str), (s), 0); *loc2 = c; if (match) return loc; loc--; if (quotes) { if (--esc < 0) { esc = esclen(startp, loc); } if (esc % 2) { esc--; loc--; } } } return 0; }
const char *scanright(unsigned long a1, char *a2, char *a3, const char *a4, int a5, int a6) { char v10; int v11; _BOOL4 v12; const char *v13; char *name; v11 = 0; v13 = a4 - 1; while ((unsigned long)v13 >= a1) { v10 = *a3; name = a3; if (a6) { *a3 = 0; name = a2; } v12 = fnmatch(a4, name, 0) == 0; *a3 = v10; if (v12) return v13; --v13; if (a5) { if (--v11 < 0) v11 = esclen(a1, (unsigned long)v13); if ((v11 & 1) != 0) { --v11; --v13; } } --a3; } return 0LL; }
dash-0.5.11+git20210903+057cd650a4ed
ida
static _Bool process_file(FTS *fts, FTSENT *ent) { char const *file_full_name = ent->fts_path; char const *file = ent->fts_accpath; const struct stat *file_stats = ent->fts_statp; _Bool ok = 1; switch (ent->fts_info) { case 1: if (recurse) { if ((root_dev_ino && ((*ent->fts_statp).st_ino == (*root_dev_ino).st_ino && (*ent->fts_statp).st_dev == (*root_dev_ino).st_dev))) { do { if ((strcmp(file_full_name, "/") == 0)) error(0, 0, gettext("it is dangerous to operate recursively on %s"), quotearg_style(shell_escape_always_quoting_style, file_full_name)); else error(0, 0, gettext("it is dangerous to operate recursively on %s (same " "as %s)"), quotearg_n_style(0, shell_escape_always_quoting_style, file_full_name), quotearg_n_style(1, shell_escape_always_quoting_style, "/")); error(0, 0, gettext("use --no-preserve-root to override this failsafe")); } while (0); rpl_fts_set(fts, ent, 4); (__extension__({ __typeof__(rpl_fts_read(fts)) __x = (rpl_fts_read(fts)); (void)__x; })); return 0; } return 1; } break; case 6: if (!recurse) return 1; break; case 10: if (ent->fts_level == 0 && ent->fts_number == 0) { ent->fts_number = 1; rpl_fts_set(fts, ent, 1); return 1; } error(0, ent->fts_errno, gettext("cannot access %s"), quotearg_style(shell_escape_always_quoting_style, file_full_name)); ok = 0; break; case 7: error( 0, ent->fts_errno, "%s", quotearg_n_style_colon(0, shell_escape_quoting_style, file_full_name)); ok = 0; break; case 4: error(0, ent->fts_errno, gettext("cannot read directory %s"), quotearg_style(shell_escape_always_quoting_style, file_full_name)); ok = 0; break; case 2: if (cycle_warning_required(fts, ent)) { do { error(0, 0, gettext("WARNING: Circular directory structure.\nThis almost " "certainly means that you have a corrupted file " "system.\nNOTIFY YOUR SYSTEM MANAGER.\nThe following " "directory is part of the cycle:\n %s\n"), quotearg_n_style_colon(0, shell_escape_quoting_style, file_full_name)); } while (0); return 0; } break; default: break; } if (ent->fts_info == 6 && ok && (root_dev_ino && ((*file_stats).st_ino == (*root_dev_ino).st_ino && (*file_stats).st_dev == (*root_dev_ino).st_dev))) { do { if ((strcmp(file_full_name, "/") == 0)) error( 0, 0, gettext("it is dangerous to operate recursively on %s"), quotearg_style(shell_escape_always_quoting_style, file_full_name)); else error(0, 0, gettext( "it is dangerous to operate recursively on %s (same as %s)"), quotearg_n_style(0, shell_escape_always_quoting_style, file_full_name), quotearg_n_style(1, shell_escape_always_quoting_style, "/")); error(0, 0, gettext("use --no-preserve-root to override this failsafe")); } while (0); ok = 0; } if (ok) { if (verbose) printf(gettext("changing security context of %s\n"), quotearg_style(shell_escape_always_quoting_style, file_full_name)); if (change_file_context(fts->fts_cwd_fd, file) != 0) ok = 0; } if (!recurse) rpl_fts_set(fts, ent, 4); return ok; }
int process_file(unsigned long long a0, struct_0 *a1) { char v0; char *v1; unsigned long long v2; unsigned long long v3[2]; unsigned long v4; unsigned int v6; unsigned long long v7; unsigned long long v8; unsigned long long v9; unsigned long long v10; unsigned long long v11; unsigned long long v12; unsigned long long v13; unsigned long long v14; unsigned long long v15; unsigned long long v16; v1 = a1->field_38; v2 = a1->field_30; v3[0] = &a1->field_70; v0 = 1; switch (a1->field_68) { case 1: if (recurse) { if (*(&root_dev_ino) && a1->field_78 == *(*(&root_dev_ino)) && a1->field_70 == *((*(&root_dev_ino) + 8))) { if (!strcmp(v1, "/")) { v10 = quotearg_style(0x4, v1); error(0x0, 0x0, gettext("it is dangerous to operate recursively on %s")); } else { v11 = quotearg_n_style(0x1, 0x4, "/"); v12 = quotearg_n_style(0x0, 0x4, v1); error( 0x0, 0x0, gettext( "it is dangerous to operate recursively on %s (same as %s)")); } error(0x0, 0x0, gettext("use --no-preserve-root to override this failsafe")); rpl_fts_set(a0, a1, 0x4, a1); v4 = rpl_fts_read(a0); v6 = 0; break; } v6 = 1; break; } case 2: if (cycle_warning_required(a0, a1, a1)) { v9 = quotearg_n_style_colon(0x0, 0x3, v1); error(0x0, 0x0, gettext("WARNING: Circular directory structure.\nThis almost " "certainly means that you have a corrupted file " "system.\nNOTIFY YOUR SYSTEM MANAGER.\nThe following " "directory is part of the cycle:\n %s\n")); v6 = 0; break; } case 4: v7 = quotearg_style(0x4, v1); error(0x0, a1->field_40, gettext("cannot read directory %s")); v0 = 0; goto LABEL_400b1b; case 6: if ((recurse ^ 1)) { v6 = 1; break; } case 7: quotearg_n_style_colon(0x0, 0x3, v1); error(0x0, a1->field_40, "%s"); v0 = 0; goto LABEL_400b1b; case 10: if (!a1->field_58 && !a1->field_20) { a1->field_20 = 1; rpl_fts_set(a0, a1, 0x1, a1); v6 = 1; break; } v8 = quotearg_style(0x4, v1); error(0x0, a1->field_40, gettext("cannot access %s")); v0 = 0; goto LABEL_400b1b; default: goto LABEL_400b1b; } LABEL_400b1b: if (a1->field_68 == 6 && v0 && *(&root_dev_ino) && v3[1] == *(*(&root_dev_ino)) && v3[0] == *((*(&root_dev_ino) + 8))) { if (!strcmp(v1, "/")) { v13 = quotearg_style(0x4, v1); error(0x0, 0x0, gettext("it is dangerous to operate recursively on %s")); } else { v14 = quotearg_n_style(0x1, 0x4, "/"); v15 = quotearg_n_style(0x0, 0x4, v1); error( 0x0, 0x0, gettext("it is dangerous to operate recursively on %s (same as %s)")); } error(0x0, 0x0, gettext("use --no-preserve-root to override this failsafe")); v0 = 0; } if (v0) { if (verbose) { v16 = quotearg_style(0x4, v1); printf(gettext("changing security context of %s\n")); } if (change_file_context(*((a0 + 44)), v2)) v0 = 0; } if ((recurse ^ 1)) rpl_fts_set(a0, a1, 0x4, a1); v6 = v0; return v6; }
coreutils
angr_phoenix
static void print_lineno(void) { if (line_no_overflow) ((!!sizeof(struct { _Static_assert( 1, "verify_expr (" "1" ", " "(error (1, 0, gettext (\"line number overflow\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, 0, gettext("line number overflow")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, 0, gettext("line number overflow")), ((0) ? (void)0 : __builtin_unreachable())))); printf(lineno_format, lineno_width, line_no, separator_str); if (__builtin_add_overflow(line_no, page_incr, &line_no)) line_no_overflow = 1; }
void print_lineno(void) { undefined8 uVar1; if (line_no_overflow != '\0') { uVar1 = gettext("line number overflow"); error(1, 0, uVar1); } printf(lineno_format, (ulong)lineno_width, line_no, separator_str); if (SCARRY8(page_incr, line_no)) { line_no_overflow = '\x01'; } line_no = page_incr + line_no; return; }
coreutils
ghidra
int BZ2_bzCompress(bz_stream *strm, int action) { Bool progress; EState *s; if (strm == ((void *)0)) return (-2); s = strm->state; if (s == ((void *)0)) return (-2); if (s->strm != strm) return (-2); preswitch: switch (s->mode) { case 1: return (-1); case 2: if (action == 0) { progress = handle_compress(strm); return progress ? 1 : (-2); } else if (action == 1) { s->avail_in_expect = strm->avail_in; s->mode = 3; goto preswitch; } else if (action == 2) { s->avail_in_expect = strm->avail_in; s->mode = 4; goto preswitch; } else return (-2); case 3: if (action != 1) return (-1); if (s->avail_in_expect != s->strm->avail_in) return (-1); progress = handle_compress(strm); if (s->avail_in_expect > 0 || !isempty_RL(s) || s->state_out_pos < s->numZ) return 2; s->mode = 2; return 1; case 4: if (action != 2) return (-1); if (s->avail_in_expect != s->strm->avail_in) return (-1); progress = handle_compress(strm); if (!progress) return (-1); if (s->avail_in_expect > 0 || !isempty_RL(s) || s->state_out_pos < s->numZ) return 3; s->mode = 1; return 4; } return 0; }
long BZ2_bzCompress(long a1, int a2) { int v3; _DWORD *v4; if (!a1) return 4294967294LL; v4 = *(_DWORD **)(a1 + 48); if (!v4) return 4294967294LL; if (a1 != *(_QWORD *)v4) return 4294967294LL; while (1) { v3 = v4[2]; if (v3 == 4) break; if (v3 > 4) return 0LL; if (v3 == 3) { if (a2 != 1) return 0xFFFFFFFFLL; if (v4[4] != *(_DWORD *)(*(_QWORD *)v4 + 8LL)) return 0xFFFFFFFFLL; handle_compress(a1); if (v4[4] || !isempty_RL((long)v4) || v4[30] < v4[29]) return 2LL; v4[2] = 2; return 1LL; } if (v3 == 1) return 0xFFFFFFFFLL; if (v3 != 2) return 0LL; switch (a2) { case 0: if (handle_compress(a1)) return 1LL; else return 4294967294LL; case 1: v4[4] = *(_DWORD *)(a1 + 8); v4[2] = 3; break; case 2: v4[4] = *(_DWORD *)(a1 + 8); v4[2] = 4; break; default: return 4294967294LL; } } if (a2 != 2) return 0xFFFFFFFFLL; if (v4[4] != *(_DWORD *)(*(_QWORD *)v4 + 8LL)) return 0xFFFFFFFFLL; if (!handle_compress(a1)) return 0xFFFFFFFFLL; if (v4[4] || !isempty_RL((long)v4) || v4[30] < v4[29]) return 3LL; v4[2] = 1; return 4LL; }
bzip2
ida
static void process_init(void) { struct sshbuf *msg; int r; if ((r = sshbuf_get_u32(iqueue, &version)) != 0) sshfatal("sftp-server.c", __func__, 716, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse"); sshlog("sftp-server.c", __func__, 717, 0, SYSLOG_LEVEL_VERBOSE, ((void *)0), "received client version %u", version); if ((msg = sshbuf_new()) == ((void *)0)) sshfatal("sftp-server.c", __func__, 719, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new failed"); if ((r = sshbuf_put_u8(msg, 2)) != 0 || (r = sshbuf_put_u32(msg, 3)) != 0) sshfatal("sftp-server.c", __func__, 722, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "compose"); compose_extension(msg, "posix-rename@openssh.com", "1"); compose_extension(msg, "statvfs@openssh.com", "2"); compose_extension(msg, "fstatvfs@openssh.com", "2"); compose_extension(msg, "hardlink@openssh.com", "1"); compose_extension(msg, "fsync@openssh.com", "1"); compose_extension(msg, "lsetstat@openssh.com", "1"); compose_extension(msg, "limits@openssh.com", "1"); compose_extension(msg, "expand-path@openssh.com", "1"); compose_extension(msg, "copy-data", "1"); compose_extension(msg, "home-directory", "1"); compose_extension(msg, "users-groups-by-id@openssh.com", "1"); send_msg(msg); sshbuf_free(msg); }
void process_init() { unsigned long long v0; unsigned int v1; unsigned long long v2; unsigned long v3; char v4; unsigned long long v6; unsigned long long v7; v1 = sshbuf_get_u32(0xe87d894820ec8348, &version); if (v1) { v0 = "parse"; sshfatal("sftp-server.c", "process_init", 0x2cc, 0x1, 0x1, ssh_err(v1)); } v3 = version; v2 = "received client version %u"; sshlog("sftp-server.c", "process_init", 0x2cd, 0x0, 0x4, 0x0, *(&v4)); v2 = sshbuf_new(); if (!v2) { v2 = "sshbuf_new failed"; sshfatal("sftp-server.c", "process_init", 0x2cf, 0x1, 0x1, 0x0); } v1 = sshbuf_put_u8(v2, 0x2); if (!v1) v1 = sshbuf_put_u32(v2, 0x3, v6); if (v1 || v1) { v2 = "compose"; sshfatal("sftp-server.c", "process_init", 0x2d2, 0x1, 0x1, ssh_err(v1)); } compose_extension(v2, "posix-rename@openssh.com", "1"); compose_extension(v2, "statvfs@openssh.com", "2"); compose_extension(v2, "fstatvfs@openssh.com", "2"); compose_extension(v2, "hardlink@openssh.com", "1"); compose_extension(v2, "fsync@openssh.com", "1"); compose_extension(v2, "lsetstat@openssh.com", "1"); compose_extension(v2, "limits@openssh.com", "1"); compose_extension(v2, "expand-path@openssh.com", "1"); compose_extension(v2, "copy-data", "1"); compose_extension(v2, "home-directory", "1"); compose_extension(v2, "users-groups-by-id@openssh.com", "1"); send_msg(v2); v7 = sshbuf_free(v2); return; }
openssh-portable
angr_dream
int bindresvport_sa(int sd, struct sockaddr *sa) { int error, af; struct sockaddr_storage myaddr; struct sockaddr_in *in; struct sockaddr_in6 *in6; u_int16_t *portp; u_int16_t port; socklen_t salen; int i; if (sa == ((void *)0)) { memset(&myaddr, 0, sizeof(myaddr)); sa = (struct sockaddr *)&myaddr; salen = sizeof(myaddr); if (getsockname(sd, sa, &salen) == -1) return -1; af = sa->sa_family; memset(&myaddr, 0, salen); } else af = sa->sa_family; if (af == 2) { in = (struct sockaddr_in *)sa; salen = sizeof(struct sockaddr_in); portp = &in->sin_port; } else if (af == 10) { in6 = (struct sockaddr_in6 *)sa; salen = sizeof(struct sockaddr_in6); portp = &in6->sin6_port; } else { (*__errno_location()) = 96; return (-1); } sa->sa_family = af; port = ntohs(*portp); if (port == 0) port = arc4random_uniform(((1024 - 1) - 600 + 1)) + 600; error = -1; for (i = 0; i < ((1024 - 1) - 600 + 1); i++) { *portp = htons(port); error = bind(sd, sa, salen); if (error == 0) break; if ((error < 0) && !(((*__errno_location()) == 98) || ((*__errno_location()) == 22))) break; port++; if (port > (1024 - 1)) port = 600; } return (error); }
long long bindresvport_sa(unsigned long a0, void *a1) { unsigned short *v0; unsigned short v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned int v5; unsigned short *v6; unsigned short *v7; unsigned short *v8; char v9; unsigned long long v11; unsigned long long v12; v0 = a1; if (!v0) { memset(&v9, 0x0, 0x80); v0 = &v9; v2 = 128; v11 = getsockname(a0, v0, &v2); if (v11 == -1) { v12 = 4294967295; } else { v4 = *(v0); memset(&v9, 0x0, v2); } } else { v4 = *(v0); } if (v0 || v11 != -1) { if (v4 == 2) { v8 = v0; v2 = 16; v6 = v8 + 1; } else if (v4 != 10) { *(__errno_location()) = 96; v12 = 4294967295; } if (v4 == 10) { v7 = v0; v2 = 28; v6 = v7 + 1; } if (v4 == 10 || v4 == 2) { *(v0) = v4; v1 = ntohs(*(v6)); if (!v1) { *(&v11) = arc4random_uniform(0x1a8) + 600; v1 = *(&v11); } v3 = -1; for (v5 = 0; v5 <= 423; v5 = __addvsi3(v5, 0x1)) { *(v6) = htons(v1); v3 = bind(a0, v0, v2); if (!v3) break; if (v3) { if (v3 < 0) { *(&v11) = *(__errno_location()); if (v11 != 98) { *(&v11) = *(__errno_location()); if (v11 != 22) break; } } if (v11 == 22) { v1 += 1; if (v1 > 1023) v1 = 600; } } } v12 = v3; } } return v12; }
openssh-portable
angr_dream
static void send_output(const char *buffer, int c, int flag) { const char *cp; char *n; int cnt, d, del; if (c == 0) c = strlen(buffer); if (flag & 0x02) { cnt = c; cp = buffer; while (cnt) { del = 0; for (d = 0; d < cnt; d++) { if (skip_mode && (cp[d] == '\001' || cp[d] == '\002')) { del = 1; break; } } write_all(1, cp, d); if (del) d++; cnt -= d; cp += d; } } if (!(flag & 0x01)) return; if (outfd > 0) write_all(outfd, buffer, c); else { n = realloc(outbuf, outbufsize + c); if (n) { outbuf = n; memcpy(((char *)outbuf) + outbufsize, buffer, c); outbufsize += c; } } }
void send_output(char *param_1, int param_2, uint param_3) { bool bVar1; size_t sVar2; void *pvVar3; int local_34; int local_24; int local_20; char *local_18; local_34 = param_2; if (param_2 == 0) { sVar2 = strlen(param_1); local_34 = (int)sVar2; } if ((param_3 & 2) != 0) { local_18 = param_1; for (local_24 = local_34; local_24 != 0; local_24 = local_24 - local_20) { bVar1 = false; for (local_20 = 0; local_20 < local_24; local_20 = local_20 + 1) { if ((skip_mode != 0) && ((local_18[local_20] == '\x01' || (local_18[local_20] == '\x02')))) { bVar1 = true; break; } } write_all(1, local_18, (long)local_20); if (bVar1) { local_20 = local_20 + 1; } local_18 = local_18 + local_20; } } if ((param_3 & 1) != 0) { if (outfd < 1) { pvVar3 = realloc(outbuf, (long)(local_34 + outbufsize)); if (pvVar3 != (void *)0x0) { outbuf = pvVar3; memcpy((void *)((long)pvVar3 + (long)outbufsize), param_1, (long)local_34); outbufsize = local_34 + outbufsize; } } else { write_all(outfd, param_1, (long)local_34); } } return; }
sysvinit
ghidra
void copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth) { do { if (src->password_authentication != -1) dst->password_authentication = src->password_authentication; } while (0); do { if (src->gss_authentication != -1) dst->gss_authentication = src->gss_authentication; } while (0); do { if (src->pubkey_authentication != -1) dst->pubkey_authentication = src->pubkey_authentication; } while (0); do { if (src->pubkey_auth_options != -1) dst->pubkey_auth_options = src->pubkey_auth_options; } while (0); do { if (src->kerberos_authentication != -1) dst->kerberos_authentication = src->kerberos_authentication; } while (0); do { if (src->hostbased_authentication != -1) dst->hostbased_authentication = src->hostbased_authentication; } while (0); do { if (src->hostbased_uses_name_from_packet_only != -1) dst->hostbased_uses_name_from_packet_only = src->hostbased_uses_name_from_packet_only; } while (0); do { if (src->kbd_interactive_authentication != -1) dst->kbd_interactive_authentication = src->kbd_interactive_authentication; } while (0); do { if (src->permit_root_login != -1) dst->permit_root_login = src->permit_root_login; } while (0); do { if (src->permit_empty_passwd != -1) dst->permit_empty_passwd = src->permit_empty_passwd; } while (0); do { if (src->ignore_rhosts != -1) dst->ignore_rhosts = src->ignore_rhosts; } while (0); do { if (src->allow_tcp_forwarding != -1) dst->allow_tcp_forwarding = src->allow_tcp_forwarding; } while (0); do { if (src->allow_streamlocal_forwarding != -1) dst->allow_streamlocal_forwarding = src->allow_streamlocal_forwarding; } while (0); do { if (src->allow_agent_forwarding != -1) dst->allow_agent_forwarding = src->allow_agent_forwarding; } while (0); do { if (src->disable_forwarding != -1) dst->disable_forwarding = src->disable_forwarding; } while (0); do { if (src->expose_userauth_info != -1) dst->expose_userauth_info = src->expose_userauth_info; } while (0); do { if (src->permit_tun != -1) dst->permit_tun = src->permit_tun; } while (0); do { if (src->fwd_opts.gateway_ports != -1) dst->fwd_opts.gateway_ports = src->fwd_opts.gateway_ports; } while (0); do { if (src->fwd_opts.streamlocal_bind_unlink != -1) dst->fwd_opts.streamlocal_bind_unlink = src->fwd_opts.streamlocal_bind_unlink; } while (0); do { if (src->x11_display_offset != -1) dst->x11_display_offset = src->x11_display_offset; } while (0); do { if (src->x11_forwarding != -1) dst->x11_forwarding = src->x11_forwarding; } while (0); do { if (src->x11_use_localhost != -1) dst->x11_use_localhost = src->x11_use_localhost; } while (0); do { if (src->permit_tty != -1) dst->permit_tty = src->permit_tty; } while (0); do { if (src->permit_user_rc != -1) dst->permit_user_rc = src->permit_user_rc; } while (0); do { if (src->max_sessions != -1) dst->max_sessions = src->max_sessions; } while (0); do { if (src->max_authtries != -1) dst->max_authtries = src->max_authtries; } while (0); do { if (src->client_alive_count_max != -1) dst->client_alive_count_max = src->client_alive_count_max; } while (0); do { if (src->client_alive_interval != -1) dst->client_alive_interval = src->client_alive_interval; } while (0); do { if (src->ip_qos_interactive != -1) dst->ip_qos_interactive = src->ip_qos_interactive; } while (0); do { if (src->ip_qos_bulk != -1) dst->ip_qos_bulk = src->ip_qos_bulk; } while (0); do { if (src->rekey_limit != -1) dst->rekey_limit = src->rekey_limit; } while (0); do { if (src->rekey_interval != -1) dst->rekey_interval = src->rekey_interval; } while (0); do { if (src->log_level != -1) dst->log_level = src->log_level; } while (0); do { if (src->required_rsa_size != -1) dst->required_rsa_size = src->required_rsa_size; } while (0); if (src->fwd_opts.streamlocal_bind_mask != (mode_t)-1) { dst->fwd_opts.streamlocal_bind_mask = src->fwd_opts.streamlocal_bind_mask; } do { do { if (src->banner != ((void *)0) && dst->banner != src->banner) { free(dst->banner); dst->banner = src->banner; } } while (0); do { if (src->trusted_user_ca_keys != ((void *)0) && dst->trusted_user_ca_keys != src->trusted_user_ca_keys) { free(dst->trusted_user_ca_keys); dst->trusted_user_ca_keys = src->trusted_user_ca_keys; } } while (0); do { if (src->revoked_keys_file != ((void *)0) && dst->revoked_keys_file != src->revoked_keys_file) { free(dst->revoked_keys_file); dst->revoked_keys_file = src->revoked_keys_file; } } while (0); do { if (src->authorized_keys_command != ((void *)0) && dst->authorized_keys_command != src->authorized_keys_command) { free(dst->authorized_keys_command); dst->authorized_keys_command = src->authorized_keys_command; } } while (0); do { if (src->authorized_keys_command_user != ((void *)0) && dst->authorized_keys_command_user != src->authorized_keys_command_user) { free(dst->authorized_keys_command_user); dst->authorized_keys_command_user = src->authorized_keys_command_user; } } while (0); do { if (src->authorized_principals_file != ((void *)0) && dst->authorized_principals_file != src->authorized_principals_file) { free(dst->authorized_principals_file); dst->authorized_principals_file = src->authorized_principals_file; } } while (0); do { if (src->authorized_principals_command != ((void *)0) && dst->authorized_principals_command != src->authorized_principals_command) { free(dst->authorized_principals_command); dst->authorized_principals_command = src->authorized_principals_command; } } while (0); do { if (src->authorized_principals_command_user != ((void *)0) && dst->authorized_principals_command_user != src->authorized_principals_command_user) { free(dst->authorized_principals_command_user); dst->authorized_principals_command_user = src->authorized_principals_command_user; } } while (0); do { if (src->hostbased_accepted_algos != ((void *)0) && dst->hostbased_accepted_algos != src->hostbased_accepted_algos) { free(dst->hostbased_accepted_algos); dst->hostbased_accepted_algos = src->hostbased_accepted_algos; } } while (0); do { if (src->pubkey_accepted_algos != ((void *)0) && dst->pubkey_accepted_algos != src->pubkey_accepted_algos) { free(dst->pubkey_accepted_algos); dst->pubkey_accepted_algos = src->pubkey_accepted_algos; } } while (0); do { if (src->ca_sign_algorithms != ((void *)0) && dst->ca_sign_algorithms != src->ca_sign_algorithms) { free(dst->ca_sign_algorithms); dst->ca_sign_algorithms = src->ca_sign_algorithms; } } while (0); do { if (src->routing_domain != ((void *)0) && dst->routing_domain != src->routing_domain) { free(dst->routing_domain); dst->routing_domain = src->routing_domain; } } while (0); do { if (src->permit_user_env_allowlist != ((void *)0) && dst->permit_user_env_allowlist != src->permit_user_env_allowlist) { free(dst->permit_user_env_allowlist); dst->permit_user_env_allowlist = src->permit_user_env_allowlist; } } while (0); do { u_int i; if (src->num_authkeys_files != 0) { for (i = 0; i < dst->num_authkeys_files; i++) free(dst->authorized_keys_files[i]); free(dst->authorized_keys_files); dst->authorized_keys_files = xcalloc( src->num_authkeys_files, sizeof(*dst->authorized_keys_files)); for (i = 0; i < src->num_authkeys_files; i++) dst->authorized_keys_files[i] = xstrdup(src->authorized_keys_files[i]); dst->num_authkeys_files = src->num_authkeys_files; } } while (0); do { u_int i; if (src->num_allow_users != 0) { for (i = 0; i < dst->num_allow_users; i++) free(dst->allow_users[i]); free(dst->allow_users); dst->allow_users = xcalloc(src->num_allow_users, sizeof(*dst->allow_users)); for (i = 0; i < src->num_allow_users; i++) dst->allow_users[i] = xstrdup(src->allow_users[i]); dst->num_allow_users = src->num_allow_users; } } while (0); do { u_int i; if (src->num_deny_users != 0) { for (i = 0; i < dst->num_deny_users; i++) free(dst->deny_users[i]); free(dst->deny_users); dst->deny_users = xcalloc(src->num_deny_users, sizeof(*dst->deny_users)); for (i = 0; i < src->num_deny_users; i++) dst->deny_users[i] = xstrdup(src->deny_users[i]); dst->num_deny_users = src->num_deny_users; } } while (0); do { u_int i; if (src->num_allow_groups != 0) { for (i = 0; i < dst->num_allow_groups; i++) free(dst->allow_groups[i]); free(dst->allow_groups); dst->allow_groups = xcalloc(src->num_allow_groups, sizeof(*dst->allow_groups)); for (i = 0; i < src->num_allow_groups; i++) dst->allow_groups[i] = xstrdup(src->allow_groups[i]); dst->num_allow_groups = src->num_allow_groups; } } while (0); do { u_int i; if (src->num_deny_groups != 0) { for (i = 0; i < dst->num_deny_groups; i++) free(dst->deny_groups[i]); free(dst->deny_groups); dst->deny_groups = xcalloc(src->num_deny_groups, sizeof(*dst->deny_groups)); for (i = 0; i < src->num_deny_groups; i++) dst->deny_groups[i] = xstrdup(src->deny_groups[i]); dst->num_deny_groups = src->num_deny_groups; } } while (0); do { u_int i; if (src->num_accept_env != 0) { for (i = 0; i < dst->num_accept_env; i++) free(dst->accept_env[i]); free(dst->accept_env); dst->accept_env = xcalloc(src->num_accept_env, sizeof(*dst->accept_env)); for (i = 0; i < src->num_accept_env; i++) dst->accept_env[i] = xstrdup(src->accept_env[i]); dst->num_accept_env = src->num_accept_env; } } while (0); do { u_int i; if (src->num_setenv != 0) { for (i = 0; i < dst->num_setenv; i++) free(dst->setenv[i]); free(dst->setenv); dst->setenv = xcalloc(src->num_setenv, sizeof(*dst->setenv)); for (i = 0; i < src->num_setenv; i++) dst->setenv[i] = xstrdup(src->setenv[i]); dst->num_setenv = src->num_setenv; } } while (0); do { u_int i; if (src->num_auth_methods != 0) { for (i = 0; i < dst->num_auth_methods; i++) free(dst->auth_methods[i]); free(dst->auth_methods); dst->auth_methods = xcalloc(src->num_auth_methods, sizeof(*dst->auth_methods)); for (i = 0; i < src->num_auth_methods; i++) dst->auth_methods[i] = xstrdup(src->auth_methods[i]); dst->num_auth_methods = src->num_auth_methods; } } while (0); do { u_int i; if (src->num_permitted_opens != 0) { for (i = 0; i < dst->num_permitted_opens; i++) free(dst->permitted_opens[i]); free(dst->permitted_opens); dst->permitted_opens = xcalloc(src->num_permitted_opens, sizeof(*dst->permitted_opens)); for (i = 0; i < src->num_permitted_opens; i++) dst->permitted_opens[i] = xstrdup(src->permitted_opens[i]); dst->num_permitted_opens = src->num_permitted_opens; } } while (0); do { u_int i; if (src->num_permitted_listens != 0) { for (i = 0; i < dst->num_permitted_listens; i++) free(dst->permitted_listens[i]); free(dst->permitted_listens); dst->permitted_listens = xcalloc(src->num_permitted_listens, sizeof(*dst->permitted_listens)); for (i = 0; i < src->num_permitted_listens; i++) dst->permitted_listens[i] = xstrdup(src->permitted_listens[i]); dst->num_permitted_listens = src->num_permitted_listens; } } while (0); do { u_int i; if (src->num_log_verbose != 0) { for (i = 0; i < dst->num_log_verbose; i++) free(dst->log_verbose[i]); free(dst->log_verbose); dst->log_verbose = xcalloc(src->num_log_verbose, sizeof(*dst->log_verbose)); for (i = 0; i < src->num_log_verbose; i++) dst->log_verbose[i] = xstrdup(src->log_verbose[i]); dst->num_log_verbose = src->num_log_verbose; } } while (0); } while (0); assemble_algorithms(dst); if (preauth) return; do { if (src->adm_forced_command != ((void *)0) && dst->adm_forced_command != src->adm_forced_command) { free(dst->adm_forced_command); dst->adm_forced_command = src->adm_forced_command; } } while (0); if (option_clear_or_none(dst->adm_forced_command)) { free(dst->adm_forced_command); dst->adm_forced_command = ((void *)0); } do { if (src->chroot_directory != ((void *)0) && dst->chroot_directory != src->chroot_directory) { free(dst->chroot_directory); dst->chroot_directory = src->chroot_directory; } } while (0); if (option_clear_or_none(dst->chroot_directory)) { free(dst->chroot_directory); dst->chroot_directory = ((void *)0); } }
void copy_set_server_options(struct_0 *a0, struct_0 *a1, unsigned long a2) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned int v5; unsigned int v6; unsigned int v7; unsigned int v8; unsigned int v9; unsigned int v10; unsigned long long v12; struct_0 *v15; if (a1->field_540 != -1) a0->field_540 = a1->field_540; if (a1->field_534 != -1) a0->field_534 = a1->field_534; if (a1->field_510 != -1) a0->field_510 = a1->field_510; if (a1->field_520 != -1) a0->field_520 = a1->field_520; if (a1->field_524 != -1) a0->field_524 = a1->field_524; if (a1->field_4f0 != -1) a0->field_4f0 = a1->field_4f0; if (a1->field_4f4 != -1) a0->field_4f4 = a1->field_4f4; if (a1->field_544 != -1) a0->field_544 = a1->field_544; if (a1->field_474 != -1) a0->field_474 = a1->field_474; if (a1->field_548 != -1) a0->field_548 = a1->field_548; if (a1->field_478 != -1) a0->field_478 = a1->field_478; if (a1->field_55c != -1) a0->field_55c = a1->field_55c; if (a1->field_560 != -1) a0->field_560 = a1->field_560; if (a1->field_564 != -1) a0->field_564 = a1->field_564; if (a1->field_568 != -1) a0->field_568 = a1->field_568; if (a1->field_1eac != -1) a0->field_1eac = a1->field_1eac; if (a1->field_1e1c != -1) a0->field_1e1c = a1->field_1e1c; if (a1->field_4d0 != -1) a0->field_4d0 = a1->field_4d0; if (a1->field_4d8 != -1) a0->field_4d8 = a1->field_4d8; if (a1->field_48c != -1) a0->field_48c = a1->field_48c; if (a1->field_488 != -1) a0->field_488 = a1->field_488; if (a1->field_490 != -1) a0->field_490 = a1->field_490; if (a1->field_4a0 != -1) a0->field_4a0 = a1->field_4a0; if (a1->field_4a4 != -1) a0->field_4a4 = a1->field_4a4; if (a1->field_1dec != -1) a0->field_1dec = a1->field_1dec; if (a1->field_1de8 != -1) a0->field_1de8 = a1->field_1de8; if (a1->field_1e00 != -1) a0->field_1e00 = a1->field_1e00; if (a1->field_1dfc != -1) a0->field_1dfc = a1->field_1dfc; if (a1->field_4b0 != -1) a0->field_4b0 = a1->field_4b0; if (a1->field_4b4 != -1) a0->field_4b4 = a1->field_4b4; if (a1->field_1e80 != -1) a0->field_1e80 = a1->field_1e80; if (a1->field_1e88 != -1) a0->field_1e88 = a1->field_1e88; if (a1->field_4e0 != -1) a0->field_4e0 = a1->field_4e0; if (a1->field_1ec0 != -1) a0->field_1ec0 = a1->field_1ec0; if (a1->field_4d4 != -1) a0->field_4d4 = a1->field_4d4; if (a1->field_1df0 && a0->field_1df0 != a1->field_1df0) { free(a0->field_1df0); a0->field_1df0 = a1->field_1df0; } if (a1->field_1e50 && a0->field_1e50 != a1->field_1e50) { free(a0->field_1e50); a0->field_1e50 = a1->field_1e50; } if (a1->field_1e48 && a0->field_1e48 != a1->field_1e48) { free(a0->field_1e48); a0->field_1e48 = a1->field_1e48; } if (a1->field_1e58 && a0->field_1e58 != a1->field_1e58) { free(a0->field_1e58); a0->field_1e58 = a1->field_1e58; } if (a1->field_1e60 && a0->field_1e60 != a1->field_1e60) { free(a0->field_1e60); a0->field_1e60 = a1->field_1e60; } if (a1->field_1e68 && a0->field_1e68 != a1->field_1e68) { free(a0->field_1e68); a0->field_1e68 = a1->field_1e68; } if (a1->field_1e70 && a0->field_1e70 != a1->field_1e70) { free(a0->field_1e70); a0->field_1e70 = a1->field_1e70; } if (a1->field_1e78 && a0->field_1e78 != a1->field_1e78) { free(a0->field_1e78); a0->field_1e78 = a1->field_1e78; } if (a1->field_4f8 && a0->field_4f8 != a1->field_4f8) { free(a0->field_4f8); a0->field_4f8 = a1->field_4f8; } if (a1->field_518 && a0->field_518 != a1->field_518) { free(a0->field_518); a0->field_518 = a1->field_518; } if (a1->field_508 && a0->field_508 != a1->field_508) { free(a0->field_508); a0->field_508 = a1->field_508; } if (a1->field_428 && a0->field_428 != a1->field_428) { free(a0->field_428); a0->field_428 = a1->field_428; } if (a1->field_550 && a0->field_550 != a1->field_550) { free(a0->field_550); a0->field_550 = a1->field_550; } if (a1->field_1e04) { for (v0 = 0; v0 < a0->field_1e04; v0 += 1) { free(*((a0->field_1e08 + v0 * 8))); } free(a0->field_1e08); a0->field_1e08 = xcalloc(a1->field_1e04, 0x8); for (v0 = 0; v0 < a1->field_1e04; v0 += 1) { *((a0->field_1e08 + v0 * 8)) = xstrdup(*((a1->field_1e08 + v0 * 8))); } a0->field_1e04 = a1->field_1e04; } if (a1->field_56c) { for (v1 = 0; v1 < a0->field_56c; v1 += 1) { free(*((a0->field_570 + v1 * 8))); } free(a0->field_570); a0->field_570 = xcalloc(a1->field_56c, 0x8); for (v1 = 0; v1 < a1->field_56c; v1 += 1) { *((a0->field_570 + v1 * 8)) = xstrdup(*((a1->field_570 + v1 * 8))); } a0->field_56c = a1->field_56c; } if (a1->field_578) { for (v2 = 0; v2 < a0->field_578; v2 += 1) { free(*((a0->field_580 + v2 * 8))); } free(a0->field_580); a0->field_580 = xcalloc(a1->field_578, 0x8); for (v2 = 0; v2 < a1->field_578; v2 += 1) { *((a0->field_580 + v2 * 8)) = xstrdup(*((a1->field_580 + v2 * 8))); } a0->field_578 = a1->field_578; } if (a1->field_588) { for (v3 = 0; v3 < a0->field_588; v3 += 1) { free(*((a0->field_590 + v3 * 8))); } free(a0->field_590); a0->field_590 = xcalloc(a1->field_588, 0x8); for (v3 = 0; v3 < a1->field_588; v3 += 1) { *((a0->field_590 + v3 * 8)) = xstrdup(*((a1->field_590 + v3 * 8))); } a0->field_588 = a1->field_588; } if (a1->field_598) { for (v4 = 0; v4 < a0->field_598; v4 += 1) { free(*((a0->field_5a0 + v4 * 8))); } free(a0->field_5a0); a0->field_5a0 = xcalloc(a1->field_598, 0x8); for (v4 = 0; v4 < a1->field_598; v4 += 1) { *((a0->field_5a0 + v4 * 8)) = xstrdup(*((a1->field_5a0 + v4 * 8))); } a0->field_598 = a1->field_598; } if (a1->field_1db0) { for (v5 = 0; v5 < a0->field_1db0; v5 += 1) { free(*((a0->field_1db8 + v5 * 8))); } free(a0->field_1db8); a0->field_1db8 = xcalloc(a1->field_1db0, 0x8); for (v5 = 0; v5 < a1->field_1db0; v5 += 1) { *((a0->field_1db8 + v5 * 8)) = xstrdup(*((a1->field_1db8 + v5 * 8))); } a0->field_1db0 = a1->field_1db0; } if (a1->field_1dc0) { for (v6 = 0; v6 < a0->field_1dc0; v6 += 1) { free(*((a0->field_1dc8 + v6 * 8))); } free(a0->field_1dc8); a0->field_1dc8 = xcalloc(a1->field_1dc0, 0x8); for (v6 = 0; v6 < a1->field_1dc0; v6 += 1) { *((a0->field_1dc8 + v6 * 8)) = xstrdup(*((a1->field_1dc8 + v6 * 8))); } a0->field_1dc0 = a1->field_1dc0; } if (a1->field_1e98) { for (v7 = 0; v7 < a0->field_1e98; v7 += 1) { free(*((a0->field_1ea0 + v7 * 8))); } free(a0->field_1ea0); a0->field_1ea0 = xcalloc(a1->field_1e98, 0x8); for (v7 = 0; v7 < a1->field_1e98; v7 += 1) { *((a0->field_1ea0 + v7 * 8)) = xstrdup(*((a1->field_1ea0 + v7 * 8))); } a0->field_1e98 = a1->field_1e98; } if (a1->field_1e28) { for (v8 = 0; v8 < a0->field_1e28; v8 += 1) { free(*((a0->field_1e20 + v8 * 8))); } free(a0->field_1e20); a0->field_1e20 = xcalloc(a1->field_1e28, 0x8); for (v8 = 0; v8 < a1->field_1e28; v8 += 1) { *((a0->field_1e20 + v8 * 8)) = xstrdup(*((a1->field_1e20 + v8 * 8))); } a0->field_1e28 = a1->field_1e28; } if (a1->field_1e38) { for (v9 = 0; v9 < a0->field_1e38; v9 += 1) { free(*((a0->field_1e30 + v9 * 8))); } free(a0->field_1e30); a0->field_1e30 = xcalloc(a1->field_1e38, 0x8); for (v9 = 0; v9 < a1->field_1e38; v9 += 1) { *((a0->field_1e30 + v9 * 8)) = xstrdup(*((a1->field_1e30 + v9 * 8))); } a0->field_1e38 = a1->field_1e38; } if (a1->field_4e4) { for (v10 = 0; v10 < a0->field_4e4; v10 += 1) { free(*((a0->field_4e8 + v10 * 8))); } free(a0->field_4e8); a0->field_4e8 = xcalloc(a1->field_4e4, 0x8); for (v10 = 0; v10 < a1->field_4e4; v10 += 1) { *((a0->field_4e8 + v10 * 8)) = xstrdup(*((a1->field_4e8 + v10 * 8))); } a0->field_4e4 = a1->field_4e4; } v12 = assemble_algorithms(a0); if (!a2) { if (a1->field_1e10 && a0->field_1e10 != a1->field_1e10) { free(a0->field_1e10); a0->field_1e10 = a1->field_1e10; } if (option_clear_or_none(a0->field_1e10)) { free(a0->field_1e10); a0->field_1e10 = 0; } if (a1->field_1e40 && a0->field_1e40 != a1->field_1e40) { free(a0->field_1e40); a0->field_1e40 = a1->field_1e40; } if (option_clear_or_none(a0->field_1e40)) { free(a0->field_1e40); v15 = a0; a0->field_1e40 = 0; } } return; }
openssh-portable
angr_dream
int fifos_pending() { return 0; }
long long fifos_pending() { return 0; }
bash
angr_sailr
void finish_deferred_unlinks(void) { flush_deferred_unlinks(1); while (dunlink_avail) { struct deferred_unlink *next = dunlink_avail->next; free(dunlink_avail); dunlink_avail = next; } }
long long finish_deferred_unlinks() { unsigned long long v0; flush_deferred_unlinks(0x1); for (; dunlink_avail; dunlink_avail = v0) { v0 = *(dunlink_avail); free(dunlink_avail); } return 0; }
tar
angr_dream
void usage(int status) { if (status != 0) do { fprintf(stderr, gettext("Try '%s --help' for more information.\n"), program_name); } while (0); else { printf(gettext("Usage: %s [OPTION]... MODE[,MODE]... FILE...\n or: %s " "[OPTION]... OCTAL-MODE FILE...\n or: %s [OPTION]... " "--reference=RFILE FILE...\n") , program_name, program_name, program_name); fputs_unlocked( gettext("Change the mode of each FILE to MODE.\nWith --reference, " "change the mode of each FILE to that of RFILE.\n\n"), stdout) ; fputs_unlocked( gettext(" -c, --changes like verbose but report only when a " "change is made\n -f, --silent, --quiet suppress most error " "messages\n -v, --verbose output a diagnostic for " "every file processed\n"), stdout) ; fputs_unlocked(gettext(" --no-preserve-root do not treat '/' " "specially (the default)\n --preserve-root " "fail to operate recursively on '/'\n"), stdout) ; fputs_unlocked(gettext(" --reference=RFILE use RFILE's mode instead " "of MODE values\n"), stdout) ; fputs_unlocked(gettext(" -R, --recursive change files and " "directories recursively\n"), stdout) ; fputs_unlocked(gettext(" --help display this help and exit\n"), stdout); fputs_unlocked( gettext(" --version output version information and exit\n"), stdout); fputs_unlocked(gettext("\nEach MODE is of the form " "'[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.\n"), stdout) ; emit_ancillary_info("chmod"); } exit(status); }
void usage(unsigned long a0) { unsigned long v0; unsigned long v1; unsigned long v2; unsigned long v4; unsigned long v5; unsigned long v6; v2 = v4; v1 = v5; v0 = v6; if (a0) { fprintf(stderr, gettext("Try '%s --help' for more information.\n")); } else { printf(gettext("Usage: %s [OPTION]... MODE[,MODE]... FILE...\n or: %s " "[OPTION]... OCTAL-MODE FILE...\n or: %s [OPTION]... " "--reference=RFILE FILE...\n")); fputs_unlocked( gettext("Change the mode of each FILE to MODE.\nWith --reference, " "change the mode of each FILE to that of RFILE.\n\n"), stdout); fputs_unlocked( gettext(" -c, --changes like verbose but report only when a " "change is made\n -f, --silent, --quiet suppress most error " "messages\n -v, --verbose output a diagnostic for " "every file processed\n"), stdout); fputs_unlocked(gettext(" --no-preserve-root do not treat '/' " "specially (the default)\n --preserve-root " "fail to operate recursively on '/'\n"), stdout); fputs_unlocked(gettext(" --reference=RFILE use RFILE's mode instead " "of MODE values\n"), stdout); fputs_unlocked(gettext(" -R, --recursive change files and " "directories recursively\n"), stdout); fputs_unlocked(gettext(" --help display this help and exit\n"), stdout); fputs_unlocked( gettext(" --version output version information and exit\n"), stdout); fputs_unlocked(gettext("\nEach MODE is of the form " "'[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.\n"), stdout); emit_ancillary_info("chmod"); } exit(a0); }
coreutils
angr_sailr
struct builtin *builtin_address_internal(name, disabled_okay) char *name; int disabled_okay; { int hi, lo, mid, j; hi = num_shell_builtins - 1; lo = 0; while (lo <= hi) { mid = (lo + hi) / 2; j = shell_builtins[mid].name[0] - name[0]; if (j == 0) j = strcmp(shell_builtins[mid].name, name); if (j == 0) { if (shell_builtins[mid].function && ((shell_builtins[mid].flags & 0x02) == 0) && ((shell_builtins[mid].flags & 0x01) || disabled_okay)) return (&shell_builtins[mid]); else return ((struct builtin *)((void *)0)); } if (j > 0) hi = mid - 1; else lo = mid + 1; } return ((struct builtin *)((void *)0)); }
char *builtin_address_internal(const char *a1, int a2) { int v3; int v4; int v5; int v6; v3 = num_shell_builtins - 1; v4 = 0; while (1) { if (v4 > v3) return 0LL; v6 = (v4 + v3) / 2; v5 = **((char **)shell_builtins + 6 * v6) - *a1; if (!v5) v5 = strcmp(*((const char **)shell_builtins + 6 * v6), a1); if (!v5) break; if (v5 <= 0) v4 = v6 + 1; else v3 = v6 - 1; } if (*((_QWORD *)shell_builtins + 6 * v6 + 1) && (*((_DWORD *)shell_builtins + 12 * v6 + 4) & 2) == 0 && ((*((_DWORD *)shell_builtins + 12 * v6 + 4) & 1) != 0 || a2)) { return (char *)shell_builtins + 48 * v6; } else { return 0LL; } }
bash
ida
char *de_backslash(string) char *string; { register size_t slen; register int i, j, prev_i; mbstate_t state; memset(&state, '\0', sizeof(mbstate_t)); slen = strlen(string); i = j = 0; while (i < slen) { if (string[i] == '\\' && (string[i + 1] == '`' || string[i + 1] == '\\' || string[i + 1] == '$')) i++; prev_i = i; do { if (locale_mb_cur_max > 1) { mbstate_t state_bak; size_t mblength; int _f; _f = is_basic((string)[i]); if (_f) mblength = 1; else if (locale_utf8locale && (((string)[i] & 0x80) == 0)) mblength = (string)[i] != 0; else { state_bak = state; mblength = mbrlen((string) + (i), (slen) - (i), &state); } if (mblength == (size_t)-2 || mblength == (size_t)-1) { state = state_bak; (i)++; } else if (mblength == 0) (i)++; else (i) += mblength; } else (i)++; } while (0); if (j < prev_i) do string[j++] = string[prev_i++]; while (prev_i < i); else j = i; } string[j] = '\0'; return (string); }
const char *de_backslash(const char *a1) { size_t v1; int v2; int v3; int v4; int v5; const char *v6; int v7; size_t v9; long s; long v11; unsigned long v12; v12 = __readfsqword(0x28u); memset(&s, 0, sizeof(s)); v1 = strlen(a1); v2 = 0; v3 = 0; while (v1 > v3) { if (a1[v3] == 92 && (a1[v3 + 1] == 96 || a1[v3 + 1] == 92 || a1[v3 + 1] == 36)) ++v3; v4 = v3; if (locale_mb_cur_max <= 1) { ++v3; } else { if ((unsigned int)is_basic(a1[v3])) { v9 = 1LL; } else if (locale_utf8locale && a1[v3] >= 0) { v9 = a1[v3] != 0; } else { v11 = s; v9 = mbrlen(&a1[v3], v1 - v3, (mbstate_t *)&s); } if (v9 < 0xFFFFFFFFFFFFFFFELL) { if (v9) v3 += v9; else ++v3; } else { s = v11; ++v3; } } if (v2 >= v4) { v2 = v3; } else { do { v5 = v4++; v6 = &a1[v5]; v7 = v2++; a1[v7] = *v6; } while (v4 < v3); } } a1[v2] = 0; return a1; }
bash
ida
void print_tree(FILE *fp, struct predicate *node, int indent) { int i; if (node == ((void *)0)) return; for (i = 0; i < indent; i++) fprintf(fp, " "); fprintf(fp, "pred=["); print_predicate(fp, node); fprintf(fp, "] type=%s prec=%s", type_name(node->p_type), prec_name(node->p_prec)); fprintf(fp, " cost=%s est_success_rate=%#.4g %sside effects ", cost_name(node->p_cost), node->est_success_rate, (node->side_effects ? "" : "no ")); if (node->need_stat || node->need_type || node->need_inum) { int comma = 0; fprintf(fp, "Needs "); if (node->need_stat) { fprintf(fp, "stat"); comma = 1; } if (node->need_inum) { fprintf(fp, "%sinode", comma ? "," : ""); comma = 1; } if (node->need_type) { fprintf(fp, "%stype", comma ? "," : ""); } } fprintf(fp, "\n"); for (i = 0; i < indent; i++) fprintf(fp, " "); if (((void *)0) == node->pred_left && ((void *)0) == node->pred_right) { fprintf(fp, "no children.\n"); } else { if (node->pred_left) { fprintf(fp, "left:\n"); print_tree(fp, node->pred_left, indent + 1); } else { fprintf(fp, "no left.\n"); } for (i = 0; i < indent; i++) fprintf(fp, " "); if (node->pred_right) { fprintf(fp, "right:\n"); print_tree(fp, node->pred_right, indent + 1); } else { fprintf(fp, "no right.\n"); } } }
void print_tree(void *a0, struct_0 *a1, unsigned long a2) { unsigned long v0; unsigned int v1; unsigned int v2; unsigned int v4; unsigned int v5; unsigned int v6; unsigned long long v7; unsigned long long v8; unsigned long long v9; if (!a1) return; for (v1 = 0; v1 < a2; v1 += 1) { fprintf(a0, " "); } fprintf(a0, "pred=["); print_predicate(a0, a1); fprintf(a0, "] type=%s prec=%s", type_name(a1->field_10), prec_name(a1->field_14)); if (!a1->field_18) v4 = &g_403b0d; else v4 = &g_403b0c; v0 = a1->field_24; fprintf(a0, " cost=%s est_success_rate=%#.4g %sside effects ", cost_name(a1->field_20), v4); if (a1->field_1a || a1->field_1b || a1->field_1c) { v2 = 0; fprintf(a0, "Needs "); if (a1->field_1a) { fprintf(a0, "stat"); v2 = 1; } if (a1->field_1c) { if (!v2) v5 = &g_403b0c; else v5 = ","; fprintf(a0, "%sinode", v5); v2 = 1; } if (a1->field_1b) { if (!v2) v6 = &g_403b0c; else v6 = ","; fprintf(a0, "%stype", v6); } } fprintf(a0, "\n"); for (v1 = 0; v1 < a2; v1 += 1) { fprintf(a0, " "); } if (!a1->field_110 && !a1->field_118) { v7 = fprintf(a0, "no children.\n"); return; } if (!a1->field_110) { fprintf(a0, "no left.\n"); } else { fprintf(a0, "left:\n"); print_tree(a0, a1->field_110, a2 + 1); } for (v1 = 0; v1 < a2; v1 += 1) { fprintf(a0, " "); } if (!a1->field_118) { v8 = fprintf(a0, "no right.\n"); return; } fprintf(a0, "right:\n"); v9 = print_tree(a0, a1->field_118, a2 + 1); return; }
findutils
angr_sailr
static FILE *auth_openfile(const char *file, struct passwd *pw, int strict_modes, int log_missing, char *file_type) { char line[1024]; struct stat st; int fd; FILE *f; if ((fd = open(file, 00 | 04000)) == -1) { if ((*__errno_location()) != 2) { sshlog("auth2-pubkeyfile.c", __func__, 453, 0, SYSLOG_LEVEL_INFO, ((void *)0), "Could not open user '%s' %s '%s': %s", pw->pw_name, file_type, file, strerror((*__errno_location()))); } else if (log_missing) { sshlog("auth2-pubkeyfile.c", __func__, 456, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "Could not open user '%s' %s '%s': %s", pw->pw_name, file_type, file, strerror((*__errno_location()))); } return ((void *)0); } if (fstat(fd, &st) == -1) { close(fd); return ((void *)0); } if (!((((st.st_mode)) & 0170000) == (0100000))) { sshlog("auth2-pubkeyfile.c", __func__, 467, 0, SYSLOG_LEVEL_INFO, ((void *)0), "User '%s' %s '%s' is not a regular file", pw->pw_name, file_type, file); close(fd); return ((void *)0); } unset_nonblock(fd); if ((f = fdopen(fd, "r")) == ((void *)0)) { close(fd); return ((void *)0); } if (strict_modes && safe_path_fd(fileno(f), file, pw, line, sizeof(line)) != 0) { fclose(f); sshlog("auth2-pubkeyfile.c", __func__, 480, 0, SYSLOG_LEVEL_INFO, ((void *)0), "Authentication refused: %s", line); auth_debug_add("Ignored %s: %s", file_type, line); return ((void *)0); } return f; }
void auth_openfile(char *a0, unsigned long long a1, unsigned long a2, unsigned long a3, unsigned long long a4) { unsigned int v0; void *v1; char v2; char v3; char v4; void *v7; void *v8; void *v9; void *v10; unsigned long long v11; void *v12; v0 = open(a0, 0x800, a2); if (v0 == -1) { if (*(__errno_location()) != 2) { strerror(*(__errno_location())); sshlog("auth2-pubkeyfile.c", "auth_openfile", 0x1c5, 0x0, 0x3, 0x0, "Could not open user '%s' %s '%s': %s", *(a1)); } else { if (a3) { strerror(*(__errno_location())); sshlog("auth2-pubkeyfile.c", "auth_openfile", 0x1c8, 0x0, 0x5, 0x0, "Could not open user '%s' %s '%s': %s", *(a1)); } } v9 = 0; return; } else if (fstat(v0, &v2) == -1) { close(v0); v7 = 0; return; } else if ((*(&v3) & 0xf000) != 0x8000) { sshlog("auth2-pubkeyfile.c", "auth_openfile", 0x1d3, 0x0, 0x3, 0x0, "User '%s' %s '%s' is not a regular file", *(a1)); close(v0); v8 = 0; return; } else { unset_nonblock(v0); v1 = fdopen(v0, "r"); if (!v1) { close(v0); v10 = 0; return; } if (a2 && safe_path_fd(fileno(v1), a0, a1, &v4, 0x400)) { fclose(v1); sshlog("auth2-pubkeyfile.c", "auth_openfile", 0x1e0, 0x0, 0x3, 0x0, "Authentication refused: %s", &v4); auth_debug_add("Ignored %s: %s", a4, &v4); v12 = 0; return; } v11 = v1; return; } }
openssh-portable
angr_sailr
static struct timespec now(void) { struct timespec retval; struct timeval tv; time_t t; if (0 == gettimeofday(&tv, ((void *)0))) { retval.tv_sec = tv.tv_sec; retval.tv_nsec = tv.tv_usec * 1000; return retval; } t = time(((void *)0)); ((void)sizeof((t != (time_t)-1) ? 1 : 0), __extension__({ if (t != (time_t)-1) ; else __assert_fail("t != (time_t)-1", "util.c", 978, __extension__ __PRETTY_FUNCTION__); })); retval.tv_sec = t; retval.tv_nsec = 0; return retval; }
int now() { unsigned long v0; unsigned long v1; unsigned long long v2; char v3; char v4; unsigned int v6; if (!gettimeofday(&v3, NULL)) { v1 = *(&v3); v2 = *(&v4) * 1000; v6 = v1; return v6; } v0 = time(NULL); if (v0 != -1) { v1 = v0; v2 = 0; v6 = v1; return v6; } __assert_fail(); }
findutils
angr_sailr
static void signal_setup(_Bool init) { static int const sig[] = { 20, 14, 1, 2, 13, 3, 15, 29, 27, 26, 24, 25, }; enum { nsigs = (sizeof(sig) / sizeof *(sig)) }; int j; if (init) { struct sigaction act; sigemptyset(&caught_signals); for (j = 0; j < nsigs; j++) { sigaction(sig[j], ((void *)0), &act); if (act.__sigaction_handler.sa_handler != ((__sighandler_t)1)) sigaddset(&caught_signals, sig[j]); } act.sa_mask = caught_signals; act.sa_flags = 0x10000000; for (j = 0; j < nsigs; j++) if (sigismember(&caught_signals, sig[j])) { act.__sigaction_handler.sa_handler = sig[j] == 20 ? stophandler : sighandler; sigaction(sig[j], &act, ((void *)0)); } } else { for (j = 0; j < nsigs; j++) if (sigismember(&caught_signals, sig[j])) signal(sig[j], ((__sighandler_t)0)); } }
void signal_setup(unsigned long a0) { unsigned int v0; unsigned long v1; unsigned long v2; unsigned long v3; unsigned long v4; unsigned long v5; unsigned long v6; unsigned long v7; unsigned long v8; unsigned long v9; unsigned long v10; unsigned long v11; unsigned long v12; unsigned long v13; unsigned long v14; unsigned long v15; unsigned long v16; unsigned long v17; unsigned int v18; char v19; unsigned long long *v22; unsigned long long v23; if (a0) { sigemptyset(&caught_signals); for (v0 = 0; v0 <= 11; v0 += 1) { sigaction(sig.9171 [v0], 0x0, &v1); if (*(&v1) != 1) sigaddset(&caught_signals, sig.9171 [v0]); } v2 = *(&caught_signals); v3 = g_40a8c8; v4 = g_40a8d0; v5 = g_40a8d8; v6 = g_40a8e0; v7 = g_40a8e8; v8 = g_40a8f0; v9 = g_40a8f8; v10 = g_40a900; v11 = g_40a908; v12 = g_40a910; v13 = g_40a918; v14 = g_40a920; v15 = g_40a928; v16 = g_40a930; v17 = g_40a938; v18 = 0x10000000; for (v0 = 0; v0 <= 11; v0 += 1) { if (sigismember(&caught_signals, sig.9171 [v0])) { *(&v1) = (sig.9171 [v0] == 20 ? sighandler : stophandler); sigaction(sig.9171 [v0], &v1, 0x0); } } } else { for (v0 = 0; v0 <= 11; v0 += 1) { if (sigismember(&caught_signals, sig.9171 [v0])) signal(sig.9171 [v0], 0x0); } } v23 = *(&v19) ^ v22[5]; return; }
coreutils
angr_sailr
static void print_link_stats(FILE *fp, struct nlmsghdr *n) { struct ifinfomsg *ifi = ((void *)(((char *)n) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))))); struct rtattr *tb[(__IFLA_MAX - 1) + 1]; parse_rtattr( tb, (__IFLA_MAX - 1), ((struct rtattr *)(((char *)(ifi)) + (((sizeof(struct ifinfomsg)) + 4U - 1) & ~(4U - 1)))), n->nlmsg_len - ((sizeof(*ifi)) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))))); __print_link_stats(fp, tb); print_nl(); }
unsigned long print_link_stats(FILE *a1, _DWORD *a2) { char v3[488]; unsigned long v4; v4 = __readfsqword(0x28u); parse_rtattr(v3, 60LL, a2 + 8, (unsigned int)(*a2 - 32)); _print_link_stats(a1, (long)v3); print_nl(a1); return __readfsqword(0x28u) ^ v4; }
iproute2-6.0.0
ida
void popallfiles(void) { unwindfiles(&basepf); }
long long popallfiles() { return unwindfiles(&basebuf); }
dash-0.5.11+git20210903+057cd650a4ed
angr_dream
static SHELL_VAR *bind_assoc_var_internal(entry, hash, key, value, flags) SHELL_VAR *entry; HASH_TABLE *hash; char *key; char *value; int flags; { char *newval; newval = make_array_variable_value(entry, 0, key, value, flags); if (entry->assign_func) (*entry->assign_func)(entry, newval, 0, key); else assoc_insert(hash, key, newval); do { if (newval) sh_xfree((newval), "arrayfunc.c", 215); } while (0); ((entry)->attributes &= ~(0x0001000)); return (entry); }
long bind_assoc_var_internal(long a1, long a2, long a3, long a4, unsigned int a5) { int v5; char *array_variable_value; array_variable_value = make_array_variable_value(a1, 0LL, a3, a4, a5); if (*(_QWORD *)(a1 + 32)) (*(void (**)(long, char *, _QWORD, long))(a1 + 32))( a1, array_variable_value, 0LL, a3); else assoc_insert(a2, a3, array_variable_value); if (array_variable_value) sh_xfree(array_variable_value, "arrayfunc.c", 215LL); v5 = *(_DWORD *)(a1 + 40); BYTE1(v5) &= ~0x10u; *(_DWORD *)(a1 + 40) = v5; return a1; }
bash
ida
static SHELL_VAR *init_funcname_var() { SHELL_VAR *v; v = find_variable("FUNCNAME"); if (v) return v; do { v = make_new_array_variable("FUNCNAME"); v->dynamic_value = get_funcname; v->assign_func = null_array_assign; } while (0); ((v)->attributes |= (0x0001000 | 0x0004000)); return v; }
long init_funcname_var(void) { long lVar1; lVar1 = find_variable("FUNCNAME"); if (lVar1 == 0) { lVar1 = make_new_array_variable("FUNCNAME"); *(code **)(lVar1 + 0x18) = get_funcname; *(code **)(lVar1 + 0x20) = null_array_assign; *(uint *)(lVar1 + 0x28) = *(uint *)(lVar1 + 0x28) | 0x5000; } return lVar1; }
bash
ghidra
static void new_fields(void) { puts(gettext("Enter the new value, or press ENTER for the default")); change_field(loginsh, sizeof loginsh, gettext("Login Shell")); }
void new_fields() { unsigned long long v1; puts(gettext("Enter the new value, or press ENTER for the default")); v1 = change_field(&loginsh, 0x2000, gettext("Login Shell")); return; }
shadow
angr_phoenix
static block_state deflate_fast(s, flush) deflate_state *s; int flush; { IPos hash_head; int bflush; for (;;) { if (s->lookahead < (258 + 3 + 1)) { fill_window(s); if (s->lookahead < (258 + 3 + 1) && flush == 0) { return need_more; } if (s->lookahead == 0) break; } hash_head = 0; if (s->lookahead >= 3) { ((s->ins_h = (((s->ins_h) << s->hash_shift) ^ (s->window[(s->strstart) + (3 - 1)])) & s->hash_mask), hash_head = s->prev[(s->strstart) & s->w_mask] = s->head[s->ins_h], s->head[s->ins_h] = (Pos)(s->strstart)); } if (hash_head != 0 && s->strstart - hash_head <= ((s)->w_size - (258 + 3 + 1))) { s->match_length = longest_match(s, hash_head); } if (s->match_length >= 3) { ; { uch len = (uch)(s->match_length - 3); ush dist = (ush)(s->strstart - s->match_start); s->sym_buf[s->sym_next++] = (uch)dist; s->sym_buf[s->sym_next++] = (uch)(dist >> 8); s->sym_buf[s->sym_next++] = len; dist--; s->dyn_ltree[_length_code[len] + 256 + 1].fc.freq++; s->dyn_dtree[((dist) < 256 ? _dist_code[dist] : _dist_code[256 + ((dist) >> 7)])] .fc.freq++; bflush = (s->sym_next == s->sym_end); }; s->lookahead -= s->match_length; if (s->match_length <= s->max_lazy_match && s->lookahead >= 3) { s->match_length--; do { s->strstart++; ((s->ins_h = (((s->ins_h) << s->hash_shift) ^ (s->window[(s->strstart) + (3 - 1)])) & s->hash_mask), hash_head = s->prev[(s->strstart) & s->w_mask] = s->head[s->ins_h], s->head[s->ins_h] = (Pos)(s->strstart)); } while (--s->match_length != 0); s->strstart++; } else { s->strstart += s->match_length; s->match_length = 0; s->ins_h = s->window[s->strstart]; (s->ins_h = (((s->ins_h) << s->hash_shift) ^ (s->window[s->strstart + 1])) & s->hash_mask); } } else { ; { uch cc = (s->window[s->strstart]); s->sym_buf[s->sym_next++] = 0; s->sym_buf[s->sym_next++] = 0; s->sym_buf[s->sym_next++] = cc; s->dyn_ltree[cc].fc.freq++; bflush = (s->sym_next == s->sym_end); }; s->lookahead--; s->strstart++; } if (bflush) { { _tr_flush_block(s, (s->block_start >= 0L ? (charf *)&s->window[(unsigned)s->block_start] : (charf *)0), (ulg)((long)s->strstart - s->block_start), (0)); s->block_start = s->strstart; flush_pending(s->strm); ; }; if (s->strm->avail_out == 0) return (0) ? finish_started : need_more; }; } s->insert = s->strstart < 3 - 1 ? s->strstart : 3 - 1; if (flush == 4) { { { _tr_flush_block(s, (s->block_start >= 0L ? (charf *)&s->window[(unsigned)s->block_start] : (charf *)0), (ulg)((long)s->strstart - s->block_start), (1)); s->block_start = s->strstart; flush_pending(s->strm); ; }; if (s->strm->avail_out == 0) return (1) ? finish_started : need_more; }; return finish_done; } if (s->sym_next) { { _tr_flush_block(s, (s->block_start >= 0L ? (charf *)&s->window[(unsigned)s->block_start] : (charf *)0), (ulg)((long)s->strstart - s->block_start), (0)); s->block_start = s->strstart; flush_pending(s->strm); ; }; if (s->strm->avail_out == 0) return (0) ? finish_started : need_more; }; return block_done; }
long long deflate_fast(struct_0 *a0, unsigned long long a1) { unsigned long long v0; int tmp_54; int tmp_99; int tmp_105; int tmp_126; int tmp_132; int tmp_159; int tmp_131; int tmp_137; int tmp_183; int tmp_189; int tmp_220; int tmp_59; struct_4 *v1; char v2; char v3; unsigned short v4; unsigned int v5; unsigned int v6; char *v9; unsigned long long v10; unsigned long long v11; unsigned long long v12; unsigned long long v13; unsigned long long v14; unsigned long long v15; v1 = &a0->field_0; *(&v0) = a1; do { do { if (a0->field_b4 <= 261) { fill_window(a0); if (a0->field_b4 <= 261 && !v0) { v13 = 0; return v13; } if (!a0->field_b4) { *(&v11) = (a0->field_ac <= 2 ? 2 : a0->field_ac); a0->field_172c = v11; if (v0 == 4) { _tr_flush_block(a0); v14 = a0->field_ac; a0->field_98 = a0->field_ac; flush_pending(a0->field_0, v0, v14, v12); v13 = (!a0->field_0->field_20 ? 3 : 2); return v13; } else if (a0->field_170c) { _tr_flush_block(a0); v15 = a0->field_ac; a0->field_98 = a0->field_ac; flush_pending(a0->field_0, v0, v15, v12); if (a0->field_0->field_20) { v13 = 1; return v13; } v13 = 0; return v13; } else { v13 = 1; return v13; } } } v5 = 0; if (a0->field_b4 > 2) { a0->field_80 = ((a0->field_80 << (a0->field_90 & 31)) ^ *((a0->field_ac + 2 + a0->field_60))) & a0->field_8c; tmp_54 = (a0->field_58 & a0->field_ac) * 2 + a0->field_70; *(((a0->field_58 & a0->field_ac) * 2 + a0->field_70)) = *((a0->field_78 + a0->field_80 * 2)); v5 = *(tmp_54); *((a0->field_80 * 2 + a0->field_78)) = a0->field_ac; } if (v5 && a0->field_ac - v5 <= a0->field_50 - 262) a0->field_a0 = longest_match(a0, v5); if (a0->field_a0 <= 2) { v2 = *((a0->field_ac + a0->field_60)); tmp_99 = a0->field_1700; tmp_105 = a0->field_170c; a0->field_170c = a0->field_170c + 1; *((tmp_105 + tmp_99)) = 0; tmp_126 = a0->field_1700; tmp_132 = a0->field_170c; a0->field_170c = a0->field_170c + 1; *((tmp_132 + tmp_126)) = 0; v9 = a0->field_1700; tmp_159 = a0->field_170c; a0->field_170c = a0->field_170c + 1; v9[tmp_159] = v2; *(&a0->padding_c4[16 + 4 * v2]) = *(&a0->padding_c4[16 + 4 * v2]) + 1; v6 = a0->field_170c == a0->field_1710; a0->field_b4 = a0->field_b4 - 1; a0->field_ac = a0->field_ac + 1; } else { v3 = a0->field_a0 - 3; v4 = a0->field_ac - a0->field_b0; tmp_131 = a0->field_1700; tmp_137 = a0->field_170c; a0->field_170c = a0->field_170c + 1; *((tmp_137 + tmp_131)) = v4; tmp_183 = a0->field_1700; tmp_189 = a0->field_170c; a0->field_170c = a0->field_170c + 1; *((tmp_189 + tmp_183)) = v4 >> 8; v9 = a0->field_1700; tmp_220 = a0->field_170c; a0->field_170c = a0->field_170c + 1; v9[tmp_220] = v3; v4 -= 1; *(&a0->padding_c4[1044 + 4 * *(v3 + &_length_code)]) = *(&a0->padding_c4[1044 + 4 * *(v3 + &_length_code)]) + 1; v10 = (v4 <= 255 ? *(((v4 >> 7) + 5243232)) : *(v4 + &_dist_code)); *(&a0->padding_c4[2308 + 4 * v10]) = *(&a0->padding_c4[2308 + 4 * v10]) + 1; v6 = a0->field_170c == a0->field_1710; a0->field_b4 = a0->field_b4 - a0->field_a0; if (a0->field_a0 > a0->field_c0 || a0->field_b4 <= 2) { a0->field_ac = a0->field_ac + a0->field_a0; a0->field_a0 = 0; a0->field_80 = *((a0->field_ac + a0->field_60)); a0->field_80 = ((a0->field_80 << (a0->field_90 & 31)) ^ *((a0->field_ac + 1 + a0->field_60))) & a0->field_8c; } else { a0->field_a0 = a0->field_a0 - 1; do { a0->field_ac = a0->field_ac + 1; a0->field_80 = ((a0->field_80 << (a0->field_90 & 31)) ^ *((a0->field_ac + 2 + a0->field_60))) & a0->field_8c; tmp_59 = (a0->field_58 & a0->field_ac) * 2 + a0->field_70; *(((a0->field_58 & a0->field_ac) * 2 + a0->field_70)) = *((a0->field_78 + a0->field_80 * 2)); *(&v10) = *(tmp_59); v5 = v10; *((a0->field_80 * 2 + a0->field_78)) = a0->field_ac; a0->field_a0 = a0->field_a0 - 1; } while (a0->field_a0); a0->field_ac = a0->field_ac + 1; } } } while (!v6); _tr_flush_block(a0); v11 = a0->field_ac; a0->field_98 = a0->field_ac; flush_pending(a0->field_0, v9, v11, v12); } while (a0->field_0->field_20); v13 = 0; return v13; }
zlib
angr_sailr
static int yylex(union YYSTYPE *lvalp, parser_control *pc) { unsigned char c; for (;;) { while (c = *pc->input, c_isspace(c)) pc->input++; if (c_isdigit(c) || c == '-' || c == '+') { char const *p = pc->input; int sign; if (c == '-' || c == '+') { sign = c == '-' ? -1 : 1; while (c = *(pc->input = ++p), c_isspace(c)) continue; if (!c_isdigit(c)) continue; } else sign = 0; time_t value = 0; do { if (__builtin_mul_overflow(value, 10, &value)) return '?'; if (__builtin_add_overflow(value, sign < 0 ? '0' - c : c - '0', &value)) return '?'; c = *++p; } while (c_isdigit(c)); if ((c == '.' || c == ',') && c_isdigit(p[1])) { time_t s = value; int digits; p++; int ns = *p++ - '0'; for (digits = 2; digits <= LOG10_BILLION; digits++) { ns *= 10; if (c_isdigit(*p)) ns += *p++ - '0'; } if (sign < 0) for (; c_isdigit(*p); p++) if (*p != '0') { ns++; break; } while (c_isdigit(*p)) p++; if (sign < 0 && ns) { if (__builtin_sub_overflow(s, 1, &s)) return '?'; ns = BILLION - ns; } lvalp->timespec.tv_sec = s; lvalp->timespec.tv_nsec = ns; pc->input = p; return sign ? tSDECIMAL_NUMBER : tUDECIMAL_NUMBER; } else { lvalp->textintval.negative = sign < 0; lvalp->textintval.value = value; lvalp->textintval.digits = p - pc->input; pc->input = p; return sign ? tSNUMBER : tUNUMBER; } } if (c_isalpha(c)) { char buff[20]; char *p = buff; table const *tp; do { if (p < buff + sizeof buff - 1) *p++ = c; c = *++pc->input; } while (c_isalpha(c) || c == '.'); *p = '\0'; tp = lookup_word(pc, buff); if (!tp) { if (debugging(pc)) dbg_printf(gettext("error: unknown word '%s'\n"), buff); return '?'; } lvalp->intval = tp->value; return tp->type; } if (c != '(') return to_uchar(*pc->input++); idx_t count = 0; do { c = *pc->input++; if (c == '\0') return c; if (c == '(') count++; else if (c == ')') count--; } while (count != 0); } }
long yylex(unsigned long *a1, unsigned char **a2) { int v2; bool v3; int v5; bool v6; char *v7; unsigned char *v8; char *v9; char *v10; long v11; long v12; long v13; unsigned char *v14; unsigned char *v15; unsigned char v16; unsigned char v17; int v18; int i; int v20; unsigned long v21; long v22; unsigned long v23; unsigned char *v24; unsigned char *v25; char *v26; long v27; const char **v28; char v29[19]; _BYTE v30[13]; *(_QWORD *)&v30[5] = __readfsqword(0x28u); while (1) { LABEL_3: while (1) { v16 = **a2; if (!(unsigned char)c_isspace(v16)) break; ++*a2; } if (!(unsigned char)c_isdigit(v16) && v16 != 45 && v16 != 43) { if ((unsigned char)c_isalpha(v16)) { v26 = v29; do { if (v26 < v30) { v9 = v26++; *v9 = v16; } v16 = *++*a2; } while ((unsigned char)c_isalpha(v16) || v16 == 46); *v26 = 0; v28 = lookup_word((long)a2, v29); if (v28) { *a1 = *((int *)v28 + 3); return *((unsigned int *)v28 + 2); } else { if ((unsigned char)debugging()) { v10 = gettext("error: unknown word '%s'\n"); dbg_printf(v10, (long)v29, (long)v10, v11, v12, v13); } return 63LL; } } else if (v16 == 40) { v27 = 0LL; while (1) { v15 = (*a2)++; v17 = *v15; if (!*v15) return 0LL; if (v17 == 40) { ++v27; } else if (v17 == 41) { --v27; } if (!v27) goto LABEL_3; } } else { v14 = (*a2)++; return (unsigned char)to_uchar(*v14); } } v24 = *a2; if (v16 != 45 && v16 != 43) break; if (v16 == 45) v2 = -1; else v2 = 1; v18 = v2; do { *a2 = ++v24; v16 = **a2; } while ((unsigned char)c_isspace(v16)); if ((unsigned char)c_isdigit(v16) == 1) goto LABEL_17; } v18 = 0; LABEL_17: v21 = 0LL; do { v3 = !is_mul_ok(0xAuLL, v21); v22 = 10 * v21; if (v3) return 63LL; if (v18 >= 0) v5 = v16 - 48; else v5 = 48 - v16; v6 = __OFADD__(v22, v5); v21 = v22 + v5; if (v6) return 63LL; v16 = *++v24; } while ((unsigned char)c_isdigit(*v24)); if ((v16 == 46 || v16 == 44) && (unsigned char)c_isdigit((unsigned int)(char)v24[1])) { v23 = v21; v7 = (char *)(v24 + 1); v25 = v24 + 2; v20 = *v7 - 48; for (i = 2; i <= 9; ++i) { v20 *= 10; if ((unsigned char)c_isdigit((unsigned int)(char)*v25)) { v8 = v25++; v20 += (char)*v8 - 48; } } if (v18 < 0) { while ((unsigned char)c_isdigit((unsigned int)(char)*v25)) { if (*v25 != 48) { ++v20; break; } ++v25; } } while ((unsigned char)c_isdigit((unsigned int)(char)*v25)) ++v25; if (v18 < 0 && v20) { v23 = v21 - 1; if (__OFSUB__(v21, 1LL)) return 63LL; v20 = 1000000000 - v20; } *a1 = v23; a1[1] = v20; *a2 = v25; if (v18) return 276LL; else return 277LL; } else { *(_BYTE *)a1 = v18 < 0; a1[1] = v21; a1[2] = v24 - *a2; *a2 = v24; if (v18) return 274LL; else return 275LL; } }
gnutls
ida
static void set_filter(const struct cmdinfo *cip, const char *value) { filter_add(value, cip->arg_int); }
long set_filter(long a1, long a2) { return filter_add(a2, *(_DWORD *)(a1 + 40) != 0); }
dpkg
ida
static struct passwd *getrootpwent(int try_manually) { static struct passwd pwd; struct passwd *pw; struct spwd *spw; FILE *fp; static char line[256]; static char sline[256]; char *p; if ((pw = getpwnam("root")) && !strcmp(pw->pw_passwd, "x") && (spw = getspnam("root"))) pw->pw_passwd = spw->sp_pwdp; if (pw || !try_manually) return pw; pwd.pw_name = "root"; pwd.pw_passwd = ""; pwd.pw_gecos = "Super User"; pwd.pw_dir = "/"; pwd.pw_shell = ""; pwd.pw_uid = 0; pwd.pw_gid = 0; if ((fp = fopen("/etc/passwd", "r")) == ((void *)0)) { perror("/etc/passwd"); return &pwd; } while ((p = fgets(line, 256, fp)) != ((void *)0)) { if (strncmp(line, "root:", 5) != 0) continue; p += 5; set(&pwd.pw_passwd, strsep(&p, ":")); (void)strsep(&p, ":"); (void)strsep(&p, ":"); set(&pwd.pw_gecos, strsep(&p, ":")); set(&pwd.pw_dir, strsep(&p, ":")); set(&pwd.pw_shell, strsep(&p, "\n")); p = line; break; } fclose(fp); if (p == ((void *)0)) { fprintf(stderr, "sulogin: %s: no entry for root\n\r", "/etc/passwd"); return &pwd; } if (valid(pwd.pw_passwd)) return &pwd; strcpy(pwd.pw_passwd, ""); if ((fp = fopen("/etc/shadow", "r")) == ((void *)0)) { fprintf(stderr, "sulogin: %s: root password garbled\n\r", "/etc/passwd"); return &pwd; } while ((p = fgets(sline, 256, fp)) != ((void *)0)) { if (strncmp(sline, "root:", 5) != 0) continue; p += 5; set(&pwd.pw_passwd, strsep(&p, ":")); break; } fclose(fp); if (p == ((void *)0)) { fprintf(stderr, "sulogin: %s: no entry for root\n\r", "/etc/shadow"); strcpy(pwd.pw_passwd, ""); } if (!valid(pwd.pw_passwd)) { fprintf(stderr, "sulogin: %s: root password garbled\n\r", "/etc/shadow"); strcpy(pwd.pw_passwd, ""); } return &pwd; }
int getrootpwent(unsigned long a0) { unsigned long v0; struct_0 *v1; struct_0 *v2; void *v3; unsigned int v5; v1 = &getpwnam("root")->pw_name; if (v1 && !strcmp(v1->field_8, "x")) { v2 = getspnam("root"); if (v2) v1->field_8 = v2->field_8; } if (v1) { LABEL_400863: v5 = v1; } else { if (!a0) goto LABEL_400863; pwd.4705 = "root"; g_402188 = &g_402496; g_402198 = "Super User"; g_4021a0 = "/"; g_4021a8 = &g_402496; g_402190 = 0; g_402194 = 0; v3 = fopen("/etc/passwd", "r"); if (!v3) { perror("/etc/passwd"); v5 = &pwd.4705; } else { do { v0 = fgets(&line.4709, 0x100, v3); if (!v0) goto LABEL_400a20; } while (strncmp(&line.4709, "root:", 0x5)); v0 += 5; set(&g_402188, strsep(&v0, ":")); strsep(&v0, ":"); strsep(&v0, ":"); set(&g_402198, strsep(&v0, ":")); set(&g_4021a0, strsep(&v0, ":")); set(&g_4021a8, strsep(&v0, "\n")); v0 = &line.4709; LABEL_400a20: fclose(v3); if (!v0) { fprintf(*(&stderr), "sulogin: %s: no entry for root\n\r", &g_4024a6); v5 = &pwd.4705; } else if (valid(g_402188)) { v5 = &pwd.4705; } else { strcpy(g_402188, &g_402496); v3 = fopen("/etc/shadow", "r"); if (!v3) { fprintf(*(&stderr), "sulogin: %s: root password garbled\n\r", &g_4024a6); v5 = &pwd.4705; } else { do { v0 = fgets(&sline.4710, 0x100, v3); if (!v0) goto LABEL_400b61; } while (strncmp(&sline.4710, "root:", 0x5)); v0 += 5; set(&g_402188, strsep(&v0, ":")); LABEL_400b61: fclose(v3); if (!v0) { fprintf(*(&stderr), "sulogin: %s: no entry for root\n\r", &g_4024e1); strcpy(g_402188, &g_402496); } if (!valid(g_402188)) { fprintf(*(&stderr), "sulogin: %s: root password garbled\n\r", &g_4024e1); strcpy(g_402188, &g_402496); } v5 = &pwd.4705; } } } } return v5; }
sysvinit
angr_phoenix
int ssh_krl_revoke_key_sha1(struct ssh_krl *krl, const u_char *p, size_t len) { sshlog("krl.c", __func__, 436, 1, SYSLOG_LEVEL_DEBUG3, ((void *)0), "revoke by sha1"); if (len != 20) return -4; return revoke_by_hash(&krl->revoked_sha1s, p, len); }
long ssh_krl_revoke_key_sha1(long a1, const void *a2, long a3) { sshlog("krl.c", "ssh_krl_revoke_key_sha1", 436LL, 1LL, 7LL, 0LL, "revoke by sha1"); if (a3 == 20) return revoke_by_hash((long *)(a1 + 40), a2, (char *)&loc_10 + 4); else return 4294967292LL; }
openssh-portable
ida
static Channel *server_request_direct_streamlocal(struct ssh *ssh) { Channel *c = ((void *)0); char *target = ((void *)0), *originator = ((void *)0); u_int originator_port = 0; struct passwd *pw = the_authctxt->pw; int r; if (pw == ((void *)0) || !the_authctxt->valid) sshfatal("serverloop.c", __func__, 486, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "no/invalid user"); if ((r = sshpkt_get_cstring(ssh, &target, ((void *)0))) != 0 || (r = sshpkt_get_cstring(ssh, &originator, ((void *)0))) != 0 || (r = sshpkt_get_u32(ssh, &originator_port)) != 0 || (r = sshpkt_get_end(ssh)) != 0) sshpkt_fatal(ssh, r, "%s: parse packet", __func__); if (originator_port > 0xFFFF) { sshlog("serverloop.c", __func__, 494, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "invalid originator port"); goto out; } sshlog("serverloop.c", __func__, 498, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0), "originator %s port %d, target %s", originator, originator_port, target); if ((options.allow_streamlocal_forwarding & (1 << 1)) != 0 && auth_opts->permit_port_forwarding_flag && !options.disable_forwarding && (pw->pw_uid == 0 || use_privsep)) { c = channel_connect_to_path(ssh, target, "direct-streamlocal@openssh.com", "direct-streamlocal"); } else { sshlog("serverloop.c", __func__, 508, 0, SYSLOG_LEVEL_INFO, ((void *)0), "refused streamlocal port forward: " "originator %s port %d, target %s", originator, originator_port, target) ; } out: free(originator); free(target); return c; }
int server_request_direct_streamlocal(unsigned long long a0) { unsigned long long v0; unsigned int v1; unsigned int v2; void *v3; void *v4; unsigned long long v5; void *v6; unsigned long long v7; void *v8; char v9; v5 = 0; v3 = 0; v4 = 0; v1 = 0; v6 = *((the_authctxt + 48)); if (v6 && !(!*((the_authctxt + 12)))) goto LABEL_4011ee; v0 = "no/invalid user"; sshfatal("serverloop.c", "server_request_direct_streamlocal", 0x1e6, 0x1, 0x1, 0x0); LABEL_4011ee: v2 = sshpkt_get_cstring(a0, &v3, 0x0, &v3); if (!v2) { v2 = sshpkt_get_cstring(a0, &v4, 0x0, &v4); if (!v2) { v2 = sshpkt_get_u32(a0, &v1, &v1); if (!v2) { v2 = sshpkt_get_end(a0); if (!v2) goto LABEL_401283; } } } sshpkt_fatal(a0, v2, "%s: parse packet", "server_request_direct_streamlocal"); LABEL_401283: if (v1 > 65535) { v7 = "invalid originator port"; sshlog("serverloop.c", "server_request_direct_streamlocal", 0x1ee, 0x1, 0x2, 0x0, *(&v9)); } else { v8 = v3; v7 = v1; v6 = v4; v5 = "originator %s port %d, target %s"; sshlog("serverloop.c", "server_request_direct_streamlocal", 0x1f2, 0x1, 0x5, 0x0, *(&v9)); if ((*(5244264) & 2) && *(auth_opts) && !*(5244272)) { if (!v6[16]) { LABEL_401351: v5 = channel_connect_to_path(a0, v3, "direct-streamlocal@openssh.com", "direct-streamlocal"); goto LABEL_4013bd; } else if (!(!use_privsep)) { goto LABEL_401351; } } v8 = v3; v7 = v1; v6 = v4; v5 = "refused streamlocal port forward: originator %s port %d, target %s"; sshlog("serverloop.c", "server_request_direct_streamlocal", 0x1fc, 0x0, 0x3, 0x0, *(&v9)); } LABEL_4013bd: free(v4); free(v3); return v5; }
openssh-portable
angr_phoenix
int do_multiaddr(int argc, char **argv) { if (argc < 1) return multiaddr_list(0, ((void *)0)); if (matches(*argv, "add") == 0) return multiaddr_modify(RTM_NEWADDR, argc - 1, argv + 1); if (matches(*argv, "delete") == 0) return multiaddr_modify(RTM_DELADDR, argc - 1, argv + 1); if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0 || matches(*argv, "lst") == 0) return multiaddr_list(argc - 1, argv + 1); if (matches(*argv, "help") == 0) usage(); fprintf(stderr, "Command \"%s\" is unknown, try \"ip maddr help\".\n", *argv); exit(-1); }
long do_multiaddr(int a1, char **a2) { if (a1 <= 0) return multiaddr_list(0, 0LL); if ((unsigned char)matches(*a2, "add") != 1) multiaddr_modify(20, a1 - 1, (const char **)a2 + 1); if ((unsigned char)matches(*a2, "delete") != 1) multiaddr_modify(21, a1 - 1, (const char **)a2 + 1); if ((unsigned char)matches(*a2, "list") == 1 && (unsigned char)matches(*a2, "show") == 1 && (unsigned char)matches(*a2, "lst") == 1) { if ((unsigned char)matches(*a2, "help") != 1) usage(); fprintf(stderr, "Command \"%s\" is unknown, try \"ip maddr help\".\n", *a2); exit(-1); } return multiaddr_list(a1 - 1, a2 + 1); }
iproute2-6.0.0
ida
static int command_do(struct kmod_module *module, const char *type, const char *command, const char *cmdline_opts) { const char *modname = kmod_module_get_name(module); char *p, *cmd = ((void *)0); size_t cmdlen, cmdline_opts_len, varlen; int ret = 0; if (cmdline_opts == ((void *)0)) cmdline_opts = ""; cmdline_opts_len = strlen(cmdline_opts); cmd = strdup(command); if (cmd == ((void *)0)) return -12; cmdlen = strlen(cmd); varlen = sizeof("$CMDLINE_OPTS") - 1; while ((p = strstr(cmd, "$CMDLINE_OPTS")) != ((void *)0)) { size_t prefixlen = p - cmd; size_t suffixlen = cmdlen - prefixlen - varlen; size_t slen = cmdlen - varlen + cmdline_opts_len; char *suffix = p + varlen; char *s = malloc(slen + 1); if (s == ((void *)0)) { free(cmd); return -12; } memcpy(s, cmd, p - cmd); memcpy(s + prefixlen, cmdline_opts, cmdline_opts_len); memcpy(s + prefixlen + cmdline_opts_len, suffix, suffixlen); s[slen] = '\0'; free(cmd); cmd = s; cmdlen = slen; } _show("%s %s\n", type, cmd); if (dry_run) goto end; setenv("MODPROBE_MODULE", modname, 1); ret = system(cmd); unsetenv("MODPROBE_MODULE"); if (ret == -1 || (((ret) & 0xff00) >> 8)) { log_printf(log_priority, "Error running %s command for %s\n", type, modname); if (ret != -1) ret = -(((ret) & 0xff00) >> 8); } end: free(cmd); return ret; }
int command_do(unsigned long long a0, unsigned long long a1, char *a2, void *a3) { unsigned long long v0; unsigned int v1; char *v2; char *v3; char *v4; unsigned int v5; unsigned long long v6; unsigned long v7; unsigned long v8; unsigned int v9; char *v10; void *v11; char *v12; unsigned int v14; v0 = a3; v4 = kmod_module_get_name(a0); v2 = 0; v1 = 0; if (!v0) v0 = &g_400bf1; *(&v5) = strlen(v0); v2 = strdup(a2); if (!v2) { v14 = -12; } else { v3 = strlen(v2); v6 = 13; while (true) { v7 = strstr(v2, "$CMDLINE_OPTS"); if (!v7) break; v8 = v7 + -0x1 * v2; *(&v9) = &v3[-1 * v8 + -1 * v6]; v10 = &v3[-1 * v6 + *(&v5)]; v11 = v6 + v7; v12 = malloc(v10 + 1); if (v12) { memcpy(v12, v2, v7 + -0x1 * v2); memcpy(&v12[v8], v0, *(&v5)); memcpy(&v12[*(&v5) + v8], v11, *(&v9)); *((v10 + v12)) = 0; free(v2); v2 = v12; v3 = v10; } else { free(v2); v14 = -12; goto LABEL_401c25; } } _show(); if (dry_run) { LABEL_401c16: free(v2); v14 = v1; goto LABEL_401c25; } setenv("MODPROBE_MODULE", v4, 0x1); v1 = system(v2); unsetenv("MODPROBE_MODULE"); if (v1 != -1 && !(v1 >> 8)) goto LABEL_401c15; log_printf(log_priority, "Error running %s command for %s\n", a1); if (v1 != -1) { v1 = -((v1 >> 8)); goto LABEL_401c16; } LABEL_401c15: goto LABEL_401c16; } LABEL_401c25: return v14; }
kmod
angr_phoenix
static void enforce_one_top_level(char **pfile_name) { char *file_name = *pfile_name; char *p; for (p = file_name; *p && (((*p) == '/') || *p == '.'); p++) ; if (*p) { int pos = strlen(one_top_level_dir); if (strncmp(p, one_top_level_dir, pos) == 0) { if (((p[pos]) == '/') || p[pos] == 0) return; } *pfile_name = make_file_name(one_top_level_dir, file_name); normalize_filename_x(*pfile_name); } else *pfile_name = xstrdup(one_top_level_dir); free(file_name); }
void enforce_one_top_level(char **param_1) { char *__ptr; int iVar1; int iVar2; size_t sVar3; char *pcVar4; char *local_18; __ptr = *param_1; for (local_18 = __ptr; (*local_18 != '\0' && ((*local_18 == '/' || (*local_18 == '.')))); local_18 = local_18 + 1) { } if (*local_18 == '\0') { pcVar4 = (char *)xstrdup(one_top_level_dir); *param_1 = pcVar4; } else { sVar3 = strlen(one_top_level_dir); iVar1 = (int)sVar3; iVar2 = strncmp(local_18, one_top_level_dir, (long)iVar1); if (iVar2 == 0) { if (local_18[iVar1] == '/') { return; } if (local_18[iVar1] == '\0') { return; } } pcVar4 = (char *)make_file_name(one_top_level_dir, __ptr); *param_1 = pcVar4; normalize_filename_x(*param_1); } free(__ptr); return; }
tar
ghidra
void strlist_walk(sl, func) STRINGLIST *sl; sh_strlist_map_func_t *func; { register int i; if (sl == 0) return; for (i = 0; i < sl->list_len; i++) if ((*func)(sl->list[i]) < 0) break; }
void strlist_walk(long a1, int (*a2)(_QWORD)) { int i; if (a1) { for (i = 0; i < *(_DWORD *)(a1 + 12) && a2(*(_QWORD *)(8LL * i + *(_QWORD *)a1)) >= 0; ++i) ; } }
bash
ida
static _Bool pipe_lines(char const *pretty_filename, int fd, uintmax_t n_lines, uintmax_t *read_pos) { struct linebuffer { char buffer[8192]; size_t nbytes; size_t nlines; struct linebuffer *next; }; typedef struct linebuffer LBUFFER; LBUFFER *first, *last, *tmp; size_t total_lines = 0; _Bool ok = 1; size_t n_read; first = last = xmalloc(sizeof(LBUFFER)); first->nbytes = first->nlines = 0; first->next = ((void *)0); tmp = xmalloc(sizeof(LBUFFER)); while (1) { n_read = safe_read(fd, tmp->buffer, 8192); if (n_read == 0 || n_read == ((size_t)-1)) break; tmp->nbytes = n_read; *read_pos += n_read; tmp->nlines = 0; tmp->next = ((void *)0); { char const *buffer_end = tmp->buffer + n_read; char const *p = tmp->buffer; while ((p = memchr(p, line_end, buffer_end - p))) { ++p; ++tmp->nlines; } } total_lines += tmp->nlines; if (tmp->nbytes + last->nbytes < 8192) { memcpy(&last->buffer[last->nbytes], tmp->buffer, tmp->nbytes); last->nbytes += tmp->nbytes; last->nlines += tmp->nlines; } else { last = last->next = tmp; if (total_lines - first->nlines > n_lines) { tmp = first; total_lines -= first->nlines; first = first->next; } else tmp = xmalloc(sizeof(LBUFFER)); } } free(tmp); if (n_read == ((size_t)-1)) { error(0, (*__errno_location()), gettext("error reading %s"), quotearg_style(shell_escape_always_quoting_style, pretty_filename)); ok = 0; goto free_lbuffers; } if (last->nbytes == 0) goto free_lbuffers; if (n_lines == 0) goto free_lbuffers; if (last->buffer[last->nbytes - 1] != line_end) { ++last->nlines; ++total_lines; } for (tmp = first; total_lines - tmp->nlines > n_lines; tmp = tmp->next) total_lines -= tmp->nlines; { char const *beg = tmp->buffer; char const *buffer_end = tmp->buffer + tmp->nbytes; if (total_lines > n_lines) { size_t j; for (j = total_lines - n_lines; j; --j) { beg = rawmemchr(beg, line_end); ++beg; } } xwrite_stdout(beg, buffer_end - beg); } for (tmp = tmp->next; tmp; tmp = tmp->next) xwrite_stdout(tmp->buffer, tmp->nbytes); free_lbuffers: while (first) { tmp = first->next; free(first); first = tmp; } return ok; }
long pipe_lines(long a1, unsigned int a2, size_t a3, _QWORD *a4) { size_t v4; char *i; long v6; char *v7; int *v8; unsigned char v12; size_t *ptr; size_t *v14; size_t *src; size_t *srca; size_t *srcb; size_t *srcc; unsigned long v19; size_t *v20; size_t j; size_t v22; char *v23; char *v24; v19 = 0LL; v12 = 1; v14 = (size_t *)xmalloc(8216LL); ptr = v14; v14[1025] = 0LL; v14[1024] = v14[1025]; v14[1026] = 0LL; src = (size_t *)xmalloc(8216LL); while (1) { v4 = safe_read(a2, src, 0x2000LL); v22 = v4; if (!v4 || v4 == -1LL) break; src[1024] = v4; *a4 += v4; src[1025] = 0LL; src[1026] = 0LL; v23 = (char *)src + v4; for (i = (char *)memchr(src, line_end, v4); i; i = (char *)memchr(i + 1, line_end, v23 - (i + 1))) ++src[1025]; v19 += src[1025]; if (src[1024] + v14[1024] > 0x1FFF) { v14[1026] = (size_t)src; v14 = (size_t *)v14[1026]; if (a3 >= v19 - ptr[1025]) { src = (size_t *)xmalloc(8216LL); } else { src = ptr; v19 -= ptr[1025]; ptr = (size_t *)ptr[1026]; } } else { memcpy((char *)v14 + v14[1024], src, src[1024]); v14[1024] += src[1024]; v14[1025] += src[1025]; } } free(src); if (v22 == -1LL) { v6 = quotearg_style(4LL, a1); v7 = gettext("error reading %s"); v8 = _errno_location(); error(0, *v8, v7, v6); v12 = 0; } else if (v14[1024] && a3) { if (*((_BYTE *)v14 + v14[1024] - 1) != line_end) { ++v14[1025]; ++v19; } for (srca = ptr; a3 < v19 - srca[1025]; srca = (size_t *)srca[1026]) v19 -= srca[1025]; v20 = srca; v24 = (char *)srca + srca[1024]; if (v19 > a3) { for (j = v19 - a3; j; --j) v20 = (size_t *)((char *)rawmemchr(v20, line_end) + 1); } xwrite_stdout(v20, v24 - (char *)v20); for (srcb = (size_t *)srca[1026]; srcb; srcb = (size_t *)srcb[1026]) xwrite_stdout(srcb, srcb[1024]); } while (ptr) { srcc = (size_t *)ptr[1026]; free(ptr); ptr = srcc; } return v12; }
coreutils
ida
static void kdf(void *bufp, aes_int_key key, UINT8 ndx, int nbytes) { UINT8 in_buf[16] = {0}; UINT8 out_buf[16]; UINT8 *dst_buf = (UINT8 *)bufp; int i; in_buf[16 - 9] = ndx; in_buf[16 - 1] = i = 1; while (nbytes >= 16) { AES_encrypt((u_char *)(in_buf), (u_char *)(out_buf), (AES_KEY *)key); memcpy(dst_buf, out_buf, 16); in_buf[16 - 1] = ++i; nbytes -= 16; dst_buf += 16; } if (nbytes) { AES_encrypt((u_char *)(in_buf), (u_char *)(out_buf), (AES_KEY *)key); memcpy(dst_buf, out_buf, nbytes); } explicit_bzero(in_buf, sizeof(in_buf)); explicit_bzero(out_buf, sizeof(out_buf)); }
void kdf(void *param_1, AES_KEY *param_2, byte param_3, int param_4) { long in_FS_OFFSET; int local_60; undefined4 local_44; void *local_40; long local_38; ulong local_30; uchar local_28[24]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_38 = (ulong)param_3 << 0x38; local_44 = 1; local_30 = 0x100000000000000; local_60 = param_4; local_40 = param_1; while (0xf < local_60) { AES_encrypt((uchar *)&local_38, local_28, param_2); memcpy(local_40, local_28, 0x10); local_44 = __addvsi3(local_44, 1); local_30 = local_30 & 0xffffffffffffff | (ulong)(byte)local_44 << 0x38; local_60 = __addvsi3(local_60, 0xfffffff0); local_40 = (void *)((long)local_40 + 0x10); } if (local_60 != 0) { AES_encrypt((uchar *)&local_38, local_28, param_2); memcpy(local_40, local_28, (long)local_60); } explicit_bzero(&local_38, 0x10); explicit_bzero(local_28, 0x10); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return; }
openssh-portable
ghidra
static void grp_update(void) { struct group grp; const struct group *ogrp; struct sgrp sgrp; const struct sgrp *osgrp = ((void *)0); ogrp = gr_locate(group_name); if (((void *)0) == ogrp) { fprintf(stderr, gettext("%s: group '%s' does not exist in %s\n"), Prog, group_name, gr_dbname()); exit(10); } grp = *ogrp; new_grent(&grp); if (is_shadow_grp && (pflg || nflg)) { osgrp = sgr_locate(group_name); if (((void *)0) != osgrp) { sgrp = *osgrp; new_sgent(&sgrp); } else if (pflg && (strcmp(grp.gr_passwd, "x") == 0)) { static char *empty = ((void *)0); memset(&sgrp, 0, sizeof sgrp); sgrp.sg_name = xstrdup(grp.gr_name); sgrp.sg_passwd = xstrdup(grp.gr_passwd); sgrp.sg_adm = &empty; sgrp.sg_mem = dup_list(grp.gr_mem); new_sgent(&sgrp); osgrp = &sgrp; } } if (gflg) { update_primary_groups(ogrp->gr_gid, group_newid); } if (user_list) { char *token; if (!aflg) { if (((void *)0) != grp.gr_mem[0]) gr_free_members(&grp); grp.gr_mem = (char **)xmalloc(sizeof(char *)); grp.gr_mem[0] = (char *)0; } else { if (((void *)0) != grp.gr_mem[0]) grp.gr_mem = dup_list(grp.gr_mem); } token = strtok(user_list, ","); while (token) { if (prefix_getpwnam(token) == ((void *)0)) { fprintf(stderr, gettext("Invalid member username %s\n"), token); exit(10); } grp.gr_mem = add_list(grp.gr_mem, token); token = strtok(((void *)0), ","); } } if (gr_update(&grp) == 0) { fprintf(stderr, gettext("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname(), grp.gr_name); exit(10); } if (nflg && (gr_remove(group_name) == 0)) { fprintf(stderr, gettext("%s: cannot remove entry '%s' from %s\n"), Prog, grp.gr_name, gr_dbname()); exit(10); } if (((void *)0) != osgrp) { if (sgr_update(&sgrp) == 0) { fprintf(stderr, gettext("%s: failed to prepare the new %s entry '%s'\n"), Prog, sgr_dbname(), sgrp.sg_name); exit(10); } if (nflg && (sgr_remove(group_name) == 0)) { fprintf(stderr, gettext("%s: cannot remove entry '%s' from %s\n"), Prog, group_name, sgr_dbname()); exit(10); } } }
long long grp_update() { void *v0; unsigned long long v1; struct_0 *v2; unsigned long long v3; char *v4; unsigned long v5; unsigned long long *v6; unsigned long v7; unsigned long v8; unsigned long long v9; unsigned long v10; unsigned long long v12; unsigned long long v13; unsigned long long v14; unsigned long long v15; unsigned long long v16; v0 = 0; v2 = gr_locate(group_name); if (!v2) { v12 = gr_dbname(); fprintf(*(&stderr), gettext("%s: group '%s' does not exist in %s\n")); exit(0xa); } v3 = v2->field_0; v4 = v2->field_8; v5 = *(&v2->field_10); v6 = v2->field_18; new_grent(&v3); if (is_shadow_grp) { if (!pflg && !nflg) goto LABEL_400429; v0 = sgr_locate(group_name); if (v0) { v7 = *(v0); v8 = v0[8]; v9 = v0[16]; v10 = v0[24]; new_sgent(&v7); } else if (pflg && !strcmp(v4, "x")) { memset(&v7, 0x0, 0x20); v7 = xstrdup(v3); v8 = xstrdup(v4); v9 = &empty.5819; v10 = dup_list(v6); new_sgent(&v7); v0 = &v7; } } LABEL_400429: if (gflg) update_primary_groups(*(&v2->field_10), group_newid, group_newid); if (user_list) { if ((aflg ^ 1)) { if (*(v6)) gr_free_members(&v3); v6 = xmalloc(0x8); *(v6) = 0; } else if (*(v6)) { v6 = dup_list(v6); } for (v1 = strtok(user_list, ","); v1; v1 = strtok(NULL, ",")) { if (!prefix_getpwnam(v1)) { fprintf(*(&stderr), gettext("Invalid member username %s\n")); exit(0xa); } v6 = add_list(v6, v1, v1); } } if (!gr_update(&v3)) { v13 = gr_dbname(); fprintf(*(&stderr), gettext("%s: failed to prepare the new %s entry '%s'\n")); exit(0xa); } if (nflg && !gr_remove(group_name)) { v14 = gr_dbname(); fprintf(*(&stderr), gettext("%s: cannot remove entry '%s' from %s\n")); exit(0xa); } if (v0) { if (!sgr_update(&v7)) { v15 = sgr_dbname(); fprintf(*(&stderr), gettext("%s: failed to prepare the new %s entry '%s'\n")); exit(0xa); } else if (nflg && !sgr_remove(group_name)) { v16 = sgr_dbname(); fprintf(*(&stderr), gettext("%s: cannot remove entry '%s' from %s\n")); exit(0xa); } } return 0; }
shadow
angr_phoenix
int login_write(struct logininfo *li) { if (geteuid() != 0) { sshlog("loginrec.c", __func__, 444, 0, SYSLOG_LEVEL_INFO, ((void *)0), "Attempt to write login records by non-root user (aborting)"); return (1); } login_set_current_time(li); syslogin_write_entry(li); if (li->type == 7) lastlog_write_entry(li); return (0); }
undefined8 login_write(long param_1) { __uid_t _Var1; undefined8 uVar2; uVar2 = 0x10044c; _Var1 = geteuid(); if (_Var1 == 0) { login_set_current_time(param_1); syslogin_write_entry(param_1); if (*(short *)(param_1 + 0x44) == 7) { lastlog_write_entry(param_1); } uVar2 = 0; } else { sshlog("loginrec.c", "login_write", 0x1bc, 0, 3, 0, "Attempt to write login records by non-root user (aborting)", uVar2); uVar2 = 1; } return uVar2; }
openssh-portable
ghidra
static int set_krb5_principal(int type, void *crt) { int ret = 0, i; if (batch) { if (!cfg.krb5_principal) return 0; for (i = 0; cfg.krb5_principal[i] != ((void *)0); i++) { if (type == 1) ret = gnutls_x509_crt_set_subject_alt_name( crt, GNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL, cfg.krb5_principal[i], strlen(cfg.krb5_principal[i]), 1); else ret = gnutls_x509_crq_set_subject_alt_name( crt, GNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL, cfg.krb5_principal[i], strlen(cfg.krb5_principal[i]), 1); if (ret < 0) break; } } if (ret < 0) { fprintf(stderr, "set_subject_alt_name(GNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL): %s\n", gnutls_strerror(ret)); exit(1); } return ret; }
long set_krb5_principal(int a1, long a2) { unsigned int v3; const char *v4; int v5; int i; v5 = 0; if (batch) { if (!*(_QWORD *)&cfg[86]) return 0LL; for (i = 0; *(_QWORD *)(8LL * i + *(_QWORD *)&cfg[86]); ++i) { v3 = strlen(*(const char **)(8LL * i + *(_QWORD *)&cfg[86])); v5 = a1 == 1 ? gnutls_x509_crt_set_subject_alt_name( a2, 1001LL, *(_QWORD *)(8LL * i + *(_QWORD *)&cfg[86]), v3, 1LL) : gnutls_x509_crq_set_subject_alt_name( a2, 1001LL, *(_QWORD *)(8LL * i + *(_QWORD *)&cfg[86]), v3, 1LL); if (v5 < 0) break; } } if (v5 < 0) { v4 = (const char *)gnutls_strerror((unsigned int)v5); fprintf(stderr, "set_subject_alt_name(GNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL): %s\n", v4); exit(1); } return (unsigned int)v5; }
gnutls
ida
int main(int argc, char **argv) { char proc_dir_name[32]; char *target_str; pid_t target; int proc_dir_fd; int ranges; struct map_range *mappings; struct stat st; struct passwd *pw; int written; _Bool allow_setgroups = 0; Prog = Basename(argv[0]); log_set_progname(Prog); log_set_logfd(stderr); if (argc < 2) usage(); target_str = argv[1]; if (!get_pid(target_str, &target)) usage(); written = snprintf(proc_dir_name, sizeof(proc_dir_name), "/proc/%u/", target); if ((written <= 0) || (written >= sizeof(proc_dir_name))) { fprintf(stderr, "%s: snprintf of proc path failed: %s\n", Prog, strerror((*__errno_location()))); } proc_dir_fd = open(proc_dir_name, 0200000); if (proc_dir_fd < 0) { fprintf(stderr, gettext("%s: Could not open proc directory for target %u\n"), Prog, target); return 1; } pw = get_my_pwent(); if (((void *)0) == pw) { fprintf(stderr, gettext("%s: Cannot determine your user name.\n"), Prog); do { char *old_locale = setlocale(6, ((void *)0)); char *saved_locale = ((void *)0); if (((void *)0) != old_locale) { saved_locale = strdup(old_locale); } if (((void *)0) != saved_locale) { (void)setlocale(6, "C"); } syslog(4, "Cannot determine the user name of the caller (UID %lu)", (unsigned long)getuid()); if (((void *)0) != saved_locale) { (void)setlocale(6, saved_locale); free(saved_locale); } } while (0); return 1; } if (fstat(proc_dir_fd, &st) < 0) { fprintf(stderr, gettext("%s: Could not stat directory for target %u\n"), Prog, target); return 1; } if ((getuid() != pw->pw_uid) || (!getdef_bool("GRANT_AUX_GROUP_SUBIDS") && (getgid() != pw->pw_gid)) || (pw->pw_uid != st.st_uid) || (getgid() != st.st_gid)) { fprintf(stderr, gettext("%s: Target %u is owned by a different user: uid:%lu " "pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n"), Prog, target, (unsigned long int)getuid(), (unsigned long int)pw->pw_uid, (unsigned long int)st.st_uid, (unsigned long int)getgid(), (unsigned long int)pw->pw_gid, (unsigned long int)st.st_gid); return 1; } if (!sub_gid_open(00)) { return 1; } ranges = ((argc - 2) + 2) / 3; mappings = get_map_ranges(ranges, argc - 2, argv + 2); if (!mappings) usage(); verify_ranges(pw, ranges, mappings, &allow_setgroups); write_setgroups(proc_dir_fd, allow_setgroups); write_mapping(proc_dir_fd, ranges, mappings, "gid_map", pw->pw_uid); sub_gid_close(); return 0; }
int main(int argc, const char **argv, const char **envp) { int *v3; char *v4; unsigned int v5; long v6; char *v7; long v9; char *v10; __uid_t v11; unsigned int v12; long v13; char *v14; long v15; long v16; long st_uid; unsigned int v18; long v19; char *v20; long v21; long v22; long st_gid; char v24; unsigned int v25; unsigned int v26; int fd; unsigned int v28; char *locale; const char *v30; _QWORD *my_pwent; long *map_ranges; char *v33; struct stat buf; char s[40]; unsigned long v36; v36 = __readfsqword(0x28u); v24 = 0; Prog = Basename(*argv, argv, envp); log_set_progname(Prog); log_set_logfd(stderr); if (argc <= 1) usage(); v30 = argv[1]; if (!(unsigned int)get_pid(v30, &v25)) usage(); v26 = snprintf(s, 0x20uLL, "/proc/%u/", v25); if ((int)v26 <= 0 || v26 > 0x1F) { v3 = _errno_location(); v4 = strerror(*v3); fprintf(stderr, "%s: snprintf of proc path failed: %s\n", (const char *)Prog, v4); } fd = open(s, 0x10000); if (fd >= 0) { my_pwent = (_QWORD *)get_my_pwent(); if (my_pwent) { if (fstat(fd, &buf) >= 0) { if (getuid() == *((_DWORD *)my_pwent + 4) && ((unsigned char)getdef_bool("GRANT_AUX_GROUP_SUBIDS") == 1 || getgid() == *((_DWORD *)my_pwent + 5)) && *((_DWORD *)my_pwent + 4) == buf.st_uid && getgid() == buf.st_gid) { if ((unsigned int)sub_gid_open(0LL)) { v28 = argc / 3; map_ranges = (long *)get_map_ranges( (unsigned int)(argc / 3), (unsigned int)(argc - 2), argv + 2); if (!map_ranges) usage(); verify_ranges(my_pwent, v28, map_ranges, &v24); write_setgroups(fd, v24); write_mapping((unsigned int)fd, v28, map_ranges, "gid_map", *((unsigned int *)my_pwent + 4)); sub_gid_close(); return 0; } else { return 1; } } else { st_gid = buf.st_gid; v15 = *((unsigned int *)my_pwent + 5); v16 = getgid(); st_uid = buf.st_uid; v22 = *((unsigned int *)my_pwent + 4); v21 = getuid(); v18 = v25; v19 = Prog; v20 = gettext("%s: Target %u is owned by a different user: uid:%lu " "pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n"); fprintf(stderr, v20, v19, v18, v21, v22, st_uid, v16, v15, st_gid); return 1; } } else { v12 = v25; v13 = Prog; v14 = gettext("%s: Could not stat directory for target %u\n"); fprintf(stderr, v14, v13, v12); return 1; } } else { v9 = Prog; v10 = gettext("%s: Cannot determine your user name.\n"); fprintf(stderr, v10, v9); v33 = setlocale(6, 0LL); locale = 0LL; if (v33) locale = strdup(v33); if (locale) setlocale(6, "C"); v11 = getuid(); syslog(4, "Cannot determine the user name of the caller (UID %lu)", v11); if (locale) { setlocale(6, locale); free(locale); } return 1; } } else { v5 = v25; v6 = Prog; v7 = gettext("%s: Could not open proc directory for target %u\n"); fprintf(stderr, v7, v6, v5); return 1; } }
shadow
ida
int rl_history_substr_search_forward(int count, int ignore) { if (count == 0) return (0); if (rl_last_func != rl_history_substr_search_forward && rl_last_func != rl_history_substr_search_backward) rl_history_search_reinit(0); if (_rl_history_search_len == 0) return (rl_get_next_history(count, ignore)); return (rl_history_search_internal((((count) >= 0) ? (count) : -(count)), (count > 0) ? 1 : -1)); }
undefined8 rl_history_substr_search_forward(uint param_1, undefined4 param_2) { undefined8 uVar1; if (param_1 == 0) { uVar1 = 0; } else { if ((rl_last_func != rl_history_substr_search_forward) && (rl_last_func != rl_history_substr_search_backward)) { rl_history_search_reinit(0); } if (_rl_history_search_len == 0) { uVar1 = rl_get_next_history(param_1, param_2); } else { if ((int)param_1 < 1) { uVar1 = 0xffffffff; } else { uVar1 = 1; } uVar1 = rl_history_search_internal( ((int)param_1 >> 0x1f ^ param_1) - ((int)param_1 >> 0x1f), uVar1); } } return uVar1; }
bash
ghidra
char *user_from_uid(uid_t uid, int nouser) { static struct ncache { uid_t uid; char *name; } c_uid[64]; static int pwopen; static char nbuf[15]; struct passwd *pw; struct ncache *cp; cp = c_uid + (uid & (64 - 1)); if (cp->uid != uid || cp->name == ((void *)0)) { if (pwopen == 0) { pwopen = 1; } if ((pw = getpwuid(uid)) == ((void *)0)) { if (nouser) return (((void *)0)); (void)snprintf(nbuf, sizeof(nbuf), "%lu", (u_long)uid); } cp->uid = uid; if (cp->name != ((void *)0)) free(cp->name); cp->name = strdup(pw ? pw->pw_name : nbuf); } return (cp->name); }
long long user_from_uid(unsigned long a0, unsigned long a1) { struct_0 *v0; unsigned long long *v1; void *v3; unsigned long long v4; v0 = &(&c_uid.6366)[2 * (a0 & 63)]; if (!v0->field_8 || a0 != v0->field_0) { if (!pwopen.6367) pwopen.6367 = 1; v1 = &getpwuid(a0)->pw_name; if (!v1) { if (a1) v3 = 0; else snprintf(&nbuf.6368, 0xf, "%lu", a0); } } if (!v0->field_8 && !a1 || !v0->field_8 && v1 || !a1 && a0 != v0->field_0 || a0 != v0->field_0 && v1) { v0->field_0 = a0; if (v0->field_8) free(v0->field_8); if (v1) v4 = *(v1); else v4 = &nbuf.6368; v0->field_8 = strdup(v4); } if (!a1) v3 = v0->field_8; return v3; }
openssh-portable
angr_dream
_Bool default_prints (struct predicate *pred) { while (pred != ((void *)0)) { if (pred->no_default_print) return (0); pred = pred->pred_next; } return (1); }
long long default_prints(unsigned long a0) { struct_0 *v0; unsigned long long v2; v0 = a0; while (true) { if (!v0) { v2 = 1; return v2; } else if (!v0->field_19) { v0 = v0->field_108; } else { v2 = 0; return v2; } } }
findutils
angr_sailr
static gnutls_pubkey_t find_pubkey(gnutls_x509_crt_t crt, common_info_st *cinfo) { gnutls_pubkey_t pubkey = ((void *)0); gnutls_privkey_t privkey = ((void *)0); gnutls_x509_crq_t crq = ((void *)0); int ret; size_t size; gnutls_datum_t pem; ret = gnutls_pubkey_init(&pubkey); if (ret < 0) { fprintf(stderr, "pubkey_init: %s\n", gnutls_strerror(ret)); app_exit(1); } if (crt == ((void *)0)) { crt = load_cert(0, cinfo); } if (crq == ((void *)0)) { crq = load_request(cinfo); } if (crt != ((void *)0)) { ret = gnutls_pubkey_import_x509(pubkey, crt, 0); if (ret < 0) { fprintf(stderr, "pubkey_import_x509: %s\n", gnutls_strerror(ret)); app_exit(1); } gnutls_x509_crt_deinit(crt); } else if (crq != ((void *)0)) { ret = gnutls_pubkey_import_x509_crq(pubkey, crq, 0); if (ret < 0) { fprintf(stderr, "pubkey_import_x509_crq: %s\n", gnutls_strerror(ret)); app_exit(1); } gnutls_x509_crq_deinit(crq); } else { privkey = load_private_key(0, cinfo); if (privkey != ((void *)0)) { ret = gnutls_pubkey_import_privkey(pubkey, privkey, 0, 0); if (ret < 0) { fprintf(stderr, "pubkey_import_privkey: %s\n", gnutls_strerror(ret)); app_exit(1); } gnutls_privkey_deinit(privkey); } else { gnutls_pubkey_deinit(pubkey); pubkey = load_pubkey(0, cinfo); if (pubkey == ((void *)0)) { pem.data = (void *)_gnutls_fread_file(infile, 0, &size); pem.size = size; if (!pem.data) { fprintf(stderr, "%s", infile ? "file" : "standard input"); app_exit(1); } ret = gnutls_pubkey_init(&pubkey); if (ret < 0) { fprintf(stderr, "pubkey_init: %s\n", gnutls_strerror(ret)); app_exit(1); } if (memmem(pem.data, pem.size, "BEGIN CERTIFICATE", 16) != 0 || memmem(pem.data, pem.size, "BEGIN X509", 10) != 0) { ret = gnutls_x509_crt_init(&crt); if (ret < 0) { fprintf(stderr, "crt_init: %s\n", gnutls_strerror(ret)); app_exit(1); } ret = gnutls_x509_crt_import(crt, &pem, GNUTLS_X509_FMT_PEM); if (ret < 0) { fprintf(stderr, "crt_import: %s\n", gnutls_strerror(ret)); app_exit(1); } ret = gnutls_pubkey_import_x509(pubkey, crt, 0); if (ret < 0) { fprintf(stderr, "pubkey_import_x509: %s\n", gnutls_strerror(ret)); app_exit(1); } gnutls_x509_crt_deinit(crt); } else { ret = gnutls_pubkey_import(pubkey, &pem, incert_format); if (ret < 0) { fprintf(stderr, "pubkey_import: %s\n", gnutls_strerror(ret)); app_exit(1); } } free(pem.data); } } } return pubkey; }
long find_pubkey(long param_1, undefined8 param_2) { undefined8 uVar1; char *pcVar2; void *pvVar3; long in_FS_OFFSET; long local_60[2]; int local_4c; long local_48; uint local_40[2]; long local_38; long local_30; void *local_28; uint local_20; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_48 = 0; local_30 = 0; local_38 = 0; local_60[0] = param_1; local_4c = gnutls_pubkey_init(&local_48); if (local_4c < 0) { uVar1 = gnutls_strerror(local_4c); fprintf(stderr, "pubkey_init: %s\n", uVar1); app_exit(1); } if (local_60[0] == 0) { local_60[0] = load_cert(0, param_2); } if (local_38 == 0) { local_38 = load_request(param_2); } if (local_60[0] != 0) { local_4c = gnutls_pubkey_import_x509(local_48, local_60[0], 0); if (local_4c < 0) { uVar1 = gnutls_strerror(local_4c); fprintf(stderr, "pubkey_import_x509: %s\n", uVar1); app_exit(1); } gnutls_x509_crt_deinit(local_60[0]); goto LAB_0010a1d0; } if (local_38 != 0) { local_4c = gnutls_pubkey_import_x509_crq(local_48, local_38, 0); if (local_4c < 0) { uVar1 = gnutls_strerror(local_4c); fprintf(stderr, "pubkey_import_x509_crq: %s\n", uVar1); app_exit(1); } gnutls_x509_crq_deinit(local_38); goto LAB_0010a1d0; } local_30 = load_private_key(0, param_2); if (local_30 != 0) { local_4c = gnutls_pubkey_import_privkey(local_48, local_30, 0, 0); if (local_4c < 0) { uVar1 = gnutls_strerror(local_4c); fprintf(stderr, "pubkey_import_privkey: %s\n", uVar1); app_exit(1); } gnutls_privkey_deinit(local_30); goto LAB_0010a1d0; } gnutls_pubkey_deinit(local_48); local_48 = load_pubkey(0, param_2); if (local_48 != 0) goto LAB_0010a1d0; local_28 = (void *)_gnutls_fread_file(infile, 0, local_40); local_20 = local_40[0]; if (local_28 == (void *)0x0) { if (infile == 0) { pcVar2 = "standard input"; } else { pcVar2 = "file"; } fprintf(stderr, "%s", pcVar2); app_exit(1); } local_4c = gnutls_pubkey_init(&local_48); if (local_4c < 0) { uVar1 = gnutls_strerror(local_4c); fprintf(stderr, "pubkey_init: %s\n", uVar1); app_exit(1); } pvVar3 = memmem(local_28, (ulong)local_20, "BEGIN CERTIFICATE", 0x10); if (pvVar3 == (void *)0x0) { pvVar3 = memmem(local_28, (ulong)local_20, "BEGIN X509", 10); if (pvVar3 != (void *)0x0) goto LAB_0010a075; local_4c = gnutls_pubkey_import(local_48, &local_28, incert_format); if (local_4c < 0) { uVar1 = gnutls_strerror(local_4c); fprintf(stderr, "pubkey_import: %s\n", uVar1); app_exit(1); } } else { LAB_0010a075: local_4c = gnutls_x509_crt_init(local_60); if (local_4c < 0) { uVar1 = gnutls_strerror(local_4c); fprintf(stderr, "crt_init: %s\n", uVar1); app_exit(1); } local_4c = gnutls_x509_crt_import(local_60[0], &local_28, 1); if (local_4c < 0) { uVar1 = gnutls_strerror(local_4c); fprintf(stderr, "crt_import: %s\n", uVar1); app_exit(1); } local_4c = gnutls_pubkey_import_x509(local_48, local_60[0], 0); if (local_4c < 0) { uVar1 = gnutls_strerror(local_4c); fprintf(stderr, "pubkey_import_x509: %s\n", uVar1); app_exit(1); } gnutls_x509_crt_deinit(local_60[0]); } free(local_28); LAB_0010a1d0: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return local_48; }
gnutls
ghidra
static int open_match(struct permission *allowed_open, const char *requestedhost, int requestedport) { if (allowed_open->host_to_connect == ((void *)0)) return 0; if (allowed_open->port_to_connect != 0 && allowed_open->port_to_connect != requestedport) return 0; if (strcmp(allowed_open->host_to_connect, "*") != 0 && strcmp(allowed_open->host_to_connect, requestedhost) != 0) return 0; return 1; }
int open_match(struct_0 *a0, char *a1, unsigned long a2) { unsigned int v1; if (!a0->field_0) { v1 = 0; } else { if (a0->field_8 && a2 != a0->field_8) v1 = 0; if (a2 == a0->field_8 || !a0->field_8) { v1 = strcmp(a0->field_0, "*"); if (v1) { v1 = strcmp(a0->field_0, a1); if (v1) v1 = 0; } if (!v1 || !v1) v1 = 1; } } return v1; }
openssh-portable
angr_dream
int process_options(int argc, char **argv) { struct systemkey_tool_options *opts = &systemkey_tool_options; int opt; while ((opt = getopt_long(argc, argv, "!d:hv:", long_options, ((void *)0))) != (-1)) switch (opt) { case '\0': break; case 'd': opts->present.debug = 1; opts->arg.debug = optarg; opts->value.debug = parse_number(optarg); opts->enabled.debug = 1; break; case 0x7f + 1: opts->present.outfile = 1; opts->arg.outfile = optarg; opts->enabled.outfile = 1; break; case 0x7f + 2: opts->present.list = 1; opts->enabled.list = 1; break; case 0x7f + 3: opts->present.delete = 1; opts->arg.delete = optarg; opts->enabled.delete = 1; break; case 0x7f + 4: opts->present.outder = 1; opts->enabled.outder = 1; break; case 0x7f + 5: opts->present.outder = 1; opts->enabled.outder = 0; break; case 'v': opts->present.version = 1; opts->arg.version = optarg; opts->enabled.version = 1; break; case 'h': opts->present.help = 1; opts->enabled.help = 1; break; case '!': opts->present.more_help = 1; opts->enabled.more_help = 1; break; default: usage(stderr, 1); break; } if (systemkey_tool_options.present.debug && systemkey_tool_options.value.debug < 0) { error(1, 0, "%s option value %d is out of range.", "debug", opts->value.debug); } if (systemkey_tool_options.present.debug && systemkey_tool_options.value.debug > 9999) { error(1, 0, "%s option value %d is out of range", "debug", opts->value.debug); } if (optind < argc) { error(1, 0, "Command line arguments are not allowed."); } if (systemkey_tool_options.present.help) { usage(stdout, (0)); } if (systemkey_tool_options.present.more_help) { pid_t pid; int pfds[2]; if (pipe(pfds) < 0) error(1, (*__errno_location()), "pipe"); pid = fork(); if (pid < 0) error(1, (*__errno_location()), "fork"); if (pid == 0) { close(pfds[0]); dup2(pfds[1], 1); close(pfds[1]); usage(stdout, 0); } else { const char *args[2]; const char *envvar; close(pfds[1]); dup2(pfds[0], 0); close(pfds[0]); envvar = secure_getenv("PAGER"); if (!envvar || *envvar == '\0') args[0] = "more"; else args[0] = envvar; args[1] = ((void *)0); execvp(args[0], (char *const *)args); exit(1); } } if (systemkey_tool_options.present.version) { if (!systemkey_tool_options.arg.version || !strcmp(systemkey_tool_options.arg.version, "c")) { const char str[] = "systemkey-tool 3.7.8\n" "Copyright (C) 2000-2021 Free Software Foundation, and others\n" "This is free software. It is licensed for use, modification and\n" "redistribution under the terms of the GNU General Public License,\n" "version 3 or later <http: "\n" "Please send bug reports to: <bugs@gnutls.org> \n"; fprintf(stdout, "%s", str); exit(0); } else if (!strcmp(systemkey_tool_options.arg.version, "v")) { const char str[] = "systemkey-tool 3.7.8\n"; fprintf(stdout, "%s", str); exit(0); } else if (!strcmp(systemkey_tool_options.arg.version, "n")) { const char str[] = "systemkey-tool 3.7.8\n" "Copyright (C) 2000-2021 Free Software Foundation, and others\n" "This is free software. It is licensed for use, modification and\n" "redistribution under the terms of the GNU General Public License,\n" "version 3 or later <http: "\n" "gnutls is free software: you can redistribute it and/or\n" "modify it under the terms of the GNU General Public License\n" "as published by the Free Software Foundation,\n" "either version 3 of the License, or (at your option) any later " "version.\n" "\n" "gnutls is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty\n" "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" "See the GNU General Public License for more details.\n" "\n" "You should have received a copy of the GNU General Public License\n" "along with this program. If not, see <http: "\n" "Please send bug reports to: <bugs@gnutls.org> \n"; fprintf(stdout, "%s", str); exit(0); } else { error(1, 0, "version option argument 'a' invalid. Use:\n" " 'v' - version only\n" " 'c' - version and copyright\n" " 'n' - version and full copyright notice"); } } return optind; }
undefined4 process_options(int param_1, undefined8 param_2) { undefined *puVar1; undefined4 uVar2; int iVar3; __pid_t _Var4; int *piVar5; long lVar6; undefined8 *puVar7; undefined8 *puVar8; long in_FS_OFFSET; byte bVar9; int local_3d0; int local_3cc; char *local_3c8; undefined8 local_3c0; undefined8 local_3b8; undefined8 local_3b0; undefined4 local_3a8; undefined2 local_3a4; long local_10; puVar1 = puRam0000000000100191; bVar9 = 0; local_10 = *(long *)(in_FS_OFFSET + 0x28); while (true) { iVar3 = getopt_long(param_1, param_2, "!d:hv:", long_options, 0); if (iVar3 == -1) { if ((*pcRam00000000001003bc != '\0') && (*(int *)(lRam00000000001003ca + 0x28) < 0)) { error(1, 0, "%s option value %d is out of range.", "debug", *(undefined4 *)(puVar1 + 0x28)); } if ((*pcRam0000000000100407 != '\0') && (9999 < *(int *)(lRam0000000000100415 + 0x28))) { error(1, 0, "%s option value %d is out of range", "debug", *(undefined4 *)(puVar1 + 0x28)); } if (*piRam0000000000100455 < param_1) { error(1, 0, "Command line arguments are not allowed."); } if (*(char *)(lRam0000000000100481 + 6) != '\0') { usage(*puRam0000000000100490, 0); } if (*(char *)(lRam00000000001004a7 + 7) != '\0') { iVar3 = pipe(&local_3d0); if (iVar3 < 0) { piVar5 = __errno_location(); error(1, *piVar5, &DAT_001009f0); } _Var4 = fork(); if (_Var4 < 0) { piVar5 = __errno_location(); error(1, *piVar5, &DAT_001009f5); } if (_Var4 == 0) { close(local_3d0); dup2(local_3cc, 1); close(local_3cc); usage(*puRam0000000000100554, 0); } close(local_3cc); dup2(local_3d0, 0); close(local_3d0); local_3c8 = (char *)secure_getenv("PAGER"); if ((local_3c8 == (char *)0x0) || (*local_3c8 == '\0')) { local_3c8 = "more"; } local_3c0 = 0; execvp(local_3c8, &local_3c8); exit(1); } if (*(char *)(lRam0000000000100613 + 5) == '\0') { if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return *puRam00000000001007ff; } if ((*(long *)(lRam0000000000100626 + 0x20) == 0) || (iVar3 = strcmp(*(char **)(lRam0000000000100636 + 0x20), "c"), iVar3 == 0)) { puVar7 = (undefined8 *)"systemkey-tool 3.7.8\nCopyright (C) 2000-2021 Free Software Foundation, and others\nThis is free software. It is licensed for use, modification and\nredistribution under the terms of the GNU General Public License,\nversion 3 or later <http: ; puVar8 = &local_3b8; for (lVar6 = 0x28; lVar6 != 0; lVar6 = lVar6 + -1) { *puVar8 = *puVar7; puVar7 = puVar7 + (ulong)bVar9 * -2 + 1; puVar8 = puVar8 + (ulong)bVar9 * -2 + 1; } *(undefined4 *)puVar8 = *(undefined4 *)puVar7; *(undefined2 *)((long)puVar8 + 4) = *(undefined2 *)((long)puVar7 + 4); *(undefined *)((long)puVar8 + 6) = *(undefined *)((long)puVar7 + 6); fprintf(*ppFRam000000000010069d, "%s", &local_3b8); exit(0); } iVar3 = strcmp(*(char **)(lRam00000000001006cc + 0x20), "v"); if (iVar3 == 0) { local_3b8 = 0x656b6d6574737973; local_3b0 = 0x33206c6f6f742d79; local_3a8 = 0x382e372e; local_3a4 = 10; fprintf(*ppFRam000000000010071f, "%s", &local_3b8); exit(0); } iVar3 = strcmp(*(char **)(lRam000000000010074e + 0x20), "n"); if (iVar3 == 0) { puVar7 = (undefined8 *)"systemkey-tool 3.7.8\nCopyright (C) 2000-2021 Free Software Foundation, and others\nThis is free software. It is licensed for use, modification and\nredistribution under the terms of the GNU General Public License,\nversion 3 or later <http: ; puVar8 = &local_3b8; for (lVar6 = 0x73; lVar6 != 0; lVar6 = lVar6 + -1) { *puVar8 = *puVar7; puVar7 = puVar7 + (ulong)bVar9 * -2 + 1; puVar8 = puVar8 + (ulong)bVar9 * -2 + 1; } *(undefined4 *)puVar8 = *(undefined4 *)puVar7; *(undefined2 *)((long)puVar8 + 4) = *(undefined2 *)((long)puVar7 + 4); *(undefined *)((long)puVar8 + 6) = *(undefined *)((long)puVar7 + 6); fprintf(*ppFRam00000000001007b5, "%s", &local_3b8); exit(0); } error(1, 0, "version option argument \'a\' invalid. Use:\n\t\'v\' - version " "only\n\t\'c\' - version and copyright\n\t\'n\' - version and full " "copyright notice"); } if (0x84 < iVar3) break; if (iVar3 < 100) { if (iVar3 != 0) { if (iVar3 != 0x21) break; puVar1[7] = 1; puVar1[0x33] = 1; } } else { switch (iVar3) { case 100: *puVar1 = 1; *(undefined8 *)(puVar1 + 8) = *puRam000000000010021b; uVar2 = parse_number(); *(undefined4 *)(puVar1 + 0x28) = uVar2; puVar1[0x2c] = 1; break; default: goto switchD_00100207_caseD_65; case 0x68: puVar1[6] = 1; puVar1[0x32] = 1; break; case 0x76: puVar1[5] = 1; *(undefined8 *)(puVar1 + 0x20) = *puRam0000000000100317; puVar1[0x31] = 1; break; case 0x80: puVar1[1] = 1; *(undefined8 *)(puVar1 + 0x10) = *puRam0000000000100269; puVar1[0x2d] = 1; break; case 0x81: puVar1[2] = 1; puVar1[0x2e] = 1; break; case 0x82: puVar1[3] = 1; *(undefined8 *)(puVar1 + 0x18) = *puRam00000000001002b4; puVar1[0x2f] = 1; break; case 0x83: puVar1[4] = 1; puVar1[0x30] = 1; break; case 0x84: puVar1[4] = 1; puVar1[0x30] = 0; } } } switchD_00100207_caseD_65: usage(*puRam0000000000100369, 1); }
gnutls
ghidra
FILE *cron_popen(char *program, const char *type, struct passwd *pw, char **jobenv) { char *cp; FILE *iop; int argc, pdes[2]; pid_t pid; char *argv[1024]; ssize_t out; char buf[4096]; struct sigaction sa; int fd; (void)&iop; if ((*type != 'r' && *type != 'w') || type[1]) return (((void *)0)); if (!pids) { if ((fds = getdtablesize()) <= 0) return (((void *)0)); if (fds > 10000) fds = 10000; if (!(pids = (pid_t *)malloc((u_int)((size_t)fds * sizeof(pid_t))))) return (((void *)0)); memset((char *)pids, 0, (size_t)fds * sizeof(pid_t)); } if (pipe(pdes) < 0) return (((void *)0)); if (pdes[0] >= fds || pdes[1] >= fds) { (void)close(pdes[0]); (void)close(pdes[1]); return ((void *)0); } for (argc = 0, cp = program; argc < 1024; cp = ((void *)0)) if (!(argv[argc++] = strtok(cp, " \t\n"))) break; iop = ((void *)0); switch (pid = fork()) { case -1: (void)close(pdes[0]); (void)close(pdes[1]); goto pfree; case 0: if (*type == 'r') { if (pdes[1] != 1) { dup2(pdes[1], 1); dup2(pdes[1], 2); (void)close(pdes[1]); } (void)close(pdes[0]); } else { if (pdes[0] != 0) { dup2(pdes[0], 0); (void)close(pdes[0]); } (void)close(pdes[1]); } memset(&sa, 0, sizeof(sa)); sa.__sigaction_handler.sa_handler = ((__sighandler_t)0); sigaction(13, &sa, ((void *)0)); for (fd = 2 + 1; fd < fds; fd++) { close(fd); } if (cron_change_user_permanently(pw, env_get("HOME", jobenv)) != 0) _exit(2); if (execvpe(argv[0], argv, jobenv) < 0) { int save_errno = (*__errno_location()); log_it("CRON", getpid(), "EXEC FAILED", program, save_errno); if (*type != 'r') { while (0 != (out = read(0, buf, 4096))) { if ((out == -1) && ((*__errno_location()) != 4)) break; } } } _exit(1); } if (*type == 'r') { fd = pdes[0]; iop = fdopen(pdes[0], type); (void)close(pdes[1]); } else { fd = pdes[1]; iop = fdopen(pdes[1], type); (void)close(pdes[0]); } pids[fd] = pid; pfree: return (iop); }
long long cron_popen(char *a0, char a1[2], unsigned long long a2, unsigned long a3) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned int v3; unsigned long v4; void *v5; unsigned long v6; char v7; char v8; void *v9; char v10; char v11; char v12; char v13; char v14; void *v16; unsigned long long *v17; unsigned long long v18; v14 = *(&v14); v12 = *(&v12); v11 = *(&v11); if (a1[0] != 114 && !(a1[0] == 119)) goto LABEL_40008d; if (!a1[1]) { if (!pids) { fds = getdtablesize(); if (fds <= 0) { v16 = 0; goto LABEL_4004ea; } if (fds > 10000) fds = 10000; pids = malloc(fds * 4); if (!pids) { v16 = 0; goto LABEL_4004ea; } else { memset(pids, 0x0, fds * 4); } } if (pipe(&v7) < 0) { v16 = 0; goto LABEL_4004ea; } if (*(&v7) < fds && *(&v8) < fds) { v0 = 0; v5 = a0; while (true) { if (v0 > 1023) break; v17 = v0; v0 += 1; *((&v10 + 0x8 * v17)) = strtok(v5, " \t\n"); if (!*((&v10 + 0x8 * v17))) break; v5 = 0; } v4 = 0; v2 = fork(); if (v2 == -1) { close(*(&v7)); close(*(&v8)); } else if (v2) { if (a1[0] == 114) { v1 = *(&v7); v4 = fdopen(*(&v7), a1); close(*(&v8)); } else { v1 = *(&v8); v4 = fdopen(*(&v8), a1); close(*(&v7)); } *((v1 * 4 + pids)) = v2; } else { if (a1[0] != 114) { if (*(&v7)) { dup2(*(&v7), 0x0); close(*(&v7)); } close(*(&v8)); } else { if (*(&v8) != 1) { dup2(*(&v8), 0x1); dup2(*(&v8), 0x2); close(*(&v8)); } close(*(&v7)); } memset(&v9, 0x0, 0x98); v9 = 0; sigaction(0xd, &v9, 0x0); for (v1 = 3; v1 < fds; v1 += 1) { close(v1); } v18 = env_get("HOME", a3); if (cron_change_user_permanently(a2, v18, v18)) _exit(0x2); if (execvpe(*(&v10), &v10, a3) < 0) { v3 = *(__errno_location()); log_it("CRON", getpid(), "EXEC FAILED", a0, v3); if (a1[0] != 114) { while (true) { v6 = read(0x0, &v13, 0x1000); if (!v6) break; if (!(v6 == -1)) continue; *(&v18) = *(__errno_location()); if (v18 != 4) break; } } } _exit(0x1); } v16 = v4; LABEL_4004ea: return v16; } close(*(&v7)); close(*(&v8)); v16 = 0; goto LABEL_4004ea; } LABEL_40008d: v16 = 0; goto LABEL_4004ea; }
cronie
angr_phoenix
void usage(int status) { if (status != 0) do { fprintf(stderr, gettext("Try '%s --help' for more information.\n"), program_name); } while (0); else { fputs_unlocked(gettext("Usage: test EXPRESSION\n or: test\n or: [ " "EXPRESSION ]\n or: [ ]\n or: [ OPTION\n"), stdout) ; fputs_unlocked( gettext("Exit with the status determined by EXPRESSION.\n\n"), stdout) ; fputs_unlocked(gettext(" --help display this help and exit\n"), stdout); fputs_unlocked( gettext(" --version output version information and exit\n"), stdout); fputs_unlocked(gettext("\nAn omitted EXPRESSION defaults to false. " "Otherwise,\nEXPRESSION is true or false and sets " "exit status. It is one of:\n"), stdout) ; fputs_unlocked( gettext("\n ( EXPRESSION ) EXPRESSION is true\n ! " "EXPRESSION EXPRESSION is false\n EXPRESSION1 " "-a EXPRESSION2 both EXPRESSION1 and EXPRESSION2 are true\n " "EXPRESSION1 -o EXPRESSION2 either EXPRESSION1 or " "EXPRESSION2 is true\n"), stdout) ; fputs_unlocked( gettext("\n -n STRING the length of STRING is nonzero\n " "STRING equivalent to -n STRING\n -z STRING " " the length of STRING is zero\n STRING1 = STRING2 " "the strings are equal\n STRING1 != STRING2 the strings are " "not equal\n"), stdout) ; fputs_unlocked( gettext("\n INTEGER1 -eq INTEGER2 INTEGER1 is equal to INTEGER2\n " "INTEGER1 -ge INTEGER2 INTEGER1 is greater than or equal to " "INTEGER2\n INTEGER1 -gt INTEGER2 INTEGER1 is greater than " "INTEGER2\n INTEGER1 -le INTEGER2 INTEGER1 is less than or " "equal to INTEGER2\n INTEGER1 -lt INTEGER2 INTEGER1 is less " "than INTEGER2\n INTEGER1 -ne INTEGER2 INTEGER1 is not " "equal to INTEGER2\n"), stdout) ; fputs_unlocked(gettext("\n FILE1 -ef FILE2 FILE1 and FILE2 have the " "same device and inode numbers\n FILE1 -nt FILE2 " "FILE1 is newer (modification date) than FILE2\n " "FILE1 -ot FILE2 FILE1 is older than FILE2\n"), stdout) ; fputs_unlocked( gettext("\n -b FILE FILE exists and is block special\n -c FILE " " FILE exists and is character special\n -d FILE FILE " "exists and is a directory\n -e FILE FILE exists\n"), stdout) ; fputs_unlocked( gettext(" -f FILE FILE exists and is a regular file\n -g FILE " " FILE exists and is set-group-ID\n -G FILE FILE exists " "and is owned by the effective group ID\n -h FILE FILE " "exists and is a symbolic link (same as -L)\n -k FILE " "FILE exists and has its sticky bit set\n"), stdout) ; fputs_unlocked( gettext( " -L FILE FILE exists and is a symbolic link (same as -h)\n " "-N FILE FILE exists and has been modified since it was last " "read\n -O FILE FILE exists and is owned by the effective " "user ID\n -p FILE FILE exists and is a named pipe\n -r FILE " " FILE exists and the user has read access\n -s FILE FILE " "exists and has a size greater than zero\n"), stdout) ; fputs_unlocked( gettext(" -S FILE FILE exists and is a socket\n -t FD file " "descriptor FD is opened on a terminal\n -u FILE FILE " "exists and its set-user-ID bit is set\n -w FILE FILE " "exists and the user has write access\n -x FILE FILE " "exists and the user has execute (or search) access\n"), stdout) ; fputs_unlocked( gettext("\nExcept for -h and -L, all FILE-related tests dereference " "symbolic links.\nBeware that parentheses need to be escaped " "(e.g., by backslashes) for shells.\nINTEGER may also be -l " "STRING, which evaluates to the length of STRING.\n"), stdout) ; fputs_unlocked( gettext( "\nNOTE: Binary -a and -o are inherently ambiguous. Use 'test " "EXPR1 && test\nEXPR2' or 'test EXPR1 || test EXPR2' instead.\n"), stdout) ; fputs_unlocked(gettext("\nNOTE: [ honors the --help and --version options, " "but test does not.\ntest treats each of those as " "it treats any other nonempty STRING.\n"), stdout) ; printf(gettext("\n" "NOTE: your shell may have its own version of %s, which " "usually supersedes\n" "the version described here. Please refer to your shell's " "documentation\n" "for details about the options it supports.\n"), gettext("test and/or [")); emit_ancillary_info("test"); } exit(status); }
void usage(int a1) { long v1; char *v2; FILE *v3; char *v4; FILE *v5; char *v6; FILE *v7; char *v8; FILE *v9; char *v10; FILE *v11; char *v12; FILE *v13; char *v14; FILE *v15; char *v16; FILE *v17; char *v18; FILE *v19; char *v20; FILE *v21; char *v22; FILE *v23; char *v24; FILE *v25; char *v26; FILE *v27; char *v28; FILE *v29; char *v30; FILE *v31; char *v32; FILE *v33; char *v34; char *v35; char *v36; if (a1) { v1 = program_name; v2 = gettext("Try '%s --help' for more information.\n"); fprintf(stderr, v2, v1); } else { v3 = stdout; v4 = gettext("Usage: test EXPRESSION\n or: test\n or: [ EXPRESSION ]\n " " or: [ ]\n or: [ OPTION\n"); fputs_unlocked(v4, v3); v5 = stdout; v6 = gettext("Exit with the status determined by EXPRESSION.\n\n"); fputs_unlocked(v6, v5); v7 = stdout; v8 = gettext(" --help display this help and exit\n"); fputs_unlocked(v8, v7); v9 = stdout; v10 = gettext(" --version output version information and exit\n"); fputs_unlocked(v10, v9); v11 = stdout; v12 = gettext( "\n" "An omitted EXPRESSION defaults to false. Otherwise,\n" "EXPRESSION is true or false and sets exit status. It is one of:\n"); fputs_unlocked(v12, v11); v13 = stdout; v14 = gettext("\n" " ( EXPRESSION ) EXPRESSION is true\n" " ! EXPRESSION EXPRESSION is false\n" " EXPRESSION1 -a EXPRESSION2 both EXPRESSION1 and " "EXPRESSION2 are true\n" " EXPRESSION1 -o EXPRESSION2 either EXPRESSION1 or " "EXPRESSION2 is true\n"); fputs_unlocked(v14, v13); v15 = stdout; v16 = gettext("\n" " -n STRING the length of STRING is nonzero\n" " STRING equivalent to -n STRING\n" " -z STRING the length of STRING is zero\n" " STRING1 = STRING2 the strings are equal\n" " STRING1 != STRING2 the strings are not equal\n"); fputs_unlocked(v16, v15); v17 = stdout; v18 = gettext( "\n" " INTEGER1 -eq INTEGER2 INTEGER1 is equal to INTEGER2\n" " INTEGER1 -ge INTEGER2 INTEGER1 is greater than or equal to " "INTEGER2\n" " INTEGER1 -gt INTEGER2 INTEGER1 is greater than INTEGER2\n" " INTEGER1 -le INTEGER2 INTEGER1 is less than or equal to INTEGER2\n" " INTEGER1 -lt INTEGER2 INTEGER1 is less than INTEGER2\n" " INTEGER1 -ne INTEGER2 INTEGER1 is not equal to INTEGER2\n"); fputs_unlocked(v18, v17); v19 = stdout; v20 = gettext( "\n" " FILE1 -ef FILE2 FILE1 and FILE2 have the same device and inode " "numbers\n" " FILE1 -nt FILE2 FILE1 is newer (modification date) than FILE2\n" " FILE1 -ot FILE2 FILE1 is older than FILE2\n"); fputs_unlocked(v20, v19); v21 = stdout; v22 = gettext("\n" " -b FILE FILE exists and is block special\n" " -c FILE FILE exists and is character special\n" " -d FILE FILE exists and is a directory\n" " -e FILE FILE exists\n"); fputs_unlocked(v22, v21); v23 = stdout; v24 = gettext( " -f FILE FILE exists and is a regular file\n" " -g FILE FILE exists and is set-group-ID\n" " -G FILE FILE exists and is owned by the effective group ID\n" " -h FILE FILE exists and is a symbolic link (same as -L)\n" " -k FILE FILE exists and has its sticky bit set\n"); fputs_unlocked(v24, v23); v25 = stdout; v26 = gettext( " -L FILE FILE exists and is a symbolic link (same as -h)\n" " -N FILE FILE exists and has been modified since it was last " "read\n" " -O FILE FILE exists and is owned by the effective user ID\n" " -p FILE FILE exists and is a named pipe\n" " -r FILE FILE exists and the user has read access\n" " -s FILE FILE exists and has a size greater than zero\n"); fputs_unlocked(v26, v25); v27 = stdout; v28 = gettext(" -S FILE FILE exists and is a socket\n" " -t FD file descriptor FD is opened on a terminal\n" " -u FILE FILE exists and its set-user-ID bit is set\n" " -w FILE FILE exists and the user has write access\n" " -x FILE FILE exists and the user has execute (or " "search) access\n"); fputs_unlocked(v28, v27); v29 = stdout; v30 = gettext("\n" "Except for -h and -L, all FILE-related tests dereference " "symbolic links.\n" "Beware that parentheses need to be escaped (e.g., by " "backslashes) for shells.\n" "INTEGER may also be -l STRING, which evaluates to the " "length of STRING.\n"); fputs_unlocked(v30, v29); v31 = stdout; v32 = gettext("\n" "NOTE: Binary -a and -o are inherently ambiguous. Use 'test " "EXPR1 && test\n" "EXPR2' or 'test EXPR1 || test EXPR2' instead.\n"); fputs_unlocked(v32, v31); v33 = stdout; v34 = gettext( "\n" "NOTE: [ honors the --help and --version options, but test does not.\n" "test treats each of those as it treats any other nonempty STRING.\n"); fputs_unlocked(v34, v33); v35 = gettext("test and/or ["); v36 = gettext("\n" "NOTE: your shell may have its own version of %s, which " "usually supersedes\n" "the version described here. Please refer to your shell's " "documentation\n" "for details about the options it supports.\n"); printf(v36, v35); emit_ancillary_info("test"); } exit(a1); }
coreutils
ida
void reap_procsubs() { reap_some_procsubs(totfds); }
long long reap_procsubs() { return reap_some_procsubs(totfds); }
bash
angr_sailr
void namebuf_free(namebuf_t buf) { free(buf->buffer); free(buf); }
long long namebuf_free(unsigned long long *a0) { free(*(a0)); return free(a0); }
tar
angr_dream
sshbuf_ptr(key->sk_key_handle), sshbuf_len(key->sk_key_handle), key->sk_flags, pin, opts, &resp)) != 0) { sshlog("ssh-sk.c", __func__, 686, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0), "sk_sign failed with code %d", r); r = skerr_to_ssherr(r); goto out; }
void sshbuf_ptr(void) { halt_baddata(); }
openssh-portable
ghidra