input
stringlengths
26
172k
output
stringlengths
18
318k
repo_name
stringclasses
23 values
decompiler
stringclasses
5 values
static int strcompare(p, pe, s, se) unsigned char *p, *pe, *s, *se; { int ret; unsigned char c1, c2; int l1, l2; l1 = pe - p; l2 = se - s; if (l1 != l2) return (1); c1 = *pe; c2 = *se; if (c1 != 0) *pe = '\0'; if (c2 != 0) *se = '\0'; ret = strcoll(((char *)p), ((char *)s)); if (c1 != 0) *pe = c1; if (c2 != 0) *se = c2; return (ret == 0 ? ret : 1); }
void strcompare(char *a0, char *a1, char *a2, char *a3) { char v0; char v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned long long v6; unsigned long v7; v2 = a1 - a0; v3 = a3 - a2; if (v2 != v3) { v6 = 1; } else { v0 = *(a1); v1 = *(a3); if (v0) *(a1) = 0; if (v1) *(a3) = 0; v4 = strcoll(a0, a2); if (v0) *(a1) = v0; if (v1) *(a3) = v1; v7 = v4; } return; }
bash
angr_dream
static void bufmap_free(struct bufmap *mark) { struct bufmap *map; for (map = bufmap_head; map && map != mark;) { struct bufmap *next = map->next; free(map->file_name); free(map); map = next; } bufmap_head = map; if (!bufmap_head) bufmap_tail = bufmap_head; }
void bufmap_free(unsigned long a0) { unsigned long long v0[3]; unsigned long long v1[3]; unsigned long long v3[3]; unsigned long long v4[3]; for (v0[0] = bufmap_head; v0; v0[0] = v1) { if (v0 == a0) break; v1[0] = v0[0]; free(v0[2]); free(v0); } bufmap_head[0] = v0; v3 = bufmap_head; if (!bufmap_head) { v4 = bufmap_head; bufmap_tail[0] = bufmap_head; } return; }
tar
angr_dream
int commandfd(const char *const *argv) { struct varbuf linevb = {0, 0, ((void *)0)}; const char *pipein; const char **newargs = ((void *)0), **endargs; char *ptr, *endptr; FILE *in; long infd; int ret = 0; int c, lno, i; _Bool skipchar; pipein = *argv++; if (pipein == ((void *)0) || *argv) badusage(gettext("--%s takes exactly one argument"), cipaction->olong); infd = dpkg_options_parse_arg_int(cipaction, pipein); in = fdopen(infd, "r"); if (in == ((void *)0)) ohshite(gettext("couldn't open '%i' for stream"), (int)infd); for (;;) { _Bool mode = 0; int argc = 1; lno = 0; push_error_context(); do { c = getc(in); if (c == '\n') lno++; } while (c != (-1) && c_isspace(c)); if (c == (-1)) break; if (c == '#') { do { c = getc(in); if (c == '\n') lno++; } while (c != (-1) && c != '\n'); continue; } varbuf_reset(&linevb); do { varbuf_add_char(&linevb, c); c = getc(in); if (c == '\n') lno++; if (c_isspace(c)) argc++; } while (c != (-1) && c != '\n'); if (c == (-1)) ohshit(gettext("unexpected end of file before end of line %d"), lno); if (!argc) continue; varbuf_end_str(&linevb); newargs = m_realloc(newargs, sizeof(const char *) * (argc + 1)); argc = 1; ptr = linevb.buf; endptr = ptr + linevb.used + 1; skipchar = 0; while (ptr < endptr) { if (skipchar) { skipchar = 0; } else if (*ptr == '\\') { memmove(ptr, (ptr + 1), (linevb.used - (linevb.buf - ptr) - 1)); endptr--; skipchar = 1; continue; } else if (c_isspace(*ptr)) { if (mode == 1) { *ptr = '\0'; mode = 0; } } else { if (mode == 0) { newargs[argc] = ptr; argc++; mode = 1; } } ptr++; } *ptr = '\0'; newargs[argc++] = ((void *)0); for (i = 1; i < argc; i++) if (newargs[i]) newargs[i] = m_strdup(newargs[i]); endargs = newargs; setaction(((void *)0), ((void *)0)); dpkg_options_parse((const char *const **)&endargs, cmdinfos, printforhelp); if (!cipaction) badusage(gettext("need an action option")); ret |= cipaction->action(endargs); fsys_hash_reset(); pop_error_context(ehflag_normaltidy); } fclose(in); return ret; }
uint commandfd(long *param_1) { undefined8 *puVar1; bool bVar2; bool bVar3; char cVar4; int iVar5; uint uVar6; undefined8 uVar7; undefined8 uVar8; ulong uVar9; long in_FS_OFFSET; uint local_84; int local_80; int local_78; int local_74; long local_70; long local_68; char *local_60; char *local_58; long local_50; ulong local_48; FILE *local_40; long local_38; undefined8 local_30; char *local_28; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_38 = 0; local_30 = 0; local_28 = (char *)0x0; local_68 = 0; local_84 = 0; local_50 = *param_1; if ((local_50 == 0) || (param_1[1] != 0)) { uVar8 = *cipaction; uVar7 = gettext("--%s takes exactly one argument"); badusage(uVar7, uVar8); } local_48 = dpkg_options_parse_arg_int(cipaction, local_50); local_40 = fdopen((int)local_48, "r"); if (local_40 == (FILE *)0x0) { uVar9 = local_48 & 0xffffffff; uVar8 = gettext("couldn\'t open \'%i\' for stream"); ohshite(uVar8, uVar9); } LAB_00100d11: do { bVar3 = false; local_74 = 1; push_error_context(); do { local_80 = getc(local_40); if (local_80 == -1) break; cVar4 = c_isspace(local_80); } while (cVar4 != '\0'); if (local_80 == -1) { fclose(local_40); if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return local_84; } if (local_80 == 0x23) { do { iVar5 = getc(local_40); if (iVar5 == -1) break; } while (iVar5 != 10); goto LAB_00100d11; } varbuf_reset(&local_38); do { varbuf_add_char(&local_38, local_80); local_80 = getc(local_40); cVar4 = c_isspace(local_80); if (cVar4 != '\0') { local_74 = local_74 + 1; } } while ((local_80 != -1) && (local_80 != 10)); if (local_80 == -1) { uVar8 = gettext("unexpected end of file before end of line %d"); ohshit(uVar8); } if (local_74 != 0) { varbuf_end_str(&local_38); local_68 = m_realloc(local_68, (long)(local_74 + 1) * 8); local_74 = 1; local_60 = local_28; local_58 = local_28 + local_38 + 1; bVar2 = false; while (local_60 < local_58) { if (bVar2) { bVar2 = false; LAB_00100f1a: local_60 = local_60 + 1; } else { if (*local_60 != '\\') { cVar4 = c_isspace((int)*local_60); if (cVar4 == '\0') { if (!bVar3) { *(char **)((long)local_74 * 8 + local_68) = local_60; local_74 = local_74 + 1; bVar3 = true; } } else if (bVar3) { *local_60 = '\0'; bVar3 = false; } goto LAB_00100f1a; } memmove(local_60, local_60 + 1, (local_38 - ((long)local_28 - (long)local_60)) - 1); local_58 = local_58 + -1; bVar2 = true; } } *local_60 = '\0'; *(undefined8 *)(local_68 + (long)local_74 * 8) = 0; for (local_78 = 1; local_78 < local_74 + 1; local_78 = local_78 + 1) { if (*(long *)(local_68 + (long)local_78 * 8) != 0) { puVar1 = (undefined8 *)((long)local_78 * 8 + local_68); uVar8 = m_strdup(*(undefined8 *)(local_68 + (long)local_78 * 8)); *puVar1 = uVar8; } } local_70 = local_68; setaction(0, 0); dpkg_options_parse( &local_70, cmdinfos, "Type dpkg --help for help about installing and deinstalling " "packages [*];\nUse \'apt\' or \'aptitude\' for user-friendly " "package management;\nType dpkg -Dhelp for a list of dpkg debug flag " "values;\nType dpkg --force-help for a list of forcing " "options;\nType dpkg-deb --help for help about manipulating *.deb " "files;\n\nOptions marked [*] produce a lot of output - pipe it " "through \'less\' or \'more\' !"); if (cipaction == (undefined8 *)0x0) { uVar8 = gettext("need an action option"); badusage(uVar8); } uVar6 = (*(code *)cipaction[7])(local_70); local_84 = local_84 | uVar6; fsys_hash_reset(); pop_error_context(1); } } while (true); }
dpkg
ghidra
static void KeyGen(Fq *h, small *f, small *ginv) { small g[761]; Fq finv[761]; for (;;) { Small_random(g); if (R3_recip(ginv, g) == 0) break; } Short_random(f); Rq_recip3(finv, f); Rq_mult_small(h, finv, g); }
void KeyGen(unsigned short *a0, unsigned long a1, unsigned int a2) { char v0; char v1; char v2; unsigned long long *v4; unsigned long long v5; do { Small_random(&v1); } while (R3_recip(a2, &v1, &v1)); Short_random(a1); Rq_recip3(&v0, a1, a1); Rq_mult_small(a0, &v0, &v1); v5 = *(&v2) ^ v4[5]; return; }
openssh-portable
angr_phoenix
static void tls_log_func(int level, const char *str) { fprintf(stderr, "|<%d>| %s", level, str); }
long long tls_log_func(unsigned long a0, unsigned long a1) { return fprintf(stderr, "|<%d>| %s", a0, a1); }
gnutls
angr_dream
int crypto_sign_ed25519_ref_sc25519_lt_vartime( const crypto_sign_ed25519_ref_sc25519 *x, const crypto_sign_ed25519_ref_sc25519 *y) { int i; for (i = 31; i >= 0; i--) { if (x->v[i] < y->v[i]) return 1; if (x->v[i] > y->v[i]) return 0; } return 0; }
long long crypto_sign_ed25519_ref_sc25519_lt_vartime(unsigned int *a0, unsigned int *a1) { unsigned int v0; unsigned long long v2; v0 = 31; while (true) { if (v0 < 0) { v2 = 0; break; } else if (a0[v0] < a1[v0]) { v2 = 1; break; } else if (a0[v0] <= a1[v0]) { v0 = __addvsi3(v0, 0xffffffff, v0); } else { v2 = 0; break; } } return v2; }
openssh-portable
angr_phoenix
static _Bool perm_related_errno(int err) { return err == 13 || err == 1; }
_BOOL8 perm_related_errno(int a1) { return a1 == 13 || a1 == 1; }
coreutils
ida
int sshkey_shield_private(struct sshkey *k) { struct sshbuf *prvbuf = ((void *)0); u_char *prekey = ((void *)0), *enc = ((void *)0), keyiv[64]; struct sshcipher_ctx *cctx = ((void *)0); const struct sshcipher *cipher; size_t i, enclen = 0; struct sshkey *kswap = ((void *)0), tmp; int r = -1; if ((cipher = cipher_by_name("aes256-ctr")) == ((void *)0)) { r = -10; goto out; } if (cipher_keylen(cipher) + cipher_ivlen(cipher) > ssh_digest_bytes(4)) { r = -1; goto out; } if ((prekey = malloc((16 * 1024))) == ((void *)0)) { r = -2; goto out; } arc4random_buf(prekey, (16 * 1024)); if ((r = ssh_digest_memory(4, prekey, (16 * 1024), keyiv, 64)) != 0) goto out; if ((r = cipher_init(&cctx, cipher, keyiv, cipher_keylen(cipher), keyiv + cipher_keylen(cipher), cipher_ivlen(cipher), 1)) != 0) goto out; if ((prvbuf = sshbuf_new()) == ((void *)0)) { r = -2; goto out; } if (sshkey_is_shielded(k) && (r = sshkey_unshield_private(k)) != 0) goto out; if ((r = sshkey_private_serialize_opt(k, prvbuf, SSHKEY_SERIALIZE_SHIELD)) != 0) goto out; i = 0; while (sshbuf_len(prvbuf) % cipher_blocksize(cipher)) { if ((r = sshbuf_put_u8(prvbuf, ++i & 0xff)) != 0) goto out; } enclen = sshbuf_len(prvbuf); if ((enc = malloc(enclen)) == ((void *)0)) { r = -2; goto out; } if ((r = cipher_crypt(cctx, 0, enc, sshbuf_ptr(prvbuf), sshbuf_len(prvbuf), 0, 0)) != 0) goto out; if ((r = sshkey_from_private(k, &kswap)) != 0) goto out; tmp = *kswap; *kswap = *k; *k = tmp; k->shielded_private = enc; k->shielded_len = enclen; k->shield_prekey = prekey; k->shield_prekey_len = (16 * 1024); enc = prekey = ((void *)0); enclen = 0; k->sk_flags = kswap->sk_flags; r = 0; out: cipher_free(cctx); explicit_bzero(keyiv, sizeof(keyiv)); explicit_bzero(&tmp, sizeof(tmp)); freezero(enc, enclen); freezero(prekey, (16 * 1024)); sshkey_free(kswap); sshbuf_free(prvbuf); return r; }
int sshkey_shield_private(struct_0 *a0) { void *v0; int tmp_215; int tmp_225; int tmp_237; int tmp_249; int tmp_261; int tmp_273; int tmp_285; int tmp_297; int tmp_75; struct_0 *v1; unsigned int v2; void *v3; void *v4; void *v5; void *v6; void *v7; void *v8; void *v9; unsigned long long v10; unsigned long v11; unsigned long v12; unsigned long v13; unsigned long v14; unsigned long v15; unsigned long v16; unsigned long v17; unsigned long v18; unsigned long v19; unsigned long v20; unsigned long v21; unsigned long v22; unsigned long v23; unsigned long v24; unsigned long v25; unsigned long v26; unsigned long v27; unsigned long v28; unsigned long v29; unsigned long v30; unsigned long v31; char v32; unsigned long long v35; void *v36; struct_0 *v37; unsigned long long v38; v1 = a0; v5 = 0; v6 = 0; v7 = 0; v3 = 0; v9 = 0; v4 = 0; v2 = -1; v10 = cipher_by_name("aes256-ctr"); if (!v10) { v2 = -10; } else if (cipher_ivlen(v10) + cipher_keylen(v10) > ssh_digest_bytes(0x4)) { v2 = -1; } else { v6 = malloc(0x4000); if (!v6) { v2 = -2; } else { arc4random_buf(v6, 0x4000); v2 = ssh_digest_memory(0x4, v6, 0x4000, &v32, 0x40); if (!v2) { v35 = &(&v32)[cipher_keylen(v10)]; v0 = 1; v2 = cipher_init(&v3, v10, &v32, cipher_keylen(v10), v35, cipher_ivlen(v10)); if (!v2) { v5 = sshbuf_new(); if (!v5) { v2 = -2; } else { if (sshkey_is_shielded(a0)) { v2 = sshkey_unshield_private(a0); if (!(!v2)) goto LABEL_404956; } v2 = sshkey_private_serialize_opt(a0, v5, 0x3, v5); if (!v2) { v8 = 0; do { if (!(0 CONCAT sshbuf_len(v5)) / m cipher_blocksize(v10) >> 64) { v9 = sshbuf_len(v5); v7 = malloc(v9); if (!v7) { v2 = -2; break; } else { v0 = 0; v2 = cipher_crypt(v3, 0x0, v7, sshbuf_ptr(v5), sshbuf_len(v5), 0x0); if (!v2) { v2 = sshkey_from_private(a0, &v4); if (!v2) { v11 = *(v4); v12 = v4[8]; v13 = v4[16]; v14 = v4[24]; v15 = v4[32]; v16 = v4[40]; v17 = v4[48]; v18 = v4[56]; v19 = v4[64]; v20 = v4[72]; v21 = v4[80]; v22 = v4[88]; v23 = v4[96]; v24 = v4[104]; v25 = v4[112]; v26 = v4[120]; v27 = v4[128]; v28 = v4[136]; v29 = v4[144]; v30 = v4[152]; v31 = v4[160]; v36 = v4; v37 = a0; tmp_215 = a0->field_8; *(v4) = a0->field_0; *(&v4[8]) = tmp_215; tmp_225 = a0->field_18; *(&v4[16]) = a0->field_10; *(&v4[24]) = tmp_225; tmp_237 = a0->field_28; *(&v4[32]) = a0->field_20; *(&v4[40]) = tmp_237; tmp_249 = a0->field_38; *(&v4[48]) = a0->field_30; *(&v4[56]) = tmp_249; tmp_261 = a0->field_48; *(&v4[64]) = a0->field_40; *(&v4[72]) = tmp_261; tmp_273 = a0->field_58; *(&v4[80]) = a0->field_50; *(&v4[88]) = tmp_273; tmp_285 = *(&a0->field_68); *(&v4[96]) = a0->field_60; *(&v4[104]) = tmp_285; tmp_297 = a0->field_78; *(&v4[112]) = a0->field_70; *(&v4[120]) = tmp_297; v38 = a0->field_88; *(&v36[128]) = a0->field_80; *(&v36[136]) = v38; tmp_75 = v37->field_98; *(&v36[144]) = v37->field_90; *(&v36[152]) = tmp_75; *(&v36[160]) = v37->field_a0; a0->field_0 = v11; a0->field_8 = v12; a0->field_10 = v13; a0->field_18 = v14; a0->field_20 = v15; a0->field_28 = v16; a0->field_30 = v17; a0->field_38 = v18; a0->field_40 = v19; a0->field_48 = v20; a0->field_50 = v21; a0->field_58 = v22; a0->field_60 = v23; *(&a0->field_68) = v24; a0->field_70 = v25; a0->field_78 = v26; a0->field_80 = v27; a0->field_88 = v28; a0->field_90 = v29; a0->field_98 = v30; a0->field_a0 = v31; a0->field_88 = v7; a0->field_90 = v9; a0->field_98 = v6; a0->field_a0 = 0x4000; v6 = 0; v7 = v6; v9 = 0; a0->field_68 = v4[104]; v2 = 0; break; } } } } v8 += 1; v2 = sshbuf_put_u8(v5, v8, v8); } while (!v2); } } } } } } LABEL_404956: cipher_free(v3); explicit_bzero(&v32, 0x40); explicit_bzero(&v11, 0xa8); freezero(v7, v9); freezero(v6, 0x4000); sshkey_free(v4); sshbuf_free(v5); return v2; }
openssh-portable
angr_phoenix
static void get_serial_value(unsigned char *serial, size_t *size, const unsigned char *config, size_t config_size, int(create_default)(unsigned char *, size_t *), const char *label, const char *rfc_section) { size_t max_size = *size; int ret; if (batch && config != ((void *)0)) { if (config_size > max_size) { fprintf(stderr, "maximum %zu octets allowed for %s!\n", max_size, label); exit(1); } memcpy(serial, config, config_size); *size = config_size; } else { ret = create_default(serial, size); if (ret < 0) { fprintf(stderr, "error generating default %s: %s\n", label, gnutls_strerror(ret)); exit(1); } } if (!batch) read_serial_value(serial, size, max_size, label, rfc_section); if ((*size == 20 && serial[0] & 0x80) || *size > 20) { fprintf(stderr, "%s would be encoded in more than 20 bytes," "see RFC 5280, section %s\n", label, rfc_section); exit(1); } }
void get_serial_value(char *param_1, ulong *param_2, void *param_3, size_t param_4, code *param_5, undefined8 param_6, undefined8 param_7) { ulong uVar1; int iVar2; uVar1 = *param_2; if ((*piRam0000000000106e0d == 0) || (param_3 == (void *)0x0)) { iVar2 = (*param_5)(param_1, param_2); if (iVar2 < 0) { gnutls_strerror(iVar2); } } else { if (uVar1 < param_4) { fprintf(*ppFRam0000000000106e2b, "maximum %zu octets allowed for %s!\n", uVar1, param_6); } memcpy(param_1, param_3, param_4); *param_2 = param_4; } if (*piRam0000000000106ed5 == 0) { read_serial_value(param_1, param_2, uVar1, param_6, param_7); } if (((*param_2 != 0x14) || (-1 < *param_1)) && (*param_2 < 0x15)) { return; } fprintf( *ppFRam0000000000106f23, "%s would be encoded in more than 20 bytes,see RFC 5280, section %s\n", param_6, param_7); }
gnutls
ghidra
static int key_print_wrapper(struct sshkey *hostkey, struct ssh *ssh) { con *c; if ((c = ssh_get_app_data(ssh)) != ((void *)0)) keyprint(c, hostkey); return -1; }
undefined8 key_print_wrapper(undefined8 param_1, undefined8 param_2) { long lVar1; lVar1 = ssh_get_app_data(param_2); if (lVar1 != 0) { keyprint(lVar1, param_1); } return 0xffffffff; }
openssh-portable
ghidra
int rl_vi_prev_word(int count, int key) { if (count < 0) return (rl_vi_next_word(-count, key)); if (rl_point == 0) { rl_ding(); return (0); } if ((1 && (1 && ((*__ctype_b_loc())[(int)(((unsigned char)key))] & (unsigned short int)_ISupper)))) rl_vi_bWord(count, key); else rl_vi_bword(count, key); return (0); }
long long rl_vi_prev_word(unsigned long a0, unsigned long a1) { unsigned int v0; void *v2; unsigned int v4; v0 = a0; if (a0 < 0) { v2 = rl_vi_next_word(-(v0), a1); return v2; } else if (rl_point) { v4 = *((*(__ctype_b_loc()) + a1 * 2)) & 0x100; if (!v4) { rl_vi_bword(a0, a1); v2 = 0; return v2; } rl_vi_bWord(a0, a1); v2 = 0; return v2; } else { rl_ding(); v2 = 0; return v2; } }
bash
angr_sailr
static inline __u64 rta_getattr_u64(const struct rtattr *rta) { __u64 tmp; memcpy(&tmp, ((void *)(((char *)(rta)) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))), sizeof(__u64)); return tmp; }
int rta_getattr_u64(unsigned long a0) { char v0; memcpy(&v0, a0 + 4, 0x8); return *(&v0); }
iproute2-6.0.0
angr_sailr
static void replace_control_chars(char *cell) { char *p = cell; while (*p) { if (c_iscntrl(to_uchar(*p))) *p = '?'; p++; } }
void replace_control_chars(unsigned long a0) { char *v0; unsigned long long v2; v0 = a0; while (true) { v2 = *(v0); if (!*(v0)) break; if (c_iscntrl(to_uchar(*(v0)))) *(v0) = 63; v0 += 1; } return; }
coreutils
angr_dream
static void explain(struct link_util *lu) { print_explain(lu, stderr); }
int explain(long a1) { return print_explain(a1, stderr); }
iproute2-6.0.0
ida
void usage(int status) { if (status != 0) do { fprintf(stderr, gettext("Try '%s --help' for more information.\n"), program_name); } while (0); else { printf(gettext("Usage: %s [OPTION]... FILE...\n"), program_name); fputs_unlocked(gettext("Overwrite the specified FILE(s) repeatedly, in " "order to make it harder\nfor even very expensive " "hardware probing to recover the data.\n"), stdout) ; fputs_unlocked(gettext("\nIf FILE is -, shred standard output.\n"), stdout) ; emit_mandatory_arg_note(); printf(gettext(" -f, --force change permissions to allow writing if " "necessary\n -n, --iterations=N overwrite N times instead " "of the default (%d)\n --random-source=FILE get " "random bytes from FILE\n -s, --size=N shred this many " "bytes (suffixes like K, M, G accepted)\n") , DEFAULT_PASSES); fputs_unlocked( gettext( " -u deallocate and remove file after overwriting\n " " --remove[=HOW] like -u but give control on HOW to delete; " "See below\n -v, --verbose show progress\n -x, --exact do " "not round file sizes up to the next full block;\n " " this is the default for non-regular files\n -z, --zero add " "a final overwrite with zeros to hide shredding\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( "\nDelete FILE(s) if --remove (-u) is specified. The default is " "not to remove\nthe files because it is common to operate on " "device files like /dev/hda,\nand those files usually should not " "be removed.\nThe optional HOW parameter indicates how to remove a " "directory entry:\n'unlink' => use a standard unlink call.\n'wipe' " "=> also first obfuscate bytes in the name.\n'wipesync' => also " "sync each obfuscated byte to the device.\nThe default mode is " "'wipesync', but note it can be expensive.\n\n"), stdout); fputs_unlocked( gettext( "CAUTION: shred assumes the file system and hardware overwrite " "data in place.\nAlthough this is common, many platforms operate " "otherwise. Also, backups\nand mirrors may contain unremovable " "copies that will let a shredded file\nbe recovered later. See " "the GNU coreutils manual for details.\n"), stdout) ; emit_ancillary_info("shred"); } exit(status); }
void usage(int param_1) { FILE *pFVar1; undefined8 uVar2; char *pcVar3; uVar2 = program_name; if (param_1 == 0) { pcVar3 = (char *)gettext("Usage: %s [OPTION]... FILE...\n"); printf(pcVar3, uVar2); pFVar1 = stdout; pcVar3 = (char *)gettext("Overwrite the specified FILE(s) repeatedly, in " "order to make it harder\nfor even very expensive " "hardware probing to recover the data.\n"); fputs_unlocked(pcVar3, pFVar1); pFVar1 = stdout; pcVar3 = (char *)gettext("\nIf FILE is -, shred standard output.\n"); fputs_unlocked(pcVar3, pFVar1); emit_mandatory_arg_note(); pcVar3 = (char *)gettext( " -f, --force change permissions to allow writing if necessary\n " "-n, --iterations=N overwrite N times instead of the default (%d)\n " " --random-source=FILE get random bytes from FILE\n -s, --size=N " "shred this many bytes (suffixes like K, M, G accepted)\n"); printf(pcVar3, 3); pFVar1 = stdout; pcVar3 = (char *)gettext( " -u deallocate and remove file after overwriting\n " "--remove[=HOW] like -u but give control on HOW to delete; See " "below\n -v, --verbose show progress\n -x, --exact do not round " "file sizes up to the next full block;\n this is the " "default for non-regular files\n -z, --zero add a final overwrite " "with zeros to hide shredding\n"); fputs_unlocked(pcVar3, pFVar1); pFVar1 = stdout; pcVar3 = (char *)gettext(" --help display this help and exit\n"); fputs_unlocked(pcVar3, pFVar1); pFVar1 = stdout; pcVar3 = (char *)gettext( " --version output version information and exit\n"); fputs_unlocked(pcVar3, pFVar1); pFVar1 = stdout; pcVar3 = (char *)gettext( "\nDelete FILE(s) if --remove (-u) is specified. The default is not " "to remove\nthe files because it is common to operate on device files " "like /dev/hda,\nand those files usually should not be removed.\nThe " "optional HOW parameter indicates how to remove a directory " "entry:\n\'unlink\' => use a standard unlink call.\n\'wipe\' => also " "first obfuscate bytes in the name.\n\'wipesync\' => also sync each " "obfuscated byte to the device.\nThe default mode is \'wipesync\', but " "note it can be expensive.\n\n"); fputs_unlocked(pcVar3, pFVar1); pFVar1 = stdout; pcVar3 = (char *)gettext( "CAUTION: shred assumes the file system and hardware overwrite data in " "place.\nAlthough this is common, many platforms operate otherwise. " "Also, backups\nand mirrors may contain unremovable copies that will " "let a shredded file\nbe recovered later. See the GNU coreutils " "manual for details.\n"); fputs_unlocked(pcVar3, pFVar1); emit_ancillary_info(); } else { pcVar3 = (char *)gettext("Try \'%s --help\' for more information.\n"); fprintf(stderr, pcVar3, uVar2); } exit(param_1); }
coreutils
ghidra
void *assoc_replace(hash, key, value) HASH_TABLE *hash; char *key; char *value; { BUCKET_CONTENTS *b; void *t; b = hash_search(key, hash, 0x02); if (b == 0) return (void *)0; if (b->key != key) sh_xfree((key), "assoc.c", 107); t = b->data; b->data = value ? (char *)strcpy(sh_xmalloc((1 + strlen(value)), "assoc.c", 109), (value)) : (char *)0; return t; }
long assoc_replace(long a1, long a2, const char *a3) { size_t v4; char *v5; char *v6; long v8; long v9; v8 = hash_search(a2, a1, 2LL); if (!v8) return 0LL; if (a2 != *(_QWORD *)(v8 + 8)) sh_xfree(a2, "assoc.c", 107LL); v9 = *(_QWORD *)(v8 + 16); if (a3) { v4 = strlen(a3); v5 = (char *)sh_xmalloc(v4 + 1, "assoc.c", 109LL); v6 = strcpy(v5, a3); } else { v6 = 0LL; } *(_QWORD *)(v8 + 16) = v6; return v9; }
bash
ida
int print_addrinfo(struct nlmsghdr *n, void *arg) { FILE *fp = arg; struct ifaddrmsg *ifa = ((void *)(((char *)n) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))))); int len = n->nlmsg_len; unsigned int ifa_flags; struct rtattr *rta_tb[(__IFA_MAX - 1) + 1]; char b1[64]; if (n->nlmsg_type != RTM_NEWADDR && n->nlmsg_type != RTM_DELADDR) return 0; len -= ((sizeof(*ifa)) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1)))); if (len < 0) { fprintf(stderr, "BUG: wrong nlmsg len %d\n", len); return -1; } if (filter.flushb && n->nlmsg_type != RTM_NEWADDR) return 0; parse_rtattr( rta_tb, (__IFA_MAX - 1), ((struct rtattr *)(((char *)(ifa)) + (((sizeof(struct ifaddrmsg)) + 4U - 1) & ~(4U - 1)))), n->nlmsg_len - ((sizeof(*ifa)) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))))); ifa_flags = get_ifa_flags(ifa, rta_tb[IFA_FLAGS]); if (!rta_tb[IFA_LOCAL]) rta_tb[IFA_LOCAL] = rta_tb[IFA_ADDRESS]; if (!rta_tb[IFA_ADDRESS]) rta_tb[IFA_ADDRESS] = rta_tb[IFA_LOCAL]; if (filter.ifindex && filter.ifindex != ifa->ifa_index) return 0; if ((filter.scope ^ ifa->ifa_scope) & filter.scopemask) return 0; if ((filter.flags ^ ifa_flags) & filter.flagmask) return 0; if (filter.family && filter.family != ifa->ifa_family) return 0; if (ifa_label_match_rta(ifa->ifa_index, rta_tb[IFA_LABEL])) return 0; if (inet_addr_match_rta(&filter.pfx, rta_tb[IFA_LOCAL])) return 0; if (filter.flushb) { struct nlmsghdr *fn; if ((((filter.flushp) + 4U - 1) & ~(4U - 1)) + n->nlmsg_len > filter.flushe) { if (flush_update()) return -1; } fn = (struct nlmsghdr *)(filter.flushb + (((filter.flushp) + 4U - 1) & ~(4U - 1))); memcpy(fn, n, n->nlmsg_len); fn->nlmsg_type = RTM_DELADDR; fn->nlmsg_flags = 0x01; fn->nlmsg_seq = ++rth.seq; filter.flushp = (((char *)fn) + n->nlmsg_len) - filter.flushb; filter.flushed++; if (show_stats < 2) return 0; } if (n->nlmsg_type == RTM_DELADDR) print_bool(PRINT_ANY, "deleted", "Deleted ", 1); if (!brief) { const char *name; if (filter.oneline || filter.flushb) { const char *dev = ll_index_to_name(ifa->ifa_index); if (is_json_context()) { print_int(PRINT_JSON, "index", ((void *)0), ifa->ifa_index); print_string(PRINT_JSON, "dev", ((void *)0), dev); } else { fprintf(fp, "%u: %s", ifa->ifa_index, dev); } } name = family_name(ifa->ifa_family); if (*name != '?') { print_string(PRINT_ANY, "family", " %s ", name); } else { print_int(PRINT_ANY, "family_index", " family %d ", ifa->ifa_family); } } if (rta_tb[IFA_LOCAL]) { print_color_string( PRINT_ANY, ifa_family_color(ifa->ifa_family), "local", "%s", format_host( ifa->ifa_family, ((int)((rta_tb[IFA_LOCAL])->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), ((void *)(((char *)(rta_tb[IFA_LOCAL])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))))); if (rta_tb[IFA_ADDRESS] && memcmp(((void *)(((char *)(rta_tb[IFA_ADDRESS])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))), ((void *)(((char *)(rta_tb[IFA_LOCAL])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))), ifa->ifa_family == 2 ? 4 : 16)) { print_string(PRINT_FP, ((void *)0), " %s ", "peer"); print_color_string( PRINT_ANY, ifa_family_color(ifa->ifa_family), "address", "%s", format_host( ifa->ifa_family, ((int)((rta_tb[IFA_ADDRESS])->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), ((void *)(((char *)(rta_tb[IFA_ADDRESS])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))))); } print_int(PRINT_ANY, "prefixlen", "/%d ", ifa->ifa_prefixlen); if (rta_tb[IFA_RT_PRIORITY]) print_uint(PRINT_ANY, "metric", "metric %u ", rta_getattr_u32(rta_tb[IFA_RT_PRIORITY])); } if (brief) goto brief_exit; if (rta_tb[IFA_BROADCAST]) { print_string(PRINT_FP, ((void *)0), "%s ", "brd"); print_color_string( PRINT_ANY, ifa_family_color(ifa->ifa_family), "broadcast", "%s ", format_host( ifa->ifa_family, ((int)((rta_tb[IFA_BROADCAST])->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), ((void *)(((char *)(rta_tb[IFA_BROADCAST])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))))); } if (rta_tb[IFA_ANYCAST]) { print_string(PRINT_FP, ((void *)0), "%s ", "any"); print_color_string( PRINT_ANY, ifa_family_color(ifa->ifa_family), "anycast", "%s ", format_host( ifa->ifa_family, ((int)((rta_tb[IFA_ANYCAST])->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), ((void *)(((char *)(rta_tb[IFA_ANYCAST])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))))); } print_string(PRINT_ANY, "scope", "scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope, b1, sizeof(b1))); print_ifa_flags(fp, ifa, ifa_flags); if (rta_tb[IFA_LABEL]) print_string(PRINT_ANY, "label", "%s", rta_getattr_str(rta_tb[IFA_LABEL])); if (rta_tb[IFA_CACHEINFO]) { struct ifa_cacheinfo *ci = ((void *)(((char *)(rta_tb[IFA_CACHEINFO])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))); print_nl(); print_string(PRINT_FP, ((void *)0), " valid_lft ", ((void *)0)); if (ci->ifa_valid == 0xFFFFFFFFU) { print_uint(PRINT_JSON, "valid_life_time", ((void *)0), 0xFFFFFFFFU); print_string(PRINT_FP, ((void *)0), "%s", "forever"); } else { print_uint(PRINT_ANY, "valid_life_time", "%usec", ci->ifa_valid); } print_string(PRINT_FP, ((void *)0), " preferred_lft ", ((void *)0)); if (ci->ifa_prefered == 0xFFFFFFFFU) { print_uint(PRINT_JSON, "preferred_life_time", ((void *)0), 0xFFFFFFFFU); print_string(PRINT_FP, ((void *)0), "%s", "forever"); } else { if (ifa_flags & 0x20) print_int(PRINT_ANY, "preferred_life_time", "%dsec", ci->ifa_prefered); else print_uint(PRINT_ANY, "preferred_life_time", "%usec", ci->ifa_prefered); } } print_string(PRINT_FP, ((void *)0), "%s", "\n"); brief_exit: fflush(fp); return 0; }
void print_addrinfo(void *a0, void *a1, unsigned long long a2, unsigned long a3, unsigned long long a4, unsigned long long a5) { struct_1 *v0; unsigned int v1; unsigned int v2; struct_2 *v3; struct_0 *v4; unsigned long long v5; char *v6; unsigned int v7[2]; char v8; unsigned long long v9; unsigned long long v10; char v11; char v12; char v13; char v14; char v15; char v16; char v17; void *v19; unsigned long long v20; void *v21; void *v22; void *v23; void *v24; void *v25; void *v26; void *v27; unsigned long long v28; void *v29; void *v30; v0 = a0; v3 = &v0[2].field_4; v1 = v0->field_0; if (v0->field_4 != 20 && v0->field_4 != 21) { v19 = 0; goto LABEL_405716; } v1 -= 24; if (v1 < 0) { fprintf(stderr, "BUG: wrong nlmsg len %d\n", v1); v20 = 4294967295; } else { if (g_408640 && v0->field_4 != 20) { v21 = 0; goto LABEL_405716; } parse_rtattr(&v8, 0xb, v3 + 1, v0->field_0 - 24); v2 = get_ifa_flags(v3, *(&v15)); if (!v10) v10 = v9; if (!v9) v9 = v10; if (filter && filter != v3->field_4) { v22 = 0; goto LABEL_405716; } if ((g_40861c & (g_408618 ^ v3->field_3))) { v23 = 0; } else if (((g_408620 ^ v2) & g_408624)) { v24 = 0; } else { if (g_408504 && g_408504 != v3->field_0) { v25 = 0; goto LABEL_405716; } if (ifa_label_match_rta(v3->field_4, *(&v11))) { v26 = 0; } else if (inet_addr_match_rta(&g_408510, v10)) { v27 = 0; } else { if (g_408640) { if ((g_408648 + 3 & -0x4) + v0->field_0 > g_40864c && flush_update()) { v28 = 4294967295; goto LABEL_405716; } v4 = (g_408648 + 3 & -0x4) + g_408640; memcpy(v4, v0, v0->field_0); v4->field_4 = 21; v4->field_6 = 1; g_5001ec = g_5001ec + 1; v4->field_8 = g_5001ec; g_408648 = &v4->padding_0[v0->field_0 + -1 * g_408640]; g_408638 = g_408638 + 1; if (show_stats <= 1) { v29 = 0; goto LABEL_405716; } } if (v0->field_4 == 21) print_bool(0x4, "deleted", "Deleted ", 0x1); if (!brief) { if (!g_408508 && !g_408640) goto LABEL_40519b; a0 = v3->field_4; v5 = ll_index_to_name(v3->field_4); if (!is_json_context()) { fprintf(a1, "%u: %s", v3->field_4, v5); } else { print_int(0x2, "index", 0x0, v3->field_4); print_string(0x2, "dev", 0x0, v5); } LABEL_40519b: v6 = family_name(v3->field_0); if (*(v6) == 63) print_int(0x4, "family_index", " family %d ", v3->field_0); else print_string(0x4, "family", " %s ", v6); } if (v10) { a0 = v3->field_0; print_color_string( 0x4, ifa_family_color(v3->field_0), "local", "%s", format_host(v3->field_0, *(v10)-4, v10 + 4, *(v10)-4)); if (v9) { if (v3->field_0 == 2) a2 = 4; else a2 = 16; if (memcmp(v9 + 4, v10 + 4, a2)) { print_string(0x1, 0x0, " %s ", "peer"); a0 = v3->field_0; print_color_string( 0x4, ifa_family_color(v3->field_0), "address", "%s", format_host(v3->field_0, *(v9)-4, v9 + 4, *(v9)-4)); } } print_int(0x4, "prefixlen", "/%d ", v3->field_1); if (*(&v16)) print_uint(0x4, "metric", "metric %u ", rta_getattr_u32(*(&v16))); } if (!brief) { if (*(&v12)) { print_string(0x1, 0x0, "%s ", "brd"); a0 = v3->field_0; print_color_string(0x4, ifa_family_color(v3->field_0), "broadcast", "%s ", format_host(v3->field_0, *(*(&v12)) - 4, *(&v12) + 4, *(*(&v12)) - 4)); } if (*(&v13)) { print_string(0x1, 0x0, "%s ", "any"); a0 = v3->field_0; print_color_string(0x4, ifa_family_color(v3->field_0), "anycast", "%s ", format_host(v3->field_0, *(*(&v13)) - 4, *(&v13) + 4, *(*(&v13)) - 4)); } print_string(0x4, "scope", "scope %s ", rtnl_rtscope_n2a(v3->field_3, &v17, 0x40, &v17)); print_ifa_flags(a1, v3, v2); if (*(&v11)) print_string(0x4, "label", "%s", rta_getattr_str(*(&v11))); if (*(&v14)) { *(&v7[0]) = *(&v14) + 4; print_nl(a0, a1, a2, v3->field_4, a4, a5); print_string(0x1, 0x0, " valid_lft ", 0x0); if (v7[1] != -1) { print_uint(0x4, "valid_life_time", "%usec", v7[1]); } else { print_uint(0x2, "valid_life_time", 0x0, 0xffffffff); print_string(0x1, 0x0, "%s", "forever"); } print_string(0x1, 0x0, " preferred_lft ", 0x0); if (v7[0] == -1) { print_uint(0x2, "preferred_life_time", 0x0, 0xffffffff); print_string(0x1, 0x0, "%s", "forever"); } else if (!(v2 & 32)) { print_uint(0x4, "preferred_life_time", "%usec", v7[0]); } else { print_int(0x4, "preferred_life_time", "%dsec", v7[0]); } } print_string(0x1, 0x0, "%s", "\n"); } fflush(a1); v30 = 0; } } } LABEL_405716: return; }
iproute2-6.0.0
angr_phoenix
static const char *_default_history_file(void) { struct passwd *p; static char *path; size_t len; if (path) return path; if ((p = getpwuid(getuid())) == ((void *)0)) return ((void *)0); len = strlen(p->pw_dir) + sizeof("/.history"); if ((path = malloc(len)) == ((void *)0)) return ((void *)0); (void)snprintf(path, len, "%s/.history", p->pw_dir); return path; }
int _default_history_file() { struct_0 *v0; unsigned int v1; unsigned int v3; if (path.6521) { v3 = path.6521; } else { v0 = &getpwuid(getuid())->pw_name; if (!v0) { v3 = 0; } else { *(&v1) = strlen(v0->field_20) + 10; path.6521 = malloc(*(&v1)); if (!path.6521) { v3 = 0; } else { snprintf(path.6521, *(&v1), "%s/.history", v0->field_20); v3 = path.6521; } } } return v3; }
libedit
angr_phoenix
static void list_entries_who(size_t n, const STRUCT_UTMP *utmp_buf) { unsigned long int entries = 0; char const *separator = ""; while (n--) { if ((((utmp_buf)->ut_user)[0] && (((utmp_buf)->ut_type == (7)) || (0 && ((utmp_buf)->ut_tv.tv_sec) != 0)))) { char *trimmed_name; trimmed_name = extract_trimmed_name(utmp_buf); printf("%s%s", separator, trimmed_name); free(trimmed_name); separator = " "; entries++; } utmp_buf++; } printf(gettext("\n# users=%lu\n"), entries); }
void list_entries_who(long param_1, short *param_2) { void *__ptr; char *__format; short *local_38; long local_30; long local_20; undefined *local_18; local_20 = 0; local_18 = &DAT_00101de3; local_38 = param_2; local_30 = param_1; while (true) { if (local_30 == 0) break; if ((*(char *)(local_38 + 0x16) != '\0') && (*local_38 == 7)) { __ptr = (void *)extract_trimmed_name(local_38); printf("%s%s", local_18, __ptr); free(__ptr); local_18 = &DAT_00101f7a; local_20 = local_20 + 1; } local_38 = local_38 + 0xc0; local_30 = local_30 + -1; } __format = (char *)gettext("\n# users=%lu\n"); printf(__format, local_20); return; }
coreutils
ghidra
_Bool maybe_backup_file (const char *file_name, _Bool this_is_the_archive) { struct stat file_stat; assign_string(&before_backup_name, file_name); assign_string(&after_backup_name, 0); if (this_is_the_archive && (!force_local_option && (rmt_dev_name__ = strchr(file_name, ':')) && rmt_dev_name__ > (file_name) && !memchr(file_name, '/', rmt_dev_name__ - (file_name)))) return 1; if (deref_stat(file_name, &file_stat) != 0) { if ((*__errno_location()) == 2) return 1; stat_error(file_name); return 0; } if (((((file_stat.st_mode)) & 0170000) == (0040000))) return 1; if (this_is_the_archive && (((((file_stat.st_mode)) & 0170000) == (0060000)) || ((((file_stat.st_mode)) & 0170000) == (0020000)))) return 1; after_backup_name = find_backup_file_name(chdir_fd, file_name, backup_type); if (!after_backup_name) xalloc_die(); if (renameat(chdir_fd, before_backup_name, chdir_fd, after_backup_name) == 0) { if (verbose_option) fprintf(stdlis, gettext("Renaming %s to %s\n"), quote_n(0, before_backup_name), quote_n(1, after_backup_name)); return 1; } else { int e = (*__errno_location()); do { if (error_hook) error_hook(); error(0, e, gettext("%s: Cannot rename to %s"), quotearg_colon(before_backup_name), quote_n(1, after_backup_name)); exit_status = 2; } while (0) ; assign_string(&after_backup_name, 0); return 0; } }
long maybe_backup_file(const char *a1, char a2) { long v3; long v4; char *v5; long v6; long v7; char *v8; int errnum; struct stat v10; unsigned long v11; v11 = __readfsqword(0x28u); assign_string((void **)&before_backup_name, (long)a1); assign_string((void **)&after_backup_name, 0LL); if (a2) { if (force_local_option != 1) { rmt_dev_name__ = strchr(a1, 58); if (rmt_dev_name__) { if ((unsigned long)a1 < rmt_dev_name__ && !memchr(a1, 47, rmt_dev_name__ - (_QWORD)a1)) return 1LL; } } } if (deref_stat(a1, &v10)) { if (*_errno_location() == 2) { return 1LL; } else { stat_error(a1); return 0LL; } } else if ((v10.st_mode & 0xF000) == 0x4000) { return 1LL; } else if (a2 && ((v10.st_mode & 0xF000) == 24576 || (v10.st_mode & 0xF000) == 0x2000)) { return 1LL; } else { after_backup_name = (char *)find_backup_file_name((unsigned int)chdir_fd, a1, backup_type); if (!after_backup_name) xalloc_die(); if (renameat(chdir_fd, before_backup_name, chdir_fd, after_backup_name)) { errnum = *_errno_location(); if (error_hook) error_hook(); v6 = quote_n(1LL, after_backup_name); v7 = quotearg_colon(before_backup_name); v8 = gettext("%s: Cannot rename to %s"); error(0, errnum, v8, v7, v6); exit_status = 2; assign_string((void **)&after_backup_name, 0LL); return 0LL; } else { if (verbose_option) { v3 = quote_n(1LL, after_backup_name); v4 = quote_n(0LL, before_backup_name); v5 = gettext("Renaming %s to %s\n"); fprintf(stdlis, v5, v4, v3); } return 1LL; } } }
tar
ida
inline int ext2fs_dirent_name_len(const struct ext2_dir_entry *entry) { return entry->name_len & 0xff; }
void ext2fs_dirent_name_len(void) { halt_baddata(); }
e2fsprogs-1.46.5
ghidra
const char *strxf_xfrmproto(__u8 proto) { static char str[16]; int i; for (i = 0;; i++) { const struct typeent *t = &xfrmproto_types[i]; if (!t->t_name || t->t_type == -1) break; if (t->t_type == proto) return t->t_name; } sprintf(str, "%u", proto); return str; }
int strxf_xfrmproto(unsigned long a0) { unsigned int v0; struct_0 *v1; unsigned int v3; v0 = 0; while (true) { v1 = &(&xfrmproto_types)[2 * v0]; if (v1->field_0 && v1->field_8 != -1) { if (v1->field_8 == a0) { v3 = v1->field_0; break; } else { v0 += 1; continue; } } if (v1->field_8 == -1 || !v1->field_0) { sprintf(&str.9239, "%u", a0); v3 = &str.9239; break; } } return v3; }
iproute2-6.0.0
angr_dream
void message5(char const *format_msgid, char const *arg1, char const *arg2, char const *arg3, char const *arg4) { if (paginate) { char *p; char const *arg[5]; int i; size_t size[5]; size_t total_size = __builtin_offsetof(struct msg, args); struct msg *new; arg[0] = format_msgid; arg[1] = arg1; arg[2] = arg2; arg[3] = arg3 ? arg3 : ""; arg[4] = arg4 ? arg4 : ""; for (i = 0; i < 5; i++) total_size += size[i] = strlen(arg[i]) + 1; new = xmalloc(total_size); for (i = 0, p = new->args; i < 5; p += size[i++]) memcpy(p, arg[i], size[i]); *msg_chain_end = new; new->next = 0; msg_chain_end = &new->next; } else { if (sdiff_merge_assist) putchar_unlocked(' '); printf(gettext(format_msgid), arg1, arg2, arg3, arg4); } }
void message5(void *a0, unsigned long a1, unsigned long a2, unsigned long long a3, unsigned long long a4) { unsigned int v0; int tmp_10; void *v1; unsigned long long v2; unsigned long long *v3; unsigned long v4; unsigned long v5; unsigned long long v6; unsigned long v7; char v8; char v9; unsigned long long v11; unsigned long long v12; unsigned long long *v13; unsigned long long v14; if (paginate) { v2 = 8; v4 = a1; v5 = a2; if (!a3) v11 = &g_4028cf; else v11 = a3; v6 = v11; if (!a4) v12 = &g_4028cf; else v12 = a4; v7 = v12; for (v0 = 0; v0 <= 4; v0 += 1) { *(&(&v8)[8 * v0]) = strlen(a0) + 1; v2 += *(&(&v8)[8 * v0]); } v3 = xmalloc(v2); v0 = 0; for (v1 = v3 + 1; v0 <= 4; v1 += *(&(&v8)[8 * tmp_10])) { memcpy(v1, a0, *(&(&v8)[8 * v0])); tmp_10 = v0; v0 += 1; } *(msg_chain_end) = v3; *(v3) = 0; msg_chain_end = v3; } else { if (sdiff_merge_assist) putchar_unlocked(0x20); printf(gettext(a0)); } v14 = *(&v9) ^ v13[5]; return; }
diffutils
angr_phoenix
static int sig_find_principals(const char *signature, const char *allowed_keys, char *const *opts, size_t nopts) { int r, ret = -1; struct sshbuf *sigbuf = ((void *)0), *abuf = ((void *)0); struct sshkey *sign_key = ((void *)0); char *principals = ((void *)0), *cp, *tmp; uint64_t verify_time = 0; if (sig_process_opts(opts, nopts, ((void *)0), &verify_time, ((void *)0)) != 0) goto done; if ((r = sshbuf_load_file(signature, &abuf)) != 0) { sshlog("ssh-keygen.c", __func__, 2875, 0, SYSLOG_LEVEL_ERROR, ssh_err(r), "Couldn't read signature file"); goto done; } if ((r = sshsig_dearmor(abuf, &sigbuf)) != 0) { sshlog("ssh-keygen.c", __func__, 2879, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "sshsig_armor"); goto done; } if ((r = sshsig_get_pubkey(sigbuf, &sign_key)) != 0) { sshlog("ssh-keygen.c", __func__, 2883, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "sshsig_get_pubkey"); goto done; } if ((r = sshsig_find_principals(allowed_keys, sign_key, verify_time, &principals)) != 0) { if (r != -46) sshlog("ssh-keygen.c", __func__, 2889, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "sshsig_find_principal"); goto done; } ret = 0; done: if (ret == 0) { tmp = principals; while ((cp = strsep(&tmp, ",")) != ((void *)0) && *cp != '\0') puts(cp); } else { fprintf(stderr, "No principal matched.\n"); } sshbuf_free(sigbuf); sshbuf_free(abuf); sshkey_free(sign_key); free(principals); return ret; }
void sig_find_principals(unsigned long long a0, unsigned long long a1, void *a2, unsigned int a3) { char v0; unsigned int v1; unsigned int v2; void *v3; void *v4; void *v5; void *v6; void *v7; void *v8; char *v9; unsigned long long v11; v1 = -1; v3 = 0; v4 = 0; v5 = 0; v6 = 0; v8 = 0; if (!sig_process_opts(a2, a3, NULL, &v8, NULL)) { v2 = sshbuf_load_file(a0, &v4, &v4); if (v2) { sshlog("ssh-keygen.c", "sig_find_principals", 0xb3b, 0x0, 0x2, ssh_err(v2), "Couldn't read signature file", *(&v0)); } else { v2 = sshsig_dearmor(v4, &v3, &v3); if (v2) { sshlog("ssh-keygen.c", "sig_find_principals", 0xb3f, 0x1, 0x2, ssh_err(v2), "sshsig_armor", *(&v0)); } else { v2 = sshsig_get_pubkey(v3, &v5, &v5); if (v2) { sshlog("ssh-keygen.c", "sig_find_principals", 0xb43, 0x1, 0x2, ssh_err(v2), "sshsig_get_pubkey", *(&v0)); } else { v2 = sshsig_find_principals(a1, v5, v8, &v6); if (!v2) { v1 = 0; } else if (v2 != -46) { sshlog("ssh-keygen.c", "sig_find_principals", 0xb49, 0x1, 0x2, ssh_err(v2), "sshsig_find_principal", *(&v0)); } } } } } if (v1) { fprintf(stderr, "No principal matched.\n"); } else { v7 = v6; while (true) { v9 = strsep(&v7, ","); if (!v9) break; if (!*(v9)) break; puts(v9); } } sshbuf_free(v3); sshbuf_free(v4); sshkey_free(v5); free(v6); v11 = v1; return; }
openssh-portable
angr_phoenix
static int dopass(int fd, struct stat const *st, char const *qname, off_t *sizep, int type, struct randread_source *s, unsigned long int k, unsigned long int n) { off_t size = *sizep; off_t offset; time_t thresh; time_t now = 0; size_t lim; size_t soff; ssize_t ssize; size_t page_size = getpagesize(); _Static_assert((60 * 1024) % 3 == 0, "verify (" "PERIODIC_OUTPUT_SIZE % 3 == 0" ")"); size_t output_size = periodic_pattern(type) ? (60 * 1024) : (64 * 1024); unsigned char *pbuf = xalignalloc(page_size, (((output_size + 2) / 3) * 3)); char pass_string[7]; _Bool write_error = 0; _Bool other_error = 0; char previous_offset_buf [((2 * sizeof(uintmax_t) * 8 * 146 / 485 + 1) * (16 + 1) - 16 + 1 + 3) + 1]; char const *previous_human_offset; _Bool try_without_directio = 0 < size && size < output_size; if (!try_without_directio) direct_mode(fd, 1); if (!dorewind(fd, st)) { error(0, (*__errno_location()), gettext("%s: cannot rewind"), qname); other_error = 1; goto free_pattern_mem; } if (type >= 0) { lim = known(size) && size < (((output_size + 2) / 3) * 3) ? size : (((output_size + 2) / 3) * 3); fillpattern(type, pbuf, lim); passname(pbuf, pass_string); } else { passname(0, pass_string); } if (n) { error(0, 0, gettext("%s: pass %lu/%lu (%s)..."), qname, k, n, pass_string); thresh = time(((void *)0)) + VERBOSE_UPDATE; previous_human_offset = ""; } offset = 0; while (1) { lim = output_size; if (known(size) && size - offset < output_size) { if (size < offset) break; lim = size - offset; if (!lim) break; } if (type < 0) randread(s, pbuf, lim); for (soff = 0; soff < lim; soff += ssize) { ssize = write(fd, pbuf + soff, lim - soff); if (0 < ssize) ((ssize <= lim - soff) ? (void)0 : __builtin_unreachable()); else { if (!known(size) && (ssize == 0 || (*__errno_location()) == 28)) { if (soff <= ((off_t)(!(!((off_t)0 < (off_t)-1)) ? (off_t)-1 : ((((off_t)1 << ((sizeof(off_t) * 8) - 2)) - 1) * 2 + 1))) - offset) *sizep = size = offset + soff; break; } else { int errnum = (*__errno_location()); char buf[( (((((sizeof(uintmax_t) * 8) - (!((__typeof__(uintmax_t))0 < (__typeof__(uintmax_t))-1))) * 146 + 484) / 485) + (!((__typeof__(uintmax_t))0 < (__typeof__(uintmax_t))-1))) + 1)]; if (!try_without_directio && (*__errno_location()) == 22) { direct_mode(fd, 0); ssize = 0; try_without_directio = 1; continue; } error(0, errnum, gettext("%s: error writing at offset %s"), qname, umaxtostr(offset + soff, buf)); _Static_assert((60 * 1024) % SECTOR_SIZE == 0, "verify (" "PERIODIC_OUTPUT_SIZE % SECTOR_SIZE == 0" ")"); _Static_assert((64 * 1024) % SECTOR_SIZE == 0, "verify (" "NONPERIODIC_OUTPUT_SIZE % SECTOR_SIZE == 0" ")"); if (errnum == 5 && known(size) && (soff | SECTOR_MASK) < lim) { size_t soff1 = (soff | SECTOR_MASK) + 1; if (lseek(fd, offset + soff1, 0) != -1) { ssize = soff1 - soff; write_error = 1; continue; } error(0, (*__errno_location()), gettext("%s: lseek failed"), qname); } other_error = 1; goto free_pattern_mem; } } } if (((off_t)(!(!((off_t)0 < (off_t)-1)) ? (off_t)-1 : ((((off_t)1 << ((sizeof(off_t) * 8) - 2)) - 1) * 2 + 1))) - offset < soff) { error(0, 0, gettext("%s: file too large"), qname); other_error = 1; goto free_pattern_mem; } offset += soff; _Bool done = offset == size; if (n && ((done && *previous_human_offset) || thresh <= (now = time(((void *)0))))) { char offset_buf[((2 * sizeof(uintmax_t) * 8 * 146 / 485 + 1) * (16 + 1) - 16 + 1 + 3) + 1]; char size_buf[((2 * sizeof(uintmax_t) * 8 * 146 / 485 + 1) * (16 + 1) - 16 + 1 + 3) + 1]; int human_progress_opts = (human_autoscale | human_SI | human_base_1024 | human_B); char const *human_offset = human_readable( offset, offset_buf, human_floor | human_progress_opts, 1, 1); if (done || !(strcmp(previous_human_offset, human_offset) == 0)) { if (!known(size)) error(0, 0, gettext("%s: pass %lu/%lu (%s)...%s"), qname, k, n, pass_string, human_offset); else { uintmax_t off = offset; int percent = (size == 0 ? 100 : (off <= ((uintmax_t)(!(!((uintmax_t)0 < (uintmax_t)-1)) ? (uintmax_t)-1 : ((((uintmax_t)1 << ((sizeof(uintmax_t) * 8) - 2)) - 1) * 2 + 1))) / 100 ? off * 100 / size : off / (size / 100))); char const *human_size = human_readable( size, size_buf, human_ceiling | human_progress_opts, 1, 1); if (done) human_offset = human_size; error(0, 0, gettext("%s: pass %lu/%lu (%s)...%s/%s %d%%"), qname, k, n, pass_string, human_offset, human_size, percent); } strcpy(previous_offset_buf, human_offset); previous_human_offset = previous_offset_buf; thresh = now + VERBOSE_UPDATE; if (dosync(fd, qname) != 0) { if ((*__errno_location()) != 5) { other_error = 1; goto free_pattern_mem; } write_error = 1; } } } } if (dosync(fd, qname) != 0) { if ((*__errno_location()) != 5) { other_error = 1; goto free_pattern_mem; } write_error = 1; } free_pattern_mem: alignfree(pbuf); return other_error ? -1 : write_error; }
long dopass(unsigned int a1, long a2, long a3, long *a4, int a5, long a6, long a7, long a8) { long v8; bool v9; char *v10; int *v11; size_t v12; char *v13; long v14; char *v15; char *v16; int *v17; char *v18; char *v19; unsigned long v20; char *v21; unsigned char v27; char v28; char v29; int errnum; unsigned int v31; long v32; unsigned long v33; time_t v34; time_t v35; unsigned long v36; unsigned long i; ssize_t v38; const char *s1; char *s2; long v41; unsigned long v42; unsigned char *v43; long v44; char v45[7]; char dest[656]; char v47[656]; char v48[664]; unsigned long v49; v49 = __readfsqword(0x28u); v32 = *a4; v35 = 0LL; v41 = getpagesize(); if (periodic_pattern(a5)) v8 = 61440LL; else v8 = 0x10000LL; v42 = v8; v43 = (unsigned char *)xalignalloc(v41, 3 * ((v8 + 2) / 3uLL)); v27 = 0; v28 = 0; v9 = v32 > 0 && v42 > v32; v29 = v9; if (!v9) direct_mode(a1, 1); if (!dorewind(a1, a2)) { v10 = gettext("%s: cannot rewind"); v11 = _errno_location(); error(0, *v11, v10, a3); v28 = 1; } else { if (a5 < 0) { passname(0LL, v45); } else { if (known(v32) && 3 * ((v42 + 2) / 3) > v32) v12 = v32; else v12 = 3 * ((v42 + 2) / 3); fillpattern(a5, v43, v12); passname(v43, v45); } if (a8) { v13 = gettext("%s: pass %lu/%lu (%s)..."); error(0, 0, v13, a3, a7, a8, v45); v34 = time(0LL) + 5; s1 = locale; } v33 = 0LL; while (1) { v36 = v42; if (known(v32) && v42 > v32 - v33) { if (v32 < (long)v33) break; v36 = v32 - v33; if (v32 == v33) break; } if (a5 < 0) randread(a6, v43, v36); for (i = 0LL; i < v36; i += v38) { v38 = write(a1, &v43[i], v36 - i); if (v38 <= 0) { if (!known(v32) && (!v38 || *_errno_location() == 28)) { if (i <= 0x7FFFFFFFFFFFFFFFLL - v33) { v32 = v33 + i; *a4 = v33 + i; } break; } errnum = *_errno_location(); if (v29 != 1 && *_errno_location() == 22) { direct_mode(a1, 0); v38 = 0LL; v29 = 1; } else { v14 = umaxtostr(i + v33, v48); v15 = gettext("%s: error writing at offset %s"); error(0, errnum, v15, a3, v14); if (errnum != 5 || !known(v32) || v36 <= (i | 0x1FF)) goto LABEL_44; if (lseek(a1, v33 + (i | 0x1FF) + 1, 0) == -1) { v16 = gettext("%s: lseek failed"); v17 = _errno_location(); error(0, *v17, v16, a3); LABEL_44: v28 = 1; goto LABEL_73; } v38 = (i | 0x1FF) + 1 - i; v27 = 1; } } } if (i > 0x7FFFFFFFFFFFFFFFLL - v33) { v18 = gettext("%s: file too large"); error(0, 0, v18, a3); v28 = 1; goto LABEL_73; } v33 += i; if (a8) { if (v33 == v32 && *s1 || (v35 = time(0LL), v35 >= v34)) { s2 = (char *)human_readable(v33, v47, 434LL, 1LL, 1LL); if (v33 == v32 || strcmp(s1, s2)) { if (!known(v32)) { v19 = gettext("%s: pass %lu/%lu (%s)...%s"); error(0, 0, v19, a3, a7, a8, v45, s2); } else { if (v32) { if (v33 > 0x28F5C28F5C28F5CLL) v20 = v33 / (v32 / 100); else v20 = 100 * v33 / v32; } else { LODWORD(v20) = 100; } v31 = v20; v44 = human_readable(v32, v48, 432LL, 1LL, 1LL); if (v33 == v32) s2 = (char *)v44; v21 = gettext("%s: pass %lu/%lu (%s)...%s/%s %d%%"); error(0, 0, v21, a3, a7, a8, v45, s2, v44, v31); } strcpy(dest, s2); s1 = dest; v34 = v35 + 5; if ((unsigned int)dosync(a1, a3)) { if (*_errno_location() != 5) { v28 = 1; goto LABEL_73; } v27 = 1; } } } } } if ((unsigned int)dosync(a1, a3)) { if (*_errno_location() == 5) v27 = 1; else v28 = 1; } } LABEL_73: alignfree(v43); if (v28) return 0xFFFFFFFFLL; else return v27; }
coreutils
ida
static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) { char s2[64]; __u16 iflags = 0; __u16 oflags = 0; __u32 flags = 0; __u32 flowinfo = 0; __u8 ttl = 0; if (!tb) return; if (tb[IFLA_GRE_COLLECT_METADATA]) { print_bool(PRINT_ANY, "external", "external ", 1); } if (tb[IFLA_GRE_FLAGS]) flags = rta_getattr_u32(tb[IFLA_GRE_FLAGS]); if (tb[IFLA_GRE_FLOWINFO]) flowinfo = rta_getattr_u32(tb[IFLA_GRE_FLOWINFO]); tnl_print_endpoint("remote", tb[IFLA_GRE_REMOTE], 10); tnl_print_endpoint("local", tb[IFLA_GRE_LOCAL], 10); if (tb[IFLA_GRE_LINK]) { __u32 link = rta_getattr_u32(tb[IFLA_GRE_LINK]); if (link) { print_string(PRINT_ANY, "link", "dev %s ", ll_index_to_name(link)); } } if (tb[IFLA_GRE_TTL]) ttl = rta_getattr_u8(tb[IFLA_GRE_TTL]); if (is_json_context() || ttl) print_uint(PRINT_ANY, "ttl", "hoplimit %u ", ttl); else print_string(PRINT_FP, ((void *)0), "hoplimit %s ", "inherit"); if (flags & 0x1) { print_bool(PRINT_ANY, "ip6_tnl_f_ign_encap_limit", "encaplimit none ", 1); } else if (tb[IFLA_GRE_ENCAP_LIMIT]) { __u8 val = rta_getattr_u8(tb[IFLA_GRE_ENCAP_LIMIT]); print_uint(PRINT_ANY, "encap_limit", "encaplimit %u ", val); } if (flags & 0x2) { print_bool(PRINT_ANY, "ip6_tnl_f_use_orig_tclass", "tclass inherit ", 1); } else if (tb[IFLA_GRE_FLOWINFO]) { __u32 val = ntohl(flowinfo & htonl(0x0FF00000)) >> 20; snprintf(s2, sizeof(s2), "0x%02x", val); print_string(PRINT_ANY, "tclass", "tclass %s ", s2); } if (flags & 0x4) { print_bool(PRINT_ANY, "ip6_tnl_f_use_orig_flowlabel", "flowlabel inherit ", 1); } else if (tb[IFLA_GRE_FLOWINFO]) { __u32 val = ntohl(flowinfo & htonl(0x000FFFFF)); snprintf(s2, sizeof(s2), "0x%05x", val); print_string(PRINT_ANY, "flowlabel", "flowlabel %s ", s2); } if (flags & 0x10) print_bool(PRINT_ANY, "ip6_tnl_f_rcv_dscp_copy", "dscp inherit ", 1); if (tb[IFLA_GRE_IFLAGS]) iflags = rta_getattr_u16(tb[IFLA_GRE_IFLAGS]); if (tb[IFLA_GRE_OFLAGS]) oflags = rta_getattr_u16(tb[IFLA_GRE_OFLAGS]); if ((iflags & ((__be16)(__builtin_constant_p((__u16)((0x2000))) ? ((__u16)((((__u16)((0x2000)) & (__u16)0x00ffU) << 8) | (((__u16)((0x2000)) & (__u16)0xff00U) >> 8))) : __fswab16((0x2000))))) && tb[IFLA_GRE_IKEY]) { inet_ntop( 2, ((void *)(((char *)(tb[IFLA_GRE_IKEY])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))), s2, sizeof(s2)); print_string(PRINT_ANY, "ikey", "ikey %s ", s2); } if ((oflags & ((__be16)(__builtin_constant_p((__u16)((0x2000))) ? ((__u16)((((__u16)((0x2000)) & (__u16)0x00ffU) << 8) | (((__u16)((0x2000)) & (__u16)0xff00U) >> 8))) : __fswab16((0x2000))))) && tb[IFLA_GRE_OKEY]) { inet_ntop( 2, ((void *)(((char *)(tb[IFLA_GRE_OKEY])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))), s2, sizeof(s2)); print_string(PRINT_ANY, "okey", "okey %s ", s2); } if (iflags & ((__be16)(__builtin_constant_p((__u16)((0x1000))) ? ((__u16)((((__u16)((0x1000)) & (__u16)0x00ffU) << 8) | (((__u16)((0x1000)) & (__u16)0xff00U) >> 8))) : __fswab16((0x1000))))) print_bool(PRINT_ANY, "iseq", "iseq ", 1); if (oflags & ((__be16)(__builtin_constant_p((__u16)((0x1000))) ? ((__u16)((((__u16)((0x1000)) & (__u16)0x00ffU) << 8) | (((__u16)((0x1000)) & (__u16)0xff00U) >> 8))) : __fswab16((0x1000))))) print_bool(PRINT_ANY, "oseq", "oseq ", 1); if (iflags & ((__be16)(__builtin_constant_p((__u16)((0x8000))) ? ((__u16)((((__u16)((0x8000)) & (__u16)0x00ffU) << 8) | (((__u16)((0x8000)) & (__u16)0xff00U) >> 8))) : __fswab16((0x8000))))) print_bool(PRINT_ANY, "icsum", "icsum ", 1); if (oflags & ((__be16)(__builtin_constant_p((__u16)((0x8000))) ? ((__u16)((((__u16)((0x8000)) & (__u16)0x00ffU) << 8) | (((__u16)((0x8000)) & (__u16)0xff00U) >> 8))) : __fswab16((0x8000))))) print_bool(PRINT_ANY, "ocsum", "ocsum ", 1); if (flags & 0x40) print_bool(PRINT_ANY, "ip6_tnl_f_allow_local_remote", "allow-localremote ", 1); if (flags & 0x20) { print_bool(PRINT_ANY, "ip6_tnl_f_use_orig_fwmark", "fwmark inherit ", 1); } else if (tb[IFLA_GRE_FWMARK]) { __u32 fwmark = rta_getattr_u32(tb[IFLA_GRE_FWMARK]); if (fwmark) { print_0xhex(PRINT_ANY, "fwmark", "fwmark %#llx ", fwmark); } } if (tb[IFLA_GRE_ERSPAN_INDEX]) { __u32 erspan_idx = rta_getattr_u32(tb[IFLA_GRE_ERSPAN_INDEX]); print_uint(PRINT_ANY, "erspan_index", "erspan_index %u ", erspan_idx); } if (tb[IFLA_GRE_ERSPAN_VER]) { __u8 erspan_ver = rta_getattr_u8(tb[IFLA_GRE_ERSPAN_VER]); print_uint(PRINT_ANY, "erspan_ver", "erspan_ver %u ", erspan_ver); } if (tb[IFLA_GRE_ERSPAN_DIR]) { __u8 erspan_dir = rta_getattr_u8(tb[IFLA_GRE_ERSPAN_DIR]); if (erspan_dir == 0) print_string(PRINT_ANY, "erspan_dir", "erspan_dir %s ", "ingress"); else print_string(PRINT_ANY, "erspan_dir", "erspan_dir %s ", "egress"); } if (tb[IFLA_GRE_ERSPAN_HWID]) { __u16 erspan_hwid = rta_getattr_u16(tb[IFLA_GRE_ERSPAN_HWID]); print_0xhex(PRINT_ANY, "erspan_hwid", "erspan_hwid %#llx ", erspan_hwid); } tnl_print_encap(tb, IFLA_GRE_ENCAP_TYPE, IFLA_GRE_ENCAP_FLAGS, IFLA_GRE_ENCAP_SPORT, IFLA_GRE_ENCAP_DPORT); }
long long gre_print_opt(unsigned long a0, unsigned long a1, unsigned long long a2[25]) { unsigned long v0; unsigned long v1; char v2; char v3; char v4; char v5; unsigned short v6; unsigned short v7; unsigned short v8; unsigned int v9; unsigned int v10; unsigned int v11; unsigned int v12; unsigned int v13; unsigned int v14; unsigned int v15; char v16; unsigned long long v18; v1 = a0; v0 = a1; v6 = 0; v7 = 0; v9 = 0; v10 = 0; v2 = 0; if (a2) { if (a2[18]) print_bool(0x4, "external", "external ", 0x1); if (a2[13]) v9 = rta_getattr_u32(a2[13]); if (a2[12]) v10 = rta_getattr_u32(a2[12]); tnl_print_endpoint("remote", a2[7], 0xa); tnl_print_endpoint("local", a2[6], 0xa); if (a2[1]) { v11 = rta_getattr_u32(a2[1]); if (v11) print_string(0x4, "link", "dev %s ", ll_index_to_name(v11)); } if (a2[8]) v2 = rta_getattr_u8(a2[8]); v18 = is_json_context(); if (!v18 && !v2) print_string(0x1, 0x0, "hoplimit %s ", "inherit"); if (v2 || v18) print_uint(0x4, "ttl", "hoplimit %u ", v2); if ((v9 & 1)) { print_bool(0x4, "ip6_tnl_f_ign_encap_limit", "encaplimit none ", 0x1); } else if (a2[11]) { v3 = rta_getattr_u8(a2[11]); print_uint(0x4, "encap_limit", "encaplimit %u ", v3); } if ((v9 & 2)) { print_bool(0x4, "ip6_tnl_f_use_orig_tclass", "tclass inherit ", 0x1); } else if (a2[12]) { v12 = ntohl(htonl(0xff00000) & v10) >> 20; snprintf(&v16, 0x40, "0x%02x", v12); print_string(0x4, "tclass", "tclass %s ", &v16); } if ((v9 & 4)) { print_bool(0x4, "ip6_tnl_f_use_orig_flowlabel", "flowlabel inherit ", 0x1); } else if (a2[12]) { v13 = ntohl(htonl(0xfffff) & v10); snprintf(&v16, 0x40, "0x%05x", v13); print_string(0x4, "flowlabel", "flowlabel %s ", &v16); } if ((v9 & 16)) print_bool(0x4, "ip6_tnl_f_rcv_dscp_copy", "dscp inherit ", 0x1); if (a2[2]) v6 = rta_getattr_u16(a2[2]); if (a2[3]) v7 = rta_getattr_u16(a2[3]); if ((v6 & 32) && a2[4]) { inet_ntop(0x2, a2[4] + 4, &v16, 0x40); print_string(0x4, "ikey", "ikey %s ", &v16); } if ((v7 & 32) && a2[5]) { inet_ntop(0x2, a2[5] + 4, &v16, 0x40); print_string(0x4, "okey", "okey %s ", &v16); } if ((v6 & 16)) print_bool(0x4, "iseq", "iseq ", 0x1); if ((v7 & 16)) print_bool(0x4, "oseq", "oseq ", 0x1); if ((v6 & 128)) print_bool(0x4, "icsum", "icsum ", 0x1); if ((v7 & 128)) print_bool(0x4, "ocsum", "ocsum ", 0x1); if ((v9 & 64)) print_bool(0x4, "ip6_tnl_f_allow_local_remote", "allow-localremote ", 0x1); if ((v9 & 32)) { print_bool(0x4, "ip6_tnl_f_use_orig_fwmark", "fwmark inherit ", 0x1); } else if (a2[20]) { v14 = rta_getattr_u32(a2[20]); if (v14) print_0xhex(0x4, "fwmark", "fwmark %#llx ", v14); } if (a2[21]) { v15 = rta_getattr_u32(a2[21]); print_uint(0x4, "erspan_index", "erspan_index %u ", v15); } if (a2[22]) { v4 = rta_getattr_u8(a2[22]); print_uint(0x4, "erspan_ver", "erspan_ver %u ", v4); } if (a2[23]) { v5 = rta_getattr_u8(a2[23]); if (!v5) print_string(0x4, "erspan_dir", "erspan_dir %s ", "ingress"); else print_string(0x4, "erspan_dir", "erspan_dir %s ", "egress"); } if (a2[24]) { v8 = rta_getattr_u16(a2[24]); print_0xhex(0x4, "erspan_hwid", "erspan_hwid %#llx ", v8); } tnl_print_encap(a2, 0xe, 0xf, 0x10, 0x11); } return 0; }
iproute2-6.0.0
angr_dream
int gzrewind(file) gzFile file; { gz_statep state; if (file == ((void *)0)) return -1; state = (gz_statep)file; if (state->mode != 7247 || (state->err != 0 && state->err != (-5))) return -1; if (lseek64(state->fd, state->start, 0) == -1) return -1; gz_reset(state); return 0; }
long gzrewind(long a1) { if (!a1) return 0xFFFFFFFFLL; if (*(_DWORD *)(a1 + 24) != 7247 || *(_DWORD *)(a1 + 116) && *(_DWORD *)(a1 + 116) != -5) return 0xFFFFFFFFLL; if (lseek64(*(_DWORD *)(a1 + 28), *(_QWORD *)(a1 + 72), 0) == -1) return 0xFFFFFFFFLL; gz_reset(a1); return 0LL; }
zlib
ida
!ciphers_valid(*arg == '+' || *arg == '^' ? arg + 1 : arg)){ sshlog("readconf.c", __func__, 1398, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "%.200s line %d: Bad SSH2 cipher spec '%s'.", filename, linenum, arg ? arg : "<NONE>"); goto out; }
void ciphers_valid(void) { halt_baddata(); }
openssh-portable
ghidra
static _Bool known_term_type(void) { char const *term = getenv("TERM"); if (!term || !*term) return 0; char const *line = G_line; while (line - G_line < sizeof(G_line)) { if (strncmp(line, "" "TERM " "", sizeof("TERM ") - 1) == 0) { if (fnmatch(line + 5, term, 0) == 0) return 1; } line += strlen(line) + 1; } return 0; }
long known_term_type() { char *s1; char *name; name = getenv("TERM"); if (!name || !*name) return 0LL; for (s1 = "# Configuration file for dircolors, a utility to help you set the"; (unsigned long)(s1 - "# Configuration file for dircolors, a utility to " "help you set the") <= 0x12C7; s1 += strlen(s1) + 1) { if (!strncmp(s1, "TERM ", 5uLL) && !fnmatch(s1 + 5, name, 0)) return 1LL; } return 0LL; }
coreutils
ida
static inline __u8 rta_getattr_u8(const struct rtattr *rta) { return *(__u8 *)(( void *)(((char *)(rta)) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))); }
int rta_getattr_u8(struct_0 *a0) { return a0->field_4; }
iproute2-6.0.0
angr_dream
static void print_clump(COLUMN *p, int n, char *clump) { while (n--) (p->char_func)(*clump++); }
void print_clump(unsigned long a0, unsigned long a1, unsigned long a2) { char *v0; int tmp_9; int tmp_17; unsigned int v1; unsigned long long v3; v1 = a1; v0 = a2; while (true) { tmp_9 = v1; v3 = v1; v1 -= 1; if (!tmp_9) break; tmp_17 = v0; v0 += 1; *((reg_72 + 32))(*(tmp_17)); } return; }
coreutils
angr_phoenix
static void perform_basename(char const *string, char const *suffix, _Bool use_nuls) { char *name = base_name(string); strip_trailing_slashes(name); if (suffix && (!(((name)[0]) == '/')) && !((void)(name), 0)) remove_suffix(name, suffix); fputs_unlocked(name, stdout); putchar_unlocked(use_nuls ? '\0' : '\n'); free(name); }
void perform_basename(undefined8 param_1, long param_2, char param_3) { int __c; char *__s; __s = (char *)base_name(param_1); strip_trailing_slashes(__s); if ((param_2 != 0) && (*__s != '/')) { remove_suffix(__s, param_2); } fputs_unlocked(__s, stdout); if (param_3 == '\0') { __c = 10; } else { __c = 0; } putchar_unlocked(__c); free(__s); return; }
coreutils
ghidra
vi_substitute_line(EditLine *el, wint_t c __attribute__((__unused__))) { cv_undo(el); cv_yank(el, el->el_line.buffer, (int)(el->el_line.lastchar - el->el_line.buffer)); (void)em_kill_line(el, 0); el->el_map.current = el->el_map.key; return 4; }
undefined8 vi_substitute_line(long param_1) { cv_undo(param_1); cv_yank(param_1, *(undefined8 *)(param_1 + 0x50), *(long *)(param_1 + 0x60) - *(long *)(param_1 + 0x50) >> 2 & 0xffffffff); em_kill_line(param_1, 0); *(undefined8 *)(param_1 + 0x400) = *(undefined8 *)(param_1 + 0x3f8); return 4; }
libedit
ghidra
u_char *sshbuf_mutable_ptr(const struct sshbuf *buf) { if (sshbuf_check_sanity(buf) != 0 || buf->readonly || buf->refcount > 1) return ((void *)0); return buf->d + buf->off; }
long sshbuf_mutable_ptr(long *param_1) { int iVar1; long lVar2; iVar1 = sshbuf_check_sanity(param_1); if (((iVar1 == 0) && (*(int *)(param_1 + 6) == 0)) && (*(uint *)(param_1 + 7) < 2)) { lVar2 = param_1[2] + *param_1; } else { lVar2 = 0; } return lVar2; }
openssh-portable
ghidra
int sshkey_cert_check_authority_now(const struct sshkey *k, int want_host, int require_principal, int wildcard_pattern, const char *name, const char **reason) { time_t now; if ((now = time(((void *)0))) < 0) { *reason = "Certificate invalid: not yet valid"; return -25; } return sshkey_cert_check_authority(k, want_host, require_principal, wildcard_pattern, (uint64_t)now, name, reason); }
long sshkey_cert_check_authority_now(long a1, int a2, int a3, int a4, const char *a5, _QWORD *a6) { signed long v11; v11 = time(0LL); if (v11 >= 0) return sshkey_cert_check_authority(a1, a2, a3, a4, v11, a5, a6); *a6 = "Certificate invalid: not yet valid"; return 4294967271LL; }
openssh-portable
ida
_Bool pred_execdir (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr) { (void)&pathname; return impl_pred_exec(state.rel_pathname, stat_buf, pred_ptr); }
long long pred_execdir(unsigned long a0, unsigned long long a1, unsigned long long a2) { unsigned long v0; v0 = a0; return impl_pred_exec(strcmp, a1, a2, a1); }
findutils
angr_phoenix
static intmax_t expcond() { intmax_t cval, val1, val2, rval; int set_noeval; set_noeval = 0; rval = cval = explor(); if (curtok == '?') { if (cval == 0) { set_noeval = 1; noeval++; } readtok(); if (curtok == 0 || curtok == ':') evalerror(gettext("expression expected")); val1 = expcomma(); if (set_noeval) noeval--; if (curtok != ':') evalerror(gettext("`:' expected for conditional expression")); set_noeval = 0; if (cval) { set_noeval = 1; noeval++; } readtok(); if (curtok == 0) evalerror(gettext("expression expected")); val2 = expcond(); if (set_noeval) noeval--; rval = cval ? val1 : val2; lasttok = 12; } return rval; }
int expcond(unsigned long long a0, unsigned long long a1, unsigned long a2, unsigned long long a3) { unsigned int v0; unsigned long v1; unsigned long v2; unsigned long long v3; unsigned long long v4; unsigned long long v6; unsigned long long v7; unsigned long long v8; v0 = 0; v2 = explor(a0, a1, a2, a3); v1 = v2; if (false) { evalerror(gettext("expression expected")); v0 = 0; if (v2) { v0 = 1; noeval = noeval + 1; } readtok(a0, a1, a2, a3, v6, v7); evalerror(gettext("expression expected")); v4 = expcond(a0, a1, a2, a3); if (v0) noeval = noeval - 1; if (v2) v8 = v3; else v8 = v4; v1 = v8; lasttok = 12; } if (curtok == 63) { if (!v2) { v0 = 1; noeval = noeval + 1; } readtok(a0, a1, a2, a3, v6, v7); v3 = expcomma(a0, a1, a2, a3); if (v0) noeval = noeval - 1; evalerror(gettext("`:' expected for conditional expression")); } else { return v1; } }
bash
angr_dream
char *utf8_mbschr(s, c) const char *s; int c; { return strchr(s, c); }
long long utf8_mbschr(char *a0, unsigned long a1) { return strchr(a0, a1); }
bash
angr_sailr
static int key_type_allowed_by_config(struct sshkey *key) { if (match_pattern_list(sshkey_ssh_name(key), options.pubkey_accepted_algos, 0) == 1) return 1; switch (key->type) { case KEY_RSA: if (match_pattern_list("rsa-sha2-512", options.pubkey_accepted_algos, 0) == 1) return 1; if (match_pattern_list("rsa-sha2-256", options.pubkey_accepted_algos, 0) == 1) return 1; break; case KEY_RSA_CERT: if (match_pattern_list("rsa-sha2-512-cert-v01@openssh.com", options.pubkey_accepted_algos, 0) == 1) return 1; if (match_pattern_list("rsa-sha2-256-cert-v01@openssh.com", options.pubkey_accepted_algos, 0) == 1) return 1; break; } return 0; }
int key_type_allowed_by_config(unsigned int *a0) { unsigned int v1; if (match_pattern_list(sshkey_ssh_name(a0), *(5248744), 0x0) == 1) { v1 = 1; } else { if (!*(a0)) { if (match_pattern_list("rsa-sha2-512", *(5248744), 0x0) == 1) { v1 = 1; goto LABEL_40439f; } if (match_pattern_list("rsa-sha2-256", *(5248744), 0x0) == 1) { v1 = 1; goto LABEL_40439f; } } else if (*(a0) == 4) { if (match_pattern_list("rsa-sha2-512-cert-v01@openssh.com", *(5248744), 0x0) == 1) { v1 = 1; goto LABEL_40439f; } if (match_pattern_list("rsa-sha2-256-cert-v01@openssh.com", *(5248744), 0x0) == 1) { v1 = 1; goto LABEL_40439f; } } v1 = 0; } LABEL_40439f: return v1; }
openssh-portable
angr_phoenix
static inline char *bad_cast(char const *s) { return (char *)s; }
int bad_cast(unsigned long a0) { return a0; }
coreutils
angr_sailr
void write_buf(fd, buf, cnt) int fd; voidp buf; unsigned cnt; { unsigned n; bytes_out += cnt; if (test) return; while ((n = write_buffer(fd, buf, cnt)) != cnt) { if (n == (unsigned)(-1)) { write_error(); } cnt -= n; buf = (voidp)((char *)buf + n); } }
void write_buf(unsigned long a0, unsigned long long a1, unsigned long a2) { unsigned long long v0; unsigned int v1; unsigned int v2; unsigned long long v4; unsigned long long v5; v0 = a1; v1 = a2; bytes_out = bytes_out + v1; v4 = test; if (test) return; while (true) { v2 = write_buffer(a0, v0, v1); v5 = v2; if (v2 == v1) return; if (v2 == -1) write_error(); v1 = v1 - v2; v0 += v2; } }
gzip-1.12
angr_sailr
static _Bool print_type_indicator(_Bool stat_ok, mode_t mode, enum filetype type) { char c = get_type_indicator(stat_ok, mode, type); if (c) dired_outbyte(c); return !!c; }
int print_type_indicator(unsigned long a0, unsigned long a1, unsigned long a2) { char v0; unsigned long long v2; v2 = get_type_indicator(a0, a1, a2); v0 = v2; if (v0) v2 = dired_outbyte(v0); *(&v2) = v0; return v2; }
coreutils
angr_phoenix
static char const *format_group(register FILE *out, char const *format, char endchar, struct group const *groups) { register char c; register char const *f = format; while ((c = *f) != endchar && c != 0) { char const *f1 = ++f; if (c == '%') switch ((c = *f++)) { case '%': break; case '(': { int i; intmax_t value[2]; FILE *thenout, *elseout; for (i = 0; i < 2; i++) { if (((unsigned int)(*f) - '0' <= 9)) { char *fend; (*__errno_location()) = 0; value[i] = strtoimax(f, &fend, 10); if ((*__errno_location())) goto bad_format; f = fend; } else { value[i] = groups_letter_value(groups, *f); if (value[i] < 0) goto bad_format; f++; } if (*f++ != "=?"[i]) goto bad_format; } if (value[0] == value[1]) thenout = out, elseout = 0; else thenout = 0, elseout = out; f = format_group(thenout, f, ':', groups); if (*f) { f = format_group(elseout, f + 1, ')', groups); if (*f) f++; } } continue; case '<': print_ifdef_lines(out, line_format[OLD], &groups[0]); continue; case '=': print_ifdef_lines(out, line_format[UNCHANGED], &groups[0]); continue; case '>': print_ifdef_lines(out, line_format[NEW], &groups[1]); continue; default: f = do_printf_spec(out, f - 2, 0, 0, groups); if (f) continue; bad_format: c = '%'; f = f1; break; } if (out) putc_unlocked(c, out); } return f; }
char *format_group(FILE *param_1, char *param_2, char param_3, long param_4) { int *piVar1; intmax_t iVar2; long lVar3; char *pcVar4; char *__nptr; char cVar5; long in_FS_OFFSET; int local_6c; char *local_68; FILE *local_60; FILE *local_58; char *local_50; long local_48[5]; local_48[3] = *(long *)(in_FS_OFFSET + 0x28); LAB_001004cf: do { cVar5 = *param_2; if ((cVar5 == param_3) || (cVar5 == '\0')) { if (local_48[3] != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return param_2; } local_50 = param_2 + 1; __nptr = local_50; if (cVar5 != '%') goto LAB_001004bc; __nptr = param_2 + 2; cVar5 = *local_50; switch (cVar5) { default: param_2 = (char *)do_printf_spec(param_1, param_2, 0, 0, param_4); if (param_2 != (char *)0x0) break; LAB_001004ac: cVar5 = '%'; __nptr = local_50; case '%': LAB_001004bc: param_2 = __nptr; if (param_1 != (FILE *)0x0) { putc_unlocked((int)cVar5, param_1); } break; case '(': for (local_6c = 0; local_6c < 2; local_6c = local_6c + 1) { if ((int)*__nptr - 0x30U < 10) { piVar1 = __errno_location(); *piVar1 = 0; iVar2 = strtoimax(__nptr, &local_68, 10); local_48[local_6c] = iVar2; piVar1 = __errno_location(); pcVar4 = local_68; if (*piVar1 != 0) goto LAB_001004ac; } else { lVar3 = groups_letter_value(param_4, (int)*__nptr); local_48[local_6c] = lVar3; if (local_48[local_6c] < 0) goto LAB_001004ac; pcVar4 = __nptr + 1; } __nptr = pcVar4 + 1; if (*pcVar4 != (&DAT_00100de0)[local_6c]) goto LAB_001004ac; } if (local_48[0] == local_48[1]) { local_58 = (FILE *)0x0; local_60 = param_1; } else { local_60 = (FILE *)0x0; local_58 = param_1; } param_2 = (char *)format_group(local_60, __nptr, 0x3a, param_4); if ((*param_2 != '\0') && (param_2 = (char *)format_group(local_58, param_2 + 1, 0x29, param_4), *param_2 != '\0')) { param_2 = param_2 + 1; } break; case '<': print_ifdef_lines(param_1, _putc_unlocked, param_4); param_2 = __nptr; break; case '=': print_ifdef_lines(param_1, line_format, param_4); param_2 = __nptr; break; case '>': goto switchD_001002cf_caseD_3e; } } while (true); switchD_001002cf_caseD_3e: print_ifdef_lines(param_1, _translate_line_number, param_4 + 0x18); param_2 = __nptr; goto LAB_001004cf; }
diffutils
ghidra
static struct jbd2_revoke_record_s * find_revoke_record(journal_t *journal, unsigned long long blocknr) { struct list_head *hash_list; struct jbd2_revoke_record_s *record; hash_list = &journal->j_revoke->hash_table[hash(journal, blocknr)]; ; record = (struct jbd2_revoke_record_s *)hash_list->next; while (&(record->hash) != hash_list) { if (record->blocknr == blocknr) { ; return record; } record = (struct jbd2_revoke_record_s *)record->hash.next; }; return ((void *)0); }
int find_revoke_record(struct_0 *a0, unsigned long long a1) { unsigned long long v0[4]; unsigned long long *v1; unsigned int v3; v1 = hash(a0, a1) * 16 + a0->field_a8->field_8; v0[0] = *(v1); while (true) { if (v1 == v0) { v3 = 0; break; } else if (a1 == v0[3]) { v3 = v0; break; } else { v0[0] = v0[0]; } } return v3; }
e2fsprogs-1.46.5
angr_dream
static void build_tree(desc) tree_desc *desc; { ct_data *tree = desc->dyn_tree; ct_data *stree = desc->static_tree; int elems = desc->elems; int n, m; int max_code = -1; int node = elems; heap_len = 0, heap_max = (2 * (256 + 1 + 29) + 1); for (n = 0; n < elems; n++) { if (tree[n].fc.freq != 0) { heap[++heap_len] = max_code = n; depth[n] = 0; } else { tree[n].dl.len = 0; } } while (heap_len < 2) { int new = heap[++heap_len] = (max_code < 2 ? ++max_code : 0); tree[new].fc.freq = 1; depth[new] = 0; opt_len--; if (stree) static_len -= stree[new].dl.len; } desc->max_code = max_code; for (n = heap_len / 2; n >= 1; n--) pqdownheap(tree, n); do { { n = heap[1]; heap[1] = heap[heap_len--]; pqdownheap(tree, 1); }; m = heap[1]; heap[--heap_max] = n; heap[--heap_max] = m; tree[node].fc.freq = tree[n].fc.freq + tree[m].fc.freq; depth[node] = (uch)((depth[n] >= depth[m] ? depth[n] : depth[m]) + 1); tree[n].dl.dad = tree[m].dl.dad = (ush)node; heap[1] = node++; pqdownheap(tree, 1); } while (heap_len >= 2); heap[--heap_max] = heap[1]; gen_bitlen((tree_desc *)desc); gen_codes((ct_data *)tree, max_code); }
void build_tree(struct_1 *a0) { unsigned int v0; int tmp_18; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned int v5; unsigned short *v6; unsigned long v7; unsigned int v9; char v10; unsigned int v11; unsigned long long v12; v6 = a0->field_0; v7 = a0->field_8; v3 = a0->field_1c; v1 = -1; v2 = v3; heap_len = 0; heap_max = 573; for (v0 = 0; v0 < v3; v0 += 1) { if (v6[2 * v0]) { v1 = v0; heap_len = heap_len + 1; *((4 * heap_len + &heap)) = v1; *(v0 + &depth) = 0; } else { v6[1 + 2 * v0] = 0; } } while (true) { if (heap_len <= 1) { if (v1 <= 1) { v1 += 1; v9 = v1; } else { v9 = 0; } heap_len = heap_len + 1; *((4 * heap_len + &heap)) = v9; v5 = *((4 * heap_len + &heap)); v6[2 * v5] = 1; *(v5 + &depth) = 0; opt_len = opt_len - 1; if (!v7) continue; static_len = static_len - *((v7 + v5 * 4 + 2)); } else { a0->field_24 = v1; for (v0 = heap_len + (heap_len >> 31) >> 1; v0 > 0; v0 -= 1) { pqdownheap(v6, v0); } while (true) { v0 = g_402f04; tmp_18 = heap_len; heap_len = heap_len - 1; g_402f04 = *((4 * tmp_18 + &heap)); pqdownheap(v6, 0x1); v4 = g_402f04; heap_max = heap_max - 1; *((4 * heap_max + &heap)) = v0; heap_max = heap_max - 1; *((4 * heap_max + &heap)) = v4; v6[2 * v2] = v6[2 * v4] + v6[2 * v0]; if (*(v0 + &depth) >= *(v4 + &depth)) v10 = *(v0 + &depth) + 1; else v10 = *(v4 + &depth) + 1; *(v2 + &depth) = v10; v11 = v2; v6[1 + 2 * v4] = v2; v6[1 + 2 * v0] = v6[1 + 2 * v4]; v2 += 1; g_402f04 = v11; pqdownheap(v6, 0x1); if (heap_len <= 1) break; } heap_max = heap_max - 1; *((4 * heap_max + &heap)) = g_402f04; gen_bitlen(a0); v12 = gen_codes(v6, v1); return; } } }
gzip-1.12
angr_dream
void sv_strict_posix(name) char *name; { SHELL_VAR *var; var = find_variable(name); posixly_correct = var && ((var)->value != 0); posix_initialize(posixly_correct); if (interactive_shell) posix_readline_initialize(posixly_correct); set_shellopts(); }
void sv_strict_posix(unsigned long long a0, unsigned long long a1, unsigned long long a2, unsigned long long a3, unsigned long long a4, unsigned long long a5) { struct_0 *v0; unsigned int v2; unsigned long long v3; v0 = find_variable(a0); if (v0 && v0->field_8) { v2 = 1; goto LABEL_40b0c6; } v2 = 0; LABEL_40b0c6: posixly_correct = v2; posix_initialize(posixly_correct); if (interactive_shell) posix_readline_initialize(posixly_correct); v3 = set_shellopts(posixly_correct, a1, a2, a3, a4, a5); return; }
bash
angr_phoenix
int kex_exchange_identification(struct ssh *ssh, int timeout_ms, const char *version_addendum) { int remote_major, remote_minor, mismatch, oerrno = 0; size_t len, i, n; int r, expect_nl; u_char c; struct sshbuf *our_version = ssh->kex->server ? ssh->kex->server_version : ssh->kex->client_version; struct sshbuf *peer_version = ssh->kex->server ? ssh->kex->client_version : ssh->kex->server_version; char *our_version_string = ((void *)0), *peer_version_string = ((void *)0); char *cp, *remote_version = ((void *)0); sshbuf_reset(our_version); if (version_addendum != ((void *)0) && *version_addendum == '\0') version_addendum = ((void *)0); if ((r = sshbuf_putf( our_version, "SSH-%d.%d-%.100s%s%s\r\n", 2, 0, "OpenSSH_9.1", version_addendum == ((void *)0) ? "" : " ", version_addendum == ((void *)0) ? "" : version_addendum)) != 0) { oerrno = (*__errno_location()); sshlog("kex.c", __func__, 1237, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "sshbuf_putf"); goto out; } if (atomicio((ssize_t (*)(int, void *, size_t))write, ssh_packet_get_connection_out(ssh), sshbuf_mutable_ptr(our_version), sshbuf_len(our_version)) != sshbuf_len(our_version)) { oerrno = (*__errno_location()); sshlog("kex.c", __func__, 1245, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0), "write: %.100s", strerror((*__errno_location()))); r = -24; goto out; } if ((r = sshbuf_consume_end(our_version, 2)) != 0) { oerrno = (*__errno_location()); sshlog("kex.c", __func__, 1251, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "sshbuf_consume_end"); goto out; } our_version_string = sshbuf_dup_string(our_version); if (our_version_string == ((void *)0)) { sshlog("kex.c", __func__, 1256, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "sshbuf_dup_string failed"); r = -2; goto out; } sshlog("kex.c", __func__, 1260, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "Local version string %.100s", our_version_string); for (n = 0;; n++) { if (n >= 1024) { send_error(ssh, "No SSH identification string " "received."); sshlog("kex.c", __func__, 1267, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "No SSH version received in first %u lines " "from server", 1024); r = -4; goto out; } sshbuf_reset(peer_version); expect_nl = 0; for (i = 0;; i++) { if (timeout_ms > 0) { r = waitrfd(ssh_packet_get_connection_in(ssh), &timeout_ms); if (r == -1 && (*__errno_location()) == 110) { send_error(ssh, "Timed out waiting " "for SSH identification string."); sshlog("kex.c", __func__, 1281, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Connection timed out during " "banner exchange"); r = -53; goto out; } else if (r == -1) { oerrno = (*__errno_location()); sshlog("kex.c", __func__, 1287, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "%s", strerror((*__errno_location()))); r = -24; goto out; } } len = atomicio(read, ssh_packet_get_connection_in(ssh), &c, 1); if (len != 1 && (*__errno_location()) == 32) { sshlog("kex.c", __func__, 1296, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "Connection closed by remote host"); r = -52; goto out; } else if (len != 1) { oerrno = (*__errno_location()); sshlog("kex.c", __func__, 1301, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "read: %.100s", strerror((*__errno_location()))); r = -24; goto out; } if (c == '\r') { expect_nl = 1; continue; } if (c == '\n') break; if (c == '\0' || expect_nl) { sshlog("kex.c", __func__, 1312, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "banner line contains invalid " "characters"); goto invalid; } if ((r = sshbuf_put_u8(peer_version, c)) != 0) { oerrno = (*__errno_location()); sshlog("kex.c", __func__, 1318, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "sshbuf_put"); goto out; } if (sshbuf_len(peer_version) > 8192) { sshlog("kex.c", __func__, 1322, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "banner line too long"); goto invalid; } } if (sshbuf_len(peer_version) > 4 && memcmp(sshbuf_ptr(peer_version), "SSH-", 4) == 0) break; if ((cp = sshbuf_dup_string(peer_version)) == ((void *)0)) { sshlog("kex.c", __func__, 1332, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "sshbuf_dup_string failed"); r = -2; goto out; } if (ssh->kex->server) { sshlog("kex.c", __func__, 1338, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "client sent invalid protocol identifier " "\"%.256s\"", cp); free(cp); goto invalid; } sshlog("kex.c", __func__, 1343, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0), "banner line %zu: %s", n, cp); free(cp); } peer_version_string = sshbuf_dup_string(peer_version); if (peer_version_string == ((void *)0)) sshlog("kex.c", __func__, 1348, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "sshbuf_dup_string failed"); if ((remote_version = calloc(1, sshbuf_len(peer_version))) == ((void *)0)) { sshlog("kex.c", __func__, 1351, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "calloc failed"); r = -2; goto out; } if (sscanf(peer_version_string, "SSH-%d.%d-%[^\n]\n", &remote_major, &remote_minor, remote_version) != 3) { sshlog("kex.c", __func__, 1362, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Bad remote protocol version identification: '%.100s'", peer_version_string); invalid: send_error(ssh, "Invalid SSH identification string."); r = -4; goto out; } sshlog("kex.c", __func__, 1369, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "Remote protocol version %d.%d, remote software version %.100s", remote_major, remote_minor, remote_version); compat_banner(ssh, remote_version); mismatch = 0; switch (remote_major) { case 2: break; case 1: if (remote_minor != 99) mismatch = 1; break; default: mismatch = 1; break; } if (mismatch) { sshlog("kex.c", __func__, 1386, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Protocol major versions differ: %d vs. %d", 2, remote_major); send_error(ssh, "Protocol major versions differ."); r = -38; goto out; } if (ssh->kex->server && (ssh->compat & 0x00400000) != 0) { sshlog("kex.c", __func__, 1394, 0, SYSLOG_LEVEL_INFO, ((void *)0), "probed from %s port %d with %s. Don't panic.", ssh_remote_ipaddr(ssh), ssh_remote_port(ssh), peer_version_string) ; r = -52; goto out; } if (ssh->kex->server && (ssh->compat & 0x00000800) != 0) { sshlog("kex.c", __func__, 1401, 0, SYSLOG_LEVEL_INFO, ((void *)0), "scanned from %s port %d with %s. Don't panic.", ssh_remote_ipaddr(ssh), ssh_remote_port(ssh), peer_version_string) ; r = -52; goto out; } if ((ssh->compat & 0x00002000) != 0) { sshlog("kex.c", __func__, 1408, 0, SYSLOG_LEVEL_INFO, ((void *)0), "Remote version \"%.100s\" uses unsafe RSA signature " "scheme; disabling use of RSA keys", remote_version); } r = 0; out: free(our_version_string); free(peer_version_string); free(remote_version); if (r == -24) (*__errno_location()) = oerrno; return r; }
long long kex_exchange_identification(struct_0 *a0, unsigned long a1, unsigned long a2) { unsigned long v0; void *v1; void *v2; char v3; char v4; char v5; char v6; unsigned int v7; unsigned int v8; unsigned int v9; unsigned int v10; void *v11; void *v12; void *v13; void *v14; void *v15; unsigned long long v16; unsigned long long v17; unsigned long v18; void *v19; unsigned long long v21; unsigned long long v22; unsigned long long v23; unsigned long long v25; unsigned long long v26; unsigned long long v27; unsigned long long v28; unsigned int v29; unsigned long long v30; unsigned long long v31; v2 = a2; v8 = 0; if (a0->field_8->field_18) v21 = a0->field_8->field_68; else v21 = a0->field_8->field_60; v16 = v21; if (a0->field_8->field_18) v22 = a0->field_8->field_60; else v22 = a0->field_8->field_68; v17 = v22; v13 = 0; v14 = 0; v15 = 0; sshbuf_reset(v16); if (v2 && !*(v2)) v2 = 0; if (!v2) v23 = &g_404683; else v23 = " "; v9 = sshbuf_putf(v16, "SSH-%d.%d-%.100s%s%s\r\n", 0x2, 0x0, "OpenS", v23); if (v9) { v8 = *(__errno_location()); sshlog("kex.c", "kex_exchange_identification", 0x4d5, 0x1, 0x2, ssh_err(v9), "sshbuf_putf"); } else { v25 = sshbuf_len(v16); if (atomicio(got.write, ssh_packet_get_connection_out(a0), sshbuf_mutable_ptr(v16), sshbuf_len(v16)) != v25) { v8 = *(__errno_location()); v1 = strerror(*(__errno_location())); sshlog("kex.c", "kex_exchange_identification", 0x4dd, 0x1, 0x5, 0x0, "write"); v9 = -24; } else { v9 = sshbuf_consume_end(v16, 0x2); if (v9) { v8 = *(__errno_location()); sshlog("kex.c", "kex_exchange_identification", 0x4e3, 0x1, 0x2, ssh_err(v9), "sshbuf_consume_end"); } else { v13 = sshbuf_dup_string(v16); if (!v13) { sshlog("kex.c", "kex_exchange_identification", 0x4e8, 0x1, 0x2, 0x0, "sshbuf_dup_string failed"); v9 = -2; } else { v1 = v13; sshlog("kex.c", "kex_exchange_identification", 0x4ec, 0x0, 0x5, 0x0, "Local version string %.100s"); v12 = 0; while (true) { if (v12 > 1023) { send_error(a0, "No SSH identification string received."); v1 = 0x400; sshlog("kex.c", "kex_exchange_identification", 0x4f3, 0x1, 0x2, 0x0, "No SSH version received in first %u lines from server"); v9 = -0x4; break; } else { sshbuf_reset(v17); v10 = 0; v11 = 0; while (true) { if (a1 > 0) { v25 = ssh_packet_get_connection_in(a0); v9 = waitrfd(v25, &v3, v25); if (v9 == -1) { *(&v25) = *(__errno_location()); if (v25 == 110) { send_error( a0, "Timed out waiting for SSH identification string."); sshlog("kex.c", "kex_exchange_identification", 0x501, 0x0, 0x2, 0x0, "Connection timed out during banner exchange"); v9 = -53; break; } else { v8 = *(__errno_location()); v1 = strerror(*(__errno_location())); sshlog("kex.c", "kex_exchange_identification", 0x507, 0x1, 0x2, 0x0, "%s"); v9 = -24; break; } } } if (a1 <= 0 || v9 != -1) { v18 = atomicio(got.read, ssh_packet_get_connection_in(a0), &v4, 0x1); if (v18 != 1) { *(&v25) = *(__errno_location()); if (v25 == 32) { sshlog("kex.c", "kex_exchange_identification", 0x510, 0x1, 0x2, 0x0, "Connection closed by remote host"); v9 = -52; break; } } if (v18 == 1 || v25 != 32) { if (v18 != 1) { v8 = *(__errno_location()); v1 = strerror(*(__errno_location())); sshlog("kex.c", "kex_exchange_identification", 0x515, 0x1, 0x2, 0x0, "read: %.100s"); v9 = -24; break; } else { if (v4 == 13) { v10 = 1; } else if (v4 != 10 && v4 && !v10) { v9 = sshbuf_put_u8(v17, v4); if (v9) { v8 = *(__errno_location()); sshlog("kex.c", "kex_exchange_identification", 0x526, 0x1, 0x2, ssh_err(v9), "sshbuf_put"); break; } else { v26 = sshbuf_len(v17); if (v26 > 0x2000) sshlog("kex.c", "kex_exchange_identification", 0x52a, 0x1, 0x2, 0x0, "banner line too long"); } } if (v4 == 10) { v27 = sshbuf_len(v17); if (v27 > 4) { v28 = memcmp(sshbuf_ptr(v17), "SSH-", 0x4); if (!v28) { v14 = sshbuf_dup_string(v17); if (!v14) sshlog("kex.c", "kex_exchange_identification", 0x544, 0x1, 0x2, 0x0, "sshbuf_dup_string failed"); v15 = calloc(0x1, sshbuf_len(v17)); if (!v15) { sshlog("kex.c", "kex_exchange_identification", 0x547, 0x1, 0x2, 0x0, "calloc failed"); v9 = -2; break; } else { v29 = __isoc99_sscanf(v14, "SSH-%d.%d-%[^\n]\n", &v5, &v6); if (v29 != 3) { v1 = v14; sshlog("kex.c", "kex_exchange_identification", 0x552, 0x0, 0x2, 0x0, "Bad remote protocol version " "identification: '%.100s'"); } else { v1 = v15; v0 = *(&v5); sshlog("kex.c", "kex_exchange_identification", 0x559, 0x0, 0x5, 0x0, "Remote protocol version %d.%d, remote " "software version %.100s"); compat_banner(a0, v15, v15); v7 = 0; v29 = *(&v5); if (*(&v5) != 1) { if (v29 != 2) v7 = 1; } else { if (*(&v6) != 99) v7 = 1; } if (v7) { v0 = 2; sshlog("kex.c", "kex_exchange_identification", 0x56a, 0x0, 0x2, 0x0, "Protocol major versions differ: %d " "vs. %d"); send_error(a0, "Protocol major versions differ."); v9 = -38; break; } else { if (a0->field_8->field_18 && (a0->field_83c & kex_alg_list)) { v30 = ssh_remote_port(a0); v1 = v14; v0 = ssh_remote_ipaddr(a0); sshlog("kex.c", "kex_exchange_identification", 0x572, 0x0, 0x3, 0x0, "probed from %s port %d with %s. " "Don't panic."); v9 = -52; break; } if (!a0->field_8->field_18 || !(a0->field_83c & kex_alg_list)) { if (a0->field_8->field_18 && (a0->field_83c & 0x800)) { v31 = ssh_remote_port(a0); v1 = v14; v0 = ssh_remote_ipaddr(a0); sshlog("kex.c", "kex_exchange_identification", 0x579, 0x0, 0x3, 0x0, "scanned from %s port %d with %s. " " Don't panic."); v9 = -52; break; } if (!(a0->field_83c & 0x800) || !a0->field_8->field_18) { if ((a0->field_83c & 0x2000)) { v1 = v15; sshlog("kex.c", "kex_exchange_identification", 0x580, 0x0, 0x3, 0x0, "Remote version \"%.100s\" uses " "unsafe RSA signature scheme; " "disabling use of RSA keys"); } v9 = 0; break; } } } } } } } if (v27 <= 4 || v28) { v19 = sshbuf_dup_string(v17); if (!v19) { sshlog("kex.c", "kex_exchange_identification", 0x534, 0x1, 0x2, 0x0, "sshbuf_dup_string failed"); v9 = -2; break; } else if (a0->field_8->field_18) { v1 = v19; sshlog("kex.c", "kex_exchange_identification", 0x53a, 0x1, 0x2, 0x0, "client sent invalid protocol identifier " "\"%.256s\""); free(v19); } else { v0 = v12; sshlog("kex.c", "kex_exchange_identification", 0x53f, 0x1, 0x5, 0x0, "banner line %zu: %s"); free(v19); v12 += 1; break; } } } if (!v4 || v10 && v4 != 10 && v4 != 13) sshlog("kex.c", "kex_exchange_identification", 0x520, 0x1, 0x2, 0x0, "banner line contains invalid characters"); if (v4 == 13 || !v10 && v26 <= 0x2000 && !v9 && v4 != 10 && v4) { v11 += 1; continue; } if (v4 == 10 && a0->field_8->field_18 && v19 && (v27 <= 4 || v28) || v4 == 10 && !v28 && v15 && v29 != 3 && v27 > 4 || !v10 && !v9 && v4 != 10 && v26 > 0x2000 && v4 != 13 && v4 || !v4 || v10 && v4 != 10 && v4 != 13) { send_error(a0, "Invalid SSH identification string."); v9 = -0x4; break; } } } } } if (...) break; } } } } } } free(v13); free(v14); free(v15); if (v9 == -24) *(__errno_location()) = v8; return v9; }
openssh-portable
angr_dream
char *vis(char *mbdst, int c, int flags, int nextc) { char cc[2]; int ret; cc[0] = c; cc[1] = nextc; ret = istrsenvisx(&mbdst, ((void *)0), cc, 1, flags, "", ((void *)0)); if (ret < 0) return ((void *)0); return mbdst + ret; }
long long vis(unsigned long a0, unsigned long a1, unsigned long a2, unsigned long a3) { char v0; unsigned int v1; char v2; char v3; void *v5; v2 = a1; v3 = a3; v1 = istrsenvisx(&v0, NULL, &v2, 0x1, a2, &g_4018dc, NULL); if (v1 < 0) v5 = 0; else v5 = v1 + a0; return v5; }
libbsd-0.11.7
angr_phoenix
int a2port(const char *s) { struct servent *se; long long port; const char *errstr; port = strtonum(s, 0, 65535, &errstr); if (errstr == ((void *)0)) return (int)port; if ((se = getservbyname(s, "tcp")) != ((void *)0)) return ntohs(se->s_port); return -1; }
int a2port(char *a0) { char v0; unsigned long v1; struct_0 *v2; unsigned int v4; v1 = strtonum(a0, 0x0, 0xffff, &v0); if (!*(&v0)) { v4 = v1; } else { v2 = &getservbyname(a0, "tcp")->s_name; if (!v2) v4 = -1; else v4 = ntohs(v2->field_10); } return v4; }
openssh-portable
angr_phoenix
static int blob_section(struct sshbuf *sect, struct revoked_blob_tree *target_tree, size_t expected_len) { u_char *rdata = ((void *)0); size_t rlen = 0; int r; while (sshbuf_len(sect) > 0) { if ((r = sshbuf_get_string(sect, &rdata, &rlen)) != 0) return r; if (expected_len != 0 && rlen != expected_len) { sshlog("krl.c", __func__, 967, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "bad length"); free(rdata); return -4; } if ((r = revoke_blob(target_tree, rdata, rlen)) != 0) { free(rdata); return r; } } return 0; }
long blob_section(long a1, long *a2, void *a3) { long i; unsigned int string; unsigned int v7; void *ptr; void *v9[2]; v9[1] = (void *)__readfsqword(0x28u); ptr = 0LL; v9[0] = 0LL; for (i = sshbuf_len(a1); i; i = sshbuf_len(a1)) { string = sshbuf_get_string(a1, &ptr, v9); if (string) return string; if (a3 && a3 != v9[0]) { sshlog("krl.c", "blob_section", 967LL, 1LL, 2LL, 0LL, "bad length"); free(ptr); return 4294967292LL; } v7 = revoke_blob(a2, ptr, v9[0]); if (v7) { free(ptr); return v7; } } return 0LL; }
openssh-portable
ida
static void kbdint_free(KbdintAuthctxt *kbdintctxt) { if (kbdintctxt->device) kbdint_reset_device(kbdintctxt); free(kbdintctxt->devices); freezero(kbdintctxt, sizeof(*kbdintctxt)); }
void kbdint_free(unsigned long long a0[3]) { unsigned long long v1; if (a0[2]) kbdint_reset_device(a0); free(a0[0]); v1 = freezero(a0, 0x20); return; }
openssh-portable
angr_dream
int inflateResetKeep(strm) z_streamp strm; { struct inflate_state *state; if (inflateStateCheck(strm)) return (-2); state = (struct inflate_state *)strm->state; strm->total_in = strm->total_out = state->total = 0; strm->msg = 0; if (state->wrap) strm->adler = state->wrap & 1; state->mode = HEAD; state->last = 0; state->havedict = 0; state->flags = -1; state->dmax = 32768U; state->head = 0; state->hold = 0; state->bits = 0; state->lencode = state->distcode = state->next = state->codes; state->sane = 1; state->back = -1; ; return 0; }
void inflateResetKeep(unsigned long long a0[13]) { struct_0 *v0; unsigned long long v2; void *v3; if (inflateStateCheck(a0)) { v2 = 4294967294; return; } v0 = a0[7]; v0->field_28 = 0; a0[5] = v0->field_28; a0[2] = a0[5]; a0[6] = 0; if (v0->field_10) a0[12] = v0->field_10 & 1; v0->field_8 = 16180; v0->field_c = 0; v0->field_14 = 0; v0->field_18 = -1; v0->field_1c = 0x8000; v0->field_30 = 0; v0->field_50 = 0; v0->field_58 = 0; v0->field_90 = &v0->padding_98[1216]; v0->field_70 = v0->field_90; v0->field_68 = v0->field_70; v0->field_1be8 = 1; v0->field_1bec = -1; v3 = 0; return; }
zlib
angr_sailr
off_t gztell(file) gzFile file; { off64_t ret; ret = gztell64(file); return ret == (off_t)ret ? (off_t)ret : -1; }
long gztell(long a1) { return gztell64(a1); }
zlib
ida
static void copy_stat(ifstat) struct stat *ifstat; { mode_t mode = ifstat->st_mode & ((0400 | 0200 | 0100) | ((0400 | 0200 | 0100) >> 3) | (((0400 | 0200 | 0100) >> 3) >> 3)); int r; _Bool restoring; struct timespec timespec[2]; timespec[0] = get_stat_atime(ifstat); timespec[1] = get_stat_mtime(ifstat); restoring = (decompress && 0 <= time_stamp.tv_nsec && !(timespec[1].tv_sec == time_stamp.tv_sec && timespec[1].tv_nsec == time_stamp.tv_nsec)); if (restoring) timespec[1] = time_stamp; if (fdutimens(ofd, ofname, timespec) == 0) { if (restoring && 1 < verbose) { fprintf(stderr, "%s: timestamp restored\n", ofname); } } else { int e = (*__errno_location()); { if (!quiet) fprintf(stderr, "%s: ", program_name); if (exit_code == 0) exit_code = 2; }; if (!quiet) { (*__errno_location()) = e; perror(ofname); } } do_chown(ofd, ofname, -1, ifstat->st_gid); r = fchmod(ofd, mode); if (r != 0) { int e = (*__errno_location()); { if (!quiet) fprintf(stderr, "%s: ", program_name); if (exit_code == 0) exit_code = 2; }; if (!quiet) { (*__errno_location()) = e; perror(ofname); } } do_chown(ofd, ofname, ifstat->st_uid, -1); }
unsigned long copy_stat(_DWORD *a1) { long v1; long v2; bool v3; time_t v4; bool v6; int mode; int v8; int v9; long v10[2]; long stat_mtime; long v12; unsigned long v13; v13 = __readfsqword(0x28u); mode = a1[6] & 0x1FF; v10[0] = get_stat_atime(a1); v10[1] = v1; stat_mtime = get_stat_mtime(a1); v12 = v2; v3 = decompress && time_stamp[1] >= 0 && (stat_mtime != time_stamp[0] || v12 != time_stamp[1]); v6 = v3; if (v3) { v4 = time_stamp[1]; stat_mtime = time_stamp[0]; v12 = v4; } if ((unsigned int)fdutimens((unsigned int)ofd, ofname, v10)) { v8 = *_errno_location(); if (!quiet) fprintf(stderr, "%s: ", program_name); if (!exit_code) exit_code = 2; if (!quiet) { *_errno_location() = v8; perror(ofname); } } else if (v6 && verbose > 1) { fprintf(stderr, "%s: timestamp restored\n", ofname); } do_chown(ofd, (long)ofname, 0xFFFFFFFF, a1[8]); if (fchmod(ofd, mode)) { v9 = *_errno_location(); if (!quiet) fprintf(stderr, "%s: ", program_name); if (!exit_code) exit_code = 2; if (!quiet) { *_errno_location() = v9; perror(ofname); } } do_chown(ofd, (long)ofname, a1[7], 0xFFFFFFFF); return __readfsqword(0x28u) ^ v13; }
gzip-1.12
ida
static int check_net_or_keyboard_input(socket_st *hd, unsigned user_term) { int maxfd; fd_set rset; int err; struct timeval tv; do { do { unsigned int __i; fd_set *__arr = (&rset); for (__i = 0; __i < sizeof(fd_set) / sizeof(__fd_mask); ++__i) ((__arr)->fds_bits)[__i] = 0; } while (0); ((void)(((&rset)->fds_bits)[((hd->fd) / (8 * (int)sizeof(__fd_mask)))] |= ((__fd_mask)(1UL << ((hd->fd) % (8 * (int)sizeof(__fd_mask))))))); if (!user_term) { ((void)(((&rset)->fds_bits)[((fileno(stdin)) / (8 * (int)sizeof(__fd_mask)))] |= ((__fd_mask)(1UL << ((fileno(stdin)) % (8 * (int)sizeof(__fd_mask))))))); maxfd = (((fileno(stdin)) > (hd->fd)) ? (fileno(stdin)) : (hd->fd)); } else { maxfd = hd->fd; } tv.tv_sec = 2; tv.tv_usec = 0; if (hd->secure == 1) if (gnutls_record_check_pending(hd->session)) return 2; err = select(maxfd + 1, &rset, ((void *)0), ((void *)0), &tv); if (err < 0) continue; if (((((&rset)->fds_bits)[((hd->fd) / (8 * (int)sizeof(__fd_mask)))] & ((__fd_mask)(1UL << ((hd->fd) % (8 * (int)sizeof(__fd_mask)))))) != 0)) return 2; if (!user_term && ((((&rset) ->fds_bits)[((fileno(stdin)) / (8 * (int)sizeof(__fd_mask)))] & ((__fd_mask)(1UL << ((fileno(stdin)) % (8 * (int)sizeof(__fd_mask)))))) != 0)) return 1; if (err == 0 && user_term) return 3; } while (err == 0); return 0; }
undefined8 check_net_or_keyboard_input(int *param_1, int param_2) { ulong uVar1; byte bVar2; int iVar3; int iVar4; long lVar5; undefined8 uVar6; long in_FS_OFFSET; int local_cc; uint local_c8; timeval local_b8; fd_set local_a8; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); do { for (local_c8 = 0; local_c8 < 0x10; local_c8 = local_c8 + 1) { local_a8.fds_bits[local_c8] = 0; } iVar4 = *param_1; if (iVar4 < 0) { iVar4 = iVar4 + 0x3f; } bVar2 = (byte)(*param_1 >> 0x37); local_a8.fds_bits[iVar4 >> 6] = local_a8.fds_bits[iVar4 >> 6] | 1 << (((char)*param_1 + (bVar2 >> 2) & 0x3f) - (bVar2 >> 2) & 0x3f); if (param_2 == 0) { iVar3 = fileno(stdin); bVar2 = (byte)(iVar3 >> 0x37); iVar4 = fileno(stdin); if (iVar4 < 0) { iVar4 = iVar4 + 0x3f; } local_a8.fds_bits[iVar4 >> 6] = 1 << (((char)iVar3 + (bVar2 >> 2) & 0x3f) - (bVar2 >> 2) & 0x3f) | local_a8.fds_bits[iVar4 >> 6]; iVar4 = fileno(stdin); if (*param_1 < iVar4) { local_cc = fileno(stdin); } else { local_cc = *param_1; } } else { local_cc = *param_1; } local_b8.tv_sec = 2; local_b8.tv_usec = 0; if ((param_1[4] == 1) && (lVar5 = gnutls_record_check_pending(), lVar5 != 0)) { uVar6 = 2; goto LAB_00101f47; } iVar4 = select(local_cc + 1, &local_a8, (fd_set *)0x0, (fd_set *)0x0, &local_b8); if (-1 < iVar4) { iVar3 = *param_1; if (iVar3 < 0) { iVar3 = iVar3 + 0x3f; } bVar2 = (byte)(*param_1 >> 0x37); if ((1 << (((char)*param_1 + (bVar2 >> 2) & 0x3f) - (bVar2 >> 2) & 0x3f) & local_a8.fds_bits[iVar3 >> 6]) != 0) { uVar6 = 2; goto LAB_00101f47; } if (param_2 == 0) { iVar3 = fileno(stdin); if (iVar3 < 0) { iVar3 = iVar3 + 0x3f; } uVar1 = local_a8.fds_bits[iVar3 >> 6]; iVar3 = fileno(stdin); bVar2 = (byte)(iVar3 >> 0x37); if ((1 << (((char)iVar3 + (bVar2 >> 2) & 0x3f) - (bVar2 >> 2) & 0x3f) & uVar1) != 0) { uVar6 = 1; goto LAB_00101f47; } } if ((iVar4 == 0) && (param_2 != 0)) { uVar6 = 3; goto LAB_00101f47; } } if (iVar4 != 0) { uVar6 = 0; LAB_00101f47: if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar6; } __stack_chk_fail(); } } while (true); }
gnutls
ghidra
static void initseq(struct seq *seq) { seq->count = 0; seq->alloc = 0; seq->lines = ((void *)0); }
void initseq(unsigned long long a0[3]) { char v0; unsigned long long v2[3]; unsigned long long v3; a0[0] = 0; a0[1] = 0; v2 = a0; a0[2] = 0; v3 = *(&v0); return; }
coreutils
angr_sailr
static int execute_list_with_replacements(list) WORD_LIST *list; { register WORD_LIST *l; int job, result; COMMAND *command; JOB *j; for (l = list; l; l = l->next) { if (l->word->word[0] == '%') { job = get_job_spec(l); if (((job) < 0 || (job) >= js.j_jobslots || (jobs[(job)]) == 0)) continue; j = (jobs[(job)]); sh_xfree((l->word->word), "./jobs.def", 190); l->word->word = itos(j->pgrp); } } begin_unwind_frame("jobs_builtin"); command = make_bare_simple_command(); command->value.Simple->words = copy_word_list(list); command->value.Simple->redirects = (REDIRECT *)((void *)0); command->flags |= 0x20; command->value.Simple->flags |= 0x20; add_unwind_protect(dispose_command, command); result = execute_command(command); dispose_command(command); discard_unwind_frame("jobs_builtin"); return (result); }
long execute_list_with_replacements(long *a1) { long *i; _QWORD *v2; long v3; unsigned int v5; int job_spec; long bare_simple_command; long v8; for (i = a1; i; i = (long *)*i) { if (**(_BYTE **)i[1] == 37) { job_spec = get_job_spec(i); if (job_spec >= 0 && job_spec < js[7] && *(_QWORD *)(8LL * job_spec + jobs)) { v8 = *(_QWORD *)(8LL * job_spec + jobs); sh_xfree(*(_QWORD *)i[1], "./jobs.def", 190LL); v2 = (_QWORD *)i[1]; *v2 = itos(*(int *)(v8 + 16)); } } } begin_unwind_frame("jobs_builtin"); bare_simple_command = make_bare_simple_command(); v3 = *(_QWORD *)(bare_simple_command + 24); *(_QWORD *)(v3 + 8) = copy_word_list(a1); *(_QWORD *)(*(_QWORD *)(bare_simple_command + 24) + 16LL) = 0LL; *(_DWORD *)(bare_simple_command + 4) |= 0x20u; **(_DWORD **)(bare_simple_command + 24) |= 0x20u; add_unwind_protect(&dispose_command, bare_simple_command); v5 = execute_command(bare_simple_command); dispose_command(bare_simple_command); discard_unwind_frame("jobs_builtin"); return v5; }
bash
ida
void onsig(int signo) { if (vforked) return; if (signo == 17) { gotsigchld = 1; if (!trap[17]) return; } gotsig[signo - 1] = 1; pending_sig = signo; if (signo == 2 && !trap[2]) { if (!suppressint) onint(); intpending = 1; } }
long long onsig(unsigned long a0) { unsigned long long v1; v1 = vforked; if (!vforked) { if (a0 == 17) { gotsigchld = 1; v1 = 0xfff78e8000000; if (!0xfff78e8000000) goto LABEL_400650; } *((a0 + 4196799)) = 1; v1 = a0; gotsigchld = a0; if (a0 == 2) { v1 = 9909343874642870411; if (false) { v1 = suppressint; if (!suppressint) v1 = onint(); intpending = 1; } } } LABEL_400650: return v1; }
dash-0.5.11+git20210903+057cd650a4ed
angr_phoenix
static void usage(void) { fprintf(stderr, "Usage: rtmon [ OPTIONS ] file FILE [ all | LISTofOBJECTS ]\n" "OPTIONS := { -f[amily] { inet | inet6 | link | help } |\n" " -4 | -6 | -0 | -V[ersion] }\n" "LISTofOBJECTS := [ link ] [ address ] [ route ]\n"); exit(-1); }
void usage() { fprintf( stderr, "Usage: rtmon [ OPTIONS ] file FILE [ all | LISTofOBJECTS ]\nOPTIONS := " "{ -f[amily] { inet | inet6 | link | help } |\n -4 | -6 | -0 " "| -V[ersion] }\nLISTofOBJECTS := [ link ] [ address ] [ route ]\n"); exit(0xffffffff); }
iproute2-6.0.0
angr_dream
void sh_erange(s, desc) char *s, *desc; { if (s) builtin_error(gettext("%s: %s out of range"), s, desc ? desc : gettext("argument")); else builtin_error(gettext("%s out of range"), desc ? desc : gettext("argument")); }
long long sh_erange(unsigned long a0, unsigned long a1) { unsigned long long v1; if (a0) { if (!a1) gettext("argument"); gettext("%s: %s out of range"); v1 = builtin_error(); } else { if (!a1) gettext("argument"); gettext("%s out of range"); v1 = builtin_error(); } return v1; }
bash
angr_phoenix
static void cleanUpAndFail(Int32 ec) { IntNative retVal; struct stat statBuf; if (srcMode == 3 && opMode != 3 && deleteOutputOnInterrupt) { retVal = stat(inName, &statBuf); if (retVal == 0) { if (noisy) fprintf(stderr, "%s: Deleting output file %s, if it exists.\n", progName, outName); if (outputHandleJustInCase != ((void *)0)) fclose(outputHandleJustInCase); retVal = remove(outName); if (retVal != 0) fprintf(stderr, "%s: WARNING: deletion of output file " "(apparently) failed.\n", progName); } else { fprintf(stderr, "%s: WARNING: deletion of output file suppressed\n", progName); fprintf(stderr, "%s: since input file no longer exists. Output file\n", progName); fprintf(stderr, "%s: `%s' may be incomplete.\n", progName, outName); fprintf(stderr, "%s: I suggest doing an integrity test (bzip2 -tv)" " of it.\n", progName); } } if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) { fprintf(stderr, "%s: WARNING: some files have not been processed:\n" "%s: %d specified on command line, %d not processed yet.\n\n", progName, progName, numFileNames, numFileNames - numFilesProcessed); } setExit(ec); exit(exitValue); }
void cleanUpAndFail(void) { int iVar1; long in_FS_OFFSET; stat local_a8; undefined8 local_10; local_10 = *(undefined8 *)(in_FS_OFFSET + 0x28); if (((srcMode == 3) && (opMode != 3)) && (deleteOutputOnInterrupt != '\0')) { iVar1 = stat(inName, &local_a8); if (iVar1 == 0) { if (noisy != '\0') { fprintf(stderr, "%s: Deleting output file %s, if it exists.\n", progName, outName); } if (outputHandleJustInCase != (FILE *)0x0) { fclose(outputHandleJustInCase); } iVar1 = remove(outName); if (iVar1 != 0) { fprintf(stderr, "%s: WARNING: deletion of output file (apparently) failed.\n", progName); } } else { fprintf(stderr, "%s: WARNING: deletion of output file suppressed\n", progName); fprintf(stderr, "%s: since input file no longer exists. Output file\n", progName); fprintf(stderr, "%s: `%s\' may be incomplete.\n", progName, outName); fprintf(stderr, "%s: I suggest doing an integrity test (bzip2 -tv) of it.\n", progName); } } if (((noisy != '\0') && (0 < (int)numFileNames)) && (numFilesProcessed < (int)numFileNames)) { fprintf(stderr, "%s: WARNING: some files have not been processed:\n%s: %d " "specified on command line, %d not processed yet.\n\n", progName, progName, (ulong)numFileNames, (ulong)(numFileNames - numFilesProcessed)); } setExit(); exit(exitValue); }
bzip2
ghidra
static char *samedir_template(char const *dstname, char buf[smallsize]) { ptrdiff_t dstdirlen = last_component(dstname) - dstname; size_t dsttmpsize = dstdirlen + sizeof simple_pattern; char *dsttmp; if (dsttmpsize <= smallsize) dsttmp = buf; else { dsttmp = malloc(dsttmpsize); if (!dsttmp) return dsttmp; } strcpy(mempcpy(dsttmp, dstname, dstdirlen), simple_pattern); return dsttmp; }
int samedir_template(void *a0, void *a1) { void *v0; unsigned int v1; unsigned int v2; unsigned int v4; *(&v1) = last_component(a0) - a0; *(&v2) = *(&v1) + 9; if (*(&v2) <= 0x100) { v0 = a1; } else { v0 = malloc(*(&v2)); if (!v0) { v4 = v0; goto LABEL_40008f; } } strcpy(mempcpy(v0, a0, *(&v1)), "CuXXXXXX"); v4 = v0; LABEL_40008f: return v4; }
coreutils
angr_phoenix
static inline void emit_mandatory_arg_note(void) { fputs_unlocked(gettext("\nMandatory arguments to long options are mandatory " "for short options too.\n"), stdout) ; }
void emit_mandatory_arg_note() { unsigned long long v1; v1 = fputs_unlocked(gettext("\nMandatory arguments to long options are " "mandatory for short options too.\n"), stdout); return; }
coreutils
angr_phoenix
static int unquoted_tilde_word(s) const char *s; { const char *r; for (r = s; ((*r) == '\0' || (*r) == '/' || (*r) == ':') == 0; r++) { switch (*r) { case '\\': case '\'': case '"': return 0; } } return 1; }
long unquoted_tilde_word(_BYTE *a1) { unsigned int v1; while (*a1 && *a1 != 47 && *a1 != 58) { v1 = (char)*a1 - 34; if (v1 <= 0x3A && ((1LL << v1) & 0x400000000000021LL) != 0) return 0LL; ++a1; } return 1LL; }
bash
ida
r->rtm_type == RTN_MULTICAST) { print_string(PRINT_ANY, "dev", "%s", ll_index_to_name(nh->rtnh_ifindex)); if (nh->rtnh_hops != 1) print_int(PRINT_ANY, "ttl", "(ttl>%d)", nh->rtnh_hops); print_string(PRINT_FP, ((void *)0), " ", ((void *)0)); } else {
void print_string(unsigned long a0, unsigned long long a1, unsigned long long a2, unsigned long long a3) { unsigned long long v1; v1 = print_color_string(a0, 0x6, a1, a2, a3); return; }
iproute2-6.0.0
angr_phoenix
static void print_heredoc_bodies(heredocs) REDIRECT *heredocs; { REDIRECT *hdtail; cprintf("\n"); for (hdtail = heredocs; hdtail; hdtail = hdtail->next) { print_heredoc_body(hdtail); cprintf("\n"); } was_heredoc = 1; }
void print_heredoc_bodies(unsigned long long a0) { unsigned long long *v0; unsigned long long v2; unsigned long long v3; cprintf("\n"); v2 = a0; for (v0 = a0; v0; v0 = *(v0)) { print_heredoc_body(v0); cprintf("\n"); v3 = *(v0); } was_heredoc = 1; return; }
bash
angr_dream
static void parse_dest_constraint(const char *s, struct dest_constraint ***dcp, size_t *ndcp, char **hostkey_files) { struct dest_constraint *dc; char *os, *cp; dc = xcalloc(1, sizeof(*dc)); os = xstrdup(s); if ((cp = strchr(os, '>')) == ((void *)0)) { parse_dest_constraint_hop(os, &dc->to, hostkey_files); } else { *(cp++) = '\0'; parse_dest_constraint_hop(os, &dc->from, hostkey_files); parse_dest_constraint_hop(cp, &dc->to, hostkey_files); if (dc->from.user != ((void *)0)) { sshfatal("ssh-add.c", __func__, 750, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "Invalid key constraint %s: cannot specify " "user on 'from' host", os); } } sshlog("ssh-add.c", __func__, 755, 1, SYSLOG_LEVEL_DEBUG2, ((void *)0), "constraint %zu: %s%s%s (%u keys) > %s%s%s (%u keys)", *ndcp, dc->from.user ? dc->from.user : "", dc->from.user ? "@" : "", dc->from.hostname ? dc->from.hostname : "(ORIGIN)", dc->from.nkeys, dc->to.user ? dc->to.user : "", dc->to.user ? "@" : "", dc->to.hostname ? dc->to.hostname : "(ANY)", dc->to.nkeys) ; *dcp = xrecallocarray(*dcp, *ndcp, *ndcp + 1, sizeof(**dcp)); (*dcp)[(*ndcp)++] = dc; free(os); }
void parse_dest_constraint(long a1, _QWORD *a2, _QWORD *a3, long a4) { const char *v4; const char *v5; const char *v6; const char *v7; const char *v8; const char *v9; long v10; long v11; long v15; char *s; char *v17; v15 = xcalloc(1LL, 80LL); s = (char *)xstrdup(a1); v17 = strchr(s, 62); if (v17) { *v17 = 0; parse_dest_constraint_hop(s, (long *)v15, a4); parse_dest_constraint_hop(v17 + 1, (long *)(v15 + 40), a4); if (*(_QWORD *)v15) sshfatal("ssh-add.c", "parse_dest_constraint", 750LL, 0LL, 1LL, 0LL, "Invalid key constraint %s: cannot specify user on 'from' host", s); } else { parse_dest_constraint_hop(s, (long *)(v15 + 40), a4); } if (*(_QWORD *)(v15 + 48)) v4 = *(const char **)(v15 + 48); else v4 = "(ANY)"; if (*(_QWORD *)(v15 + 40)) v5 = "@"; else v5 = &byte_33DF; if (*(_QWORD *)(v15 + 40)) v6 = *(const char **)(v15 + 40); else v6 = &byte_33DF; if (*(_QWORD *)(v15 + 8)) v7 = *(const char **)(v15 + 8); else v7 = "(ORIGIN)"; if (*(_QWORD *)v15) v8 = "@"; else v8 = &byte_33DF; if (*(_QWORD *)v15) v9 = *(const char **)v15; else v9 = &byte_33DF; sshlog("ssh-add.c", "parse_dest_constraint", 755LL, 1LL, 6LL, 0LL, "constraint %zu: %s%s%s (%u keys) > %s%s%s (%u keys)", *a3, v9, v8, v7, *(unsigned int *)(v15 + 20), v6, v5, v4, *(unsigned int *)(v15 + 60)); *a2 = xrecallocarray(*a2, *a3, *a3 + 1LL, 8LL); v10 = *a2; v11 = (*a3)++; *(_QWORD *)(v10 + 8 * v11) = v15; free(s); }
openssh-portable
ida
int main(int argc, char **argv) { char *keys = ((void *)0); idx_t keycc = 0, keyalloc = 0; int matcher = -1; int opt; int prev_optind, last_recursive; intmax_t default_context; FILE *fp; exit_failure = EXIT_TROUBLE; ; int filename_option = 0; eolbyte = '\n'; filename_mask = ~0; max_count = (9223372036854775807L); out_after = out_before = -1; default_context = -1; only_matching = 0; setlocale(6, ""); bindtextdomain("grep", "/usr/local/share/locale"); textdomain("grep"); init_localeinfo(&localeinfo); atexit(clean_up_stdout); c_stack_action(((void *)0)); last_recursive = 0; pattern_table = hash_initialize(0, 0, hash_pattern, compare_patterns, 0); if (!pattern_table) xalloc_die(); while (prev_optind = optind, (opt = get_nondigit_option(argc, argv, &default_context)) != -1) switch (opt) { case 'A': context_length_arg(optarg, &out_after); break; case 'B': context_length_arg(optarg, &out_before); break; case 'C': context_length_arg(optarg, &default_context); break; case 'D': if ((strcmp(optarg, "read") == 0)) devices = READ_DEVICES; else if ((strcmp(optarg, "skip") == 0)) devices = SKIP_DEVICES; else ((!!sizeof(struct { _Static_assert(EXIT_TROUBLE, "verify_expr (" "EXIT_TROUBLE" ", " "(error (EXIT_TROUBLE, 0, gettext(\"unknown devices " "method\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(EXIT_TROUBLE, 0, gettext("unknown devices method")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(EXIT_TROUBLE, 0, gettext("unknown devices method")), ((0) ? (void)0 : __builtin_unreachable())))); break; case 'E': matcher = setmatcher("egrep", matcher); break; case 'F': matcher = setmatcher("fgrep", matcher); break; case 'P': matcher = setmatcher("perl", matcher); break; case 'G': matcher = setmatcher("grep", matcher); break; case 'X': matcher = setmatcher(optarg, matcher); break; case 'H': filename_option = 1; break; case 'I': binary_files = WITHOUT_MATCH_BINARY_FILES; break; case 'T': align_tabs = 1; break; case 'U': if (0) binary = 1; break; case 'u': error(0, 0, gettext("warning: --unix-byte-offsets (-u) is obsolete")); break; case 'V': show_version = 1; break; case 'a': binary_files = TEXT_BINARY_FILES; break; case 'b': out_byte = 1; break; case 'c': count_matches = 1; break; case 'd': directories = ((directories_types)[__xargmatch_internal( "--directories", optarg, directories_args, (void const *)(directories_types), sizeof *(directories_types), argmatch_die, 1)]); if (directories == RECURSE_DIRECTORIES) last_recursive = prev_optind; break; case 'e': { idx_t cc = strlen(optarg); ptrdiff_t shortage = keycc - keyalloc + cc + 1; if (0 < shortage) pattern_array = keys = xpalloc(keys, &keyalloc, shortage, -1, 1); char *keyend = mempcpy(keys + keycc, optarg, cc); *keyend = '\n'; keycc = update_patterns(keys, keycc, keycc + cc + 1, ""); } break; case 'f': { if ((strcmp(optarg, "-") == 0)) { if (binary) xset_binary_mode(0, 0); fp = stdin; } else { fp = fopen(optarg, binary ? "rb" : "r"); if (!fp) ((!!sizeof(struct { _Static_assert(EXIT_TROUBLE, "verify_expr (" "EXIT_TROUBLE" ", " "(error (EXIT_TROUBLE, (*__errno_location ()), " "\"%s\", optarg), assume (false))" ")"); int _gl_dummy; })) ? ((error(EXIT_TROUBLE, (*__errno_location()), "%s", optarg), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(EXIT_TROUBLE, (*__errno_location()), "%s", optarg), ((0) ? (void)0 : __builtin_unreachable())))); } idx_t newkeycc = keycc, cc; for (;; newkeycc += cc) { ptrdiff_t shortage = newkeycc - keyalloc + 2; if (0 < shortage) pattern_array = keys = xpalloc(keys, &keyalloc, shortage, -1, 1); cc = fread_unlocked(keys + newkeycc, 1, keyalloc - (newkeycc + 1), fp); if (cc == 0) break; } int err = (*__errno_location()); if (!ferror_unlocked(fp)) { err = 0; if (fp == stdin) clearerr_unlocked(fp); else if (fclose(fp) != 0) err = (*__errno_location()); } if (err) ((!!sizeof(struct { _Static_assert( EXIT_TROUBLE, "verify_expr (" "EXIT_TROUBLE" ", " "(error (EXIT_TROUBLE, err, \"%s\", optarg), assume (false))" ")"); int _gl_dummy; })) ? ((error(EXIT_TROUBLE, err, "%s", optarg), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(EXIT_TROUBLE, err, "%s", optarg), ((0) ? (void)0 : __builtin_unreachable())))); if (newkeycc != keycc && keys[newkeycc - 1] != '\n') keys[newkeycc++] = '\n'; keycc = update_patterns(keys, keycc, newkeycc, optarg); } break; case 'h': filename_option = -1; break; case 'i': case 'y': match_icase = 1; break; case NO_IGNORE_CASE_OPTION: match_icase = 0; break; case 'L': list_files = LISTFILES_NONMATCHING; break; case 'l': list_files = LISTFILES_MATCHING; break; case 'm': switch (xstrtoimax(optarg, 0, 10, &max_count, "")) { case LONGINT_OK: case LONGINT_OVERFLOW: break; default: ((!!sizeof(struct { _Static_assert(EXIT_TROUBLE, "verify_expr (" "EXIT_TROUBLE" ", " "(error (EXIT_TROUBLE, 0, gettext(\"invalid max " "count\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(EXIT_TROUBLE, 0, gettext("invalid max count")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(EXIT_TROUBLE, 0, gettext("invalid max count")), ((0) ? (void)0 : __builtin_unreachable())))); } break; case 'n': out_line = 1; break; case 'o': only_matching = 1; break; case 'q': exit_on_match = 1; exit_failure = 0; break; case 'R': fts_options = basic_fts_options | 0x0002; __attribute__((__fallthrough__)); case 'r': directories = RECURSE_DIRECTORIES; last_recursive = prev_optind; break; case 's': suppress_errors = 1; break; case 'v': out_invert = 1; break; case 'w': wordinit(); match_words = 1; break; case 'x': match_lines = 1; break; case 'Z': filename_mask = 0; break; case 'z': eolbyte = '\0'; break; case BINARY_FILES_OPTION: if ((strcmp(optarg, "binary") == 0)) binary_files = BINARY_BINARY_FILES; else if ((strcmp(optarg, "text") == 0)) binary_files = TEXT_BINARY_FILES; else if ((strcmp(optarg, "without-match") == 0)) binary_files = WITHOUT_MATCH_BINARY_FILES; else ((!!sizeof(struct { _Static_assert(EXIT_TROUBLE, "verify_expr (" "EXIT_TROUBLE" ", " "(error (EXIT_TROUBLE, 0, gettext(\"unknown " "binary-files type\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(EXIT_TROUBLE, 0, gettext("unknown binary-files type")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(EXIT_TROUBLE, 0, gettext("unknown binary-files type")), ((0) ? (void)0 : __builtin_unreachable())))); break; case COLOR_OPTION: if (optarg) { if (!c_strcasecmp(optarg, "always") || !c_strcasecmp(optarg, "yes") || !c_strcasecmp(optarg, "force")) color_option = 1; else if (!c_strcasecmp(optarg, "never") || !c_strcasecmp(optarg, "no") || !c_strcasecmp(optarg, "none")) color_option = 0; else if (!c_strcasecmp(optarg, "auto") || !c_strcasecmp(optarg, "tty") || !c_strcasecmp(optarg, "if-tty")) color_option = 2; else show_help = 1; } else color_option = 2; break; case EXCLUDE_OPTION: case INCLUDE_OPTION: for (int cmd = 0; cmd < 2; cmd++) { if (!excluded_patterns[cmd]) excluded_patterns[cmd] = new_exclude(); add_exclude( excluded_patterns[cmd], optarg, ((opt == INCLUDE_OPTION ? (1 << 29) : 0) | exclude_options(cmd))); } break; case EXCLUDE_FROM_OPTION: for (int cmd = 0; cmd < 2; cmd++) { if (!excluded_patterns[cmd]) excluded_patterns[cmd] = new_exclude(); if (add_exclude_file(add_exclude, excluded_patterns[cmd], optarg, exclude_options(cmd), '\n') != 0) ((!!sizeof(struct { _Static_assert(EXIT_TROUBLE, "verify_expr (" "EXIT_TROUBLE" ", " "(error (EXIT_TROUBLE, (*__errno_location ()), " "\"%s\", optarg), assume (false))" ")"); int _gl_dummy; })) ? ((error(EXIT_TROUBLE, (*__errno_location()), "%s", optarg), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(EXIT_TROUBLE, (*__errno_location()), "%s", optarg), ((0) ? (void)0 : __builtin_unreachable())))); } break; case EXCLUDE_DIRECTORY_OPTION: strip_trailing_slashes(optarg); for (int cmd = 0; cmd < 2; cmd++) { if (!excluded_directory_patterns[cmd]) excluded_directory_patterns[cmd] = new_exclude(); add_exclude(excluded_directory_patterns[cmd], optarg, exclude_options(cmd)); } break; case GROUP_SEPARATOR_OPTION: group_separator = optarg; break; case LINE_BUFFERED_OPTION: line_buffered = 1; break; case LABEL_OPTION: label = optarg; break; case 0: break; default: usage(EXIT_TROUBLE); break; } if (show_version) { version_etc(stdout, getprogname(), "GNU grep", "3.8", (char *)((void *)0)); puts (gettext("Written by Mike Haertel and others; see\n" "<https: ); return 0 ; } if (show_help) usage(0); if (keys) { if (keycc == 0) { out_invert ^= 1; match_lines = match_words = 0; keys[keycc++] = '\n'; } } else if (optind < argc) { char const *pat = argv[optind++]; _Bool skip_bs = (matcher != F_MATCHER_INDEX && pat[0] == '\\' && pat[1] == '-'); pattern_array = keys = xstrdup(pat + skip_bs); idx_t patlen = strlen(keys); keys[patlen] = '\n'; keycc = update_patterns(keys, 0, patlen + 1, ""); } else usage(EXIT_TROUBLE); keycc--; hash_free(pattern_table); _Bool possibly_tty = 0; struct stat tmp_stat; if (!exit_on_match && fstat(1, &tmp_stat) == 0) { if (((((tmp_stat.st_mode)) & 0170000) == (0100000))) out_stat = tmp_stat; else if (((((tmp_stat.st_mode)) & 0170000) == (0020000))) { struct stat null_stat; if (stat("/dev/null", &null_stat) == 0 && ((tmp_stat).st_ino == (null_stat).st_ino && (tmp_stat).st_dev == (null_stat).st_dev)) dev_null_output = 1; else possibly_tty = 1; } } if (exit_on_match | dev_null_output) list_files = LISTFILES_NONE; if ((exit_on_match | dev_null_output) || list_files != LISTFILES_NONE) { count_matches = 0; done_on_match = 1; } out_quiet = count_matches | done_on_match; if (out_after < 0) out_after = default_context; if (out_before < 0) out_before = default_context; if ((max_count == 0 || (keycc == 0 && out_invert && !match_lines && !match_words)) && list_files != LISTFILES_NONMATCHING) return 1; if (color_option == 2) color_option = possibly_tty && should_colorize() && isatty(1); init_colorize(); if (color_option) { char *userval = getenv("GREP_COLOR"); if (userval != ((void *)0) && *userval != '\0') for (char *q = userval; *q == ';' || c_isdigit(*q); q++) if (!q[1]) { selected_match_color = context_match_color = userval; break; } parse_grep_colors(); if (selected_match_color == userval || context_match_color == userval) error(0, 0, gettext("warning: GREP_COLOR='%s' is deprecated;" " use GREP_COLORS='mt=%s'"), userval, userval); } initialize_unibyte_mask(); if (matcher < 0) matcher = G_MATCHER_INDEX; if (matcher == F_MATCHER_INDEX || matcher == E_MATCHER_INDEX || matcher == G_MATCHER_INDEX) { if (match_icase) setup_ok_fold(); if (matcher == F_MATCHER_INDEX) { if (!localeinfo.multibyte ? n_patterns == 1 && match_words : (contains_encoding_error(keys, keycc) || (match_icase && !fgrep_icase_available(keys, keycc)))) { fgrep_to_grep_pattern(&pattern_array, &keycc); keys = pattern_array; matcher = G_MATCHER_INDEX; } } else if (1 < n_patterns) matcher = try_fgrep_pattern(matcher, keys, &keycc); } execute = matchers[matcher].execute; compiled_pattern = matchers[matcher].compile( keys, keycc, matchers[matcher].syntax, only_matching | color_option); char eolbytes[3] = {0, eolbyte, 0}; idx_t match_size; skip_empty_lines = ((execute(compiled_pattern, eolbytes + 1, 1, &match_size, ((void *)0)) == 0) == out_invert); int num_operands = argc - optind; out_file = (filename_option == 0 && num_operands <= 1 ? -(directories == RECURSE_DIRECTORIES) : 0 <= filename_option); if (binary) xset_binary_mode(1, 0); long psize = sysconf(_SC_PAGESIZE); if (!(0 < psize && psize <= ((9223372036854775807L) - uword_size) / 2)) abort(); pagesize = psize; bufalloc = ((uintptr_t)(INITIAL_BUFSIZE) % (pagesize) == 0 ? (INITIAL_BUFSIZE) : (INITIAL_BUFSIZE) + ((pagesize) - (uintptr_t)(INITIAL_BUFSIZE) % (pagesize))) + pagesize + uword_size; buffer = ximalloc(bufalloc); if (fts_options & 0x0002 && devices == READ_COMMAND_LINE_DEVICES) devices = READ_DEVICES; char *const *files; if (0 < num_operands) { files = argv + optind; } else if (directories == RECURSE_DIRECTORIES && 0 < last_recursive) { static char *const cwd_only[] = {(char *)".", ((void *)0)}; files = cwd_only; omit_dot_slash = 1; } else { static char *const stdin_only[] = {(char *)"-", ((void *)0)}; files = stdin_only; } _Bool status = 1; do status &= grep_command_line_arg(*files++); while (*files != ((void *)0)); return errseen ? EXIT_TROUBLE : status; }
undefined main(int param_1, long param_2) { bool bVar1; char cVar2; byte bVar3; uint uVar4; uint uVar5; undefined4 uVar6; int iVar7; int *piVar8; char *pcVar9; long lVar10; long in_FS_OFFSET; undefined8 uVar11; undefined local_202; int local_200; int local_1fc; uint local_1f8; int local_1f4; int local_1f0; int local_1ec; int local_1e8; int local_1e4; int local_1e0; long local_1d8; long local_1d0; long local_1c8; undefined local_1c0[8]; char *local_1b8; FILE *local_1b0; long local_1a8; char *local_1a0; undefined1 *local_198; char *local_190; size_t local_188; char *local_180; ulong local_178; long local_170; size_t local_168; size_t local_160; long local_158; undefined *local_150; undefined local_148[40]; __dev_t local_120; __off_t local_118; __blksize_t local_110; __blkcnt_t local_108; __time_t local_100; long local_f8; __time_t local_f0; long local_e8; __time_t local_e0; long local_d8; long local_d0; long local_c8; long local_c0; stat local_b8; undefined local_23; undefined local_22; undefined local_21; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_1b8 = (char *)0x0; local_1d8 = 0; local_1d0 = 0; local_200 = -1; exit_failure = 2; local_1f8 = 0; eolbyte = 10; filename_mask = 0xffffffff; max_count = 0x7fffffffffffffff; out_before = -1; out_after = -1; local_1c8 = -1; only_matching = 0; setlocale(6, ""); bindtextdomain(&DAT_0010767c, "/usr/local/share/locale"); textdomain(&DAT_0010767c); init_localeinfo(localeinfo); atexit(clean_up_stdout); c_stack_action(0); local_1fc = 0; pattern_table = hash_initialize(0, 0, hash_pattern, compare_patterns, 0); if (pattern_table != 0) goto switchD_001040f0_caseD_0; uVar11 = 0x1040bc; xalloc_die(); do { switch (local_1e0) { case 0: case 0x55: break; default: usage(); break; case 0x41: context_length_arg(optarg, &out_after); break; case 0x42: context_length_arg(optarg, &out_before); break; case 0x43: context_length_arg(optarg, &local_1c8); break; case 0x44: iVar7 = strcmp(optarg, "read"); if (iVar7 == 0) { devices = 1; } else { iVar7 = strcmp(optarg, "skip"); if (iVar7 != 0) { uVar11 = gettext("unknown devices method"); error(2, 0, uVar11); goto switchD_001040f0_caseD_45; } devices = 2; } break; case 0x45: switchD_001040f0_caseD_45: local_200 = setmatcher("egrep", local_200); break; case 0x46: local_200 = setmatcher("fgrep", local_200); break; case 0x47: local_200 = setmatcher(&DAT_0010767c, local_200); break; case 0x48: local_1f8 = 1; break; case 0x49: binary_files = 2; break; case 0x4c: list_files = 2; break; case 0x50: local_200 = setmatcher(&DAT_001076a4, local_200); break; case 0x52: fts_options = 0x30a; case 0x72: directories = 3; local_1fc = local_1e4; break; case 0x54: align_tabs = 1; break; case 0x56: show_version = '\x01'; break; case 0x58: local_200 = setmatcher(optarg, local_200); break; case 0x5a: filename_mask = 0; break; case 0x61: binary_files = 1; break; case 0x62: out_byte = 1; break; case 99: count_matches = 1; break; case 100: lVar10 = __xargmatch_internal("--directories", optarg, directories_args, directories_types, 4, argmatch_die, 1, uVar11); directories = *(int *)(directories_types + lVar10 * 4); if (directories == 3) { local_1fc = local_1e4; } break; case 0x65: local_160 = strlen(optarg); local_158 = local_160 + (local_1d8 - local_1d0) + 1; if (0 < local_158) { pattern_array = (char *)xpalloc(local_1b8, &local_1d0, local_158, 0xffffffffffffffff, 1); local_1b8 = pattern_array; } local_150 = (undefined *)mempcpy(local_1b8 + local_1d8, optarg, local_160); *local_150 = 10; local_1d8 = update_patterns(local_1b8, local_1d8, local_160 + local_1d8 + 1, &DAT_00105fd2); break; case 0x66: iVar7 = strcmp(optarg, "-"); if (iVar7 == 0) { if (binary != '\0') { xset_binary_mode(0, 0); } local_1b0 = stdin; } else { if (binary == '\0') { pcVar9 = "r"; } else { pcVar9 = "rb"; } local_1b0 = fopen(optarg, pcVar9); pcVar9 = optarg; if (local_1b0 == (FILE *)0x0) { piVar8 = __errno_location(); error(2, *piVar8, &DAT_001062c5, pcVar9); } } local_1a8 = local_1d8; while (true) { local_170 = (local_1a8 - local_1d0) + 2; if (0 < local_170) { pattern_array = (char *)xpalloc(local_1b8, &local_1d0, local_170, 0xffffffffffffffff, 1); local_1b8 = pattern_array; } local_168 = fread_unlocked(local_1b8 + local_1a8, 1, local_1d0 - (local_1a8 + 1), local_1b0); if (local_168 == 0) break; local_1a8 = local_1a8 + local_168; } piVar8 = __errno_location(); local_1f4 = *piVar8; iVar7 = ferror_unlocked(local_1b0); if (iVar7 == 0) { local_1f4 = 0; if (local_1b0 == stdin) { clearerr_unlocked(local_1b0); } else { iVar7 = fclose(local_1b0); if (iVar7 != 0) { piVar8 = __errno_location(); local_1f4 = *piVar8; } } } if (local_1f4 != 0) { error(2, local_1f4, &DAT_001062c5, optarg); } if ((local_1a8 != local_1d8) && (local_1b8[local_1a8 + -1] != '\n')) { local_1b8[local_1a8] = '\n'; local_1a8 = local_1a8 + 1; } local_1d8 = update_patterns(local_1b8, local_1d8, local_1a8, optarg); break; case 0x68: local_1f8 = 0xffffffff; break; case 0x69: case 0x79: match_icase = '\x01'; break; case 0x6c: list_files = 1; break; case 0x6d: uVar4 = xstrtoimax(optarg, 0, 10, &max_count, &DAT_00105fd2); if (1 < uVar4) { uVar11 = gettext("invalid max count"); error(2, 0, uVar11); } break; case 0x6e: out_line = 1; break; case 0x6f: only_matching = 1; break; case 0x71: exit_on_match = 1; exit_failure = 0; break; case 0x73: suppress_errors = 1; break; case 0x75: uVar11 = gettext("warning: --unix-byte-offsets (-u) is obsolete"); error(0, 0, uVar11); break; case 0x76: out_invert = '\x01'; break; case 0x77: wordinit(); match_words = '\x01'; break; case 0x78: match_lines = '\x01'; break; case 0x7a: eolbyte = 0; break; case 0x80: iVar7 = strcmp(optarg, "binary"); if (iVar7 == 0) { binary_files = 0; } else { iVar7 = strcmp(optarg, "text"); if (iVar7 == 0) { binary_files = 1; } else { iVar7 = strcmp(optarg, "without-match"); if (iVar7 != 0) { uVar11 = gettext("unknown binary-files type"); error(2, 0, uVar11); goto switchD_001040f0_caseD_81; } binary_files = 2; } } break; case 0x81: switchD_001040f0_caseD_81: if (optarg == (char *)0x0) { color_option = 2; } else { iVar7 = c_strcasecmp(optarg, "always"); if (((iVar7 == 0) || (iVar7 = c_strcasecmp(optarg, &DAT_00107732), iVar7 == 0)) || (iVar7 = c_strcasecmp(optarg, "force"), iVar7 == 0)) { color_option = 1; } else { iVar7 = c_strcasecmp(optarg, "never"); if (((iVar7 == 0) || (iVar7 = c_strcasecmp(optarg, &DAT_00107742), iVar7 == 0)) || (iVar7 = c_strcasecmp(optarg, &DAT_00107745), iVar7 == 0)) { color_option = 0; } else { iVar7 = c_strcasecmp(optarg, &DAT_0010774a); if (((iVar7 == 0) || (iVar7 = c_strcasecmp(optarg, &DAT_0010774f), iVar7 == 0)) || (iVar7 = c_strcasecmp(optarg, "if-tty"), iVar7 == 0)) { color_option = 2; } else { show_help = 1; } } } } break; case 0x82: strip_trailing_slashes(); for (local_1e8 = 0; local_1e8 < 2; local_1e8 = local_1e8 + 1) { if (*(long *)(excluded_directory_patterns + (long)local_1e8 * 8) == 0) { uVar11 = new_exclude(); *(undefined8 *)(excluded_directory_patterns + (long)local_1e8 * 8) = uVar11; } uVar6 = exclude_options(local_1e8 != 0); add_exclude( *(undefined8 *)(excluded_directory_patterns + (long)local_1e8 * 8), optarg, uVar6); } break; case 0x83: case 0x86: for (local_1f0 = 0; local_1f0 < 2; local_1f0 = local_1f0 + 1) { if (*(long *)(excluded_patterns + (long)local_1f0 * 8) == 0) { uVar11 = new_exclude(); *(undefined8 *)(excluded_patterns + (long)local_1f0 * 8) = uVar11; } if (local_1e0 == 0x86) { uVar4 = 0x20000000; } else { uVar4 = 0; } uVar5 = exclude_options(local_1f0 != 0); add_exclude(*(undefined8 *)(excluded_patterns + (long)local_1f0 * 8), optarg, uVar4 | uVar5); } break; case 0x84: for (local_1ec = 0; local_1ec < 2; local_1ec = local_1ec + 1) { if (*(long *)(excluded_patterns + (long)local_1ec * 8) == 0) { uVar11 = new_exclude(); *(undefined8 *)(excluded_patterns + (long)local_1ec * 8) = uVar11; } uVar6 = exclude_options(local_1ec != 0); iVar7 = add_exclude_file( uRam0000000000104b73, *(undefined8 *)(excluded_patterns + (long)local_1ec * 8), optarg, uVar6, 10); if (iVar7 != 0) { piVar8 = __errno_location(); error(2, *piVar8, &DAT_001062c5); } } break; case 0x85: group_separator = optarg; break; case 0x87: line_buffered = 1; break; case 0x88: label = optarg; break; case 0x89: match_icase = '\0'; } switchD_001040f0_caseD_0: local_1e4 = optind; uVar11 = 0x104cd8; local_1e0 = get_nondigit_option(param_1, param_2, &local_1c8); } while (local_1e0 != -1); if (show_version == '\0') { if (show_help != 0) { usage(0); } if (local_1b8 == (char *)0x0) { if (optind < param_1) { local_190 = *(char **)(param_2 + (long)optind * 8); if (((local_200 == 2) || (*local_190 != '\\')) || (local_190[1] != '-')) { bVar3 = 0; } else { bVar3 = 1; } optind = optind + 1; pattern_array = (char *)xstrdup(local_190 + bVar3); local_1b8 = pattern_array; local_188 = strlen(pattern_array); local_1b8[local_188] = '\n'; local_1d8 = update_patterns(local_1b8, 0, local_188 + 1, &DAT_00105fd2); } else { usage(2); } } else if (local_1d8 == 0) { out_invert = out_invert != '\x01'; match_words = '\0'; match_lines = '\0'; local_1d8 = 1; *local_1b8 = '\n'; } local_1d8 = local_1d8 + -1; hash_free(pattern_table); bVar1 = false; if ((exit_on_match != 1) && (iVar7 = fstat(1, (stat *)local_148), iVar7 == 0)) { if ((local_148._24_4_ & 0xf000) == 0x8000) { out_stat._0_8_ = local_148._0_8_; out_stat._8_8_ = local_148._8_8_; out_stat._24_8_ = CONCAT44(local_148._28_4_, local_148._24_4_); out_stat._16_8_ = local_148._16_8_; out_stat._32_8_ = local_148._32_8_; out_stat._40_8_ = local_120; out_stat._48_8_ = local_118; out_stat._56_8_ = local_110; out_stat._64_8_ = local_108; out_stat._72_8_ = local_100; out_stat._80_8_ = local_f8; out_stat._88_8_ = local_f0; out_stat._96_8_ = local_e8; out_stat._104_8_ = local_e0; out_stat._112_8_ = local_d8; out_stat._120_8_ = local_d0; out_stat._128_8_ = local_c8; out_stat._136_8_ = local_c0; } else if ((local_148._24_4_ & 0xf000) == 0x2000) { iVar7 = stat("/dev/null", &local_b8); if (((iVar7 == 0) && (local_148._8_8_ == local_b8.st_ino)) && (local_148._0_8_ == local_b8.st_dev)) { dev_null_output = 1; } else { bVar1 = true; } } } if ((dev_null_output | exit_on_match) != 0) { list_files = 0; } if (((dev_null_output | exit_on_match) != 0) || (list_files != 0)) { count_matches = 0; done_on_match = 1; } out_quiet = (done_on_match | count_matches) != 0; if (out_after < 0) { out_after = local_1c8; } if (out_before < 0) { out_before = local_1c8; } if (((max_count == 0) || ((((local_1d8 == 0 && (out_invert != '\0')) && (match_lines != '\x01')) && (match_words != '\x01')))) && (list_files != 2)) { local_202 = 1; } else { if (color_option == 2) { if (((bVar1) && (iVar7 = should_colorize(), iVar7 != 0)) && (iVar7 = isatty(1), iVar7 != 0)) { color_option = 1; } else { color_option = 0; } } init_colorize(); if (color_option != 0) { local_180 = getenv("GREP_COLOR"); if ((local_180 != (char *)0x0) && (pcVar9 = local_180, *local_180 != '\0')) { while (true) { local_1a0 = pcVar9; if ((*local_1a0 != ';') && (cVar2 = c_isdigit((int)*local_1a0), cVar2 == '\0')) goto LAB_0010527c; if (local_1a0[1] == '\0') break; pcVar9 = local_1a0 + 1; } context_match_color = local_180; selected_match_color = local_180; } LAB_0010527c: parse_grep_colors(); if ((local_180 == selected_match_color) || (local_180 == context_match_color)) { uVar11 = gettext("warning: GREP_COLOR=\'%s\' is deprecated; use " "GREP_COLORS=\'mt=%s\'"); error(0, 0, uVar11, local_180, local_180); } } initialize_unibyte_mask(); if (local_200 < 0) { local_200 = 0; } if (((local_200 == 2) || (local_200 == 1)) || (local_200 == 0)) { if (match_icase != '\0') { setup_ok_fold(); } if (local_200 == 2) { if (localeinfo[0] == '\x01') { cVar2 = contains_encoding_error(local_1b8, local_1d8); if ((cVar2 == '\0') && ((match_icase == '\0' || (cVar2 = fgrep_icase_available(local_1b8, local_1d8), cVar2 == '\x01')))) { bVar1 = false; } else { bVar1 = true; } } else if ((n_patterns == 1) && (match_words != '\0')) { bVar1 = true; } else { bVar1 = false; } if (bVar1) { fgrep_to_grep_pattern(&pattern_array, &local_1d8); local_1b8 = pattern_array; local_200 = 0; } } else if (1 < n_patterns) { local_200 = try_fgrep_pattern(local_200, local_1b8, &local_1d8); } } execute = *(code **)(&DAT_00108298 + (long)local_200 * 0x20); compiled_pattern = (**(code **)(&DAT_00108290 + (long)local_200 * 0x20))( local_1b8, local_1d8, (long)*(int *)(&DAT_0010828c + (long)local_200 * 0x20), (color_option | only_matching) != 0); local_23 = 0; local_22 = eolbyte; local_21 = 0; lVar10 = (*execute)(compiled_pattern, &local_22, 1, local_1c0, 0); skip_empty_lines = (lVar10 == 0) == (bool)out_invert; param_1 = param_1 - optind; if ((local_1f8 == 0) && (param_1 < 2)) { out_file = -(uint)(directories == 3); } else { out_file = ~local_1f8 >> 0x1f; } if (binary != '\0') { xset_binary_mode(1, 0); } local_178 = sysconf(0x1e); if (((long)local_178 < 1) || (0x3ffffffffffffffb < (long)local_178)) { abort(); } if (SUB168((ZEXT816(0) << 0x40 | ZEXT816(0x18000)) % ZEXT816(local_178), 0) == 0) { lVar10 = 0x18000; } else { lVar10 = (local_178 - SUB168((ZEXT816(0) << 0x40 | ZEXT816(0x18000)) % ZEXT816(local_178), 0)) + 0x18000; } bufalloc = lVar10 + local_178 + 8; pagesize = local_178; buffer = ximalloc(bufalloc); if (((fts_options & 2) != 0) && (devices == 0)) { devices = 1; } if (param_1 < 1) { if ((directories == 3) && (0 < local_1fc)) { local_198 = cwd_only_7971; omit_dot_slash = 1; } else { local_198 = stdin_only_7972; } } else { local_198 = (undefined1 *)(param_2 + (long)optind * 8); } local_202 = true; do { lVar10 = *(long *)local_198; local_198 = (undefined1 *)((long)local_198 + 8); bVar3 = grep_command_line_arg(lVar10); local_202 = (bVar3 & local_202) != 0; } while (*(long *)local_198 != 0); if (errseen != '\0') { local_202 = 2; } } } else { uVar11 = getprogname(); version_etc(stdout, uVar11, "GNU grep", &DAT_0010775a, 0); pcVar9 = (char *)gettext("Written by Mike Haertel and others; see\n<https: ); puts(pcVar9); local_202 = 0; } if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return local_202; }
grep
ghidra
int mm_answer_keyallowed(struct ssh *ssh, int sock, struct sshbuf *m) { struct sshkey *key = ((void *)0); char *cuser, *chost; u_int pubkey_auth_attempt; u_int type = 0; int r, allowed = 0; struct sshauthopt *opts = ((void *)0); sshlog("monitor.c", __func__, 1155, 1, SYSLOG_LEVEL_DEBUG3, ((void *)0), "entering"); if ((r = sshbuf_get_u32(m, &type)) != 0 || (r = sshbuf_get_cstring(m, &cuser, ((void *)0))) != 0 || (r = sshbuf_get_cstring(m, &chost, ((void *)0))) != 0 || (r = sshkey_froms(m, &key)) != 0 || (r = sshbuf_get_u32(m, &pubkey_auth_attempt)) != 0) sshfatal("monitor.c", __func__, 1161, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse"); if (key != ((void *)0) && authctxt->valid) { if (sshkey_type_plain(key->type) == KEY_RSA && (ssh->compat & 0x00002000) != 0) sshfatal("monitor.c", __func__, 1167, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "passed a SSH_BUG_RSASIGMD5 key"); switch (type) { case MM_USERKEY: auth_method = "publickey"; if (!options.pubkey_authentication) break; if (auth2_key_already_used(authctxt, key)) break; if (!key_base_type_match(auth_method, key, options.pubkey_accepted_algos)) break; allowed = user_key_allowed(ssh, authctxt->pw, key, pubkey_auth_attempt, &opts); break; case MM_HOSTKEY: auth_method = "hostbased"; if (!options.hostbased_authentication) break; if (auth2_key_already_used(authctxt, key)) break; if (!key_base_type_match(auth_method, key, options.hostbased_accepted_algos)) break; allowed = hostbased_key_allowed(ssh, authctxt->pw, cuser, chost, key); auth2_record_info(authctxt, "client user \"%.100s\", client host \"%.100s\"", cuser, chost); break; default: sshfatal("monitor.c", __func__, 1198, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "unknown key type %u", type); break; } } sshlog("monitor.c", __func__, 1203, 1, SYSLOG_LEVEL_DEBUG3, ((void *)0), "%s authentication%s: %s key is %s", auth_method, pubkey_auth_attempt ? "" : " test", (key == ((void *)0) || !authctxt->valid) ? "invalid" : sshkey_type(key), allowed ? "allowed" : "not allowed") ; auth2_record_key(authctxt, 0, key); monitor_reset_key_state(); if (allowed) { if ((r = sshkey_to_blob(key, &key_blob, &key_bloblen)) != 0) sshfatal("monitor.c", __func__, 1216, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "sshkey_to_blob"); key_blobtype = type; key_opts = opts; hostbased_cuser = cuser; hostbased_chost = chost; } else { auth_log(ssh, 0, 0, auth_method, ((void *)0)); free(cuser); free(chost); } sshkey_free(key); sshbuf_reset(m); if ((r = sshbuf_put_u32(m, allowed)) != 0) sshfatal("monitor.c", __func__, 1231, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "assemble"); if (opts != ((void *)0) && (r = sshauthopt_serialise(opts, m, 1)) != 0) sshfatal("monitor.c", __func__, 1233, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "sshauthopt_serialise"); mm_request_send(sock, MONITOR_ANS_KEYALLOWED, m); if (!allowed) sshauthopt_free(opts); return (0); }
long long mm_answer_keyallowed(struct_0 *a0, unsigned long a1, unsigned long long a2) { unsigned long long v0; char v1; unsigned int v2; unsigned int v3; unsigned int v4; void *v5; char v6; unsigned long long v7; void *v8; unsigned long long v9; unsigned long long v10; unsigned long long v11; unsigned long v12; char v13; unsigned long long v20; unsigned long long v21; unsigned long long v22; v0 = a2; v5 = 0; v2 = 0; v4 = 0; v8 = 0; sshlog("monitor.c", "mm_answer_keyallowed", 0x483, 0x1, 0x7, 0x0); v3 = sshbuf_get_u32(v0, &v2, &v2); if (!v3) { v3 = sshbuf_get_cstring(v0, &v6, 0x0, &v6); if (!v3) { v3 = sshbuf_get_cstring(v0, &v7, 0x0, &v7); if (!v3) { v3 = sshkey_froms(v0, &v5, &v5); if (!v3) v3 = sshbuf_get_u32(v0, &v1, &v1); } } } if (v3 || v3 || v3 || v3 || v3) sshfatal("monitor.c", "mm_answer_keyallowed", 0x489, 0x1, 0x1, ssh_err(v3), "parse"); if (v5 && *((authctxt + 12))) { if (!sshkey_type_plain(*(v5)) && (a0->field_83c & 0x2000)) { v11 = "passed a SSH_BUG_RSASIGMD5 key"; sshfatal("monitor.c", "mm_answer_keyallowed", 0x48f, 0x1, 0x1, 0x0, *(&v13)); } if (v2 == 1) { auth_method = "hostbased"; if (*(5244184) && !auth2_key_already_used(authctxt, v5, v5) && key_base_type_match(auth_method, v5, *(5244192))) { v4 = hostbased_key_allowed(a0, *((authctxt + 48)), *(&v6), *(&v7), v5); auth2_record_info(authctxt, "client user \"%.100s\", client host \"%.100s\"", *(&v6), *(&v7)); } } else if (v2 != 2) { v12 = v2; v11 = "unknown key type %u"; sshfatal("monitor.c", "mm_answer_keyallowed", 0x4ae, 0x1, 0x1, 0x0, *(&v13)); } if (v2 == 2) { auth_method = "publickey"; if (*(5244216) && !auth2_key_already_used(authctxt, v5, v5) && key_base_type_match(auth_method, v5, *(5244224))) v4 = user_key_allowed(a0, *((authctxt + 48)), v5, *(&v1), &v8); } } if (v4) v20 = "allowed"; else v20 = "not allowed"; if (v5 && *((authctxt + 12))) v21 = sshkey_type(v5); if (!v5 || !*((authctxt + 12))) v21 = "invalid"; if (*(&v1)) v22 = &g_4063a3; else v22 = " test"; v11 = v20; v10 = v21; v9 = v22; v8 = auth_method; v7 = "%s authentication%s: %s key is %s"; sshlog("monitor.c", "mm_answer_keyallowed", 0x4b3, 0x1, 0x7, 0x0); auth2_record_key(authctxt, 0x0, v5); monitor_reset_key_state(); if (v4) { v3 = sshkey_to_blob(v5, &key_blob, &key_bloblen); if (v3) { v11 = "sshkey_to_blob"; sshfatal("monitor.c", "mm_answer_keyallowed", 0x4c0, 0x1, 0x1, ssh_err(v3), *(&v13)); } key_blobtype = v2; key_opts = v8; hostbased_cuser = *(&v6); hostbased_chost = v7; } else { auth_log(a0, 0x0, 0x0, auth_method, 0x0); free(*(&v6)); free(v7); } sshkey_free(v5); sshbuf_reset(v0); v3 = sshbuf_put_u32(v0, v4, v4); if (v3) { v11 = "assemble"; sshfatal("monitor.c", "mm_answer_keyallowed", 0x4cf, 0x1, 0x1, ssh_err(v3), *(&v13)); } if (v8) { v3 = sshauthopt_serialise(v8, v0, 0x1, v0); if (v3) { v11 = "sshauthopt_serialise"; sshfatal("monitor.c", "mm_answer_keyallowed", 0x4d1, 0x1, 0x1, ssh_err(v3), *(&v13)); } } mm_request_send(a1, 0x17, v0); if (!v4) sshauthopt_free(v8); return 0; }
openssh-portable
angr_dream
int print_rule(struct nlmsghdr *n, void *arg) { FILE *fp = arg; struct fib_rule_hdr *frh = ((void *)(((char *)n) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))))); int len = n->nlmsg_len; int host_len = -1; __u32 table, prio = 0; struct rtattr *tb[(__FRA_MAX - 1) + 1]; char b1[64]; if (n->nlmsg_type != RTM_NEWRULE && n->nlmsg_type != RTM_DELRULE) return 0; len -= ((sizeof(*frh)) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1)))); if (len < 0) return -1; parse_rtattr( tb, (__FRA_MAX - 1), ((struct rtattr *)(((char *)(frh)) + (((sizeof(struct rtmsg)) + 4U - 1) & ~(4U - 1)))), len); host_len = af_bit_len(frh->family); if (!filter_nlmsg(n, tb, host_len)) return 0; open_json_object(((void *)0)); if (n->nlmsg_type == RTM_DELRULE) print_bool(PRINT_ANY, "deleted", "Deleted ", 1); if (tb[FRA_PRIORITY]) prio = rta_getattr_u32(tb[FRA_PRIORITY]); print_uint(PRINT_ANY, "priority", "%u:\t", prio); if (frh->flags & 0x00000002) print_null(PRINT_ANY, "not", "not ", ((void *)0)); if (tb[FRA_SRC]) { const char *src = rt_addr_n2a( frh->family, ((int)((tb[FRA_SRC])->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), ((void *)(((char *)(tb[FRA_SRC])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))))); print_string(PRINT_FP, ((void *)0), "from ", ((void *)0)); print_color_string(PRINT_ANY, ifa_family_color(frh->family), "src", "%s", src); if (frh->src_len != host_len) print_uint(PRINT_ANY, "srclen", "/%u", frh->src_len); } else if (frh->src_len) { print_string(PRINT_ANY, "src", "from %s", "0"); print_uint(PRINT_ANY, "srclen", "/%u", frh->src_len); } else { print_string(PRINT_ANY, "src", "from %s", "all"); } if (tb[FRA_DST]) { const char *dst = rt_addr_n2a( frh->family, ((int)((tb[FRA_DST])->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), ((void *)(((char *)(tb[FRA_DST])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))))); print_string(PRINT_FP, ((void *)0), " to ", ((void *)0)); print_color_string(PRINT_ANY, ifa_family_color(frh->family), "dst", "%s", dst); if (frh->dst_len != host_len) print_uint(PRINT_ANY, "dstlen", "/%u", frh->dst_len); } else if (frh->dst_len) { print_string(PRINT_ANY, "dst", " to %s", "0"); print_uint(PRINT_ANY, "dstlen", "/%u", frh->dst_len); } if (frh->tos) { print_string(PRINT_ANY, "tos", " tos %s", rtnl_dsfield_n2a(frh->tos, b1, sizeof(b1))); } if (tb[FRA_FWMARK] || tb[FRA_FWMASK]) { __u32 mark = 0, mask = 0; if (tb[FRA_FWMARK]) mark = rta_getattr_u32(tb[FRA_FWMARK]); if (tb[FRA_FWMASK] && (mask = rta_getattr_u32(tb[FRA_FWMASK])) != 0xFFFFFFFF) { print_0xhex(PRINT_ANY, "fwmark", " fwmark %#llx", mark); print_0xhex(PRINT_ANY, "fwmask", "/%#llx", mask); } else { print_0xhex(PRINT_ANY, "fwmark", " fwmark %#llx", mark); } } if (tb[FRA_IIFNAME]) { if (!is_json_context()) fprintf(fp, " iif "); print_color_string(PRINT_ANY, COLOR_IFNAME, "iif", "%s", rta_getattr_str(tb[FRA_IIFNAME])); if (frh->flags & 0x00000008) print_null(PRINT_ANY, "iif_detached", " [detached]", ((void *)0)); } if (tb[FRA_OIFNAME]) { if (!is_json_context()) fprintf(fp, " oif "); print_color_string(PRINT_ANY, COLOR_IFNAME, "oif", "%s", rta_getattr_str(tb[FRA_OIFNAME])); if (frh->flags & 0x00000010) print_null(PRINT_ANY, "oif_detached", " [detached]", ((void *)0)); } if (tb[FRA_L3MDEV]) { __u8 mdev = rta_getattr_u8(tb[FRA_L3MDEV]); if (mdev) print_null(PRINT_ANY, "l3mdev", " lookup [l3mdev-table]", ((void *)0)); } if (tb[FRA_UID_RANGE]) { struct fib_rule_uid_range *r = ((void *)(((char *)(tb[FRA_UID_RANGE])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))); print_uint(PRINT_ANY, "uid_start", " uidrange %u", r->start); print_uint(PRINT_ANY, "uid_end", "-%u", r->end); } if (tb[FRA_IP_PROTO]) { char pbuf[64]; print_string( PRINT_ANY, "ipproto", " ipproto %s", inet_proto_n2a(rta_getattr_u8(tb[FRA_IP_PROTO]), pbuf, sizeof(pbuf))); } if (tb[FRA_SPORT_RANGE]) { struct fib_rule_port_range *r = ((void *)(((char *)(tb[FRA_SPORT_RANGE])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))); if (r->start == r->end) { print_uint(PRINT_ANY, "sport", " sport %u", r->start); } else { print_uint(PRINT_ANY, "sport_start", " sport %u", r->start); print_uint(PRINT_ANY, "sport_end", "-%u", r->end); } } if (tb[FRA_DPORT_RANGE]) { struct fib_rule_port_range *r = ((void *)(((char *)(tb[FRA_DPORT_RANGE])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))); if (r->start == r->end) { print_uint(PRINT_ANY, "dport", " dport %u", r->start); } else { print_uint(PRINT_ANY, "dport_start", " dport %u", r->start); print_uint(PRINT_ANY, "dport_end", "-%u", r->end); } } if (tb[FRA_TUN_ID]) { __u64 tun_id = ((1 == ntohl(1)) ? (rta_getattr_u64(tb[FRA_TUN_ID])) : ((uint64_t)ntohl((rta_getattr_u64(tb[FRA_TUN_ID])) & 0xFFFFFFFF) << 32) | ntohl((rta_getattr_u64(tb[FRA_TUN_ID])) >> 32)); print_u64(PRINT_ANY, "tun_id", " tun_id %llu", tun_id); } table = frh_get_table(frh, tb); if (table) { print_string(PRINT_ANY, "table", " lookup %s", rtnl_rttable_n2a(table, b1, sizeof(b1))); if (tb[FRA_SUPPRESS_PREFIXLEN]) { int pl = rta_getattr_u32(tb[FRA_SUPPRESS_PREFIXLEN]); if (pl != -1) print_int(PRINT_ANY, "suppress_prefixlen", " suppress_prefixlength %d", pl); } if (tb[FRA_SUPPRESS_IFGROUP]) { int group = rta_getattr_u32(tb[FRA_SUPPRESS_IFGROUP]); if (group != -1) { const char *grname = rtnl_group_n2a(group, b1, sizeof(b1)); print_string(PRINT_ANY, "suppress_ifgroup", " suppress_ifgroup %s", grname); } } } if (tb[FRA_FLOW]) { __u32 to = rta_getattr_u32(tb[FRA_FLOW]); __u32 from = to >> 16; to &= 0xFFFF; if (from) print_string(PRINT_ANY, "flow_from", " realms %s/", rtnl_rtrealm_n2a(from, b1, sizeof(b1))); else print_string(PRINT_FP, ((void *)0), " realms ", ((void *)0)); print_string(PRINT_ANY, "flow_to", "%s", rtnl_rtrealm_n2a(to, b1, sizeof(b1))); } if (frh->action == RTN_NAT) { if (tb[RTA_GATEWAY]) { const char *gateway; gateway = format_host( frh->family, ((int)((tb[RTA_GATEWAY])->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), ((void *)(((char *)(tb[RTA_GATEWAY])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))))); print_string(PRINT_ANY, "nat_gateway", " map-to %s", gateway); } else { print_null(PRINT_ANY, "masquerade", " masquerade", ((void *)0)); } } else if (frh->action == FR_ACT_GOTO) { if (tb[FRA_GOTO]) print_uint(PRINT_ANY, "goto", " goto %u", rta_getattr_u32(tb[FRA_GOTO])); else print_string(PRINT_ANY, "goto", " goto %s", "none"); if (frh->flags & 0x00000004) print_null(PRINT_ANY, "unresolved", " [unresolved]", ((void *)0)); } else if (frh->action == FR_ACT_NOP) { print_null(PRINT_ANY, "nop", " nop", ((void *)0)); } else if (frh->action != FR_ACT_TO_TBL) { print_string(PRINT_ANY, "action", " %s", rtnl_rtntype_n2a(frh->action, b1, sizeof(b1))); } if (tb[FRA_PROTOCOL]) { __u8 protocol = rta_getattr_u8(tb[FRA_PROTOCOL]); if ((protocol && protocol != 2) || show_details > 0) { print_string(PRINT_ANY, "protocol", " proto %s", rtnl_rtprot_n2a(protocol, b1, sizeof(b1))); } } print_string(PRINT_FP, ((void *)0), "\n", ""); close_json_object(); fflush(fp); return 0; }
undefined8 print_rule(int *param_1, FILE *param_2) { char cVar1; undefined uVar2; uint uVar3; undefined4 uVar4; int iVar5; uint32_t uVar6; uint32_t uVar7; int *piVar8; undefined8 uVar9; short *psVar10; uint32_t __netlong; long in_FS_OFFSET; undefined4 local_1f0; undefined4 local_1ec; undefined local_178[8]; ushort *local_170; ushort *local_168; long local_160; long local_158; ushort *local_150; long local_148; long local_128; long local_120; long local_118; long local_110; long local_108; long local_f8; long local_f0; long local_e0; long local_d8; long local_d0; long local_c8; long local_c0; long local_b8; undefined local_a8[64]; undefined local_68[72]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); piVar8 = param_1 + 4; local_1f0 = 0; if ((*(short *)(param_1 + 1) != 0x20) && (*(short *)(param_1 + 1) != 0x21)) { uVar9 = 0; goto LAB_00101653; } if (*param_1 + -0x1c < 0) { uVar9 = 0xffffffff; goto LAB_00101653; } parse_rtattr(local_178, 0x18, param_1 + 7, *param_1 + -0x1c); uVar3 = af_bit_len(*(undefined *)piVar8); cVar1 = filter_nlmsg(param_1, local_178, uVar3); if (cVar1 != '\x01') { uVar9 = 0; goto LAB_00101653; } open_json_object(0); if (*(short *)(param_1 + 1) == 0x21) { print_bool(4, "deleted", "Deleted ", 1); } if (local_148 != 0) { local_1f0 = rta_getattr_u32(local_148); } print_uint(4, "priority", &DAT_00103e5c, local_1f0); if ((param_1[6] & 2U) != 0) { print_null(4, &DAT_00103e6f, &DAT_00103e6a, 0); } if (local_168 == (ushort *)0x0) { if (*(char *)((long)param_1 + 0x12) == '\0') { print_string(4, &DAT_00103e7c, "from %s", &DAT_00103e95); } else { print_string(4, &DAT_00103e7c, "from %s", &DAT_00103e8b); print_uint(4, "srclen", &DAT_00103e80, *(undefined *)((long)param_1 + 0x12)); } } else { uVar9 = rt_addr_n2a(*(undefined *)piVar8, *local_168 - 4, local_168 + 2); print_string(1, 0, "from ", 0); uVar4 = ifa_family_color(*(undefined *)piVar8); print_color_string(4, uVar4, &DAT_00103e7c, &DAT_00103e79, uVar9); if (uVar3 != *(byte *)((long)param_1 + 0x12)) { print_uint(4, "srclen", &DAT_00103e80, *(undefined *)((long)param_1 + 0x12)); } } if (local_170 == (ushort *)0x0) { if (*(char *)((long)param_1 + 0x11) != '\0') { print_string(4, &DAT_00103e9e, " to %s", &DAT_00103e8b); print_uint(4, "dstlen", &DAT_00103e80, *(undefined *)((long)param_1 + 0x11)); } } else { uVar9 = rt_addr_n2a(*(undefined *)piVar8, *local_170 - 4, local_170 + 2); print_string(1, 0, &DAT_00103e99, 0); uVar4 = ifa_family_color(*(undefined *)piVar8); print_color_string(4, uVar4, &DAT_00103e9e, &DAT_00103e79, uVar9); if (uVar3 != *(byte *)((long)param_1 + 0x11)) { print_uint(4, "dstlen", &DAT_00103e80, *(undefined *)((long)param_1 + 0x11)); } } if (*(char *)((long)param_1 + 0x13) != '\0') { uVar9 = rtnl_dsfield_n2a(*(undefined *)((long)param_1 + 0x13), local_a8, 0x40); print_string(4, &DAT_00103eb8, " tos %s", uVar9); } if ((local_128 != 0) || (local_f8 != 0)) { local_1ec = 0; if (local_128 != 0) { local_1ec = rta_getattr_u32(local_128); } if (local_f8 != 0) { iVar5 = rta_getattr_u32(local_f8); if (iVar5 != -1) { print_0xhex(4, "fwmark", " fwmark %#llx", local_1ec); print_0xhex(4, "fwmask", "/%#llx", iVar5); goto LAB_00100de0; } } print_0xhex(4, "fwmark", " fwmark %#llx", local_1ec); } LAB_00100de0: if (local_160 != 0) { cVar1 = is_json_context(); if (cVar1 != '\x01') { fprintf(param_2, " iif "); } uVar9 = rta_getattr_str(local_160); print_color_string(4, 0, &DAT_00103ee5, &DAT_00103e79, uVar9); if ((param_1[6] & 8U) != 0) { print_null(4, "iif_detached", " [detached]", 0); } } if (local_f0 != 0) { cVar1 = is_json_context(); if (cVar1 != '\x01') { fprintf(param_2, " oif "); } uVar9 = rta_getattr_str(local_f0); print_color_string(4, 0, &DAT_00103f08, &DAT_00103e79, uVar9); if ((param_1[6] & 0x10U) != 0) { print_null(4, "oif_detached", " [detached]", 0); } } if (local_e0 != 0) { cVar1 = rta_getattr_u8(local_e0); if (cVar1 != '\0') { print_null(4, "l3mdev", " lookup [l3mdev-table]", 0); } } if (local_d8 != 0) { print_uint(4, "uid_start", " uidrange %u", *(undefined4 *)(local_d8 + 4)); print_uint(4, "uid_end", &DAT_00103f4e, *(undefined4 *)(local_d8 + 8)); } if (local_c8 != 0) { uVar2 = rta_getattr_u8(local_c8); uVar9 = inet_proto_n2a(uVar2, local_68, 0x40); print_string(4, "ipproto", " ipproto %s", uVar9); } if (local_c0 != 0) { psVar10 = (short *)(local_c0 + 4); if (*psVar10 == *(short *)(local_c0 + 6)) { print_uint(4, "sport", " sport %u", *psVar10); } else { print_uint(4, "sport_start", " sport %u", *psVar10); print_uint(4, "sport_end", &DAT_00103f4e, *(undefined2 *)(local_c0 + 6)); } } if (local_b8 != 0) { psVar10 = (short *)(local_b8 + 4); if (*psVar10 == *(short *)(local_b8 + 6)) { print_uint(4, "dport", " dport %u", *psVar10); } else { print_uint(4, "dport_start", " dport %u", *psVar10); print_uint(4, "dport_end", &DAT_00103f4e, *(undefined2 *)(local_b8 + 6)); } } if (local_118 != 0) { uVar6 = ntohl(1); if (uVar6 == 1) { uVar9 = rta_getattr_u64(local_118); } else { uVar6 = rta_getattr_u64(); uVar6 = ntohl(uVar6); rta_getattr_u64(); uVar7 = ntohl(__netlong); uVar9 = CONCAT44(uVar6, uVar7); } print_u64(4, "tun_id", " tun_id %llu", uVar9); } iVar5 = frh_get_table(piVar8, local_178); if (iVar5 != 0) { uVar9 = rtnl_rttable_n2a(iVar5, local_a8, 0x40); print_string(4, "table", " lookup %s", uVar9); if (local_108 != 0) { iVar5 = rta_getattr_u32(local_108); if (iVar5 != -1) { print_int(4, "suppress_prefixlen", " suppress_prefixlength %d", iVar5); } } if (local_110 != 0) { iVar5 = rta_getattr_u32(local_110); if (iVar5 != -1) { uVar9 = rtnl_group_n2a(iVar5, local_a8, 0x40); print_string(4, "suppress_ifgroup", " suppress_ifgroup %s", uVar9); } } } if (local_120 != 0) { uVar3 = rta_getattr_u32(local_120); if (uVar3 >> 0x10 == 0) { print_string(1, 0, " realms ", 0); } else { uVar9 = rtnl_rtrealm_n2a(uVar3 >> 0x10, local_a8, 0x40); print_string(4, "flow_from", " realms %s/", uVar9); } uVar9 = rtnl_rtrealm_n2a(uVar3 & 0xffff, local_a8, 0x40); print_string(4, "flow_to", &DAT_00103e79, uVar9); } if (*(char *)((long)param_1 + 0x17) == '\n') { if (local_150 == (ushort *)0x0) { print_null(4, "masquerade", " masquerade", 0); } else { uVar9 = format_host(*(undefined *)piVar8, *local_150 - 4, local_150 + 2); print_string(4, "nat_gateway", " map-to %s", uVar9); } } else if (*(char *)((long)param_1 + 0x17) == '\x02') { if (local_158 == 0) { print_string(4, &DAT_00104090, " goto %s", &DAT_00104095); } else { uVar4 = rta_getattr_u32(local_158); print_uint(4, &DAT_00104090, " goto %u", uVar4); } if ((param_1[6] & 4U) != 0) { print_null(4, "unresolved", " [unresolved]", 0); } } else if (*(char *)((long)param_1 + 0x17) == '\x03') { print_null(4, &DAT_001040c1, &DAT_001040bc, 0); } else if (*(char *)((long)param_1 + 0x17) != '\x01') { uVar9 = rtnl_rtntype_n2a(*(undefined *)((long)param_1 + 0x17), local_a8, 0x40); print_string(4, "action", &DAT_001040c5, uVar9); } if (local_d0 != 0) { cVar1 = rta_getattr_u8(local_d0); if (((cVar1 != '\0') && (cVar1 != '\x02')) || (0 < show_details)) { uVar9 = rtnl_rtprot_n2a(cVar1, local_a8, 0x40); print_string(4, "protocol", " proto %s", uVar9); } } print_string(1, 0, &DAT_001040e4, &DAT_001040e3); close_json_object(); fflush(param_2); uVar9 = 0; LAB_00101653: if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return uVar9; }
iproute2-6.0.0
ghidra
static double getdouble(void) { double val; char *cp, *ep; cp = *gargv; if (cp == ((void *)0)) return 0; gargv++; if (*cp == '\"' || *cp == '\'') return (unsigned char)cp[1]; (*__errno_location()) = 0; val = strtod(cp, &ep); check_conversion(cp, ep); return val; }
void getdouble() { char v0; char *v1; unsigned long v2; char v3; unsigned long v5; unsigned long long *v6; unsigned long long v7; v1 = *(gargv); if (v1) { gargv = gargv + 8; switch (*(v1)) { case 34: case 39: break; default: *(__errno_location()) = 0; strtod(v1, &v0); v2 = v5; check_conversion(v1, *(&v0)); break; } } v7 = *(&v3) ^ v6[5]; return; }
dash-0.5.11+git20210903+057cd650a4ed
angr_sailr
static inline __be16 rta_getattr_be16(const struct rtattr *rta) { return ntohs(rta_getattr_u16(rta)); }
void rta_getattr_be16(void) { uint16_t __netshort; __netshort = rta_getattr_u16(); ntohs(__netshort); return; }
iproute2-6.0.0
ghidra
static int find_matching_open(char *string, int from, int closer) { register int i; int opener, level, delimiter; switch (closer) { case ']': opener = '['; break; case '}': opener = '{'; break; case ')': opener = '('; break; default: return (-1); } level = 1; delimiter = 0; for (i = from; i > -1; i--) { if (delimiter && (string[i] == delimiter)) delimiter = 0; else if (rl_basic_quote_characters && strchr(rl_basic_quote_characters, string[i])) delimiter = string[i]; else if (!delimiter && (string[i] == closer)) level++; else if (!delimiter && (string[i] == opener)) level--; if (!level) break; } return (i); }
int find_matching_open(char *a0, unsigned long a1, unsigned long a2) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned int v4; char *v5; if (a2 == 125) { v0 = 123; } else if (a2 > 125) { v4 = -1; goto LABEL_4004ce; } else if (a2 == 41) { v0 = 40; } else if (a2 == 93) { v0 = 91; } v1 = 1; v2 = 0; v5 = a1; while (true) { if (v5 < 0) break; if (v2 && v2 == *((a0 + v5))) { v2 = 0; goto LABEL_4004b8; } if (rl_basic_quote_characters && strchr(rl_basic_quote_characters, *((a0 + v5)))) { v2 = *((a0 + v5)); goto LABEL_4004b8; } if (!v2 && a2 == *((a0 + v5))) { v1 += 1; goto LABEL_4004b8; } if (!v2 && v0 == *((a0 + v5))) v1 -= 1; LABEL_4004b8: if (!v1) break; v5 = v5 - 1; } v4 = v5; LABEL_4004ce: return v4; }
bash
angr_phoenix
int bash_delete_last_history() { register int i; HIST_ENTRY **hlist, *histent; int r; hlist = history_list(); if (hlist == ((void *)0)) return 0; for (i = 0; hlist[i]; i++) ; i--; histent = history_get(history_base + i); if (histent == ((void *)0)) return 0; r = bash_delete_histent(i); if (where_history() > history_length) history_set_pos(history_length); return r; }
long long bash_delete_last_history(unsigned long long a0, unsigned long long a1, unsigned long long a2, unsigned long long a3, unsigned long long a4, unsigned long long a5) { unsigned int v0; unsigned long long *v1; unsigned long v2; void *v4; void *v5; unsigned long v6; v1 = history_list(); if (!v1) { v4 = 0; } else { for (v5 = 0; *((v1 + 0x8 * v5)); v5 = v5 + 1) ; v6 = v5 - 1; v2 = history_get(history_base + v6); if (!v2) { v4 = 0; } else { v0 = bash_delete_histent(v6); if (where_history(a0, a1, a2, a3, a4, a5) > history_length) history_set_pos(history_length); v4 = v0; } } return v4; }
bash
angr_dream
static int xfrm_state_allocspi(int argc, char **argv) { struct rtnl_handle rth; struct { struct nlmsghdr n; struct xfrm_userspi_info xspi; char buf[2048]; } req = { .n.nlmsg_len = ((sizeof(req.xspi)) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1)))), .n.nlmsg_flags = 0x01, .n.nlmsg_type = XFRM_MSG_ALLOCSPI, .xspi.info.family = preferred_family, }; char *idp = ((void *)0); char *minp = ((void *)0); char *maxp = ((void *)0); struct xfrm_mark mark = {0, 0}; struct nlmsghdr *answer; while (argc > 0) { if (strcmp(*argv, "mode") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); xfrm_mode_parse(&req.xspi.info.mode, &argc, &argv); } else if (strcmp(*argv, "mark") == 0) { xfrm_parse_mark(&mark, &argc, &argv); } else if (strcmp(*argv, "reqid") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); xfrm_reqid_parse(&req.xspi.info.reqid, &argc, &argv); } else if (strcmp(*argv, "seq") == 0) { do { argv++; if (--argc <= 0) incomplete_command(); } while (0); xfrm_seq_parse(&req.xspi.info.seq, &argc, &argv); } else if (strcmp(*argv, "min") == 0) { if (minp) duparg("min", *argv); minp = *argv; do { argv++; if (--argc <= 0) incomplete_command(); } while (0); if (get_u32(&req.xspi.min, *argv, 0)) invarg("value after \"min\" is invalid", *argv); } else if (strcmp(*argv, "max") == 0) { if (maxp) duparg("max", *argv); maxp = *argv; do { argv++; if (--argc <= 0) incomplete_command(); } while (0); if (get_u32(&req.xspi.max, *argv, 0)) invarg("value after \"max\" is invalid", *argv); } else { if (idp) invarg("unknown", *argv); idp = *argv; xfrm_id_parse(&req.xspi.info.saddr, &req.xspi.info.id, &req.xspi.info.family, 0, &argc, &argv); if (req.xspi.info.id.spi) { fprintf(stderr, "\"spi\" is invalid\n"); exit(1); } if (preferred_family == 0) preferred_family = req.xspi.info.family; } argc--; argv++; } if (!idp) { fprintf(stderr, "Not enough information: ID is required\n"); exit(1); } if (minp) { if (!maxp) { fprintf(stderr, "\"max\" is missing\n"); exit(1); } if (req.xspi.min > req.xspi.max) { fprintf(stderr, "value after \"min\" is larger than value after \"max\"\n"); exit(1); } } else { if (maxp) { fprintf(stderr, "\"min\" is missing\n"); exit(1); } req.xspi.min = 0x100; req.xspi.max = 0x0fffffff; if (req.xspi.info.id.proto == IPPROTO_COMP) req.xspi.max = 0xffff; } if (mark.m & mark.v) { int r = addattr_l(&req.n, sizeof(req.buf), XFRMA_MARK, (void *)&mark, sizeof(mark)); if (r < 0) { fprintf(stderr, "XFRMA_MARK failed\n"); exit(1); } } if (rtnl_open_byproto(&rth, 0, 6) < 0) exit(1); if (req.xspi.info.family == 0) req.xspi.info.family = 2; if (rtnl_talk(&rth, &req.n, &answer) < 0) exit(2); if (xfrm_state_print(answer, (void *)stdout) < 0) { fprintf(stderr, "An error :-)\n"); exit(1); } free(answer); rtnl_close(&rth); return 0; }
void xfrm_state_allocspi(unsigned long a0, unsigned long a1) { unsigned long long *v0; unsigned int v1; unsigned int v2; char v3; void *v4; void *v5; void *v6; unsigned int v7; unsigned int v8; char v9; char v10; unsigned short v11; unsigned short v12; char v13; char v14; char v15; char v16; char v17; char v18; unsigned short v19; char v20; char v21; unsigned int v22; unsigned long long v24; unsigned long long *v25; unsigned long v26; void *v27; v1 = a0; v0 = a1; v24 = 287; for (v25 = &v10; v24; v25 = &v25[v26]) { v24 -= 1; v10 = 0; } v10 = 248; v11 = 22; v12 = 1; v19 = preferred_family; v4 = 0; v5 = 0; v6 = 0; v7 = 0; v8 = 0; while (true) { if (v1 <= 0) break; if (!strcmp(*(v0), "mode")) { v0 = v0 + 1; goto LABEL_0x402881; } if (!strcmp(*(v0), "mark")) { xfrm_parse_mark(&v7, &a0, &v0, &a0); goto LABEL_0x402881; } if (!strcmp(*(v0), "reqid")) { v0 = v0 + 1; goto LABEL_0x402881; } if (!strcmp(*(v0), "seq")) goto LABEL_0x40299a; if (!strcmp(*(v0), "min")) { if (v5) duparg("min", *(v0)); v5 = *(v0); v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); if (!get_u32(&v21, *(v0), 0x0, &v21)) goto LABEL_0x402881; invarg("value after \"min\" is invalid", *(v0)); } if (strcmp(*(v0), "max")) { LABEL_402b92: if (v4) invarg("unknown", *(v0)); v4 = *(v0); xfrm_id_parse(&v16, &v13, &v19, 0x0, &a0, &v0); if (*(&v14)) { fprintf(*(&stderr), "\"spi\" is invalid\n"); exit(0x1); } else if (!preferred_family) { preferred_family = v19; goto LABEL_0x402881; } goto LABEL_0x402881; } else { if (v6) duparg("max", *(v0)); v6 = *(v0); v0 = v0 + 1; v1 = v1 - 1; if (v1 <= 0) incomplete_command(); if (!get_u32(&v22, *(v0), 0x0, &v22)) { while (true) { while (true) { while (true) { v1 = v1 - 1; if (strcmp(*(v0), "mode")) break; if (v1 <= 0) incomplete_command(); xfrm_mode_parse(&v20, &a0, &v0, &v20); } if (!(!strcmp(*(v0), "reqid")) || !(strcmp(*(v0), "mode")) || !(strcmp(*(v0), "mark"))) break; if (v1 <= 0) incomplete_command(); xfrm_reqid_parse(&v18, &a0, &v0, &v18); } if (!(!strcmp(*(v0), "seq")) || !(strcmp(*(v0), "mode")) || !(strcmp(*(v0), "reqid")) || !(strcmp(*(v0), "mark"))) { v0 = v0 + 1; if (!(!strcmp(*(v0), "seq")) || !(strcmp(*(v0), "mode")) || !(strcmp(*(v0), "reqid")) || !(strcmp(*(v0), "mark"))) break; } else { if (v1 <= 0) incomplete_command(); xfrm_seq_parse(&v17, &a0, &v0); } } } else { invarg("value after \"max\" is invalid", *(v0)); goto LABEL_402b92; } } } if (!v4) { fprintf(*(&stderr), "Not enough information: ID is required\n"); exit(0x1); } if (v5) { if (!v6) { fprintf(*(&stderr), "\"max\" is missing\n"); exit(0x1); } else if (v21 > v22) { fprintf(*(&stderr), "value after \"min\" is larger than value after \"max\"\n"); exit(0x1); } } else { if (v6) { fprintf(*(&stderr), "\"min\" is missing\n"); exit(0x1); } v21 = 0x100; v22 = 268435455; if (v15 == 108) v22 = 65535; } if ((v7 & v8)) { v2 = addattr_l(&v10, 0x800, 0x15, &v7, 0x8); if (v2 < 0) { fprintf(*(&stderr), "XFRMA_MARK failed\n"); exit(0x1); } } if (rtnl_open_byproto(&v9, 0x0, 0x6) < 0) exit(0x1); if (!v19) v19 = 2; if (rtnl_talk(&v9, &v10, &v3, &v10) < 0) { exit(0x2); } else if (xfrm_state_print(*(&v3), stdout) < 0) { fprintf(*(&stderr), "An error :-)\n"); exit(0x1); } else { free(*(&v3)); rtnl_close(&v9); v27 = 0; return; } }
iproute2-6.0.0
angr_sailr
Attrib *do_stat(struct sftp_conn *conn, const char *path, int quiet) { u_int id; sshlog("sftp-client.c", __func__, 909, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "Sending SSH2_FXP_STAT \"%s\"", path); id = conn->msg_id++; send_string_request(conn, id, conn->version == 0 ? 7 : 17, path, strlen(path)); return (get_decode_stat(conn, id, quiet)); }
int *do_stat(unsigned int *a1, const char *a2, int a3) { unsigned int v3; unsigned int v4; unsigned int v5; unsigned int v9; sshlog("sftp-client.c", "do_stat", 909LL, 0LL, 6LL, 0LL, "Sending SSH2_FXP_STAT \"%s\"", a2); v3 = a1[6]; a1[6] = v3 + 1; v9 = v3; v4 = strlen(a2); if (a1[5]) v5 = 17; else v5 = 7; send_string_request((long)a1, v9, v5, (long)a2, v4); return get_decode_stat(a1, v9, a3); }
openssh-portable
ida
int pkcs11_del_provider(char *name) { int r, ret = -1; struct sshbuf *msg; if ((msg = sshbuf_new()) == ((void *)0)) sshfatal("ssh-pkcs11-client.c", __func__, 377, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new failed"); if ((r = sshbuf_put_u8(msg, 21)) != 0 || (r = sshbuf_put_cstring(msg, name)) != 0 || (r = sshbuf_put_cstring(msg, "")) != 0) sshfatal("ssh-pkcs11-client.c", __func__, 381, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "compose"); send_msg(msg); sshbuf_reset(msg); if (recv_msg(msg) == 6) ret = 0; sshbuf_free(msg); return (ret); }
long long pkcs11_del_provider(unsigned long long a0) { unsigned long long v0; unsigned int v1; unsigned int v2; unsigned long long v3; unsigned long long v5; v2 = -1; v3 = sshbuf_new(); if (!v3) { v0 = "sshbuf_new failed"; sshfatal("ssh-pkcs11-client.c", "pkcs11_del_provider", 0x179, 0x1, 0x1, 0x0); } v1 = sshbuf_put_u8(v3, 0x15); if (!v1) { v1 = sshbuf_put_cstring(v3, a0, a0); if (!v1) { v1 = sshbuf_put_cstring(v3, &g_4017a5, v5); if (!v1) goto LABEL_401578; } } v3 = "compose"; sshfatal("ssh-pkcs11-client.c", "pkcs11_del_provider", 0x17d, 0x1, 0x1, ssh_err(v1)); LABEL_401578: send_msg(v3); sshbuf_reset(v3); if (recv_msg(v3) == 6) v2 = 0; sshbuf_free(v3); return v2; }
openssh-portable
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 { printf(gettext("Usage: %s FORMAT [ARGUMENT]...\n or: %s OPTION\n") , program_name, program_name); fputs_unlocked(gettext("Print ARGUMENT(s) according to FORMAT, or execute " "according to OPTION:\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("\nFORMAT controls the output as in C printf. Interpreted " "sequences are:\n\n \\\" double quote\n"), stdout) ; fputs_unlocked( gettext(" \\\\ backslash\n \\a alert (BEL)\n \\b " "backspace\n \\c produce no further output\n \\e " "escape\n \\f form feed\n \\n new line\n \\r " "carriage return\n \\t horizontal tab\n \\v " "vertical tab\n"), stdout); fputs_unlocked( gettext(" \\NNN byte with octal value NNN (1 to 3 digits)\n \\xHH " " byte with hexadecimal value HH (1 to 2 digits)\n \\uHHHH " "Unicode (ISO/IEC 10646) character with hex value HHHH (4 " "digits)\n \\UHHHHHHHH Unicode character with hex value " "HHHHHHHH (8 digits)\n"), stdout) ; fputs_unlocked( gettext(" %% a single %\n %b ARGUMENT as a string with " "'\\' escapes interpreted,\n except that octal " "escapes are of the form \\0 or \\0NNN\n %q ARGUMENT is " "printed in a format that can be reused as shell input,\n " " escaping non-printable characters with the proposed POSIX " "$'' syntax.\n\nand all C format specifications ending with " "one of diouxXfeEgGcs, with\nARGUMENTs converted to proper " "type first. Variable widths are handled.\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"), "printf"); emit_ancillary_info("printf"); } exit(status); }
void usage(unsigned long a0) { unsigned long v0; unsigned long v1; unsigned long v3; unsigned long v4; v1 = v3; v0 = v4; if (a0) { fprintf(stderr, gettext("Try '%s --help' for more information.\n")); } else { printf(gettext("Usage: %s FORMAT [ARGUMENT]...\n or: %s OPTION\n")); fputs_unlocked(gettext("Print ARGUMENT(s) according to FORMAT, or execute " "according to OPTION:\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("\nFORMAT controls the output as in C printf. Interpreted " "sequences are:\n\n \\\" double quote\n"), stdout); fputs_unlocked( gettext(" \\\\ backslash\n \\a alert (BEL)\n \\b " "backspace\n \\c produce no further output\n \\e " "escape\n \\f form feed\n \\n new line\n \\r " "carriage return\n \\t horizontal tab\n \\v " "vertical tab\n"), stdout); fputs_unlocked( gettext(" \\NNN byte with octal value NNN (1 to 3 digits)\n \\xHH " " byte with hexadecimal value HH (1 to 2 digits)\n \\uHHHH " "Unicode (ISO/IEC 10646) character with hex value HHHH (4 " "digits)\n \\UHHHHHHHH Unicode character with hex value " "HHHHHHHH (8 digits)\n"), stdout); fputs_unlocked( gettext(" %% a single %\n %b ARGUMENT as a string with " "'\\' escapes interpreted,\n except that octal " "escapes are of the form \\0 or \\0NNN\n %q ARGUMENT is " "printed in a format that can be reused as shell input,\n " " escaping non-printable characters with the proposed POSIX " "$'' syntax.\n\nand all C format specifications ending with " "one of diouxXfeEgGcs, with\nARGUMENTs converted to proper " "type first. Variable widths are handled.\n"), stdout); printf(gettext( "\nNOTE: your shell may have its own version of %s, which usually " "supersedes\nthe version described here. Please refer to your shell's " "documentation\nfor details about the options it supports.\n")); emit_ancillary_info("printf"); } exit(a0); }
coreutils
angr_dream
static void channel_post_mux_client_read(struct ssh *ssh, Channel *c) { u_int need; if ((c->io_ready & 0x01) == 0) return; if (c->istate != 0 && c->istate != 1) return; if (c->mux_pause) return; if (read_mux(ssh, c, 4) < 4) return; need = (((u_int32_t)(((const u_char *)(sshbuf_ptr(c->input)))[0]) << 24) | ((u_int32_t)(((const u_char *)(sshbuf_ptr(c->input)))[1]) << 16) | ((u_int32_t)(((const u_char *)(sshbuf_ptr(c->input)))[2]) << 8) | (u_int32_t)(((const u_char *)(sshbuf_ptr(c->input)))[3])); if (need > (256 * 1024)) { sshlog("channels.c", __func__, 2254, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "channel %d: packet too big %u > %u", c->self, (256 * 1024), need); chan_rcvd_oclose(ssh, c); return; } if (read_mux(ssh, c, need + 4) < need + 4) return; if (c->mux_rcb(ssh, c) != 0) { sshlog("channels.c", __func__, 2262, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "channel %d: mux_rcb failed", c->self); chan_mark_dead(ssh, c); return; } }
void channel_post_mux_client_read(unsigned long long a0, struct_0 *a1) { unsigned long v0; unsigned long v1; unsigned int v2; unsigned long long v4; unsigned long long v5; unsigned long long v6; unsigned int v9; unsigned int v11; unsigned long long v12; unsigned int v13; unsigned long long v15; unsigned long long v17; v4 = a1->field_30 & 1; if ((a1->field_30 & 1)) { switch (a1->field_10) { case 0: LABEL_407659: v6 = a1->field_158; if (!a1->field_158 && read_mux(a0, a1, 0x4) > 3) { v9 = *(sshbuf_ptr(a1->field_68)) * 0x1000000; v11 = v9 | (*((sshbuf_ptr(a1->field_68) + 1)) * 0x10000); v12 = *((sshbuf_ptr(a1->field_68) + 2)); v13 = v11 | (v12 * 0x100); *(&v12) = *((sshbuf_ptr(a1->field_68) + 3)); *(&v12) = v12 | v13; v2 = v12; if (v2 > 0x40000) { v1 = v2; v0 = a1->field_4; sshlog("channels.c", "channel_post_mux_client_read", 0x8ce, 0x0, 0x6, 0x0, "channel %d: packet too big %u > %u"); v15 = chan_rcvd_oclose(a0, a1, a1); break; } else if (read_mux(a0, a1, v2 + 4) >= v2 + 4 && a1->field_148(a0, a1, a1, a1->field_148)) { v1 = a1->field_4; sshlog("channels.c", "channel_post_mux_client_read", 0x8d6, 0x0, 0x5, 0x0, "channel %d: mux_rcb failed"); v17 = chan_mark_dead(a0, a1, a1); break; } } case 1: v5 = a1->field_10; break; default: v5 = a1->field_10; goto LABEL_407659; } } return; }
openssh-portable
angr_sailr
static int ssh_packet_need_rekeying(struct ssh *ssh, u_int outbound_packet_len) { struct session_state *state = ssh->state; u_int32_t out_blocks; if (!state->after_authentication) return 0; if (ssh_packet_is_rekeying(ssh)) return 0; if (ssh->compat & 0x00008000) return 0; if (state->p_send.packets == 0 && state->p_read.packets == 0) return 0; if (state->rekey_interval != 0 && (int64_t)state->rekey_time + state->rekey_interval <= monotime()) return 1; if (state->p_send.packets > (1U << 31) || state->p_read.packets > (1U << 31)) return 1; out_blocks = ((((outbound_packet_len) + ((state->newkeys[MODE_OUT]->enc.block_size) - 1)) / (state->newkeys[MODE_OUT]->enc.block_size)) * (state->newkeys[MODE_OUT]->enc.block_size)); return (state->max_blocks_out && (state->p_send.blocks + out_blocks > state->max_blocks_out)) || (state->max_blocks_in && (state->p_read.blocks > state->max_blocks_in)); }
undefined8 ssh_packet_need_rekeying(long *param_1, int param_2) { long lVar1; int iVar2; undefined8 uVar3; long lVar4; long lVar5; lVar1 = *param_1; if (*(int *)(lVar1 + 0x148) == 0) { uVar3 = 0; } else { iVar2 = ssh_packet_is_rekeying(param_1); if (iVar2 == 0) { if ((*(uint *)((long)param_1 + 0x83c) & 0x8000) == 0) { if ((*(int *)(lVar1 + 0x184) == 0) && (*(int *)(lVar1 + 0x16c) == 0)) { uVar3 = 0; } else { if (*(int *)(lVar1 + 0x1b0) != 0) { lVar4 = __addvdi3(*(undefined8 *)(lVar1 + 0x1b8)); lVar5 = monotime(); if (lVar4 <= lVar5) { return 1; } } if ((*(uint *)(lVar1 + 0x184) < 0x80000001) && (*(uint *)(lVar1 + 0x16c) < 0x80000001)) { if (((*(long *)(lVar1 + 0x1a0) == 0) || (*(long *)(lVar1 + 0x188) + (ulong)(*(int *)(*(long *)(lVar1 + 0x160) + 0x1c) * (((param_2 + *(int *)(*(long *)(lVar1 + 0x160) + 0x1c)) - 1U) / *(uint *)(*(long *)(lVar1 + 0x160) + 0x1c))) <= *(ulong *)(lVar1 + 0x1a0))) && ((*(long *)(lVar1 + 0x198) == 0 || (*(ulong *)(lVar1 + 0x170) <= *(ulong *)(lVar1 + 0x198))))) { uVar3 = 0; } else { uVar3 = 1; } } else { uVar3 = 1; } } } else { uVar3 = 0; } } else { uVar3 = 0; } } return uVar3; }
openssh-portable
ghidra
static void print_rxsc_stats(const char *prefix, struct rtattr *attr) { struct rtattr *stats[MACSEC_RXSC_STATS_ATTR_MAX + 1]; if (!attr || show_stats == 0) return; (parse_rtattr_flags( (stats), (MACSEC_RXSC_STATS_ATTR_MAX), ((void *)(((char *)(attr)) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))), ((int)((attr)->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), (1 << 15))); print_stats(prefix, rxsc_stats_names, NUM_MACSEC_RXSC_STATS_ATTR, stats); }
void print_rxsc_stats(unsigned int a0, unsigned short *a1, unsigned long a2, unsigned long a3, unsigned long a4, unsigned long long a5) { char v0; char v1; unsigned long long *v3; unsigned long long v4; if (a1 && show_stats) { parse_rtattr_flags(&v0, 0xb, a1 + 2, *(a1)-4, 0x8000); print_stats(a0, &rxsc_stats_names, 0xc, &v0, 0x8000, a5); } v4 = *(&v1) ^ v3[5]; return; }
iproute2-6.0.0
angr_dream
int spname(oldname, newname) char *oldname; char *newname; { char *op, *np, *p; char guess[4096 + 1], best[4096 + 1]; op = oldname; np = newname; for (;;) { while (*op == '/') *np++ = *op++; *np = '\0'; if (*op == '\0') { if (oldname[1] == '\0' && newname[1] == '\0' && oldname[0] != '.' && newname[0] == '.') return -1; return strcmp(oldname, newname) != 0; } for (p = guess; *op != '/' && *op != '\0'; op++) if (p < guess + 4096) *p++ = *op; *p = '\0'; if (mindist(newname, guess, best) >= 3) return -1; for (p = best; *np = *p++; np++) ; } }
long spname(char *a1, char *a2) { char *v2; char *v3; char *v5; char *v6; char *v7; char *v8; char *v9; char *v10; char v11[32]; long v12; char v13[16]; unsigned long v14; v14 = __readfsqword(0x28u); v7 = a1; v8 = a2; while (1) { while (*v7 == 47) { v2 = v7++; v3 = v8++; *v3 = *v2; } *v8 = 0; if (!*v7) break; v9 = v11; while (*v7 != 47 && *v7) { if (v9 < (char *)&v12) { v5 = v9++; *v5 = *v7; } ++v7; } *v9 = 0; if ((int)mindist(a2, v11, v13) > 2) return 0xFFFFFFFFLL; v10 = v13; while (1) { v6 = v10++; *v8 = *v6; if (!*v8) break; ++v8; } } if (a1[1] || a2[1] || *a1 == 46 || *a2 != 46) return strcmp(a1, a2) != 0; else return 0xFFFFFFFFLL; }
bash
ida
static int path_in_hostfiles(const char *path, char **hostfiles, u_int num_hostfiles) { u_int i; for (i = 0; i < num_hostfiles; i++) { if (strcmp(path, hostfiles[i]) == 0) return 1; } return 0; }
int path_in_hostfiles(char *a0, unsigned long long *a1, unsigned long a2) { unsigned int v0; unsigned int v2; v0 = 0; while (true) { if (v0 >= a2) { v2 = 0; return v2; } else if (strcmp(a0, a1[v0])) { v0 += 1; } else { v2 = 1; return v2; } } }
openssh-portable
angr_sailr
static void verify_chain(common_info_st *cinfo) { char *buf; size_t size; if (cinfo->ca != ((void *)0)) { fprintf(stderr, "This option cannot be combined with --load-ca-certificate\n"); app_exit(1); } buf = (void *)_gnutls_fread_file(infile, 0, &size); if (buf == ((void *)0)) { fprintf(stderr, "Error reading certificate chain"); app_exit(1); } _verify_x509_mem(buf, size, cinfo, 0, certtool_options.arg.verify_purpose, certtool_options.arg.verify_hostname, certtool_options.arg.verify_email); free(buf); }
unsigned long verify_chain(long a1) { long v2; void *ptr; unsigned long v4; v4 = __readfsqword(0x28u); if (*(_QWORD *)(a1 + 64)) { fprintf(stderr, "This option cannot be combined with --load-ca-certificate\n"); app_exit(1); } ptr = (void *)gnutls_fread_file(infile, 0LL, &v2); if (!ptr) { fprintf(stderr, "Error reading certificate chain"); app_exit(1); } verify_x509_mem((long)ptr, v2, a1, 0, *(const char **)&certtool_options[184], *(const char **)&certtool_options[168], *(const char **)&certtool_options[176]); free(ptr); return __readfsqword(0x28u) ^ v4; }
gnutls
ida
|| (remout != -1 && (fp = fdopen(remout, "w")))) { (void)fprintf(fp, "%c", 0x01); (void)fprintf(fp, "scp: "); __builtin_va_start(ap, fmt); (void)vfprintf(fp, fmt, ap); __builtin_va_end(ap); (void)fprintf(fp, "\n"); (void)fflush(fp); }
FILE *fdopen(int __fd, char *__modes) { halt_baddata(); }
openssh-portable
ghidra
int strsenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags, const char *mbextra, int *cerr_ptr) { return istrsenvisxna(mbdst, &dlen, mbsrc, len, flags, mbextra, cerr_ptr); }
long long strsenvisx(unsigned int a0, unsigned long a1, char *a2, unsigned long a3, unsigned long a4, void *a5, unsigned int *v1) { unsigned long v0; v0 = a1; return istrsenvisxna(a0, &v0, a2, a3, a4, a5, v1); }
libbsd-0.11.7
angr_phoenix
static int read_getcmd(EditLine *el, el_action_t *cmdnum, wchar_t *ch) { static const wchar_t meta = (wchar_t)0x80; el_action_t cmd; do { if (el_wgetc(el, ch) != 1) return -1; if (el->el_state.metanext) { el->el_state.metanext = 0; *ch |= meta; } if (*ch >= 256) cmd = 9; else cmd = el->el_map.current[(unsigned char)*ch]; if (cmd == 25) { keymacro_value_t val; switch (keymacro_get(el, ch, &val)) { case 0: cmd = val.cmd; break; case 1: el_wpush(el, val.str); break; case 2: return -1; default: abort(); break; } } } while (cmd == 25); *cmdnum = cmd; return 0; }
long read_getcmd(long a1, char *a2, int *a3) { int v4; char v6; const wchar_t *v7[2]; v7[1] = (const wchar_t *)__readfsqword(0x28u); do { if ((unsigned int)el_wgetc(a1, a3) != 1) return 0xFFFFFFFFLL; if (*(_DWORD *)(a1 + 124)) { *(_DWORD *)(a1 + 124) = 0; *a3 |= meta_5602; } if (*a3 <= 255) v6 = *(_BYTE *)(*(_QWORD *)(a1 + 1024) + (unsigned char)*a3); else v6 = 9; if (v6 == 25) { v4 = keymacro_get(a1, a3, v7); if (v4 == 2) return 0xFFFFFFFFLL; if (v4 > 2) goto LABEL_18; if (v4) { if (v4 != 1) LABEL_18: abort(); el_wpush(a1, v7[0]); } else { v6 = (char)v7[0]; } } } while (v6 == 25); *a2 = v6; return 0LL; }
libedit
ida
int __apply_mask_to_mode(mode_t *mode, acl_t acl) { acl_entry_t entry; int entry_id = 0; if (acl_entries(acl) == 3) return 0; while (acl_get_entry(acl, entry_id, &entry) == 1) { acl_tag_t tag_type; acl_get_tag_type(entry, &tag_type); if (tag_type == (0x10)) { acl_permset_t permset; acl_get_permset(entry, &permset); if (acl_get_perm(permset, (0x04)) != 1) *mode &= ~(0400 >> 3); if (acl_get_perm(permset, (0x02)) != 1) *mode &= ~(0200 >> 3); if (acl_get_perm(permset, (0x01)) != 1) *mode &= ~(0100 >> 3); return 0; } entry_id = 1; } *mode &= ~((0400 | 0200 | 0100) >> 3); return 1; }
undefined8 __apply_mask_to_mode(uint *param_1, undefined8 param_2) { int iVar1; undefined8 uVar2; long in_FS_OFFSET; int local_28; undefined4 local_24; undefined8 local_20; undefined8 local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_24 = 0; iVar1 = acl_entries(param_2); if (iVar1 == 3) { uVar2 = 0; } else { while (true) { iVar1 = acl_get_entry(param_2, local_24, &local_20); if (iVar1 != 1) break; acl_get_tag_type(local_20); if (local_28 == 0x10) { acl_get_permset(local_20, &local_18); iVar1 = acl_get_perm(local_18, 4); if (iVar1 != 1) { *param_1 = *param_1 & 0xffffffdf; } iVar1 = acl_get_perm(local_18, 2); if (iVar1 != 1) { *param_1 = *param_1 & 0xffffffef; } iVar1 = acl_get_perm(local_18, 1); if (iVar1 != 1) { *param_1 = *param_1 & 0xfffffff7; } uVar2 = 0; goto LAB_00100132; } local_24 = 1; } *param_1 = *param_1 & 0xffffffc7; uVar2 = 1; } LAB_00100132: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return uVar2; }
acl-2.3.1
ghidra
int unquoted_glob_pattern_p(string) register char *string; { register int c; char *send; int open, bsquote; mbstate_t state; memset(&state, '\0', sizeof(mbstate_t)); open = bsquote = 0; send = string + strlen(string); while (c = *string++) { switch (c) { case '?': case '*': return (1); case '[': open++; continue; case ']': if (open) return (1); continue; case '/': if (open) open = 0; case '+': case '@': case '!': if (*string == '(') return (1); continue; case '\\': if (*string != '\0' && *string != '/') { bsquote = 1; string++; continue; } else if (open && *string == '/') { string++; continue; } else if (*string == 0) return (0); case '\001': if (*string++ == '\0') return (0); } string--; do { if (locale_mb_cur_max > 1) { mbstate_t state_bak; size_t mblength; int _f; _f = is_basic(*(string)); if (_f) mblength = 1; else if (locale_utf8locale && ((*(string) & 0x80) == 0)) mblength = *(string) != 0; else { state_bak = state; mblength = mbrlen((string), (send - string), &state); } if (mblength == (size_t)-2 || mblength == (size_t)-1) { state = state_bak; mblength = 1; } else (string) += (mblength < 1) ? 0 : (mblength - 1); } } while (0); string++; } return (0); }
long long unquoted_glob_pattern_p(char *a0) { unsigned int v0; int tmp_5; unsigned int v1; unsigned int v2; unsigned long long v3; unsigned long v4; unsigned long long v5; unsigned long long v6; char *v8; unsigned long long v9; struct_0 *v10; char *v11; void *v12; unsigned long long v13; v8 = a0; memset(&v5, 0x0, 0x8); v1 = 0; v0 = v1; v9 = &a0[strlen(a0)]; v4 = v9; while (true) { tmp_5 = v8; v8 += 1; *(&v9) = *(tmp_5); if (!v9) { v13 = 0; break; } if (v9 == 1) { tmp_5 = v8; v8 += 1; *(&v9) = *(tmp_5); if (!v9) { v13 = 0; break; } } else { if (v9 <= 0) goto LABEL_400192; if (!(v9 <= 93)) goto LABEL_400192; if (v9 < 33) goto LABEL_400192; v10 = v9 - 33; switch (v10) { case 9: case 30: v13 = 1; break; case 58: v0 += 1; continue; case 59: if (*(v8) && *(v8) != 47) { v1 = 1; v8 += 1; continue; } if (v0 && *(v8) == 47) { v8 += 1; continue; } if (!*(v8)) { v13 = 0; break; } case 60: if (!v0) continue; v13 = 1; break; case 14: if (v0) { v0 = 0; goto LABEL_400120; } case 0: case 10: case 31: LABEL_400120: if (!(*(v8) == 40)) continue; v13 = 1; break; default: LABEL_400192: v11 = v8 + 1; if (locale_mb_cur_max <= 1) { LABEL_400248: v8 = v11 + 1; continue; } else { v2 = is_basic(*(v11)); if (v2) { v3 = 1; goto LABEL_40020f; } if (locale_utf8locale && *(v11) >= 0) { v3 = *(v11); goto LABEL_40020f; } v6 = v5; v3 = mbrlen(v11, v4 + -0x1 * v11, &v5, v4 + -0x1 * v11); LABEL_40020f: if (v3 != -2 && v3 != -1) { if (!v3) v12 = 0; else v12 = v3 - 1; v11 += v12; goto LABEL_400248; } v5 = v6; v3 = 1; goto LABEL_400248; } } } } return v13; }
bash
angr_phoenix
static void add_p1p1(ge25519_p1p1 *r, const crypto_sign_ed25519_ref_ge25519 *p, const crypto_sign_ed25519_ref_ge25519 *q) { crypto_sign_ed25519_ref_fe25519 a, b, c, d, t; crypto_sign_ed25519_ref_fe25519_sub(&a, &p->y, &p->x); crypto_sign_ed25519_ref_fe25519_sub(&t, &q->y, &q->x); crypto_sign_ed25519_ref_fe25519_mul(&a, &a, &t); crypto_sign_ed25519_ref_fe25519_add(&b, &p->x, &p->y); crypto_sign_ed25519_ref_fe25519_add(&t, &q->x, &q->y); crypto_sign_ed25519_ref_fe25519_mul(&b, &b, &t); crypto_sign_ed25519_ref_fe25519_mul(&c, &p->t, &q->t); crypto_sign_ed25519_ref_fe25519_mul(&c, &c, &ge25519_ec2d); crypto_sign_ed25519_ref_fe25519_mul(&d, &p->z, &q->z); crypto_sign_ed25519_ref_fe25519_add(&d, &d, &d); crypto_sign_ed25519_ref_fe25519_sub(&r->x, &b, &a); crypto_sign_ed25519_ref_fe25519_sub(&r->t, &d, &c); crypto_sign_ed25519_ref_fe25519_add(&r->z, &d, &c); crypto_sign_ed25519_ref_fe25519_add(&r->y, &b, &a); }
unsigned long add_p1p1(long a1, long a2, long a3) { char v5[128]; char v6[128]; char v7[128]; char v8[128]; char v9[136]; unsigned long v10; v10 = __readfsqword(0x28u); crypto_sign_ed25519_ref_fe25519_sub(v5, a2 + 128, a2); crypto_sign_ed25519_ref_fe25519_sub(v9, a3 + 128, a3); crypto_sign_ed25519_ref_fe25519_mul(v5, v5, v9); crypto_sign_ed25519_ref_fe25519_add(v6, a2, a2 + 128); crypto_sign_ed25519_ref_fe25519_add(v9, a3, a3 + 128); crypto_sign_ed25519_ref_fe25519_mul(v6, v6, v9); crypto_sign_ed25519_ref_fe25519_mul(v7, a2 + 384, a3 + 384); crypto_sign_ed25519_ref_fe25519_mul(v7, v7, &ge25519_ec2d); crypto_sign_ed25519_ref_fe25519_mul(v8, a2 + 256, a3 + 256); crypto_sign_ed25519_ref_fe25519_add(v8, v8, v8); crypto_sign_ed25519_ref_fe25519_sub(a1, v6, v5); crypto_sign_ed25519_ref_fe25519_sub(a1 + 384, v8, v7); crypto_sign_ed25519_ref_fe25519_add(a1 + 128, v8, v7); crypto_sign_ed25519_ref_fe25519_add(a1 + 256, v6, v5); return __readfsqword(0x28u) ^ v10; }
openssh-portable
ida
(ino > fs->super->s_inodes_count)) { clear_problem_context(&pctx); pctx.ino = ino; fix_problem(ctx, 0x000023, &pctx); goto err_qctx; }
void clear_problem_context(void) { halt_baddata(); }
e2fsprogs-1.46.5
ghidra
static void process_lstat(u_int32_t id) { process_do_stat(id, 1); }
long long process_lstat(unsigned long a0) { return process_do_stat(a0, 0x1); }
openssh-portable
angr_sailr
static void treedelta(struct tree const *tree, idx_t depth, unsigned char delta[]) { if (!tree) return; treedelta(tree->llink, depth, delta); treedelta(tree->rlink, depth, delta); if (depth < delta[tree->label]) delta[tree->label] = depth; }
void treedelta(struct_0 *a0, unsigned long long a1, char *a2) { unsigned long long v1; unsigned long long v2; if (a0) { treedelta(a0->field_0, a1, a2); treedelta(a0->field_8, a1, a2); v1 = a2[a0->field_18]; if (a1 < a2[a0->field_18]) { v2 = &a2[a0->field_18]; a2[a0->field_18] = a1; } } return; }
grep
angr_phoenix
) { dlh = BODY = dlopen(((void *)0), 0x00001); if (dlh == ((void *)0)) return ((void *)0); }
void dlopen(void) { halt_baddata(); }
iproute2-6.0.0
ghidra
static int ipstats_show_do(int ifindex, struct ipstats_stat_enabled *enabled) { int rc; new_json_obj(json); if (ifindex) rc = ipstats_show_one(ifindex, enabled); else rc = ipstats_dump(enabled); delete_json_obj(); return rc; }
int ipstats_show_do(unsigned long a0, unsigned long long a1, unsigned long a2, unsigned int a3, unsigned long long a4, unsigned long long a5) { unsigned int v0; new_json_obj(json); if (!a0) v0 = ipstats_dump(a1); else v0 = ipstats_show_one(a0, a1, a1, a3, a4, a5); delete_json_obj(); return v0; }
iproute2-6.0.0
angr_phoenix
(r = sshbuf_get_string(b, &mac->key, &maclen)) != 0) goto out; if (maclen > mac->key_len) { r = -4; goto out; }
void sshbuf_get_string(void) { halt_baddata(); }
openssh-portable
ghidra
static char *find_cmd_name(start, sp, ep) int start; int *sp, *ep; { char *name; register int s, e; for (s = start; (((rl_line_buffer[s]) == ' ') || ((rl_line_buffer[s]) == '\t')); s++) ; e = skip_to_delim(rl_line_buffer, s, "()<>;&| \t\n", 0x001 | 0x100); name = substring(rl_line_buffer, s, e); if (sp) *sp = s; if (ep) *ep = e; return (name); }
long long find_cmd_name(unsigned long a0, unsigned int *a1, unsigned int *a2) { unsigned long v0; char *v2; unsigned long long v3; v2 = a0; while (true) { switch (v2[rl_line_buffer]) { case 9: case 32: v2 = v2 + 1; break; default: goto LABEL_402d76; } } LABEL_402d76: v3 = skip_to_delim(rl_line_buffer, v2, "()<>;&| \t\n", 0x101); v0 = substring(rl_line_buffer, v2, v3); if (a1) *(a1) = v2; if (a2) *(a2) = v3; return v0; }
bash
angr_sailr
static int do_modinfo(int argc, char *argv[]) { struct kmod_ctx *ctx; char dirname_buf[4096]; const char *dirname = ((void *)0); const char *kversion = ((void *)0); const char *root = ((void *)0); const char *null_config = ((void *)0); _Bool arg_is_modname = 0; int i, err; for (;;) { int c, idx = 0; c = getopt_long(argc, argv, cmdopts_s, cmdopts, &idx); if (c == -1) break; switch (c) { case 'a': field = "author"; break; case 'd': field = "description"; break; case 'l': field = "license"; break; case 'p': field = "parm"; break; case 'n': field = "filename"; break; case '0': separator = '\0'; break; case 'm': arg_is_modname = 1; break; case 'F': field = optarg; break; case 'k': kversion = optarg; break; case 'b': root = optarg; break; case 'h': help(); return 0; case 'V': puts("kmod" " version " "30"); puts("-ZSTD -XZ -ZLIB -LIBCRYPTO -EXPERIMENTAL"); return 0; case '?': return 1; default: log_printf(3, "unexpected getopt_long() value '%c'.\n", c); return 1; } } if (optind >= argc) { log_printf(3, "missing module or filename.\n"); return 1; } if (root != ((void *)0) || kversion != ((void *)0)) { struct utsname u; if (root == ((void *)0)) root = ""; if (kversion == ((void *)0)) { if (uname(&u) < 0) { log_printf(3, "uname() failed: %m\n"); return 1; } kversion = u.release; } snprintf(dirname_buf, sizeof(dirname_buf), "%s/lib/modules/%s", root, kversion); dirname = dirname_buf; } ctx = kmod_new(dirname, &null_config); if (!ctx) { log_printf(3, "kmod_new() failed!\n"); return 1; } err = 0; for (i = optind; i < argc; i++) { const char *name = argv[i]; int r; if (arg_is_modname) r = modinfo_name_do(ctx, name); else if (is_module_filename(name)) r = modinfo_path_do(ctx, name); else r = modinfo_alias_do(ctx, name); if (r < 0) err = r; } kmod_unref(ctx); return err >= 0 ? 0 : 1; }
uint do_modinfo(int param_1, long param_2) { bool bVar1; char cVar2; int iVar3; uint uVar4; long in_FS_OFFSET; undefined4 local_11ec; int local_11e8; uint local_11e4; uint local_11e0; int local_11dc; undefined8 local_11d8; char *local_11d0; char *local_11c8; char *local_11c0; long local_11b8; undefined8 local_11b0; utsname local_11a8; char local_1018[4104]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_11d0 = (char *)0x0; local_11c8 = (char *)0x0; local_11c0 = (char *)0x0; local_11d8 = 0; bVar1 = false; while (true) { local_11ec = 0; local_11dc = getopt_long(param_1, param_2, cmdopts_s, cmdopts, &local_11ec); if (local_11dc == -1) break; switch (local_11dc) { case 0x30: separator = 0; break; default: log_printf(3, "unexpected getopt_long() value \'%c\'.\n", local_11dc); uVar4 = 1; goto LAB_001018e3; case 0x3f: uVar4 = 1; goto LAB_001018e3; case 0x46: field = optarg; break; case 0x56: puts("kmod version 30"); puts("-ZSTD -XZ -ZLIB -LIBCRYPTO -EXPERIMENTAL"); uVar4 = 0; goto LAB_001018e3; case 0x61: field = "author"; break; case 0x62: local_11c0 = optarg; break; case 100: field = "description"; break; case 0x68: help(); uVar4 = 0; goto LAB_001018e3; case 0x6b: local_11c8 = optarg; break; case 0x6c: field = "license"; break; case 0x6d: bVar1 = true; break; case 0x6e: field = "filename"; break; case 0x70: field = "parm"; } } if (optind < param_1) { if ((local_11c0 != (char *)0x0) || (local_11c8 != (char *)0x0)) { if (local_11c0 == (char *)0x0) { local_11c0 = ""; } if (local_11c8 == (char *)0x0) { iVar3 = uname(&local_11a8); if (iVar3 < 0) { log_printf(3, "uname() failed: %m\n"); uVar4 = 1; goto LAB_001018e3; } local_11c8 = local_11a8.release; } snprintf(local_1018, 0x1000, "%s/lib/modules/%s", local_11c0, local_11c8); local_11d0 = local_1018; } local_11b8 = kmod_new(local_11d0, &local_11d8); if (local_11b8 == 0) { log_printf(3, "kmod_new() failed!\n"); uVar4 = 1; } else { local_11e4 = 0; for (local_11e8 = optind; local_11e8 < param_1; local_11e8 = local_11e8 + 1) { local_11b0 = *(undefined8 *)(param_2 + (long)local_11e8 * 8); if (bVar1) { local_11e0 = modinfo_name_do(local_11b8, local_11b0); } else { cVar2 = is_module_filename(local_11b0); if (cVar2 == '\0') { local_11e0 = modinfo_alias_do(local_11b8, local_11b0); } else { local_11e0 = modinfo_path_do(local_11b8, local_11b0); } } if ((int)local_11e0 < 0) { local_11e4 = local_11e0; } } kmod_unref(local_11b8); uVar4 = local_11e4 >> 0x1f; } } else { log_printf(3, "missing module or filename.\n"); uVar4 = 1; } LAB_001018e3: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return uVar4; }
kmod
ghidra
int addr_is_all0s(const struct xaddr *a) { int i; switch (a->af) { case 2: return (a->xa.v4.s_addr == 0 ? 0 : -1); case 10: for (i = 0; i < 4; i++) if (a->xa.addr32[i] != 0) return -1; return 0; default: return -1; } }
void addr_is_all0s(struct_1 *a0, unsigned long a1, unsigned long a2, unsigned long long a3) { unsigned int v0; unsigned long v2; unsigned long long v3; void *v4; unsigned long long v5; switch (a0->field_0) { case 2: v2 = (!a0->field_4 ? 4294967295 : 0); return; case 10: v0 = 0; while (v0 > 3) { v4 = 0; return; } if ((&a0->field_4)[v0]) { v5 = 4294967295; return; } v0 = __addvsi3(v0, 0x1, v0, a3); break; default: v3 = 4294967295; return; } }
openssh-portable
angr_sailr
intmax_t strtoimax(ptr, endptr, base) const char *ptr; char **endptr; int base; { struct size_is_that_of_long_or_long_long { char a[((sizeof(intmax_t) == sizeof(long) || sizeof(intmax_t) == sizeof(long long))) ? 1 : -1]; } ; if (sizeof(intmax_t) != sizeof(long)) return (strtoll(ptr, endptr, base)); return (strtol(ptr, endptr, base)); }
intmax_t strtoimax(char *__nptr, char **__endptr, int __base) { long lVar1; lVar1 = strtol(__nptr, __endptr, __base); return lVar1; }
bash
ghidra