input
stringlengths
26
172k
output
stringlengths
18
318k
repo_name
stringclasses
23 values
decompiler
stringclasses
5 values
static int valid_rdomain(const char *name) { return sys_valid_rdomain(name); }
int valid_rdomain(unsigned long long a0) { return sys_valid_rdomain(a0); }
openssh-portable
angr_sailr
static int flush_update(void) { if (rtnl_send_check(&grth, f.flushb, f.flushp) < 0) { perror("Failed to send flush request\n"); return -1; } f.flushp = 0; return 0; }
int flush_update() { unsigned int v1; if (rtnl_send_check(&grth, g_401988, g_401990) >= 0) { g_401990 = 0; v1 = 0; return v1; } perror("Failed to send flush request\n"); v1 = -1; return v1; }
iproute2-6.0.0
angr_sailr
static void indent(amount) int amount; { register int i; do { if ((0) + (amount) >= indentation_size) { while ((0) + (amount) >= indentation_size) indentation_size += (16); indentation_string = sh_xrealloc((indentation_string), (indentation_size), "print_cmd.c", 1492); } } while (0); for (i = 0; amount > 0; amount--) indentation_string[i++] = ' '; indentation_string[i] = '\0'; cprintf("%s", indentation_string); }
void indent(int param_1) { int iVar1; int local_1c; if (indentation_size <= param_1) { for (; indentation_size <= param_1; indentation_size = indentation_size + 0x10) { } indentation_string = sh_xrealloc(indentation_string, (long)indentation_size, "print_cmd.c", 0x5d4); } iVar1 = 0; for (local_1c = param_1; 0 < local_1c; local_1c = local_1c + -1) { *(undefined *)(iVar1 + indentation_string) = 0x20; iVar1 = iVar1 + 1; } *(undefined *)(iVar1 + indentation_string) = 0; cprintf(&DAT_00103580, indentation_string); return; }
bash
ghidra
(n = atomicio(read, s, cp, 1)) == 1 && *cp != '\n') { if (*cp == '\r') *cp = '\n'; cp++; }
void atomicio(void) { halt_baddata(); }
openssh-portable
ghidra
static char const *expand_name(char *name, _Bool is_dir, char const *other_name) { if ((strcmp(name, "-") == 0)) fatal("cannot interactively merge standard input"); if (!is_dir) return name; else { char const *base = last_component(other_name); size_t namelen = strlen(name), baselen = base_len(base); _Bool insert_slash = *last_component(name) && name[namelen - 1] != '/'; char *r = xmalloc(namelen + insert_slash + baselen + 1); memcpy(r, name, namelen); r[namelen] = '/'; memcpy(r + namelen + insert_slash, base, baselen); r[namelen + insert_slash + baselen] = '\0'; return r; } }
char *expand_name(const char *a1, char a2, long a3) { bool v4; bool v6; void *src; size_t n; long v9; char *dest; if (!strcmp(a1, "-")) fatal("cannot interactively merge standard input"); if (a2 != 1) return (char *)a1; src = (void *)last_component(a3); n = strlen(a1); v9 = base_len(src); v4 = *(_BYTE *)last_component(a1) && a1[n - 1] != 47; v6 = v4; dest = (char *)xmalloc(n + v4 + v9 + 1); memcpy(dest, a1, n); dest[n] = 47; memcpy(&dest[n + v6], src, v9); dest[v9 + n + v6] = 0; return dest; }
diffutils
ida
inline static unsigned long timespec_sub_ns(struct timespec *a, struct timespec *b) { return (a->tv_sec - b->tv_sec) * 1000000000 + (a->tv_nsec - b->tv_nsec); }
int timespec_sub_ns(unsigned long long a0[2], unsigned long long a1[2]) { return a0[1] - a1[1] + (a0[0] - a1[0]) * 0x3b9aca00; }
gnutls
angr_phoenix
void rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc) { rl_set_prompt(prompt); (rl_readline_state |= (0x0080000)); rl_linefunc = linefunc; _rl_callback_newline(); }
long long rl_callback_handler_install() { unsigned long long v1; unsigned long long v2; rl_set_prompt(v1); rl_readline_state = rl_readline_state | 0x80000; rl_linefunc = v2; _rl_callback_newline(); }
bash
angr_phoenix
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; return v3; } else if (a1 != v0[3]) { v0[0] = v0[0]; } else { v3 = v0; return v3; } } }
e2fsprogs-1.46.5
angr_sailr
int kex_load_hostkey(struct ssh *ssh, struct sshkey **prvp, struct sshkey **pubp) { struct kex *kex = ssh->kex; *pubp = ((void *)0); *prvp = ((void *)0); if (kex->load_host_public_key == ((void *)0) || kex->load_host_private_key == ((void *)0)) { sshlog("kex.c", __func__, 1150, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "missing hostkey loader"); return -10; } *pubp = kex->load_host_public_key(kex->hostkey_type, kex->hostkey_nid, ssh); *prvp = kex->load_host_private_key(kex->hostkey_type, kex->hostkey_nid, ssh); if (*pubp == ((void *)0)) return -36; return 0; }
long long kex_load_hostkey(struct_0 *a0, unsigned long long *a1, unsigned long long *a2) { struct_1 *v0; unsigned long long v2; v0 = a0->field_8; *(a2) = 0; *(a1) = 0; if (v0->field_a8 && v0->field_b0) { *(a2) = v0->field_a8(v0->field_30, v0->field_34, a0, v0->field_34, v0->field_a8); *(a1) = v0->field_b0(v0->field_30, v0->field_34, a0, v0->field_34, v0->field_b0); v2 = (!*(a2) ? 0 : 4294967260); return v2; } sshlog("kex.c", "kex_load_hostkey", 0x47e, 0x1, 0x2, 0x0, "missing hostkey loader"); v2 = 4294967286; return v2; }
openssh-portable
angr_sailr
static Session *session_by_channel(int id) { int i; for (i = 0; i < sessions_nalloc; i++) { Session *s = &sessions[i]; if (s->used && s->chanid == id) { sshlog("session.c", __func__, 1836, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "session_by_channel: session %d channel %d", i, id); return s; } } sshlog("session.c", __func__, 1841, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "session_by_channel: unknown channel %d", id); session_dump(); return ((void *)0); }
int session_by_channel(unsigned long a0) { unsigned long long v0; unsigned long v1; unsigned long long v2; unsigned long v3; unsigned int v4; unsigned int v5[48]; unsigned int v7; v4 = 0; while (true) { if (v4 < sessions_nalloc) { *(&v5[0]) = v4 * 232 + sessions; if (v5[0] && a0 == v5[47]) { v2 = a0; v1 = v4; v0 = "session_by_channel: session %d channel %d"; sshlog("session.c", "session_by_channel", 0x72c, 0x0, 0x5, 0x0); v7 = v5; break; } if (!v5[0] || a0 != v5[47]) v4 = __addvsi3(v4, 0x1); } else { v3 = a0; v2 = "session_by_channel: unknown channel %d"; sshlog("session.c", "session_by_channel", 0x731, 0x0, 0x5, 0x0); session_dump(); v7 = 0; break; } } return v7; }
openssh-portable
angr_dream
struct builtincmd *find_builtin(const char *name) { struct builtincmd *bp; bp = bsearch(&name, builtincmd, 39, sizeof(struct builtincmd), pstrcmp); return bp; }
int find_builtin(unsigned long a0) { unsigned long v0; unsigned long v1; v0 = a0; v1 = bsearch(&v0, 0x500120, 0x27, 0x18, got.pstrcmp); return v1; }
dash-0.5.11+git20210903+057cd650a4ed
angr_phoenix
static void check_flags(int argc, int opt_index) { int exclusive = 0; if (aflg) { exclusive++; } if (dflg) { exclusive++; } if (rflg) { exclusive++; } if (Rflg) { exclusive++; } if (Aflg || Mflg) { exclusive++; } if (exclusive > 1) { usage(2); } if ((argc != (opt_index + 1)) || (((void *)0) == group)) { usage(2); } }
long long check_flags(unsigned long a0, unsigned long a1) { unsigned int v0; v0 = 0; if (aflg) v0 += 1; if (dflg) v0 += 1; if (rflg) v0 += 1; if (Rflg) v0 += 1; if (!Aflg && !Mflg) goto LABEL_400589; v0 += 1; LABEL_400589: if (v0 > 1) usage(0x2); if (a0 == a1 + 1 && group) return group; usage(0x2); }
shadow
angr_phoenix
char *stputs(const char *s, char *p) { return stnputs(s, strlen(s), p); }
void *stputs(const char *a1, long a2) { size_t v2; v2 = strlen(a1); return stnputs(a1, v2, a2); }
dash-0.5.11+git20210903+057cd650a4ed
ida
void sshbuf_dump_data(const void *s, size_t len, FILE *f) { size_t i, j; const u_char *p = (const u_char *)s; for (i = 0; i < len; i += 16) { fprintf(f, "%.4zu: ", i); for (j = i; j < i + 16; j++) { if (j < len) fprintf(f, "%02x ", p[j]); else fprintf(f, " "); } fprintf(f, " "); for (j = i; j < i + 16; j++) { if (j < len) { if ((((p[j]) & ~0x7f) == 0) && ((*__ctype_b_loc())[(int)((p[j]))] & (unsigned short int)_ISprint)) fprintf(f, "%c", p[j]); else fprintf(f, "."); } } fprintf(f, "\n"); } }
unsigned long sshbuf_dump_data(long a1, unsigned long a2, FILE *a3) { unsigned long result; unsigned long i; unsigned long j; unsigned long k; for (i = 0LL;; i += 16LL) { result = i; if (i >= a2) break; fprintf(a3, "%.4zu: ", i); for (j = i; j < i + 16; ++j) { if (j >= a2) fprintf(a3, " "); else fprintf(a3, "%02x ", *(unsigned char *)(a1 + j)); } fprintf(a3, " "); for (k = i; k < i + 16; ++k) { if (k < a2) { if ((*(_BYTE *)(a1 + k) & 0x80) != 0 || ((*_ctype_b_loc())[*(unsigned char *)(a1 + k)] & 0x4000) == 0) fprintf(a3, "."); else fprintf(a3, "%c", *(unsigned char *)(a1 + k)); } } fprintf(a3, "\n"); } return result; }
openssh-portable
ida
static int istrsenvisxl(char **mbdstp, size_t *dlen, const char *mbsrc, int flags, const char *mbextra, int *cerr_ptr) { return istrsenvisx(mbdstp, dlen, mbsrc, mbsrc != ((void *)0) ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr); }
long istrsenvisxl(char **a1, size_t *a2, const char *a3, int a4, char *a5, int *a6) { unsigned long v6; if (a3) v6 = strlen(a3); else v6 = 0LL; return istrsenvisx(a1, a2, a3, v6, a4, a5, a6); }
libedit
ida
void fixredir(union node *n, const char *text, int err) { ; if (!err) n->ndup.vname = ((void *)0); if (((unsigned)((text[0]) - '0') <= 9) && text[1] == '\0') n->ndup.dupfd = ((text[0]) - '0'); else if (text[0] == '-' && text[1] == '\0') n->ndup.dupfd = -1; else { if (err) synerror("Bad fd number"); else n->ndup.vname = makename(); } }
void fixredir(long param_1, char *param_2, int param_3) { undefined8 uVar1; if (param_3 == 0) { *(undefined8 *)(param_1 + 0x18) = 0; } if (((int)*param_2 - 0x30U < 10) && (param_2[1] == '\0')) { *(int *)(param_1 + 0x14) = *param_2 + -0x30; } else if ((*param_2 == '-') && (param_2[1] == '\0')) { *(undefined4 *)(param_1 + 0x14) = 0xffffffff; } else { if (param_3 != 0) { synerror("Bad fd number"); } uVar1 = makename(); *(undefined8 *)(param_1 + 0x18) = uVar1; } return; }
dash-0.5.11+git20210903+057cd650a4ed
ghidra
static int connect_to_helper(struct ssh *ssh, const char *name, int port, int socktype, char *ctype, char *rname, struct channel_connect *cctx, int *reason, const char **errmsg) { struct addrinfo hints; int gaierr; int sock = -1; char strport[32]; if (port == -2) { struct sockaddr_un *sunaddr; struct addrinfo *ai; if (strlen(name) > sizeof(sunaddr->sun_path)) { sshlog("channels.c", __func__, 4476, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "%.100s: %.100s", name, strerror(36)); return -1; } ai = xmalloc(sizeof(*ai) + sizeof(*sunaddr)); memset(ai, 0, sizeof(*ai) + sizeof(*sunaddr)); ai->ai_addr = (struct sockaddr *)(ai + 1); ai->ai_addrlen = sizeof(*sunaddr); ai->ai_family = 1; ai->ai_socktype = socktype; ai->ai_protocol = 0; sunaddr = (struct sockaddr_un *)ai->ai_addr; sunaddr->sun_family = 1; strlcpy(sunaddr->sun_path, name, sizeof(sunaddr->sun_path)); cctx->aitop = ai; } else { memset(&hints, 0, sizeof(hints)); hints.ai_family = ssh->chanctxt->IPv4or6; hints.ai_socktype = socktype; snprintf(strport, sizeof strport, "%d", port); if ((gaierr = getaddrinfo(name, strport, &hints, &cctx->aitop)) != 0) { if (errmsg != ((void *)0)) *errmsg = ssh_gai_strerror(gaierr); if (reason != ((void *)0)) *reason = 2; sshlog("channels.c", __func__, 4507, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "connect_to %.100s: unknown host (%s)", name, ssh_gai_strerror(gaierr)); return -1; } } cctx->host = xstrdup(name); cctx->port = port; cctx->ai = cctx->aitop; if ((sock = connect_next(cctx)) == -1) { sshlog("channels.c", __func__, 4518, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "connect to %.100s port %d failed: %s", name, port, strerror((*__errno_location()))); return -1; } return sock; }
long connect_to_helper(long a1, const char *a2, unsigned int a3, int a4, long a5, long a6, long a7, _DWORD *a8, _QWORD *a9) { char *v9; const char *v11; int *v12; char *v13; unsigned int v16; unsigned int v17; char *v18; _WORD *v19; struct addrinfo req; char service[40]; unsigned long v22; v22 = __readfsqword(0x28u); if (a3 == -2) { if (strlen(a2) > 0x6C) { v9 = strerror(36); sshlog("channels.c", "connect_to_helper", 4476LL, 0LL, 2LL, 0LL, "%.100s: %.100s", a2, v9); return 0xFFFFFFFFLL; } v18 = (char *)xmalloc(158LL); memset(v18, 0, 0x9EuLL); *((_QWORD *)v18 + 3) = v18 + 48; *((_DWORD *)v18 + 4) = 110; *((_DWORD *)v18 + 1) = 1; *((_DWORD *)v18 + 2) = a4; *((_DWORD *)v18 + 3) = 0; v19 = (_WORD *)*((_QWORD *)v18 + 3); *v19 = 1; strlcpy(v19 + 1, a2, 108LL); *(_QWORD *)(a7 + 24) = v18; goto LABEL_11; } memset(&req, 0, sizeof(req)); req.ai_family = *(_DWORD *)(*(_QWORD *)(a1 + 2152) + 156LL); req.ai_socktype = a4; snprintf(service, 0x20uLL, "%d", a3); v17 = getaddrinfo(a2, service, &req, (struct addrinfo **)(a7 + 24)); if (!v17) { LABEL_11: *(_QWORD *)a7 = xstrdup(a2); *(_DWORD *)(a7 + 8) = a3; *(_QWORD *)(a7 + 16) = *(_QWORD *)(a7 + 24); v16 = connect_next((const char **)a7); if (v16 != -1) return v16; v12 = _errno_location(); v13 = strerror(*v12); sshlog("channels.c", "connect_to_helper", 4518LL, 0LL, 2LL, 0LL, "connect to %.100s port %d failed: %s", a2, a3, v13); return 0xFFFFFFFFLL; } if (a9) *a9 = ssh_gai_strerror(v17); if (a8) *a8 = 2; v11 = (const char *)ssh_gai_strerror(v17); sshlog("channels.c", "connect_to_helper", 4507LL, 0LL, 2LL, 0LL, "connect_to %.100s: unknown host (%s)", a2, v11); return 0xFFFFFFFFLL; }
openssh-portable
ida
void popfile(void) { struct parsefile *pf = parsefile; ({ suppressint++; ({ __asm__ __volatile__("" : : : "memory"); }); 0; }); if (pf->fd >= 0) close(pf->fd); if (pf->buf) free((pointer)(pf->buf)); if (parsefile->spfree) freestrings(parsefile->spfree); while (pf->strpush) { popstring(); freestrings(parsefile->spfree); } parsefile = pf->prev; free((pointer)(pf)); ({ ({ __asm__ __volatile__("" : : : "memory"); }); if (--suppressint == 0 && intpending) onint(); 0; }); }
void popfile(void) { undefined *__ptr; __ptr = parsefile; suppressint = suppressint + 1; if (-1 < *(int *)(parsefile + 0xc)) { close(*(int *)(parsefile + 0xc)); } if (*(long *)(__ptr + 0x20) != 0) { free(*(void **)(__ptr + 0x20)); } if (*(long *)(parsefile + 0x70) != 0) { freestrings(*(undefined8 *)(parsefile + 0x70)); } while (*(long *)(__ptr + 0x28) != 0) { popstring(); freestrings(*(undefined8 *)(parsefile + 0x70)); } parsefile = *(undefined **)__ptr; free(__ptr); suppressint = suppressint + -1; if ((suppressint == 0) && (intpending != 0)) { onint(); } return; }
dash-0.5.11+git20210903+057cd650a4ed
ghidra
void sigblockall(sigset_t *oldmask) { sigset_t mask; sigfillset(&mask); sigprocmask(2, &mask, oldmask); }
long long sigblockall(unsigned int *a0) { char v0; sigfillset(&v0); sigprocmask(0x2, &v0, a0); return 0; }
dash-0.5.11+git20210903+057cd650a4ed
angr_phoenix
static void process_flags(int argc, char **argv) { int c; int bad_s; static struct option long_options[] = { {"crypt-method", 1, ((void *)0), 'c'}, {"encrypted", 0, ((void *)0), 'e'}, {"help", 0, ((void *)0), 'h'}, {"md5", 0, ((void *)0), 'm'}, {"root", 1, ((void *)0), 'R'}, {"sha-rounds", 1, ((void *)0), 's'}, {((void *)0), 0, ((void *)0), '\0'}}; while ((c = getopt_long(argc, argv, "c:ehmR:s:", long_options, ((void *)0))) != -1) { switch (c) { case 'c': crypt_method = optarg; break; case 'e': eflg = 1; break; case 'h': usage(0); break; case 'm': md5flg = 1; break; case 'R': break; case 's': sflg = 1; bad_s = 0; if ((((0 == strcmp(crypt_method, "SHA256")) || (0 == strcmp(crypt_method, "SHA512"))) && (0 == getlong(optarg, &sha_rounds)))) { bad_s = 1; } if (bad_s != 0) { fprintf(stderr, gettext("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage(2); } break; default: usage(2); break; } } check_flags(); }
void process_flags(unsigned long a0, char **a1) { unsigned int v0; unsigned int v1; unsigned long long v3; do { while (true) { v1 = getopt_long(a0, a1, "c:ehmR:s:", &long_options.5664, NULL); if (v1 == -1) { v3 = check_flags(); return; } switch (v1) { case 82: break; case 99: crypt_method = *(&optarg); break; case 101: eflg = 1; break; case 104: usage(0x0); case 109: md5flg = 1; break; case 115: sflg = 1; v0 = 0; if ((!strcmp(crypt_method, "SHA256") || !strcmp(crypt_method, "SHA512")) && !getlong(*(&optarg), &sha_rounds)) v0 = 1; default: usage(0x2); } } } while (!v0); fprintf(stderr, gettext("%s: invalid numeric argument '%s'\n")); usage(0x2); }
shadow
angr_sailr
void *realloc(mem, nbytes) void *mem; size_t nbytes; { return internal_realloc(mem, nbytes, (char *)((void *)0), 0, 0); }
long long realloc(unsigned long a0, unsigned int a1) { return internal_realloc(a0, a1, 0x0, 0x0, 0x0); }
bash
angr_sailr
ed_next_char(EditLine *el, wint_t c __attribute__((__unused__))) { wchar_t *lim = el->el_line.lastchar; if (el->el_line.cursor >= lim || (el->el_line.cursor == lim - 1 && el->el_map.type == 1 && el->el_chared.c_vcmd.action == 0x00)) return 6; el->el_line.cursor += el->el_state.argument; if (el->el_line.cursor > lim) el->el_line.cursor = lim; if (el->el_map.type == 1) if (el->el_chared.c_vcmd.action != 0x00) { cv_delfini(el); return 4; } return 5; }
long long ed_next_char(struct_0 *a0, unsigned long a1) { unsigned int v0; unsigned long v1; unsigned long long v3; v0 = a1; v1 = a0->field_60; if (v1 <= a0->field_58) { v3 = 6; return v3; } if (a0->field_58 == v1 - 4 && a0->field_420 == 1 && !a0->field_3c0) { v3 = 6; return v3; } a0->field_58 = a0->field_58 + a0->field_78 * 4; if (v1 < a0->field_58) a0->field_58 = v1; if (a0->field_420 != 1) { v3 = 5; return v3; } else if (!a0->field_3c0) { v3 = 5; return v3; } else { cv_delfini(a0); v3 = 4; return v3; } }
libedit
angr_sailr
int uncompress(dest, destLen, source, sourceLen) Bytef *dest; uLongf *destLen; const Bytef *source; uLong sourceLen; { return uncompress2(dest, destLen, source, &sourceLen); }
long uncompress(char *a1, unsigned long *a2, long a3, unsigned long a4) { unsigned long v5[4]; v5[3] = (unsigned long)a1; v5[2] = (unsigned long)a2; v5[1] = a3; v5[0] = a4; return uncompress2(a1, a2, a3, v5); }
zlib
ida
static void discard_input_bytes(nbytes, flags) size_t nbytes; unsigned int flags; { while (nbytes != 0) { uch c = (inptr < insize ? inbuf[inptr++] : fill_inbuf(0)); if (flags & 0x02) updcrc(&c, 1); if (nbytes != (size_t)-1) nbytes--; else if (!c) break; } }
unsigned long discard_input_bytes(long a1, char a2) { int v2; char v3; char v6; unsigned long v7; v7 = __readfsqword(0x28u); while (a1) { if (inptr >= (unsigned int)insize) { v3 = fill_inbuf(0LL); } else { v2 = inptr++; v3 = inbuf[v2]; } v6 = v3; if ((a2 & 2) != 0) updcrc(&v6, 1LL); if (a1 == -1) { if (!v6) return __readfsqword(0x28u) ^ v7; } else { --a1; } } return __readfsqword(0x28u) ^ v7; }
gzip-1.12
ida
static int histignore_item_func(ign) struct ign *ign; { if (should_expand(ign->val)) ign->flags |= 0x01; return (0); }
long long histignore_item_func(struct_0 *a0) { if (should_expand(a0->field_0)) a0->field_c = a0->field_c | 1; return 0; }
bash
angr_phoenix
static int getstatus(struct job *job) { int status; int retval; status = job->ps[job->nprocs - 1].status; retval = (((status) & 0xff00) >> 8); if (!(((status) & 0x7f) == 0)) { retval = (((status) & 0xff00) >> 8); if (!(((status) & 0xff) == 0x7f)) { retval = ((status) & 0x7f); if (retval == 2) job->sigint = 1; } retval += 128; } ; return retval; }
uint getstatus(long param_1) { uint uVar1; uint local_10; uVar1 = *(uint *)((ulong) * (ushort *)(param_1 + 0x1c) * 0x10 + *(long *)(param_1 + 0x10) + -0xc); local_10 = (int)uVar1 >> 8 & 0xff; if ((uVar1 & 0x7f) != 0) { local_10 = (int)uVar1 >> 8 & 0xff; if (((uVar1 & 0xff) != 0x7f) && (local_10 = uVar1 & 0x7f, local_10 == 2)) { *(byte *)(param_1 + 0x1f) = *(byte *)(param_1 + 0x1f) | 1; } local_10 = local_10 + 0x80; } return local_10; }
dash-0.5.11+git20210903+057cd650a4ed
ghidra
size_t hash_do_for_each(const Hash_table *table, Hash_processor processor, void *processor_data) { size_t counter = 0; struct hash_entry const *bucket; struct hash_entry const *cursor; for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) { if (bucket->data) { for (cursor = bucket; cursor; cursor = cursor->next) { if (!processor(cursor->data, processor_data)) return counter; counter++; } } } return counter; }
long long hash_do_for_each(unsigned long long a0[2], unsigned long long a1, unsigned long long a2) { void *v0; unsigned long long *v1; unsigned long long v2[2]; void *v5; v0 = 0; for (v1 = a0[0]; v1 < a0[1]; v1 += 2) { if (*(v1)) { for (v2[0] = v1; v2; v2[0] = v2[1]) { if (!((stack_base)[56](v2[0], a2, a2, a1) ^ 1)) { v0 += 1; } else { v5 = v0; return v5; } } } } v5 = v0; return v5; }
gnutls
angr_sailr
static void cleanup(void) { if (!interrupt_signal) { int sync_status = synchronize_output(); if (sync_status) exit(sync_status); } if (iclose(0) != 0) ((!!sizeof(struct { _Static_assert( 1, "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), gettext (\"closing input file " "%s\"), quotearg_style (shell_escape_always_quoting_style, " "input_file)), assume (false))" ")"); int _gl_dummy; })) ? ((nl_error( 1, (*__errno_location()), gettext("closing input file %s"), quotearg_style(shell_escape_always_quoting_style, input_file)), ((0) ? (void)0 : __builtin_unreachable()))) : ((nl_error( 1, (*__errno_location()), gettext("closing input file %s"), quotearg_style(shell_escape_always_quoting_style, input_file)), ((0) ? (void)0 : __builtin_unreachable())))); if (iclose(1) != 0) ((!!sizeof(struct { _Static_assert( 1, "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), gettext (\"closing output " "file %s\"), quotearg_style (shell_escape_always_quoting_style, " "output_file)), assume (false))" ")"); int _gl_dummy; })) ? ((nl_error(1, (*__errno_location()), gettext("closing output file %s"), quotearg_style(shell_escape_always_quoting_style, output_file)), ((0) ? (void)0 : __builtin_unreachable()))) : ((nl_error(1, (*__errno_location()), gettext("closing output file %s"), quotearg_style(shell_escape_always_quoting_style, output_file)), ((0) ? (void)0 : __builtin_unreachable())))); }
void cleanup(unsigned long long a0, unsigned long long a1, unsigned long long a2, unsigned long long a3, unsigned long a4, unsigned long a5) { unsigned int v0; unsigned long long v4; if (!interrupt_signal) { v0 = synchronize_output(a0, a1, a2, a3, a4, a5); if (v0) exit(v0); } if (!v0 || interrupt_signal) { if (iclose(0x0)) nl_error(0x1, *(__errno_location()), gettext("closing input file %s"), quotearg_style(0x4, input_file), a4, a5); if (iclose(0x1)) v4 = nl_error(0x1, *(__errno_location()), gettext("closing output file %s"), quotearg_style(0x4, output_file), a4, a5); return; } }
coreutils
angr_dream
static int do_assignment_statements(varlist, command, is_nullcmd) WORD_LIST *varlist; char *command; int is_nullcmd; { WORD_LIST *temp_list; char *savecmd; sh_wassign_func_t *assign_func; int is_special_builtin, is_builtin_or_func, tint; assign_func = is_nullcmd ? do_word_assignment : assign_in_env; tempenv_assign_error = 0; is_builtin_or_func = command && (find_shell_builtin(command) || find_function(command)); is_special_builtin = posixly_correct && command && find_special_builtin(command); savecmd = this_command_name; for (temp_list = varlist; temp_list; temp_list = temp_list->next) { this_command_name = (char *)((void *)0); assigning_in_environment = is_nullcmd == 0; tint = (*assign_func)(temp_list->word, is_builtin_or_func); assigning_in_environment = 0; this_command_name = savecmd; if (tint == 0) { if (is_nullcmd) { last_command_exit_value = 1; if (posixly_correct && interactive_shell == 0 && executing_command_builtin == 0) exp_jump_to_top_level(1); else exp_jump_to_top_level(2); } else if (posixly_correct) { last_command_exit_value = 1; if (interactive_shell == 0 && is_special_builtin) exp_jump_to_top_level(1); else if (interactive_shell == 0) exp_jump_to_top_level(2); else exp_jump_to_top_level(2); } else tempenv_assign_error++; } } return (tempenv_assign_error); }
int do_assignment_statements(undefined8 *param_1, long param_2, int param_3) { bool bVar1; undefined8 uVar2; undefined4 uVar3; int iVar4; code *pcVar5; long lVar6; undefined8 *local_20; pcVar5 = pcRam000000000011f4e3; if (param_3 != 0) { pcVar5 = do_word_assignment; } tempenv_assign_error = 0; if ((param_2 == 0) || ((lVar6 = find_shell_builtin(param_2), lVar6 == 0 && (lVar6 = find_function(param_2), lVar6 == 0)))) { uVar3 = 0; } else { uVar3 = 1; } local_20 = param_1; if (((posixly_correct == 0) || (param_2 == 0)) || (lVar6 = find_special_builtin(param_2), lVar6 == 0)) { bVar1 = false; uVar2 = this_command_name; } else { bVar1 = true; uVar2 = this_command_name; } for (; local_20 != (undefined8 *)0x0; local_20 = (undefined8 *)*local_20) { this_command_name = 0; assigning_in_environment = (uint)(param_3 == 0); iVar4 = (*pcVar5)(local_20[1], uVar3); assigning_in_environment = 0; this_command_name = uVar2; if (iVar4 == 0) { if (param_3 == 0) { if (posixly_correct == 0) { tempenv_assign_error = tempenv_assign_error + 1; } else { last_command_exit_value = 1; if ((interactive_shell == 0) && (bVar1)) { exp_jump_to_top_level(1); } else if (interactive_shell == 0) { exp_jump_to_top_level(2); } else { exp_jump_to_top_level(2); } } } else { last_command_exit_value = 1; if (((posixly_correct == 0) || (interactive_shell != 0)) || (executing_command_builtin != 0)) { exp_jump_to_top_level(2); } else { exp_jump_to_top_level(1); } } } } return tempenv_assign_error; }
bash
ghidra
int kex_c25519_dec(struct kex *kex, const struct sshbuf *server_blob, struct sshbuf **shared_secretp) { struct sshbuf *buf = ((void *)0); const u_char *server_pub; int r; *shared_secretp = ((void *)0); if (sshbuf_len(server_blob) != 32) { r = -21; goto out; } server_pub = sshbuf_ptr(server_blob); if ((buf = sshbuf_new()) == ((void *)0)) { r = -2; goto out; } if ((r = kexc25519_shared_key_ext(kex->c25519_client_key, server_pub, buf, 0)) < 0) goto out; *shared_secretp = buf; buf = ((void *)0); out: sshbuf_free(buf); return r; }
long long kex_c25519_dec(unsigned long a0, unsigned long long a1, unsigned long long *a2) { unsigned int v0; void *v1; unsigned long long v2; v1 = 0; *(a2) = 0; if (sshbuf_len(a1) != 32) { v0 = -21; } else { v2 = sshbuf_ptr(a1); v1 = sshbuf_new(); if (!v1) { v0 = -2; } else { v0 = kexc25519_shared_key_ext(a0 + 320, v2, v1, 0x0); if (v0 >= 0) { *(a2) = v1; v1 = 0; } } } sshbuf_free(v1); return v0; }
openssh-portable
angr_phoenix
ARRAY_ELEMENT *array_shift(a, n, flags) ARRAY *a; int n, flags; { register ARRAY_ELEMENT *ae, *ret; register int i; if (a == 0 || ((a)->num_elements == 0) || n <= 0) return ((ARRAY_ELEMENT *)((void *)0)); a->lastref = 0; for (i = 0, ret = ae = ((a->head)->next); ae != a->head && i < n; ae = ((ae)->next), i++) ; if (ae == a->head) { if (flags & 0x01) { array_flush(a); return ((ARRAY_ELEMENT *)((void *)0)); } for (ae = ret; ((ae)->next) != a->head; ae = ((ae)->next)) ; ((ae)->next) = (ARRAY_ELEMENT *)((void *)0); a->head->next = a->head->prev = a->head; a->max_index = -1; a->num_elements = 0; return ret; } ae->prev->next = (ARRAY_ELEMENT *)((void *)0); a->head->next = ae; ae->prev = a->head; for (; ae != a->head; ae = ((ae)->next)) ((ae)->ind) -= n; a->num_elements -= n; a->max_index = ((a->head->prev)->ind); if (flags & 0x01) { for (ae = ret; ae;) { ret = ((ae)->next); array_dispose_element(ae); ae = ret; } return ((ARRAY_ELEMENT *)((void *)0)); } return ret; }
void array_shift(struct_0 *a0, unsigned long a1, unsigned long a2) { void *v1; unsigned int v2; struct_4 *v3; struct_4 *v4; struct_3 *v5; void *v6; struct_4 *v7; unsigned long long v8[4]; void *v9; if (a0 && a0->field_8 && a1 > 0) { a0->field_18 = 0; v2 = 0; v5 = a0->field_10->field_10; for (v3 = a0->field_10->field_10; v5 != a0->field_10 && v2 < a1; v2 += 1) { v5 = v5->field_10; } if (v5 != a0->field_10) { v5->field_18->field_10 = 0; a0->field_10->field_10 = v5; for (v5->field_18 = &a0->field_10->padding_0; v5 != a0->field_10; v5 = v5->field_10) { v5->field_0 = v5->field_0 - a1; } a0->field_8 = a0->field_8 - a1; if (!(a2 & 1)) { v8 = v5; return; } for (a0->field_0 = a0->field_10->field_18->field_0; v5; v5 = v5->field_10) { array_dispose_element(v5); } v9 = 0; return; } else if ((a2 & 1)) { array_flush(a0); v6 = 0; return; } else { for (v5 = v3; v4->field_10 != a0->field_10; v4 = v4->field_10) ; v4->field_10 = 0; a0->field_10->field_18 = &a0->field_10->padding_0[0]; a0->field_10->field_10 = a0->field_10->field_18; a0->field_0 = -1; a0->field_8 = 0; v7 = v5; return; } } v1 = 0; return; }
bash
angr_sailr
static char *exptilde(char *startp, int flag) { signed char c; char *name; const char *home; char *p; p = startp; name = p + 1; while ((c = *++p) != '\0') { switch (c) { case -127: return (startp); case -120: return (startp); case ':': if (flag & 0x4) goto done; break; case '/': case -125: goto done; } } done: if (flag & 0x400) goto out; *p = '\0'; if (*name == '\0') { home = lookupvar(homestr); } else { home = getpwhome(name); } *p = c; if (!home) goto lose; strtodest(home, flag | 0x100); out: return (p); lose: return (startp); }
int exptilde(unsigned long a0, unsigned long a1) { unsigned int v0; int tmp_14; char v1; unsigned long long v2; char *v3; char *v4; unsigned int v6; v0 = a1; v3 = a0; v4 = v3 + 1; while (true) { v3 += 1; v1 = *(v3); if (v1 && v1 != 58) { if (v1 > 58) continue; if (v1 <= 58 && v1 != 47) { if (v1 > 47) continue; if (v1 <= 47) { if (v1 != -120) { if (v1 > -120) continue; if (v1 <= -120 && v1 == -127) { continue; v6 = a0; break; } } else { v6 = a0; break; } } } } if (v1 != 58) continue; if (!v1 || v1 == 58 && (v0 & 4) || v1 == 47 && v1 <= 58 && v1 && v1 != 58 || v1 == -125 && v1 <= -120 && v1 <= 58 && v1 <= 47 && v1 && v1 != 58 && v1 != -127 && v1 != 47 && v1 != -120) { if (!(v0 & 0x400)) { *(v3) = 0; if (!*(v4)) v2 = lookupvar(0x500048); else v2 = getpwhome(v4); *(v3) = v1; if (v2) { v6 = v0; *(&v6) = (v0 >> 8) | 1; tmp_14 = v6; strtodest(v2, tmp_14); } else { v6 = a0; break; } } if (v2 || (v0 & 0x400)) { *(&v6) = v3; break; } } } return v6; }
dash-0.5.11+git20210903+057cd650a4ed
angr_dream
int write_history(const char *filename) { return (history_do_write(filename, history_length, 1)); }
long write_history(const char *a1) { return history_do_write(a1, history_length, 1); }
bash
ida
test_code_t test_tls1_nossl3(gnutls_session_t session) { int ret; if (tls1_ok != 0) return TEST_IGNORE; sprintf(prio_str, "NONE:" "+CIPHER-ALL:+ARCFOUR-128:+3DES-CBC" ":+GOST28147-TC26Z-CNT" ":" "+COMP-NULL" ":+VERS-TLS1.0:%%LATEST_RECORD_VERSION:" "+MAC-ALL:+MD5:+SHA1" ":+GOST28147-TC26Z-IMIT" ":" "+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+ECDHE-RSA:+ECDHE-ECDSA:+ANON-ECDH" ":+VKO-GOST-12" ":%s", rest); { int _ret; if ((_ret = __gnutls_priority_set_direct(session, prio_str, 1024)) != TEST_SUCCEED) { return _ret; } }; gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred); ret = test_do_handshake(session); if (ret == TEST_SUCCEED) { strcat(rest, ":%LATEST_RECORD_VERSION"); tls1_ok = 1; } return ret; }
long long test_tls1_nossl3(unsigned long long a0) { unsigned int v0; unsigned int v1; unsigned long long v3; if (tls1_ok) { v3 = 3; } else { sprintf(&prio_str, "NONE:+CIPHER-ALL:+ARCFOUR-128:+3DES-CBC:+GOST28147-TC26Z-CNT:+" "COMP-NULL:+VERS-TLS1.0:%%LATEST_RECORD_VERSION:+MAC-ALL:+MD5:+" "SHA1:+GOST28147-TC26Z-IMIT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+ECDHE-" "RSA:+ECDHE-ECDSA:+ANON-ECDH:+VKO-GOST-12:%s", &rest); v0 = __gnutls_priority_set_direct(a0, &prio_str, 0x400); if (v0) { v3 = v0; } else { gnutls_credentials_set(a0, 0x1, xcred); v1 = test_do_handshake(a0); if (!v1) { strcat("%UNSAFE_RENEGOTIATION:+SIGN-ALL:+GROUP-ALL:+SIGN-GOSTR341012-" "512:+SIGN-GOSTR341012-256:+SIGN-GOSTR341001:+GROUP-GOST-ALL", ":%LATEST_RECORD_VERSION"); tls1_ok = 1; } v3 = v1; } } return v3; }
gnutls
angr_dream
static void getoptnum(char const *n_str, int min, int *num, char const *err) { intmax_t tnum = xdectoimax(n_str, min, 0x7fffffff, "", err, 0); *num = tnum; }
void getoptnum(unsigned long long a0, unsigned long a1, unsigned int *a2, unsigned long long a3) { unsigned long v0; unsigned int *v2; v0 = xdectoimax(a0, a1, 0x7fffffff, &g_403efb, a3, 0x0, a3); v2 = a2; *(a2) = v0; return; }
coreutils
angr_dream
static void check_kernel_console() { FILE *fp; char buf[4096]; if ((fp = fopen("/proc/cmdline", "r")) == 0) { return; } if (fgets(buf, sizeof(buf), fp)) { char *p = buf; if (strstr(p, "init.autocon=1")) { while ((p = strstr(p, "console="))) { char *e; p += strlen("console="); for (e = p; *e; ++e) { switch (*e) { case '-' ... '9': case 'A' ... 'Z': case '_': case 'a' ... 'z': continue; } break; } if (p != e) { CHILD *old; int dup = 0; char id[8] = {0}; char dev[32] = {0}; strncpy(dev, p, (((sizeof(dev)) < ((unsigned)(e - p))) ? (sizeof(dev)) : ((unsigned)(e - p)))); if (!strncmp(dev, "tty", 3)) strncpy(id, dev + 3, sizeof(id)); else strncpy(id, dev, sizeof(id)); for (old = newFamily; old; old = old->next) { if (!strcmp(old->id, id)) { dup = 1; } } if (!dup) { CHILD *ch = imalloc(sizeof(CHILD)); ch->action = 1; strcpy(ch->id, id); strcpy(ch->rlevel, "2345"); sprintf(ch->process, "/sbin/agetty -L -s 115200,38400,9600 %s vt102", dev); ch->next = ((void *)0); for (old = family; old; old = old->next) { if (strcmp(old->id, ch->id) == 0) { old->new = ch; break; } } for (old = newFamily; old; old = old->next) { if (!old->next) { old->next = ch; break; } } initlog((1 | 2), "added agetty on %s with id %s", dev, id); } } } } } fclose(fp); return; }
void check_kernel_console(unsigned long a0, unsigned int a1, unsigned long a2, unsigned long a3, unsigned int a4, unsigned int a5) { unsigned int v0; char *v1; char *v2; struct_0 *v3; void *v4; struct_1 *v5; void *v6; void *v7; void *v8; void *v9; void *v10; char v11; char v12; char v13; unsigned long long v15; unsigned long long *v16; unsigned long long v17; v12 = *(&v12); v4 = fopen("/proc/cmdline", "r"); if (v4) { if (fgets(&v11, 0x1000, v4)) { v1 = &v11; if (strstr(v1, "init.autocon=1")) { while (true) { v1 = strstr(v1, "console="); if (!v1) break; v1 += strlen("console="); for (v2 = v1; true; v2 += 1) { if (!*(v2)) break; if (*(v2) <= 57) { if (*(v2) < 45) break; } else { if (*(v2) > 122) { break; } else if (*(v2) < 65) { break; } else if (!(288230372997595135 & 1 << (*(v2)-65 & 63))) { break; } } } if (v1 == v2) continue; v0 = 0; v6 = 0; v7 = 0; v8 = 0; v9 = 0; v10 = 0; v15 = v2 - v1; if (32 < (v2 - v1)) v15 = 32; strncpy(&v7, v1, v15); if (strncmp(&v7, "tty", 0x3)) strncpy(&v6, &v7, 0x8); else strncpy(&v6, &v7, 0x8); for (v3 = newFamily; v3; v3 = v3->field_c0) { if (!strcmp(&v3->padding_0[28], &v6)) v0 = 1; } if (!(!v0)) continue; v5 = imalloc(0xc8, a1, 0x8, a3, a4, a5); v5->field_30 = 1; strcpy(&v5->padding_0[28], &v6); strcpy(&v5->padding_0[36], "2345"); sprintf(&v5->padding_34, "/sbin/agetty -L -s 115200,38400,9600 %s vt102", &v7); v5->field_c0 = 0; v3[0] = family; while (true) { if (!v3) break; if (strcmp(&v3[3] + 4, &v5->padding_0[28])) { v3[0] = v3[24]; } else { v3[23] = v5; break; } } v3 = newFamily; while (true) { if (!v3) break; if (v3->field_c0) { v3 = v3->field_c0; } else { v3->field_c0 = v5; break; } } initlog(0x3, "added agetty on %s with id %s", &v7, &v6, a4, a5); } } } fclose(v4); } v17 = *(&v13) ^ v16[5]; return; }
sysvinit
angr_sailr
struct builtincmd *find_builtin(const char *name) { struct builtincmd *bp; bp = bsearch(&name, builtincmd, 39, sizeof(struct builtincmd), pstrcmp); return bp; }
int find_builtin(unsigned long a0) { unsigned long v0; unsigned long v1; v0 = a0; v1 = bsearch(&v0, 0x500120, 0x27, 0x18, got.pstrcmp); return v1; }
dash-0.5.11+git20210903+057cd650a4ed
angr_sailr
static void add_volume_label(void) { 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)]; char *p = umaxtostr(volno, buf); char *s = xmalloc(strlen(volume_label_option) + sizeof "Volume" + strlen(p) + 2); sprintf(s, "%s %s %s", volume_label_option, "Volume", p); _write_volume_label(s); free(s); }
void add_volume_label() { char *v0; void *v1; char v2; char v3; unsigned long long *v5; unsigned long long v6; v0 = umaxtostr(volno, &v2, &v2); v1 = xmalloc(strlen(v0) + strlen(volume_label_option) + 9); sprintf(v1, "%s %s %s", volume_label_option, &g_4053e5, v0); _write_volume_label(v1); free(v1); v6 = *(&v3) ^ v5[5]; return; }
tar
angr_phoenix
static void print_boottime(const STRUCT_UTMP *utmp_ent) { print_line(-1, "", ' ', -1, gettext("system boot"), time_string(utmp_ent), "", "", "", ""); }
void print_boottime(undefined8 param_1) { undefined8 uVar1; undefined8 uVar2; uVar1 = time_string(param_1); uVar2 = gettext("system boot"); print_line(0xffffffff, &DAT_00101de3, 0x20, 0xffffffff, uVar2, uVar1, &DAT_00101de3, &DAT_00101de3, &DAT_00101de3, &DAT_00101de3); return; }
coreutils
ghidra
static struct dns_rr *parse_dns_rrsection(const u_char *answer, int size, const u_char **cp, int count) { struct dns_rr *head, *curr, *prev; int i, length; char name[1025]; for (i = 1, head = ((void *)0), prev = ((void *)0); i <= count; i++, prev = curr) { curr = calloc(1, sizeof(struct dns_rr)); if (curr == ((void *)0)) { free_dns_rr(head); return (((void *)0)); } if (head == ((void *)0)) head = curr; if (prev != ((void *)0)) prev->next = curr; length = dn_expand(answer, answer + size, *cp, name, sizeof(name)); if (length < 0) { free_dns_rr(head); return (((void *)0)); } curr->name = strdup(name); if (curr->name == ((void *)0)) { free_dns_rr(head); return (((void *)0)); } *cp += length; curr->type = (_ssh_compat_getshort(*cp)); *cp += 2; curr->class = (_ssh_compat_getshort(*cp)); *cp += 2; curr->ttl = (_ssh_compat_getlong(*cp)); *cp += 4; curr->size = (_ssh_compat_getshort(*cp)); *cp += 2; curr->rdata = malloc(curr->size); if (curr->rdata == ((void *)0)) { free_dns_rr(head); return (((void *)0)); } memcpy(curr->rdata, *cp, curr->size); *cp += curr->size; } return (head); }
int parse_dns_rrsection(unsigned long long a0, unsigned long a1, unsigned long long *a2, unsigned long a3) { unsigned long long *v0; unsigned int v1; unsigned int v2; void *v3; void *v4; void *v5; char v6; unsigned int v8; v0 = a2; v1 = 1; v3 = 0; v4 = 0; while (true) { if (v1 <= a3) { v5 = calloc(0x1, 0x20); if (!v5) { free_dns_rr(v3); v8 = 0; break; } else { if (!v3) v3 = v5; if (v4) *(&v4[24]) = v5; v2 = dn_expand(a0, a1 + a0, *(a2), &v6, 0x401); if (v2 < 0) { free_dns_rr(v3); v8 = 0; break; } else { *(v5) = strdup(&v6); if (!*(v5)) { free_dns_rr(v3); v8 = 0; break; } else { *(a2) = *(a2) + v2; *(&v5[8]) = _ssh_compat_getshort(*(a2)); *(a2) = *(a2) + 2; *(&v5[10]) = _ssh_compat_getshort(*(a2)); *(a2) = *(a2) + 2; *(&v5[12]) = _ssh_compat_getlong(*(a2)); *(a2) = *(a2) + 4; *(&v5[14]) = _ssh_compat_getshort(*(a2)); *(a2) = *(a2) + 2; *(&v5[16]) = malloc(v5[14]); if (!v5[16]) { free_dns_rr(v3); v8 = 0; break; } else { memcpy(v5[16], *(a2), v5[14]); *(a2) = *(a2) + v5[14]; v1 = __addvsi3(v1, 0x1, *(a2) + v5[14]); v4 = v5; } } } } } else { v8 = v3; break; } } return v8; }
openssh-portable
angr_dream
static int mux_client_request_stdio_fwd(int fd) { struct sshbuf *m; char *e; u_int type, rid, sid; int r; sshlog("mux.c", __func__, 2096, 1, SYSLOG_LEVEL_DEBUG3, ((void *)0), "entering"); if ((muxserver_pid = mux_client_request_alive(fd)) == 0) { sshlog("mux.c", __func__, 2099, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "master alive request failed"); return -1; } ssh_signal(13, ((__sighandler_t)1)); if (options.stdin_null && stdfd_devnull(1, 0, 0) == -1) sshfatal("mux.c", __func__, 2106, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "stdfd_devnull failed"); if ((m = sshbuf_new()) == ((void *)0)) sshfatal("mux.c", __func__, 2109, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new"); if ((r = sshbuf_put_u32(m, 0x10000008)) != 0 || (r = sshbuf_put_u32(m, muxclient_request_id)) != 0 || (r = sshbuf_put_string(m, ((void *)0), 0)) != 0 || (r = sshbuf_put_cstring(m, options.stdio_forward_host)) != 0 || (r = sshbuf_put_u32(m, options.stdio_forward_port)) != 0) sshfatal("mux.c", __func__, 2115, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "request"); if (mux_client_write_packet(fd, m) != 0) sshfatal("mux.c", __func__, 2118, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "write packet: %s", strerror((*__errno_location()))); if (mm_send_fd(fd, 0) == -1 || mm_send_fd(fd, 1) == -1) sshfatal("mux.c", __func__, 2123, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "send fds failed"); if (pledge("stdio proc tty", ((void *)0)) == -1) sshfatal("mux.c", __func__, 2126, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "pledge(): %s", strerror((*__errno_location()))); platform_pledge_mux(); sshlog("mux.c", __func__, 2129, 1, SYSLOG_LEVEL_DEBUG3, ((void *)0), "stdio forward request sent"); sshbuf_reset(m); if (mux_client_read_packet(fd, m) != 0) { sshlog("mux.c", __func__, 2135, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "read from master failed: %s", strerror((*__errno_location()))); sshbuf_free(m); return -1; } if ((r = sshbuf_get_u32(m, &type)) != 0 || (r = sshbuf_get_u32(m, &rid)) != 0) sshfatal("mux.c", __func__, 2142, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse"); if (rid != muxclient_request_id) sshfatal("mux.c", __func__, 2144, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "out of sequence reply: my id %u theirs %u", muxclient_request_id, rid); switch (type) { case 0x80000006: if ((r = sshbuf_get_u32(m, &sid)) != 0) sshfatal("mux.c", __func__, 2149, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse session ID"); sshlog("mux.c", __func__, 2150, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0), "master session id: %u", sid); break; case 0x80000002: if ((r = sshbuf_get_cstring(m, &e, ((void *)0))) != 0) sshfatal("mux.c", __func__, 2154, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse error message"); sshbuf_free(m); sshfatal("mux.c", __func__, 2156, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "Master refused stdio forwarding request: %s", e); case 0x80000003: if ((r = sshbuf_get_cstring(m, &e, ((void *)0))) != 0) sshfatal("mux.c", __func__, 2159, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse error message"); sshbuf_free(m); sshfatal("mux.c", __func__, 2161, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "Stdio forwarding request failed: %s", e); default: sshbuf_free(m); sshlog("mux.c", __func__, 2164, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "unexpected response from master 0x%08x", type); return -1; } muxclient_request_id++; ssh_signal(1, control_client_sighandler); ssh_signal(2, control_client_sighandler); ssh_signal(15, control_client_sighandler); ssh_signal(28, control_client_sigrelay); sshbuf_reset(m); if (mux_client_read_packet(fd, m) != 0) { if ((*__errno_location()) == 32 || ((*__errno_location()) == 4 && muxclient_terminate != 0)) return 0; sshfatal("mux.c", __func__, 2182, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "mux_client_read_packet: %s", strerror((*__errno_location()))); } sshfatal("mux.c", __func__, 2184, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "master returned unexpected message %u", type); }
undefined8 mux_client_request_stdio_fwd(undefined4 param_1) { int iVar1; undefined8 uVar2; int *piVar3; char *pcVar4; char **ppcVar5; undefined *puVar6; undefined *puVar7; long in_FS_OFFSET; char *apcStack304[2]; ulong uStack288; char *apcStack280[3]; ulong uStack256; char *apcStack248[5]; ulong auStack208[3]; char *apcStack184[14]; undefined auStack72[12]; undefined4 local_3c; uint local_2c; uint local_28; int local_24; uint local_20; undefined4 uStack28; long local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); apcStack184[12] = "entering"; local_3c = param_1; sshlog("mux.c", "mux_client_request_stdio_fwd", 0x830, 1, 7, 0); puVar7 = auStack72; apcStack184[13] = (char *)0x107ac2; muxserver_pid = mux_client_request_alive(local_3c); if (muxserver_pid == 0) { apcStack184[12] = "master alive request failed"; sshlog("mux.c", "mux_client_request_stdio_fwd", 0x833, 1, 2, 0); uVar2 = 0xffffffff; goto LAB_001082e1; } apcStack184[13] = (char *)0x107b29; ssh_signal(0xd, 1); ppcVar5 = (char **)auStack72; if (_DAT_0010c404 != 0) { apcStack184[13] = (char *)0x107b47; iVar1 = stdfd_devnull(1, 0, 0); ppcVar5 = (char **)auStack72; if (iVar1 == -1) { ppcVar5 = apcStack184 + 0xc; apcStack184[12] = "stdfd_devnull failed"; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x83a, 1, 1, 0); } } *(undefined8 *)((long)ppcVar5 + -8) = 0x107b8b; local_18 = sshbuf_new(); puVar7 = (undefined *)ppcVar5; if (local_18 == 0) { puVar7 = (undefined *)((long)ppcVar5 + -0x10); *(char **)((long)ppcVar5 + -0x10) = "sshbuf_new"; *(undefined8 *)((long)ppcVar5 + -0x18) = 0x107bd0; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x83d, 1, 1, 0); } *(undefined8 *)(puVar7 + -8) = 0x107be1; local_24 = sshbuf_put_u32(local_18, 0x10000008); if (local_24 == 0) { *(undefined8 *)(puVar7 + -8) = 0x107bfe; local_24 = sshbuf_put_u32(local_18, muxclient_request_id); if (local_24 != 0) goto LAB_00107c64; *(undefined8 *)(puVar7 + -8) = 0x107c1d; local_24 = sshbuf_put_string(local_18, 0, 0); if (local_24 != 0) goto LAB_00107c64; *(undefined8 *)(puVar7 + -8) = 0x107c3c; local_24 = sshbuf_put_cstring(local_18, _DAT_0010c370); if (local_24 != 0) goto LAB_00107c64; *(undefined8 *)(puVar7 + -8) = 0x107c5b; local_24 = sshbuf_put_u32(local_18, _DAT_0010c378); puVar6 = puVar7; if (local_24 != 0) goto LAB_00107c64; } else { LAB_00107c64: *(undefined8 *)(puVar7 + -8) = 0x107c6e; uVar2 = ssh_err(local_24); puVar6 = puVar7 + -0x10; *(char **)(puVar7 + -0x10) = "request"; *(undefined8 *)(puVar7 + -0x18) = 0x107ca5; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x843, 1, 1, uVar2); } *(undefined8 *)(puVar6 + -8) = 0x107cb6; iVar1 = mux_client_write_packet(local_3c, local_18); puVar7 = puVar6; if (iVar1 != 0) { *(undefined8 *)(puVar6 + -8) = 0x107cbf; piVar3 = __errno_location(); iVar1 = *piVar3; *(undefined8 *)(puVar6 + -8) = 0x107cc8; pcVar4 = strerror(iVar1); *(char **)(puVar6 + -8) = pcVar4; puVar7 = puVar6 + -0x10; *(char **)(puVar6 + -0x10) = "write packet: %s"; *(undefined8 *)(puVar6 + -0x18) = 0x107cff; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x846, 1, 1, 0); } *(undefined8 *)(puVar7 + -8) = 0x107d0e; iVar1 = mm_send_fd(local_3c, 0); if (iVar1 == -1) { LAB_00107d27: puVar6 = puVar7 + -0x10; *(char **)(puVar7 + -0x10) = "send fds failed"; *(undefined8 *)(puVar7 + -0x18) = 0x107d61; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x84b, 1, 1, 0); } else { *(undefined8 *)(puVar7 + -8) = 0x107d22; iVar1 = mm_send_fd(local_3c, 1); puVar6 = puVar7; if (iVar1 == -1) goto LAB_00107d27; } *(undefined8 *)(puVar6 + -8) = 0x107d72; iVar1 = pledge("stdio proc tty", 0); puVar7 = puVar6; if (iVar1 == -1) { *(undefined8 *)(puVar6 + -8) = 0x107d7c; piVar3 = __errno_location(); iVar1 = *piVar3; *(undefined8 *)(puVar6 + -8) = 0x107d85; pcVar4 = strerror(iVar1); *(char **)(puVar6 + -8) = pcVar4; puVar7 = puVar6 + -0x10; *(char **)(puVar6 + -0x10) = "pledge(): %s"; *(undefined8 *)(puVar6 + -0x18) = 0x107dbc; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x84e, 1, 1, 0); } *(undefined8 *)(puVar7 + -8) = 0x107dc1; platform_pledge_mux(); *(char **)(puVar7 + -0x10) = "stdio forward request sent"; *(undefined8 *)(puVar7 + -0x18) = 0x107dfb; sshlog("mux.c", "mux_client_request_stdio_fwd", 0x851, 1, 7, 0); *(undefined8 *)(puVar7 + -8) = 0x107e0b; sshbuf_reset(); *(undefined8 *)(puVar7 + -8) = 0x107e1c; iVar1 = mux_client_read_packet(local_3c, local_18); if (iVar1 != 0) { *(undefined8 *)(puVar7 + -8) = 0x107e25; piVar3 = __errno_location(); iVar1 = *piVar3; *(undefined8 *)(puVar7 + -8) = 0x107e2e; pcVar4 = strerror(iVar1); *(char **)(puVar7 + -8) = pcVar4; *(char **)(puVar7 + -0x10) = "read from master failed: %s"; *(undefined8 *)(puVar7 + -0x18) = 0x107e65; sshlog("mux.c", "mux_client_request_stdio_fwd", 0x857, 1, 2, 0); *(undefined8 *)(puVar7 + -8) = 0x107e75; sshbuf_free(local_18); uVar2 = 0xffffffff; goto LAB_001082e1; } *(undefined8 *)(puVar7 + -8) = 0x107e92; local_24 = sshbuf_get_u32(local_18, &local_2c); if (local_24 == 0) { *(undefined8 *)(puVar7 + -8) = 0x107eae; local_24 = sshbuf_get_u32(local_18, &local_28); puVar6 = puVar7; if (local_24 != 0) goto LAB_00107eb7; } else { LAB_00107eb7: *(undefined8 *)(puVar7 + -8) = 0x107ec1; uVar2 = ssh_err(local_24); puVar6 = puVar7 + -0x10; *(char **)(puVar7 + -0x10) = "parse"; *(undefined8 *)(puVar7 + -0x18) = 0x107ef8; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x85e, 1, 1, uVar2); } puVar7 = puVar6; if (local_28 != muxclient_request_id) { *(ulong *)(puVar6 + -0x10) = (ulong)local_28; *(ulong *)(puVar6 + -0x18) = (ulong)muxclient_request_id; puVar7 = puVar6 + -0x20; *(char **)(puVar6 + -0x20) = "out of sequence reply: my id %u theirs %u"; *(undefined8 *)(puVar6 + -0x28) = 0x107f4a; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x860, 1, 1, 0); } if (local_2c == 0x80000006) { *(undefined8 *)(puVar7 + -8) = 0x107f8d; local_24 = sshbuf_get_u32(local_18, &local_20); if (local_24 != 0) { *(undefined8 *)(puVar7 + -8) = 0x107fa0; uVar2 = ssh_err(local_24); *(char **)(puVar7 + -0x10) = "parse session ID"; *(undefined8 *)(puVar7 + -0x18) = 0x107fd7; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x865, 1, 1, uVar2); puVar7 = puVar7 + -0x10; } *(ulong *)(puVar7 + -8) = (ulong)local_20; *(char **)(puVar7 + -0x10) = "master session id: %u"; *(undefined8 *)(puVar7 + -0x18) = 0x108011; sshlog("mux.c", "mux_client_request_stdio_fwd", 0x866, 1, 5, 0); muxclient_request_id = muxclient_request_id + 1; *(undefined8 *)(puVar7 + -8) = 0x108036; ssh_signal(1, control_client_sighandler); *(undefined8 *)(puVar7 + -8) = 0x108047; ssh_signal(2, control_client_sighandler); *(undefined8 *)(puVar7 + -8) = 0x108058; ssh_signal(0xf, control_client_sighandler); *(undefined8 *)(puVar7 + -8) = 0x108069; ssh_signal(0x1c, control_client_sigrelay); *(undefined8 *)(puVar7 + -8) = 0x108075; sshbuf_reset(); *(undefined8 *)(puVar7 + -8) = 0x108086; iVar1 = mux_client_read_packet(local_3c, local_18); puVar6 = puVar7; if (iVar1 == 0) { LAB_001082a7: *(ulong *)(puVar6 + -8) = (ulong)local_2c; puVar7 = puVar6 + -0x10; *(char **)(puVar6 + -0x10) = "master returned unexpected message %u"; *(undefined8 *)(puVar6 + -0x18) = 0x1082e1; uVar2 = sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x888, 1, 1, 0); } else { *(undefined8 *)(puVar7 + -8) = 0x10823e; piVar3 = __errno_location(); if (*piVar3 != 0x20) { *(undefined8 *)(puVar7 + -8) = 0x10824a; piVar3 = __errno_location(); if ((*piVar3 != 4) || (muxclient_terminate == 0)) { *(undefined8 *)(puVar7 + -8) = 0x108267; piVar3 = __errno_location(); iVar1 = *piVar3; *(undefined8 *)(puVar7 + -8) = 0x108270; pcVar4 = strerror(iVar1); *(char **)(puVar7 + -8) = pcVar4; puVar6 = puVar7 + -0x10; *(char **)(puVar7 + -0x10) = "mux_client_read_packet: %s"; *(undefined8 *)(puVar7 + -0x18) = 0x1082a7; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x886, 1, 1, 0); goto LAB_001082a7; } } uVar2 = 0; } goto LAB_001082e1; } if (local_2c < 0x80000007) { if (local_2c == 0x80000002) { *(undefined8 *)(puVar7 + -8) = 0x1080ab; local_24 = sshbuf_get_cstring(local_18, &local_20, 0); puVar6 = puVar7; if (local_24 != 0) { *(undefined8 *)(puVar7 + -8) = 0x1080be; uVar2 = ssh_err(local_24); puVar6 = puVar7 + -0x10; *(char **)(puVar7 + -0x10) = "parse error message"; *(undefined8 *)(puVar7 + -0x18) = 0x1080f5; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x86a, 1, 1, uVar2); } *(undefined8 *)(puVar6 + -8) = 0x108101; sshbuf_free(local_18); *(ulong *)(puVar6 + -8) = CONCAT44(uStack28, local_20); puVar7 = puVar6 + -0x10; *(char **)(puVar6 + -0x10) = "Master refused stdio forwarding request: %s"; *(undefined8 *)(puVar6 + -0x18) = 0x10813c; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x86c, 0, 1, 0); } else if (local_2c != 0x80000003) goto LAB_001081e5; *(undefined8 *)(puVar7 + -8) = 0x108154; local_24 = sshbuf_get_cstring(local_18, &local_20, 0); puVar6 = puVar7; if (local_24 != 0) { *(undefined8 *)(puVar7 + -8) = 0x108167; uVar2 = ssh_err(local_24); puVar6 = puVar7 + -0x10; *(char **)(puVar7 + -0x10) = "parse error message"; *(undefined8 *)(puVar7 + -0x18) = 0x10819e; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x86f, 1, 1, uVar2); } *(undefined8 *)(puVar6 + -8) = 0x1081aa; sshbuf_free(local_18); *(ulong *)(puVar6 + -8) = CONCAT44(uStack28, local_20); puVar7 = puVar6 + -0x10; *(char **)(puVar6 + -0x10) = "Stdio forwarding request failed: %s"; *(undefined8 *)(puVar6 + -0x18) = 0x1081e5; sshfatal("mux.c", "mux_client_request_stdio_fwd", 0x871, 0, 1, 0); } LAB_001081e5: *(undefined8 *)(puVar7 + -8) = 0x1081f1; sshbuf_free(local_18); *(ulong *)(puVar7 + -8) = (ulong)local_2c; *(char **)(puVar7 + -0x10) = "unexpected response from master 0x%08x"; *(undefined8 *)(puVar7 + -0x18) = 0x10822b; sshlog("mux.c", "mux_client_request_stdio_fwd", 0x874, 1, 2, 0); uVar2 = 0xffffffff; LAB_001082e1: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar2; } *(undefined8 *)(puVar7 + -8) = 0x1082f5; __stack_chk_fail(); }
openssh-portable
ghidra
COMPSPEC *compspec_copy(cs) COMPSPEC *cs; { COMPSPEC *new; new = (COMPSPEC *)sh_xmalloc((sizeof(COMPSPEC)), "pcomplib.c", 97); new->refcount = 1; new->actions = cs->actions; new->options = cs->options; new->globpat = ((cs->globpat) ? (char *)strcpy(sh_xmalloc((1 + strlen(cs->globpat)), "pcomplib.c", 103), (cs->globpat)) : (char *)((void *)0)); new->words = ((cs->words) ? (char *)strcpy(sh_xmalloc((1 + strlen(cs->words)), "pcomplib.c", 104), (cs->words)) : (char *)((void *)0)); new->prefix = ((cs->prefix) ? (char *)strcpy(sh_xmalloc((1 + strlen(cs->prefix)), "pcomplib.c", 105), (cs->prefix)) : (char *)((void *)0)); new->suffix = ((cs->suffix) ? (char *)strcpy(sh_xmalloc((1 + strlen(cs->suffix)), "pcomplib.c", 106), (cs->suffix)) : (char *)((void *)0)); new->funcname = ((cs->funcname) ? (char *)strcpy(sh_xmalloc((1 + strlen(cs->funcname)), "pcomplib.c", 107), (cs->funcname)) : (char *)((void *)0)); new->command = ((cs->command) ? (char *)strcpy(sh_xmalloc((1 + strlen(cs->command)), "pcomplib.c", 108), (cs->command)) : (char *)((void *)0)); new->lcommand = ((cs->lcommand) ? (char *)strcpy(sh_xmalloc((1 + strlen(cs->lcommand)), "pcomplib.c", 109), (cs->lcommand)) : (char *)((void *)0)); new->filterpat = ((cs->filterpat) ? (char *)strcpy(sh_xmalloc((1 + strlen(cs->filterpat)), "pcomplib.c", 110), (cs->filterpat)) : (char *)((void *)0)); return new; }
long long compspec_copy(unsigned long long a0[11]) { struct_0 *v0; void *v2; void *v3; void *v4; void *v5; void *v6; void *v7; void *v8; void *v9; v0 = sh_xmalloc(0x58, "pcomplib.c", 0x61); v0->field_0 = 1; v0->field_8 = a0[1]; v0->field_10 = a0[2]; if (!a0[3]) v2 = 0; else v2 = strcpy(sh_xmalloc(strlen(a0[3]) + 1, "pcomplib.c", 0x67), a0[3]); v0->field_18 = v2; if (!a0[4]) v3 = 0; else v3 = strcpy(sh_xmalloc(strlen(a0[4]) + 1, "pcomplib.c", 0x68), a0[4]); v0->field_20 = v3; if (!a0[5]) v4 = 0; else v4 = strcpy(sh_xmalloc(strlen(a0[5]) + 1, "pcomplib.c", 0x69), a0[5]); v0->field_28 = v4; if (!a0[6]) v5 = 0; else v5 = strcpy(sh_xmalloc(strlen(a0[6]) + 1, "pcomplib.c", 0x6a), a0[6]); v0->field_30 = v5; if (!a0[7]) v6 = 0; else v6 = strcpy(sh_xmalloc(strlen(a0[7]) + 1, "pcomplib.c", 0x6b), a0[7]); v0->field_38 = v6; if (!a0[8]) v7 = 0; else v7 = strcpy(sh_xmalloc(strlen(a0[8]) + 1, "pcomplib.c", 0x6c), a0[8]); v0->field_40 = v7; if (!a0[9]) v8 = 0; else v8 = strcpy(sh_xmalloc(strlen(a0[9]) + 1, "pcomplib.c", 0x6d), a0[9]); v0->field_48 = v8; if (!a0[10]) v9 = 0; else v9 = strcpy(sh_xmalloc(strlen(a0[10]) + 1, "pcomplib.c", 0x6e), a0[10]); v0->field_50 = v9; return v0; }
bash
angr_phoenix
static int ipnh_get_id(__u32 id) { struct nlmsghdr *answer; if (__ipnh_get_id(&rth, id, &answer) < 0) return -2; new_json_obj(json); if (print_nexthop_nocache(answer, (void *)stdout) < 0) { free(answer); return -1; } delete_json_obj(); fflush(stdout); free(answer); return 0; }
void ipnh_get_id(unsigned long a0) { char v0; unsigned long long v3; unsigned long long v5; void *v6; if (__ipnh_get_id(0x500090, a0, &v0) < 0) { v3 = 4294967294; } else { new_json_obj(json); if (print_nexthop_nocache(*(&v0), stdout) < 0) { free(*(&v0)); v5 = 4294967295; } else { delete_json_obj(); fflush(stdout); free(*(&v0)); v6 = 0; } } return; }
iproute2-6.0.0
angr_dream
static void tarobject_extract(struct tarcontext *tc, struct tar_entry *te, const char *path, struct file_stat *st, struct fsys_namenode *namenode) { static struct varbuf hardlinkfn; static int fd; struct dpkg_error err; struct fsys_namenode *linknode; char fnamebuf[256]; char fnamenewbuf[256]; char *newhash; int rc; switch (te->type) { case TAR_FILETYPE_FILE: fd = open(path, 0100 | 0200 | 01, 0); if (fd < 0) ohshite(gettext("unable to create '%.255s' (while processing '%.255s')"), path, te->name); push_cleanup(cu_closefd, ehflag_bombout, 1, &fd); debug(dbg_eachfiledetail, "tarobject file open size=%jd", (intmax_t)te->size); fd_allocate_size(fd, 0, te->size); newhash = nfmalloc(32 + 1); if (buffer_copy_IntInt(tc->backendpipe, 0, newhash, 5, fd, 2, te->size, &err) < 0) ohshit(gettext("cannot copy extracted data for '%.255s' to '%.255s': %s"), path_quote_filename(fnamebuf, te->name, 256), path_quote_filename(fnamenewbuf, fnamenewvb.buf, 256), err.str); namenode->newhash = newhash; debug(dbg_eachfiledetail, "tarobject file hash=%s", namenode->newhash); tarobject_skip_padding(tc, te); fd_writeback_init(fd); if (namenode->statoverride) debug(dbg_eachfile, "tarobject ... stat override, uid=%d, gid=%d, mode=%04o", namenode->statoverride->uid, namenode->statoverride->gid, namenode->statoverride->mode); rc = fchown(fd, st->uid, st->gid); if (forcible_nonroot_error(rc)) ohshite(gettext("error setting ownership of '%.255s'"), te->name); rc = fchmod(fd, st->mode & ~0170000); if (forcible_nonroot_error(rc)) ohshite(gettext("error setting permissions of '%.255s'"), te->name); if (!in_force(FORCE_UNSAFE_IO)) namenode->flags |= FNNF_DEFERRED_FSYNC; pop_cleanup(ehflag_normaltidy); if (close(fd)) ohshite(gettext("error closing/writing '%.255s'"), te->name); break; case TAR_FILETYPE_FIFO: if (mkfifo(path, 0)) ohshite(gettext("error creating pipe '%.255s'"), te->name); debug(dbg_eachfiledetail, "tarobject fifo"); break; case TAR_FILETYPE_CHARDEV: if (mknod(path, 0020000, te->dev)) ohshite(gettext("error creating device '%.255s'"), te->name); debug(dbg_eachfiledetail, "tarobject chardev"); break; case TAR_FILETYPE_BLOCKDEV: if (mknod(path, 0060000, te->dev)) ohshite(gettext("error creating device '%.255s'"), te->name); debug(dbg_eachfiledetail, "tarobject blockdev"); break; case TAR_FILETYPE_HARDLINK: varbuf_reset(&hardlinkfn); varbuf_add_buf(&hardlinkfn, instdir, strlen(instdir)); linknode = fsys_hash_find_node(te->linkname, 0); varbuf_add_buf( &hardlinkfn, namenodetouse(linknode, tc->pkg, &tc->pkg->available)->name, strlen(namenodetouse(linknode, tc->pkg, &tc->pkg->available)->name)); if (linknode->flags & (FNNF_DEFERRED_RENAME | FNNF_NEW_CONFF)) varbuf_add_buf(&hardlinkfn, ".dpkg-new", strlen(".dpkg-new")); varbuf_end_str(&hardlinkfn); if (link(hardlinkfn.buf, path)) ohshite(gettext("error creating hard link '%.255s'"), te->name); namenode->newhash = linknode->newhash; debug(dbg_eachfiledetail, "tarobject hardlink hash=%s", namenode->newhash); break; case TAR_FILETYPE_SYMLINK: if (symlink(te->linkname, path)) ohshite(gettext("error creating symbolic link '%.255s'"), te->name); debug(dbg_eachfiledetail, "tarobject symlink creating"); break; case TAR_FILETYPE_DIR: if (mkdir(path, 0)) ohshite(gettext("error creating directory '%.255s'"), te->name); debug(dbg_eachfiledetail, "tarobject directory creating"); break; default: do_internerr("archives.c", 451, __func__, "unknown tar type '%d', but already checked", te->type); } }
void tarobject_extract(struct_0 *a0, struct_1 *a1, char *a2, unsigned long long a3, struct_2 *a4) { unsigned long v0; unsigned long v1; struct_3 *v2; unsigned long long v3; char v4; char v5; char v6; char v7; unsigned long long *v9; unsigned long long v10; v1 = a3; switch (a1->field_4) { case 48: fd.6104 = open(a2, 0xc1, 0x0); if (fd.6104 < 0) ohshite(gettext("unable to create '%.255s' (while processing '%.255s')")); push_cleanup(got.cu_closefd, 0x2, 0x1, &fd.6104); debug(0x40, "tarobject file open size=%jd", a1->field_18, &fd.6104); fd_allocate_size(fd.6104, 0x0, a1->field_18); v3 = nfmalloc(0x21); v0 = &v4; if (buffer_copy_IntInt(*(&a0->padding_0[0]), 0x0, v3, 0x5, fd.6104, 0x2, a1->field_18) < 0) ohshit(gettext("cannot copy extracted data for '%.255s' to '%.255s': %s"), path_quote_filename(&v5, a1->field_8, 0x100, a1->field_8), path_quote_filename(&v6, 0xf3c3c990000fffdc, 0x100, 0xf3c3c990000fffdc)); a4->field_40 = v3; debug(0x40, "tarobject file hash=%s", a4->field_40, a3); tarobject_skip_padding(a0, a1); fd_writeback_init(fd.6104); case 49: varbuf_reset(&hardlinkfn.6103); varbuf_add_buf(&hardlinkfn.6103, instdir, strlen(instdir)); v2 = fsys_hash_find_node(a1->field_10, 0x0); varbuf_add_buf( &hardlinkfn.6103, *((namenodetouse(v2, a0->field_8, a0->field_8 + 192, a0->field_8) + 8)), strlen( *((namenodetouse(v2, a0->field_8, a0->field_8 + 192, a0->field_8) + 8)))); if ((v2->field_30 & 257)) varbuf_add_buf(&hardlinkfn.6103, ".dpkg-new", strlen(".dpkg-new")); varbuf_end_str(&hardlinkfn.6103); if (link(g_405120, a2)) ohshite(gettext("error creating hard link '%.255s'")); a4->field_40 = v2->field_40; debug(0x40, "tarobject hardlink hash=%s", a4->field_40, a3); break; case 50: if (symlink(a1->field_10, a2)) ohshite(gettext("error creating symbolic link '%.255s'")); debug(0x40, "tarobject symlink creating", a2, a3); break; case 51: if (mknod(a2, 0x2000, a1->field_28)) ohshite(gettext("error creating device '%.255s'")); debug(0x40, "tarobject chardev", a2, a3); break; case 52: if (mknod(a2, 0x6000, a1->field_28)) ohshite(gettext("error creating device '%.255s'")); debug(0x40, "tarobject blockdev", a2, a3); break; case 53: if (mkdir(a2, 0x0)) ohshite(gettext("error creating directory '%.255s'")); debug(0x40, "tarobject directory creating", a2, a3); break; case 54: if (mkfifo(a2, 0x0)) ohshite(gettext("error creating pipe '%.255s'")); debug(0x40, "tarobject fifo", a2, a3); break; default: do_internerr("archives.c", 0x1c3, "tarobject_extract", "unknown tar type '%d', but already checked", a1->field_4); break; } v10 = *(&v7) ^ v9[5]; return; }
dpkg
angr_phoenix
void dpkg_selabel_set_context(const char *matchpath, const char *path, mode_t mode) { char *scontext = ((void *)0); int ret; if (sehandle == ((void *)0)) return; ret = selabel_lookup_raw(sehandle, &scontext, matchpath, mode & 0170000); if (ret == -1 || (ret == 0 && scontext == ((void *)0))) return; ret = lsetfilecon_raw(path, scontext); if (ret < 0 && (*__errno_location()) != 95) ohshite(gettext("cannot set security context for file object '%s'"), path); freecon(scontext); }
long long dpkg_selabel_set_context(unsigned long long a0, unsigned long long a1, unsigned long a2) { unsigned int v0; void *v1; v1 = 0; if (sehandle) { v0 = selabel_lookup_raw(sehandle, &v1, a0, a2 & 0xf000); if (v0 != -1) { if (v0) { LABEL_400162: v0 = lsetfilecon_raw(a1, v1, v1); if (v0 < 0 && *(__errno_location()) != 95) ohshite(gettext("cannot set security context for file object '%s'")); freecon(v1); goto LABEL_4001bf; } else if (!(!v1)) { goto LABEL_400162; } } } LABEL_4001bf: return 0; }
dpkg
angr_phoenix
int sshkey_cert_check_host(const struct sshkey *key, const char *host, int wildcard_principals, const char *ca_sign_algorithms, const char **reason) { int r; if ((r = sshkey_cert_check_authority_now(key, 1, 0, wildcard_principals, host, reason)) != 0) return r; if (sshbuf_len(key->cert->critical) != 0) { *reason = "Certificate contains unsupported critical options"; return -25; } if (ca_sign_algorithms != ((void *)0) && (r = sshkey_check_cert_sigtype(key, ca_sign_algorithms)) != 0) { *reason = "Certificate signed with disallowed algorithm"; return -25; } return 0; }
long long sshkey_cert_check_host(struct_0 *a0, char *a1, unsigned long a2, unsigned long long a3, unsigned long long *a4) { unsigned int v0; unsigned long long v2; v0 = sshkey_cert_check_authority_now(a0, 0x1, 0x0, a2, a1, a4); if (v0) { v2 = v0; } else if (sshbuf_len(a0->field_80->field_40)) { *(a4) = "Certificate contains unsupported critical options"; v2 = 4294967271; } else { if (a3) { v0 = sshkey_check_cert_sigtype(a0, a3); if (v0) { *(a4) = "Certificate signed with disallowed algorithm"; v2 = 4294967271; } } if (!a3 || !v0) v2 = 0; } return v2; }
openssh-portable
angr_dream
char *ansicstr(string, len, flags, sawc, rlen) char *string; int len, flags, *sawc, *rlen; { int c, temp; char *ret, *r, *s; unsigned long v; size_t clen; int b, mb_cur_max; wchar_t wc; if (string == 0 || *string == '\0') return ((char *)((void *)0)); mb_cur_max = (__ctype_get_mb_cur_max()); temp = 4 * len + 4; if (temp < 12) temp = 12; ret = (char *)sh_xmalloc((temp), "strtrans.c", 72); for (r = ret, s = string; s && *s;) { c = *s++; if (c != '\\' || *s == '\0') { clen = 1; if ((locale_utf8locale && (c & 0x80)) || (locale_utf8locale == 0 && mb_cur_max > 0 && is_basic(c) == 0)) { clen = mbrtowc(&wc, s - 1, mb_cur_max, 0); if (((clen) == (size_t)-1 || (clen) == (size_t)-2)) clen = 1; } *r++ = c; for (--clen; clen > 0; clen--) *r++ = *s++; } else { switch (c = *s++) { case 'a': c = '\a'; break; case 'v': c = '\v'; break; case 'b': c = '\b'; break; case 'e': case 'E': c = '\033'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': if (flags & 1) { *r++ = '\\'; break; } case '0': temp = 2 + ((flags & 1) && (c == '0')); for (c -= '0'; ((*s) >= '0' && (*s) <= '7') && temp--; s++) c = (c * 8) + ((*s) - '0'); c &= 0xFF; break; case 'x': if ((flags & 2) && *s == '{') { flags |= 16; s++; } for (temp = 2, c = 0; (1 && ((*__ctype_b_loc())[(int)(((unsigned char)(unsigned char)*s))] & (unsigned short int)_ISxdigit)) && temp--; s++) c = (c * 16) + (((*s) >= 'a' && (*s) <= 'f') ? (*s) - 'a' + 10 : (*s) >= 'A' && (*s) <= 'F' ? (*s) - 'A' + 10 : (*s) - '0'); if (flags & 16) { for (; (1 && ((*__ctype_b_loc())[(int)(((unsigned char)(unsigned char)*s))] & (unsigned short int)_ISxdigit)); s++) c = (c * 16) + (((*s) >= 'a' && (*s) <= 'f') ? (*s) - 'a' + 10 : (*s) >= 'A' && (*s) <= 'F' ? (*s) - 'A' + 10 : (*s) - '0'); flags &= ~16; if (*s == '}') s++; } else if (temp == 2) { *r++ = '\\'; c = 'x'; } c &= 0xFF; break; case 'u': case 'U': temp = (c == 'u') ? 4 : 8; for (v = 0; (1 && ((*__ctype_b_loc())[(int)(((unsigned char)(unsigned char)*s))] & (unsigned short int)_ISxdigit)) && temp--; s++) v = (v * 16) + (((*s) >= 'a' && (*s) <= 'f') ? (*s) - 'a' + 10 : (*s) >= 'A' && (*s) <= 'F' ? (*s) - 'A' + 10 : (*s) - '0'); if (temp == ((c == 'u') ? 4 : 8)) { *r++ = '\\'; break; } else if (v <= 0x7f) { c = v; break; } else { temp = u32cconv(v, r); r += temp; continue; } case '\\': break; case '\'': case '"': case '?': if (flags & 1) *r++ = '\\'; break; case 'c': if (sawc) { *sawc = 1; *r = '\0'; if (rlen) *rlen = r - ret; return ret; } else if ((flags & 1) == 0 && *s == 0) ; else if ((flags & 1) == 0 && (c = *s)) { s++; if ((flags & 2) && c == '\\' && c == *s) s++; c = ((c) == '?' ? 0x7f : (((1 && ((*__ctype_b_loc())[(int)(((unsigned char)c))] & (unsigned short int)_ISlower)) ? toupper(c) : (c)) & 0x1f)); break; } default: if ((flags & 4) == 0) *r++ = '\\'; break; } if ((flags & 2) && (c == '\001' || c == '\177')) *r++ = '\001'; *r++ = c; } } *r = '\0'; if (rlen) *rlen = r - ret; return ret; }
int ansicstr(char *a0, unsigned long a1, unsigned long a2, unsigned int *a3, unsigned int *a4) { unsigned int v0; int tmp_11; int tmp_14; int tmp_9; char v1; unsigned int v2; unsigned int v3; unsigned int v4; char *v5; char *v6; void *v7; unsigned long long v8; char *v9; unsigned int v11; unsigned int v13; unsigned int v14; char *v15; char *v16; unsigned int v17; unsigned long long v18; unsigned int v19; unsigned int v20; unsigned int v21; unsigned long long v22; unsigned int v23; unsigned long long v24; char *v25; char *v26; char *v27; unsigned int v29; unsigned int v30; char *v31; v0 = a2; if (!a0) { v11 = 0; return v11; } if (!*(a0)) { v11 = 0; return v11; } v4 = __ctype_get_mb_cur_max(); v3 = (a1 + 1) * 4; if (v3 <= 11) v3 = 12; v9 = sh_xmalloc(v3, "strtrans.c", 0x48); v5 = v9; v6 = a0; while (true) { while (true) { if (!(v6) || !(*(v6))) { *(v5) = 0; if (a4) *(a4) = v5 - v9; v11 = v9; return v11; } tmp_11 = v6; v6 += 1; v2 = *(tmp_11); if (!(v2 != 92) && !(!*(v6))) break; v8 = 1; if (locale_utf8locale && (v2 & 128) || !locale_utf8locale && v4 > 0 && !is_basic(v2)) { v8 = mbrtowc(&v1, v6 + 1, v4, 0x0); if (v8 == -1 || v8 == -2) v8 = 1; } v11 = v5; v5 += 1; *(v11) = v2; for (v8 -= 1; v8; v8 -= 1) { tmp_14 = v6; v6 += 1; v11 = v5; v5 += 1; *(v11) = *(tmp_14); } } tmp_14 = v6; v6 += 1; v13 = *(tmp_14); v2 = v13; switch (v2) { case 34: case 39: case 63: if ((v0 & 1)) { v16 = v5; v5 += 1; *(v16) = 92; } break; case 48: if (!(v0 & 1) || v2 != 48) v19 = 0; else v19 = 1; v20 = v19 + 2; v3 = v20; for (v2 -= 48; *(v6) > 47 && *(v6) <= 55 && (tmp_9 = v3, v3 -= 1, tmp_9); v6 += 1) { v2 = *(v6)-48 + (v2 * 8); } v2 &= 255; break; case 49: case 50: case 51: case 52: case 53: case 54: case 55: if ((v0 & 1)) { v15 = v5; v5 += 1; *(v15) = 92; break; } case 69: case 101: v2 = 27; break; case 85: case 117: v14 = (v2 == 117 ? 8 : 4); v3 = v14; v7 = 0; while (true) { *(&v14) = *((*(v6) * 2 + *(__ctype_b_loc()))); v17 = v14 & 0x1000; if (!(v17) || !((tmp_9 = v3, v3 -= 1, tmp_9))) break; if (!(*(v6) <= 96 || *(v6) > 102)) { v18 = *(v6)-87; } else if (*(v6) <= 64 || *(v6) > 70) { v18 = *(v6)-48; } else { v18 = *(v6)-55; } v11 = v18 + v7 * 16; v7 = v11; v6 += 1; } if (v2 != 117) v11 = 8; else v11 = 4; if (v11 == v3) { v26 = v5; v5 += 1; *(v26) = 92; break; } else if (v7 <= 127) { v2 = v7; break; } else { v3 = u32cconv(v7, v5, v5); v5 = &v5[v3]; continue; } case 92: break; case 97: v2 = 7; break; case 98: v2 = 8; break; case 99: if (a3) { *(a3) = 1; *(v5) = 0; if (a4) *(a4) = v5 - v9; v11 = v9; return v11; } if (((v0 & 1) || *(v6)) && !(v0 & 1) && (v2 = *(v6), v2)) { v6 += 1; if ((v0 & 2) && v2 == 92 && v2 == *(v6)) v6 += 1; if (v2 == 63) { v29 = 127; } else { *(&v13) = *((*(__ctype_b_loc()) + v2 * 2)); v30 = v13 & 0x200; v29 = (!v30 ? toupper(v2) & 31 : v2 & 31); } v2 = v29; break; } case 102: v2 = 12; break; case 110: v2 = 10; break; case 114: v2 = 13; break; case 116: v2 = 9; break; case 118: v2 = 11; break; case 120: if ((v0 & 2) && *(v6) == 123) { v0 |= 16; v6 += 1; } v3 = 2; v2 = 0; while (true) { *(&v13) = *((*(v6) * 2 + *(__ctype_b_loc()))); v21 = v13 & 0x1000; if (!(v21) || !((tmp_9 = v3, v3 -= 1, tmp_9))) break; if (!(*(v6) <= 96 || *(v6) > 102)) { v22 = *(v6)-87; } else if (*(v6) <= 64 || *(v6) > 70) { v22 = *(v6)-48; } else { v22 = *(v6)-55; } *(&v22) = v22 + v2 * 16; v2 = v22; v6 += 1; } if ((v0 & 16)) { while (true) { *(&v21) = *((*(v6) * 2 + *(__ctype_b_loc()))); v23 = v21 & 0x1000; if (!v23) break; if (*(v6) <= 96 || *(v6) > 102) { if (*(v6) <= 64 || *(v6) > 70) v24 = *(v6)-48; else v24 = *(v6)-55; } else { v24 = *(v6)-87; } *(&v24) = v24 + v2 * 16; v2 = v24; v6 += 1; } v0 = v0 & -17; if (*(v6) == 125) v6 += 1; } else if (v3 == 2) { v27 = v5; v5 += 1; *(v27) = 92; v2 = 120; } v2 &= 255; break; default: if (!(v0 & 4)) { v25 = v5; v5 += 1; *(v25) = 92; } break; } if ((v0 & 2)) { switch (v2) { case 1: case 127: v31 = v5; v5 += 1; *(v31) = 1; break; default: goto LABEL_400729; } } LABEL_400729: v11 = v5; v5 += 1; *(v11) = v2; } }
bash
angr_sailr
static void print_problem(FILE *f, problem_t code, int answer, int fixed, struct e2fsck_problem *ptr, struct problem_context *pctx) { if (ptr->flags & 0x400000) { fprintf(f, "<header code=\"0x%06x\"/>\n", code); return; } fprintf(f, "<problem code=\"0x%06x\" answer=\"%d\"", code, answer); if (pctx->errcode) fprintf(f, " errcode=\"%lu\"", pctx->errcode); if (fixed) fputs(" fixed=\"1\"", f); if (pctx->ino) fprintf(f, " ino=\"%u\"", pctx->ino); if (pctx->ino2) fprintf(f, " ino2=\"%u\"", pctx->ino2); if (pctx->dir) fprintf(f, " dir=\"%u\"", pctx->dir); if (pctx->blk) fprintf(f, " blk=\"%llu\"", (unsigned long long)pctx->blk); if (pctx->blk2) fprintf(f, " blk2=\"%llu\"", (unsigned long long)pctx->blk2); if (pctx->blkcount != (e2_blkcnt_t)-1) fprintf(f, " blkcount=\"%lld\"", (unsigned long long)pctx->blkcount); if (pctx->group != (dgrp_t)-1) fprintf(f, " group=\"%u\"", pctx->group); if (pctx->csum1) fprintf(f, " csum1=\"%u\"", pctx->csum1); if (pctx->csum2) fprintf(f, " csum2=\"%u\"", pctx->csum2); if (pctx->num) fprintf(f, " num=\"%llu\"", (unsigned long long)pctx->num); if (pctx->num2) fprintf(f, " num2=\"%llu\"", (unsigned long long)pctx->num2); if (pctx->str) fprintf(f, " str=\"%s\"", pctx->str); fputs("/>\n", f); }
int print_problem(FILE *a1, unsigned int a2, unsigned int a3, int a4, long a5, long a6) { if ((*(_DWORD *)(a5 + 20) & 0x400000) != 0) return fprintf(a1, "<header code=\"0x%06x\"/>\n", a2); fprintf(a1, "<problem code=\"0x%06x\" answer=\"%d\"", a2, a3); if (*(_QWORD *)a6) fprintf(a1, " errcode=\"%lu\"", *(_QWORD *)a6); if (a4) fputs(" fixed=\"1\"", a1); if (*(_DWORD *)(a6 + 8)) fprintf(a1, " ino=\"%u\"", *(unsigned int *)(a6 + 8)); if (*(_DWORD *)(a6 + 12)) fprintf(a1, " ino2=\"%u\"", *(unsigned int *)(a6 + 12)); if (*(_DWORD *)(a6 + 16)) fprintf(a1, " dir=\"%u\"", *(unsigned int *)(a6 + 16)); if (*(_QWORD *)(a6 + 40)) fprintf(a1, " blk=\"%llu\"", *(_QWORD *)(a6 + 40)); if (*(_QWORD *)(a6 + 48)) fprintf(a1, " blk2=\"%llu\"", *(_QWORD *)(a6 + 48)); if (*(_QWORD *)(a6 + 56) != -1LL) fprintf(a1, " blkcount=\"%lld\"", *(_QWORD *)(a6 + 56)); if (*(_DWORD *)(a6 + 64) != -1) fprintf(a1, " group=\"%u\"", *(unsigned int *)(a6 + 64)); if (*(_DWORD *)(a6 + 68)) fprintf(a1, " csum1=\"%u\"", *(unsigned int *)(a6 + 68)); if (*(_DWORD *)(a6 + 72)) fprintf(a1, " csum2=\"%u\"", *(unsigned int *)(a6 + 72)); if (*(_QWORD *)(a6 + 80)) fprintf(a1, " num=\"%llu\"", *(_QWORD *)(a6 + 80)); if (*(_QWORD *)(a6 + 88)) fprintf(a1, " num2=\"%llu\"", *(_QWORD *)(a6 + 88)); if (*(_QWORD *)(a6 + 96)) fprintf(a1, " str=\"%s\"", *(const char **)(a6 + 96)); return fputs("/>\n", a1); }
e2fsprogs-1.46.5
ida
test_code_t test_dhe_group(gnutls_session_t session) { int ret, ret2; gnutls_datum_t gen, prime, pubkey2; const char *print; FILE *fp; (void)remove("debug-dh.out"); if (verbose == 0 || pubkey.data == ((void *)0)) return TEST_IGNORE; sprintf(prio_str, "NONE:" "+CIPHER-ALL:+ARCFOUR-128:+3DES-CBC" ":+GOST28147-TC26Z-CNT" ":" "+COMP-NULL" ":%s:" "+MAC-ALL:+MD5:+SHA1" ":+GOST28147-TC26Z-IMIT" ":+DHE-RSA:+DHE-DSS:%s", protocol_str, rest); { int _ret; if ((_ret = __gnutls_priority_set_direct(session, prio_str, 544)) != TEST_SUCCEED) { return _ret; } }; gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred); ret = test_do_handshake(session); ret2 = gnutls_dh_get_group(session, &gen, &prime); if (ret2 >= 0) { fp = fopen("debug-dh.out", "w"); if (fp == ((void *)0)) return TEST_FAILED; ext_text = "saved in debug-dh.out"; print = raw_to_string(gen.data, gen.size); if (print) { fprintf(fp, " Generator [%d bits]: %s\n", gen.size * 8, print); } print = raw_to_string(prime.data, prime.size); if (print) { fprintf(fp, " Prime [%d bits]: %s\n", prime.size * 8, print); } gnutls_dh_get_pubkey(session, &pubkey2); print = raw_to_string(pubkey2.data, pubkey2.size); if (print) { fprintf(fp, " Pubkey [%d bits]: %s\n", pubkey2.size * 8, print); } if (pubkey2.data && pubkey2.size == pubkey.size && memcmp(pubkey.data, pubkey2.data, pubkey.size) == 0) { fprintf(fp, " (public key seems to be static among sessions)\n"); } { gnutls_dh_params_t dhp; gnutls_datum_t p3; ret2 = gnutls_dh_params_init(&dhp); if (ret2 < 0) { fclose(fp); return TEST_FAILED; } ret2 = gnutls_dh_params_import_raw(dhp, &prime, &gen); if (ret2 < 0) { gnutls_dh_params_deinit(dhp); fclose(fp); return TEST_FAILED; } ret2 = gnutls_dh_params_export2_pkcs3(dhp, GNUTLS_X509_FMT_PEM, &p3); if (ret2 < 0) { gnutls_dh_params_deinit(dhp); fclose(fp); return TEST_FAILED; } gnutls_dh_params_deinit(dhp); fprintf(fp, "\n%s\n", p3.data); gnutls_free((void *)(p3.data)), p3.data = ((void *)0); } fclose(fp); } return ret; }
int test_dhe_group(undefined8 param_1) { int iVar1; int iVar2; long in_FS_OFFSET; undefined8 local_70; FILE *local_68; long local_60; undefined8 local_58; int local_50; undefined8 local_48; int local_40; void *local_38; uint local_30; undefined8 local_28[3]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); remove("debug-dh.out"); if ((verbose == 0) || (pubkey._0_8_ == (void *)0x0)) { iVar1 = 3; } else { sprintf(prio_str, "NONE:+CIPHER-ALL:+ARCFOUR-128:+3DES-CBC:+GOST28147-TC26Z-CNT:+" "COMP-NULL:%s:+MAC-ALL:+MD5:+SHA1:+GOST28147-TC26Z-IMIT:+DHE-RSA:+" "DHE-DSS:%s", protocol_str, rest); iVar1 = __gnutls_priority_set_direct(param_1, prio_str, 0x220); if (iVar1 == 0) { gnutls_credentials_set(param_1, 1, xcred); iVar1 = test_do_handshake(param_1); iVar2 = gnutls_dh_get_group(param_1, &local_58, &local_48); if (-1 < iVar2) { local_68 = fopen("debug-dh.out", "w"); if (local_68 == (FILE *)0x0) { iVar1 = 1; } else { ext_text = s_saved_in_debug_dh_out_00106d2b; local_60 = raw_to_string(local_58, local_50); if (local_60 != 0) { fprintf(local_68, " Generator [%d bits]: %s\n", (ulong)(uint)(local_50 * 8), local_60); } local_60 = raw_to_string(local_48, local_40); if (local_60 != 0) { fprintf(local_68, " Prime [%d bits]: %s\n", (ulong)(uint)(local_40 * 8), local_60); } gnutls_dh_get_pubkey(param_1, &local_38); local_60 = raw_to_string(local_38, local_30); if (local_60 != 0) { fprintf(local_68, " Pubkey [%d bits]: %s\n", (ulong)(local_30 * 8), local_60); } if (((local_38 != (void *)0x0) && (local_30 == pubkey._8_4_)) && (iVar2 = memcmp(pubkey._0_8_, local_38, (ulong)pubkey._8_4_), iVar2 == 0)) { fprintf(local_68, " (public key seems to be static among sessions)\n"); } iVar2 = gnutls_dh_params_init(&local_70); if (iVar2 < 0) { fclose(local_68); iVar1 = 1; } else { iVar2 = gnutls_dh_params_import_raw(local_70, &local_48, &local_58); if (iVar2 < 0) { gnutls_dh_params_deinit(local_70); fclose(local_68); iVar1 = 1; } else { iVar2 = gnutls_dh_params_export2_pkcs3(local_70, 1, local_28); if (iVar2 < 0) { gnutls_dh_params_deinit(local_70); fclose(local_68); iVar1 = 1; } else { gnutls_dh_params_deinit(local_70); fprintf(local_68, "\n%s\n", local_28[0]); (*gnutls_free)(local_28[0]); local_28[0] = 0; fclose(local_68); } } } } } } } if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return iVar1; } __stack_chk_fail(); }
gnutls
ghidra
static void interrupt_handler(int sig) { if (!0x80000000) signal(sig, ((__sighandler_t)0)); interrupt_signal = sig; }
long interrupt_handler(int a1) { long result; result = (unsigned int)a1; interrupt_signal = a1; return result; }
coreutils
ida
static void display_members(const char *const *members) { int i; for (i = 0; ((void *)0) != members[i]; i++) { printf("%s ", members[i]); if (((void *)0) == members[i + 1]) { printf("\n"); } else { printf(" "); } } }
void display_members(unsigned long long *a0) { unsigned int v0; unsigned long long v2; v0 = 0; while (true) { v2 = a0[v0]; if (!a0[v0]) break; printf("%s ", a0[v0]); if (a0[1 + v0]) printf(" "); else printf("\n"); v0 += 1; } return; }
shadow
angr_phoenix
static int print_token(struct nlmsghdr *n, void *arg) { struct rtnl_dump_args *args = arg; FILE *fp = args->fp; int ifindex = args->ifindex; struct ifinfomsg *ifi = ((void *)(((char *)n) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))))); int len = n->nlmsg_len; struct rtattr *tb[(__IFLA_MAX - 1) + 1]; struct rtattr *ltb[(__IFLA_INET6_MAX - 1) + 1]; if (n->nlmsg_type != RTM_NEWLINK) return -1; len -= ((sizeof(*ifi)) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1)))); if (len < 0) return -1; if (ifi->ifi_family != 10) return 0; if (ifi->ifi_index == 0) return 0; if (ifindex > 0 && ifi->ifi_index != ifindex) return 0; if (ifi->ifi_flags & (IFF_LOOPBACK | IFF_NOARP)) return 0; parse_rtattr( tb, (__IFLA_MAX - 1), ((struct rtattr *)(((char *)(ifi)) + (((sizeof(struct ifinfomsg)) + 4U - 1) & ~(4U - 1)))), len); if (!tb[IFLA_PROTINFO]) return -1; (parse_rtattr_flags( (ltb), ((__IFLA_INET6_MAX - 1)), ((void *)(((char *)(tb[IFLA_PROTINFO])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))), ((int)((tb[IFLA_PROTINFO])->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), (1 << 15))); if (!ltb[IFLA_INET6_TOKEN]) { fprintf(stderr, "Seems there's no support for IPv6 token!\n"); return -1; } open_json_object(((void *)0)); print_string(PRINT_FP, ((void *)0), "token ", ((void *)0)); print_color_string( PRINT_ANY, ifa_family_color(ifi->ifi_family), "token", "%s", format_host(ifi->ifi_family, ((int)((ltb[IFLA_INET6_TOKEN])->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), ((void *)(((char *)(ltb[IFLA_INET6_TOKEN])) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))))); print_string(PRINT_FP, ((void *)0), " dev ", ((void *)0)); print_color_string(PRINT_ANY, COLOR_IFNAME, "ifname", "%s\n", ll_index_to_name(ifi->ifi_index)); close_json_object(); fflush(fp); return 0; }
long long print_token(struct_0 *a0, struct_1 *a1, unsigned long a2, unsigned long a3, unsigned long long a4, unsigned long long a5) { unsigned int v0; unsigned int v1; void *v2; struct_2 *v3; char v4; char v5; char v6; char v7; unsigned long long v9; v2 = a1->field_0; v0 = a1->field_8; v3 = &a0[2].field_4; v1 = a0->field_0; if (a0->field_4 != 16) { v9 = 4294967295; return v9; } v1 -= 32; if (v1 < 0) { v9 = 4294967295; return v9; } else if (v3->field_0 != 10) { v9 = 0; return v9; } else if (v3->field_4) { if (v0 > 0 && v0 != v3->field_4) { v9 = 0; return v9; } if ((v3->field_8 & 136)) { v9 = 0; return v9; } parse_rtattr(&v6, 0x3c, &v3[1].field_4, v1); if (!*(&v7)) { v9 = 4294967295; return v9; } parse_rtattr_flags(&v4, 0x9, *(&v7) + 4, *(*(&v7)) - 4, 0x8000); if (!*(&v5)) { fprintf(stderr, "Seems there's no support for IPv6 token!\n"); v9 = 4294967295; return v9; } open_json_object(0x0); print_string(0x1, 0x0, "token ", 0x0); print_color_string( 0x4, ifa_family_color(v3->field_0), "token", "%s", format_host(v3->field_0, *(*(&v5)) - 4, *(&v5) + 4, *(*(&v5)) - 4)); print_string(0x1, 0x0, " dev ", 0x0); print_color_string(0x4, 0x0, "ifname", "%s\n", ll_index_to_name(v3->field_4)); close_json_object(0x4, 0x0, "ifname", "%s\n", a4, a5); fflush(v2); v9 = 0; return v9; } else { v9 = 0; return v9; } }
iproute2-6.0.0
angr_sailr
stderr , gettext ("%s: cannot open %s\n"), Prog, gr_dbname ()); do { char *old_locale = setlocale(6, ((void *)0)); char *saved_locale = ((void *)0); if (((void *)0) != old_locale) { saved_locale = strdup(old_locale); } if (((void *)0) != saved_locale) { (void)setlocale(6, "C"); } syslog(4, "cannot open %s", gr_dbname()); if (((void *)0) != saved_locale) { (void)setlocale(6, saved_locale); free(saved_locale); } } while (
void gettext(void) { halt_baddata(); }
shadow
ghidra
char *array_value(s, quoted, flags, estatep) const char *s; int quoted, flags; array_eltstate_t *estatep; { char *retval; retval = array_value_internal(s, quoted, flags | 0x001, estatep); return retval; }
long array_value(const char *a1, unsigned int a2, int a3, long a4) { return array_value_internal(a1, a2, a3 | 1u, a4); }
bash
ida
c_insert(EditLine *el, int num) { wchar_t *cp; if (el->el_line.lastchar + num >= el->el_line.limit) { if (!ch_enlargebufs(el, (size_t)num)) return; } if (el->el_line.cursor < el->el_line.lastchar) { for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--) cp[num] = *cp; } el->el_line.lastchar += num; }
void c_insert(unsigned long long a0[14], unsigned long a1) { unsigned int *v0; unsigned long long v3[14]; if ((a1 << 2) + a0[12] < a0[13] || ch_enlargebufs(a0, a1)) { if (a0[11] < a0[12]) { for (v0 = a0[12]; v0 >= a0[11]; v0 += 1) { v0[a1] = *(v0); } } v3 = a0; a0[12] = a1 * 4 + a0[12]; } return; }
libedit
angr_dream
static void check_duparg(__u64 *attrs, int type, const char *key, const char *argv) { if (!(((*attrs) & (1L << (type))) != 0)) { *attrs |= (1L << type); return; } duparg2(key, argv); }
void check_duparg(ulong *param_1, byte param_2, undefined8 param_3, undefined8 param_4) { if ((1 << (param_2 & 0x3f) & *param_1) == 0) { *param_1 = *param_1 | 1 << (param_2 & 0x3f); } else { duparg2(param_3, param_4); } return; }
iproute2-6.0.0
ghidra
find_reverse_change(struct change *start) { return start; }
long long find_reverse_change(unsigned long a0) { return a0; }
diffutils
angr_dream
static const char *safe_strerror(int value) { const char *ret = gnutls_strerror(value); if (ret == ((void *)0)) ret = str_unknown; return ret; }
int safe_strerror(unsigned long a0) { unsigned long long v0; v0 = gnutls_strerror(a0); if (!v0) v0 = &str_unknown; return v0; }
gnutls
angr_phoenix
0 ) do { fprintf(stderr, gettext("Try '%s --help' for more information.\n"), program_name); } while (0) ;
int fprintf(FILE *__stream, char *__format, ...) { halt_baddata(); }
coreutils
ghidra
static _Bool load_buffer(void) { struct buffer_record *b; idx_t bytes_wanted = 8191; idx_t bytes_avail; idx_t lines_found; char *p; if (have_read_eof) return 0; if (bytes_wanted <= hold_count) bytes_wanted = hold_count + 1; while (1) { b = get_new_buffer(bytes_wanted); bytes_avail = b->bytes_alloc; p = b->buffer; if (hold_count) { memcpy(p, hold_area, hold_count); p += hold_count; b->bytes_used += hold_count; bytes_avail -= hold_count; hold_count = 0; } b->bytes_used += read_input(p, bytes_avail - 1); lines_found = record_line_starts(b); if (lines_found || have_read_eof) break; if (__builtin_mul_overflow(b->bytes_alloc, 2, &bytes_wanted)) xalloc_die(); free_buffer(b); } if (lines_found) save_buffer(b); else free_buffer(b); return lines_found != 0; }
int load_buffer() { unsigned long long v0; unsigned long v1; void *v2; unsigned long long v3[6]; unsigned long v4; unsigned int v6; unsigned long v7; v0 = 8191; if (have_read_eof) { v6 = 0; } else { if (v0 <= hold_count) v0 = hold_count + 1; while (true) { v3[0] = get_new_buffer(v0); v1 = v3[0]; v2 = v3[5]; if (hold_count) { memcpy(v2, hold_area, hold_count); v2 += hold_count; v3[1] = v3[1] + hold_count; v1 -= hold_count; hold_count = 0; } v3[1] = v3[1] + read_input(v2, v1 - 1); v4 = record_line_starts(v3); if (v4) break; if (have_read_eof) break; v7 = 0; if ([D] amd64g_calculate_condition( 0x0 < 64 >, 0x34 < 64 >, Load(addr = Load(addr = stack_base - 32, size = 8, endness = Iend_LE), size = 8, endness = Iend_LE), 0x2 < 64 >, cc_ndep<8>)) *(&v7) = 1; v0 = v3[0] * 2; if ((v7 & 1)) xalloc_die(); free_buffer(v3); } if (!v4) v6 = free_buffer(v3); else v6 = save_buffer(v3); *(&v6) = v4; } return v6; }
coreutils
angr_phoenix
static _Bool minor_to_chars(int v, char *p, size_t s) { return to_chars(v < 0, (uintmax_t)v, sizeof v, 0, p, s, "minor_t"); }
void minor_to_chars(uint param_1, undefined8 param_2, undefined8 param_3) { to_chars(param_1 >> 0x1f, (long)(int)param_1, 4, 0, param_2, param_3, "minor_t"); return; }
tar
ghidra
char *getifs() { return ifs_value; }
long long getifs() { return 425802354520363004; }
bash
angr_phoenix
inline int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap, blk64_t block) { return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap)bitmap, block); }
void ext2fs_unmark_block_bitmap2(void) { halt_baddata(); }
e2fsprogs-1.46.5
ghidra
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("Remove (unlink) the FILE(s).\n\n -f, --force " "ignore nonexistent files and arguments, never prompt\n -i " " prompt before every removal\n"), stdout) ; fputs_unlocked( gettext(" -I prompt once before removing more than " "three files, or\n when removing " "recursively; less intrusive than -i,\n " " while still giving protection against most mistakes\n " "--interactive[=WHEN] prompt according to WHEN: never, once " "(-I), or\n always (-i); without " "WHEN, prompt always\n"), stdout) ; fputs_unlocked( gettext(" --one-file-system when removing a hierarchy " "recursively, skip any\n directory " "that is on a file system different from\n " " that of the corresponding command line argument\n"), stdout) ; fputs_unlocked( gettext(" --no-preserve-root do not treat '/' specially\n " "--preserve-root[=all] do not remove '/' (default);\n " " with 'all', reject any command line " "argument\n on a separate device " "from its parent\n"), stdout) ; fputs_unlocked( gettext( " -r, -R, --recursive remove directories and their contents " "recursively\n -d, --dir remove empty directories\n " "-v, --verbose explain what is being done\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("\nBy default, rm does not remove directories. Use the " "--recursive (-r or -R)\noption to remove each listed " "directory, too, along with all of its contents.\n"), stdout) ; printf(gettext("\nTo remove a file whose name starts with a '-', for " "example '-foo',\nuse one of these commands:\n %s -- " "-foo\n\n %s ./-foo\n") , program_name, program_name); fputs_unlocked( gettext("\nNote that if you use rm to remove a file, it might be " "possible to recover\nsome of its contents, given sufficient " "expertise and/or time. For greater\nassurance that the " "contents are truly unrecoverable, consider using shred(1).\n"), stdout) ; emit_ancillary_info("rm"); } 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( "Remove (unlink) the FILE(s).\n\n -f, --force ignore " "nonexistent files and arguments, never prompt\n -i " " prompt before every removal\n"); fputs_unlocked(pcVar3, pFVar1); pFVar1 = stdout; pcVar3 = (char *)gettext( " -I prompt once before removing more than three " "files, or\n when removing recursively; less " "intrusive than -i,\n while still giving " "protection against most mistakes\n --interactive[=WHEN] prompt " "according to WHEN: never, once (-I), or\n " "always (-i); without WHEN, prompt always\n"); fputs_unlocked(pcVar3, pFVar1); pFVar1 = stdout; pcVar3 = (char *)gettext( " --one-file-system when removing a hierarchy recursively, skip " "any\n directory that is on a file system " "different from\n that of the corresponding " "command line argument\n"); fputs_unlocked(pcVar3, pFVar1); pFVar1 = stdout; pcVar3 = (char *)gettext( " --no-preserve-root do not treat \'/\' specially\n " "--preserve-root[=all] do not remove \'/\' (default);\n " " with \'all\', reject any command line argument\n " " on a separate device from its parent\n"); fputs_unlocked(pcVar3, pFVar1); pFVar1 = stdout; pcVar3 = (char *)gettext( " -r, -R, --recursive remove directories and their contents " "recursively\n -d, --dir remove empty directories\n -v, " "--verbose explain what is being done\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( "\nBy default, rm does not remove directories. Use the --recursive " "(-r or -R)\noption to remove each listed directory, too, along with " "all of its contents.\n"); fputs_unlocked(pcVar3, pFVar1); uVar2 = program_name; pcVar3 = (char *)gettext( "\nTo remove a file whose name starts with a \'-\', for example " "\'-foo\',\nuse one of these commands:\n %s -- -foo\n\n %s ./-foo\n"); printf(pcVar3, uVar2, uVar2); pFVar1 = stdout; pcVar3 = (char *)gettext( "\nNote that if you use rm to remove a file, it might be possible to " "recover\nsome of its contents, given sufficient expertise and/or " "time. For greater\nassurance that the contents are truly " "unrecoverable, consider using shred(1).\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
static WORD_LIST *command_line_to_word_list(line, llen, sentinel, nwp, cwp) char *line; int llen, sentinel, *nwp, *cwp; { WORD_LIST *ret; const char *delims; delims = rl_completer_word_break_characters; ret = split_at_delims(line, llen, delims, sentinel, 0x004 | 0x100, nwp, cwp); return (ret); }
undefined8 command_line_to_word_list(undefined8 param_1, undefined4 param_2, undefined4 param_3, undefined8 param_4, undefined8 param_5) { undefined8 uVar1; uVar1 = split_at_delims(param_1, param_2, rl_completer_word_break_characters, param_3, 0x104, param_4, param_5); return uVar1; }
bash
ghidra
static int int16_nonzero_mask(crypto_int16 x) { crypto_uint16 u = x; crypto_uint32 v = u; v = -v; v >>= 31; return -v; }
int int16_nonzero_mask(unsigned long a0) { unsigned int v0; v0 = a0; v0 = -(v0); v0 >>= 31; return -(v0); }
openssh-portable
angr_dream
static time_t get_int_date(const char *txt_val, int int_val, const char *msg) { if (batch) { if (txt_val == ((void *)0)) { time_t secs; if (int_val == 0 || int_val < -2) secs = days_to_secs(365); else { secs = days_to_secs(int_val); } return secs; } else return get_date(txt_val); } else { int days; do { days = read_int(msg); } while (days == 0); return days_to_secs(days); } }
undefined8 get_int_date(long param_1, int param_2, undefined8 param_3) { int iVar1; undefined8 uVar2; if (*piRam000000000010725d == 0) { do { iVar1 = read_int(param_3); } while (iVar1 == 0); uVar2 = days_to_secs(iVar1); } else if (param_1 == 0) { if ((param_2 == 0) || (param_2 < -2)) { uVar2 = days_to_secs(0x16d); } else { uVar2 = days_to_secs(param_2); } } else { uVar2 = get_date(param_1); } return uVar2; }
gnutls
ghidra
int rl_show_char(int c) { int n = 1; if (((c) > 0x07f && (c) <= 255) && (_rl_output_meta_chars == 0)) { fprintf(rl_outstream, "M-"); n += 2; c = ((c) & (~0x080)); } if ((((c) < 0x020 && (((c) & 0x80) == 0)) && c != '\t') || c == 0x7f) { fprintf(rl_outstream, "C-"); n += 2; c = ((c) < 0x020 && (((c) & 0x80) == 0)) ? ((1 && (1 && ((*__ctype_b_loc())[(int)(((unsigned char)((c) | 0x40)))] & (unsigned short int)_ISlower))) ? toupper((unsigned char)(((c) | 0x40))) : (((c) | 0x40))) : '?'; } putc(c, rl_outstream); fflush(rl_outstream); return n; }
long rl_show_char(int a1) { int v1; signed int c; unsigned int v4; c = a1; v4 = 1; if (a1 > 127 && a1 <= 255 && !rl_output_meta_chars) { fprintf(rl_outstream, "M-"); v4 = 3; c = a1 & 0xFFFFFF7F; } if (c <= 31 && (c & 0x80) == 0 && c != 9 || c == 127) { fprintf(rl_outstream, "C-"); v4 += 2; if (c > 31 || (c & 0x80) != 0) { v1 = 63; } else if (((*_ctype_b_loc())[(unsigned char)c | 0x40] & 0x200) != 0) { v1 = toupper((unsigned char)c | 0x40); } else { v1 = c | 0x40; } c = v1; } putc(c, rl_outstream); fflush(rl_outstream); return v4; }
bash
ida
static int append_ino_and_policy_id(e2fsck_t ctx, struct problem_context *pctx, ext2_ino_t ino, __u32 policy_id) { struct encrypted_file_info *info = ctx->encrypted_files; struct encrypted_file_range *range; if (info->file_ranges_count > 0) { range = &info->file_ranges[info->file_ranges_count - 1]; if (ino <= range->last_ino) { fatal_error(ctx, "Encrypted inodes processed out of order"); } if (ino == range->last_ino + 1 && policy_id == range->policy_id) { range->last_ino++; return 0; } } if (info->file_ranges_count == info->file_ranges_capacity) { size_t new_capacity = info->file_ranges_capacity * 2; if (new_capacity < 128) new_capacity = 128; if (new_capacity > ctx->fs->super->s_inodes_count) new_capacity = ctx->fs->super->s_inodes_count; if (new_capacity < info->file_ranges_capacity + 1) new_capacity = info->file_ranges_capacity + 1; if (ext2fs_resize_mem(info->file_ranges_capacity * sizeof(*range), new_capacity * sizeof(*range), &info->file_ranges) != 0) return handle_nomem(ctx, pctx, new_capacity * sizeof(*range)); info->file_ranges_capacity = new_capacity; } range = &info->file_ranges[info->file_ranges_count++]; range->first_ino = ino; range->last_ino = ino; range->policy_id = policy_id; return 0; }
undefined8 append_ino_and_policy_id(long *param_1, undefined8 param_2, uint param_3, uint param_4) { long *plVar1; long lVar2; undefined8 uVar3; uint *puVar4; ulong local_20; plVar1 = (long *)param_1[0x4a]; if (plVar1[1] != 0) { lVar2 = plVar1[1] * 0xc + -0xc + *plVar1; if (param_3 <= *(uint *)(lVar2 + 4)) { fatal_error(param_1, "Encrypted inodes processed out of order"); } if ((param_3 == *(int *)(lVar2 + 4) + 1U) && (param_4 == *(uint *)(lVar2 + 8))) { *(int *)(lVar2 + 4) = *(int *)(lVar2 + 4) + 1; return 0; } } if (plVar1[1] == plVar1[2]) { local_20 = plVar1[2] * 2; if (local_20 < 0x80) { local_20 = 0x80; } if (**(uint **)(*param_1 + 0x20) < local_20) { local_20 = (ulong) * *(uint **)(*param_1 + 0x20); } if (local_20 < plVar1[2] + 1U) { local_20 = plVar1[2] + 1; } lVar2 = ext2fs_resize_mem(plVar1[2] * 0xc, local_20 * 0xc, plVar1); if (lVar2 != 0) { uVar3 = handle_nomem(param_1, param_2, local_20 * 0xc); return uVar3; } plVar1[2] = local_20; } lVar2 = plVar1[1]; plVar1[1] = lVar2 + 1; puVar4 = (uint *)(lVar2 * 0xc + *plVar1); *puVar4 = param_3; puVar4[1] = param_3; puVar4[2] = param_4; return 0; }
e2fsprogs-1.46.5
ghidra
static errcode_t e2fsck_read_all_quotas(e2fsck_t ctx) { ext2_ino_t qf_ino; enum quota_type qtype; errcode_t retval = 0; if (!ext2fs_has_feature_quota(ctx->fs->super)) return retval; retval = quota_init_context(&ctx->qctx, ctx->fs, 0); if (retval) return retval; for (qtype = 0; qtype < MAXQUOTAS; qtype++) { qf_ino = *quota_sb_inump(ctx->fs->super, qtype); if (qf_ino == 0) continue; retval = quota_read_all_dquots(ctx->qctx, qf_ino, qtype, 0x01 | 0x02); if (retval) break; } if (retval) quota_release_context(&ctx->qctx); return retval; }
int e2fsck_read_all_quotas(struct_0 *a0) { unsigned int v0; unsigned int v1; unsigned long v2; unsigned int v4; v2 = 0; if (!ext2fs_has_feature_quota(a0->field_0->field_20)) { v4 = v2; } else { v2 = quota_init_context(&a0->field_278, a0->field_0, 0x0, &a0->field_278); if (v2) { v4 = v2; } else { v0 = 0; while (true) { if (v0 > 2) break; v1 = *(quota_sb_inump(a0->field_0->field_20, v0)); if (v1) { v2 = quota_read_all_dquots(a0->field_278, v1, v0, 0x3); if (v2) break; } v0 += 1; } if (v2) quota_release_context(&a0->field_278); v4 = v2; } } return v4; }
e2fsprogs-1.46.5
angr_phoenix
char *kex_names_cat(const char *a, const char *b) { char *ret = ((void *)0), *tmp = ((void *)0), *cp, *p, *m; size_t len; if (a == ((void *)0) || *a == '\0') return strdup(b); if (b == ((void *)0) || *b == '\0') return strdup(a); if (strlen(b) > 1024 * 1024) return ((void *)0); len = strlen(a) + strlen(b) + 2; if ((tmp = cp = strdup(b)) == ((void *)0) || (ret = calloc(1, len)) == ((void *)0)) { free(tmp); return ((void *)0); } strlcpy(ret, a, len); for ((p = strsep(&cp, ",")); p && *p != '\0'; (p = strsep(&cp, ","))) { if ((m = match_list(ret, p, ((void *)0))) != ((void *)0)) { free(m); continue; } if (strlcat(ret, ",", len) >= len || strlcat(ret, p, len) >= len) { free(tmp); free(ret); return ((void *)0); } } free(tmp); return ret; }
int kex_names_cat(char *a0, char *a1) { void *v0; char *v1; void *v2; void *v3; unsigned long v4; void *v5; unsigned int v7; v2 = 0; v3 = 0; if (a0 && *(a0)) { if (a1 && *(a1)) { v7 = strlen(a1); if (v7 > 0x100000) { v7 = 0; } else { v4 = strlen(a1) + strlen(a0) + 2; v0 = strdup(a1); v3 = v0; if (v3) { v2 = calloc(0x1, v4); if (v2) { strlcpy(v2, a0, v4, a0); v1 = strsep(&v0, ","); while (true) { if (v1 && *(v1)) { v5 = match_list(v2, v1, 0x0, v1); if (v5) { free(v5); } else { v7 = strlcat(v2, ",", v4); if (v4 > v7) v7 = strlcat(v2, v1, v4); if (v4 <= v7 || v4 <= v7) { free(v3); free(v2); v7 = 0; break; } } if (v5 || v4 > v7 && v4 > v7) { v1 = strsep(&v0, ","); continue; } } if (!*(v1) || !v1) { free(v3); v7 = v2; break; } } } } if (!v2 || !v3) { free(v3); v7 = 0; } } } if (!a1 || !*(a1)) v7 = strdup(a0); } if (!a0 || !*(a0)) v7 = strdup(a1); return v7; }
openssh-portable
angr_dream
static void parsefname(void) { union node *n = redirnode; if (n->type == 23) checkkwd = 0x8; if (readtoken() != 12) synexpect(-1); if (n->type == 23) { struct heredoc *here = heredoc; struct heredoc *p; if (quoteflag == 0) n->type = 24; ; _rmescapes((wordtext), 0); here->eofmark = wordtext; here->next = ((void *)0); if (heredoclist == ((void *)0)) heredoclist = here; else { for (p = heredoclist; p->next; p = p->next) ; p->next = here; } } else if (n->type == 21 || n->type == 22) { fixredir(n, wordtext, 0); } else { n->nfile.fname = makename(); } }
void parsefname(unsigned long long a0, unsigned long long a1, unsigned long long a2, unsigned long long a3, unsigned long long a4, unsigned long long a5) { unsigned long long v0; unsigned long long v1; unsigned long long v2; unsigned long long v6; unsigned long long v7; unsigned long long v8; v1 = -556885833387505336; if (*(v1) == 23) quoteflag = 8; if (readtoken(a0, a1, a2, a3, a4, a5) != 12) synexpect(0xffffffff); if (*(v1) == 23) { v2 = -556885833387505336; if (false) *(v1) = 24; _rmescapes(0xf8458b48f87d8948, 0x0); *((v2 + 16)) = -556885833387505336; *(v2) = 0; if (false) { v7 = v2; heredoc = v2; } for (v0 = -556885833387505336; *(v0); v0 = *(v0)) ; v8 = v0; *(v0) = v2; } else { if (*(v1) != 21 && *(v1) != 22) *((v1 + 24)) = makename(); if (*(v1) == 22 || *(v1) == 21) v6 = fixredir(v1, 0xf8458b48f87d8948, 0x0); } return; }
dash-0.5.11+git20210903+057cd650a4ed
angr_dream
static _Bool skipped_file(char const *name, _Bool command_line, _Bool is_dir) { struct exclude **pats; if (!is_dir) pats = excluded_patterns; else if (directories == SKIP_DIRECTORIES) return 1; else if (command_line && omit_dot_slash) return 0; else pats = excluded_directory_patterns; return pats[command_line] && excluded_file_name(pats[command_line], name); }
int skipped_file(unsigned long long a0, unsigned long a1, unsigned long a2) { unsigned long long v0; unsigned int v2; unsigned int v3; if ((a2 ^ 1)) { v0 = &excluded_patterns; } else { if (directories == 4) { v2 = 1; return v2; } if (a1 && omit_dot_slash) { v2 = 0; return v2; } v0 = &excluded_directory_patterns; } if (!*((v0 + (a1 << 3))) || !excluded_file_name(*((v0 + (a1 << 3))), a0, a0)) v3 = 0; else v3 = 1; v2 = v3 & 1; return v2; }
grep
angr_sailr
static int add_file(int agent_fd, const char *filename, int key_only, int qflag, const char *skprovider, struct dest_constraint **dest_constraints, size_t ndest_constraints) { struct sshkey *private, *cert; char *comment = ((void *)0); char msg[1024], *certpath = ((void *)0); int r, fd, ret = -1; size_t i; u_int32_t left; struct sshbuf *keyblob; struct ssh_identitylist *idlist; if (strcmp(filename, "-") == 0) { fd = 0; filename = "(stdin)"; } else if ((fd = open(filename, 00)) == -1) { perror(filename); return -1; } if (fd != 0) { if (sshkey_perm_ok(fd, filename) != 0) { close(fd); return -1; } } if ((r = sshbuf_load_fd(fd, &keyblob)) != 0) { fprintf(stderr, "Error loading key \"%s\": %s\n", filename, ssh_err(r)); sshbuf_free(keyblob); close(fd); return -1; } close(fd); if ((r = sshkey_parse_private_fileblob(keyblob, "", &private, &comment)) != 0 && r != -43) { fprintf(stderr, "Error loading key \"%s\": %s\n", filename, ssh_err(r)); goto fail_load; } if (private == ((void *)0) && pass != ((void *)0)) { if ((r = sshkey_parse_private_fileblob(keyblob, pass, &private, &comment)) != 0 && r != -43) { fprintf(stderr, "Error loading key \"%s\": %s\n", filename, ssh_err(r)); goto fail_load; } } if (private == ((void *)0)) { clear_pass(); snprintf(msg, sizeof msg, "Enter passphrase for %s%s: ", filename, confirm ? " (will confirm each use)" : ""); for (;;) { pass = read_passphrase(msg, 0x0002); if (strcmp(pass, "") == 0) goto fail_load; if ((r = sshkey_parse_private_fileblob(keyblob, pass, &private, &comment)) == 0) break; else if (r != -43) { fprintf(stderr, "Error loading key \"%s\": %s\n", filename, ssh_err(r)); fail_load: clear_pass(); sshbuf_free(keyblob); return -1; } clear_pass(); snprintf(msg, sizeof msg, "Bad passphrase, try again for %s%s: ", filename, confirm ? " (will confirm each use)" : ""); } } if (comment == ((void *)0) || *comment == '\0') comment = xstrdup(filename); sshbuf_free(keyblob); if ((r = sshkey_set_filename(private, filename)) != 0) { fprintf(stderr, "Could not add filename to private key: %s (%s)\n", filename, comment); goto out; } if (maxsign && minleft && (r = ssh_fetch_identitylist(agent_fd, &idlist)) == 0) { for (i = 0; i < idlist->nkeys; i++) { if (!sshkey_equal_public(idlist->keys[i], private)) continue; left = sshkey_signatures_left(idlist->keys[i]); if (left < minleft) { fprintf(stderr, "Only %d signatures left.\n", left); break; } fprintf(stderr, "Skipping update: "); if (left == minleft) { fprintf(stderr, "required signatures left (%d).\n", left); } else { fprintf(stderr, "more signatures left (%d) than" " required (%d).\n", left, minleft); } ssh_free_identitylist(idlist); goto out; } ssh_free_identitylist(idlist); } if (sshkey_is_sk(private)) { if (skprovider == ((void *)0)) { fprintf(stderr, "Cannot load FIDO key %s " "without provider\n", filename); goto out; } } else { skprovider = ((void *)0); } if ((r = ssh_add_identity_constrained( agent_fd, private, comment, lifetime, confirm, maxsign, skprovider, dest_constraints, ndest_constraints)) == 0) { ret = 0; if (!qflag) { fprintf(stderr, "Identity added: %s (%s)\n", filename, comment); if (lifetime != 0) { fprintf(stderr, "Lifetime set to %d seconds\n", lifetime); } if (confirm != 0) { fprintf(stderr, "The user must confirm " "each use of the key\n"); } } } else { fprintf(stderr, "Could not add identity \"%s\": %s\n", filename, ssh_err(r)); } if (key_only) goto out; xasprintf(&certpath, "%s-cert.pub", filename); if ((r = sshkey_load_public(certpath, &cert, ((void *)0))) != 0) { if (r != -24 || (*__errno_location()) != 2) sshlog("ssh-add.c", __func__, 393, 0, SYSLOG_LEVEL_ERROR, ssh_err(r), "Failed to load certificate \"%s\"", certpath); goto out; } if (!sshkey_equal_public(cert, private)) { sshlog("ssh-add.c", __func__, 398, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Certificate %s does not match private key %s", certpath, filename); sshkey_free(cert); goto out; } if ((r = sshkey_to_certified(private)) != 0) { sshlog("ssh-add.c", __func__, 406, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "sshkey_to_certified"); sshkey_free(cert); goto out; } if ((r = sshkey_cert_copy(cert, private)) != 0) { sshlog("ssh-add.c", __func__, 411, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "sshkey_cert_copy"); sshkey_free(cert); goto out; } sshkey_free(cert); if ((r = ssh_add_identity_constrained( agent_fd, private, comment, lifetime, confirm, maxsign, skprovider, dest_constraints, ndest_constraints)) != 0) { sshlog("ssh-add.c", __func__, 420, 0, SYSLOG_LEVEL_ERROR, ssh_err(r), "Certificate %s (%s) add failed", certpath, private->cert->key_id); goto out; } if (!qflag) { fprintf(stderr, "Certificate added: %s (%s)\n", certpath, private->cert->key_id); if (lifetime != 0) { fprintf(stderr, "Lifetime set to %d seconds\n", lifetime); } if (confirm != 0) { fprintf(stderr, "The user must confirm each use " "of the key\n"); } } out: free(certpath); free(comment); sshkey_free(private); return ret; }
undefined4 add_file(undefined4 param_1, char *param_2, int param_3, int param_4, long param_5, undefined8 param_6, undefined8 param_7) { void *pvVar1; int iVar2; uint uVar3; undefined8 uVar4; char *pcVar5; int *piVar6; long in_FS_OFFSET; undefined8 uVar7; undefined8 uVar8; long local_498; char *local_488; int local_470; undefined4 local_46c; long local_460; undefined8 local_458; char *local_450; void *local_448; undefined8 local_440; ulong *local_438; ulong local_430; char local_428[1032]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_450 = (char *)0x0; local_448 = (void *)0x0; local_46c = 0xffffffff; iVar2 = strcmp(param_2, "-"); if (iVar2 == 0) { local_470 = 0; local_488 = "(stdin)"; } else { local_470 = open(param_2, 0); local_488 = param_2; if (local_470 == -1) { perror(param_2); local_46c = 0xffffffff; goto LAB_001011ad; } } if ((local_470 != 0) && (iVar2 = sshkey_perm_ok(local_470, local_488), iVar2 != 0)) { close(local_470); local_46c = 0xffffffff; goto LAB_001011ad; } iVar2 = sshbuf_load_fd(local_470, &local_440); if (iVar2 != 0) { uVar4 = ssh_err(iVar2); fprintf(stderr, "Error loading key \"%s\": %s\n", local_488, uVar4); sshbuf_free(); close(local_470); local_46c = 0xffffffff; goto LAB_001011ad; } close(local_470); iVar2 = sshkey_parse_private_fileblob(local_440, &DAT_001033df, &local_460, &local_450); if ((iVar2 == 0) || (iVar2 == -0x2b)) { if ((local_460 == 0) && (((pass != (char *)0x0 && (iVar2 = sshkey_parse_private_fileblob( local_440, pass, &local_460, &local_450), iVar2 != 0)) && (iVar2 != -0x2b)))) { uVar4 = ssh_err(iVar2); fprintf(stderr, "Error loading key \"%s\": %s\n", local_488, uVar4); } else { if (local_460 != 0) { LAB_00100a21: if ((local_450 == (char *)0x0) || (*local_450 == '\0')) { local_450 = (char *)xstrdup(local_488); } sshbuf_free(local_440); iVar2 = sshkey_set_filename(local_460, local_488); if (iVar2 == 0) { if (((maxsign != 0) && (minleft != 0)) && (iVar2 = ssh_fetch_identitylist(param_1, &local_438), iVar2 == 0)) { for (local_430 = 0; local_430 < *local_438; local_430 = local_430 + 1) { iVar2 = sshkey_equal_public( *(undefined8 *)(local_438[1] + local_430 * 8), local_460); if (iVar2 != 0) { uVar3 = sshkey_signatures_left( *(undefined8 *)(local_438[1] + local_430 * 8)); if (minleft <= uVar3) { fprintf(stderr, "Skipping update: "); if (uVar3 == minleft) { fprintf(stderr, "required signatures left (%d).\n", (ulong)uVar3); } else { fprintf(stderr, "more signatures left (%d) than required (%d).\n", (ulong)uVar3, (ulong)minleft); } ssh_free_identitylist(local_438); goto LAB_0010117a; } fprintf(stderr, "Only %d signatures left.\n", (ulong)uVar3); break; } } ssh_free_identitylist(local_438); } uVar4 = 0x100c65; iVar2 = sshkey_is_sk(local_460); if (iVar2 == 0) { local_498 = 0; } else { local_498 = param_5; if (param_5 == 0) { fprintf(stderr, "Cannot load FIDO key %s without provider\n", local_488); goto LAB_0010117a; } } iVar2 = ssh_add_identity_constrained( param_1, local_460, local_450, lifetime, confirm, maxsign, local_498, param_6, param_7, uVar4); if (iVar2 == 0) { local_46c = 0; if (param_4 == 0) { fprintf(stderr, "Identity added: %s (%s)\n", local_488, local_450); if (lifetime != 0) { fprintf(stderr, "Lifetime set to %d seconds\n", (ulong)lifetime); } if (confirm != 0) { fprintf(stderr, "The user must confirm each use of the key\n"); } } } else { uVar4 = ssh_err(iVar2); fprintf(stderr, "Could not add identity \"%s\": %s\n", local_488, uVar4); } if (param_3 == 0) { xasprintf(&local_448, "%s-cert.pub", local_488); iVar2 = sshkey_load_public(local_448, &local_458, 0); if (iVar2 == 0) { uVar4 = 0x100ea9; iVar2 = sshkey_equal_public(local_458, local_460); if (iVar2 == 0) { sshlog("ssh-add.c", "add_file", 0x18e, 0, 2, 0, "Certificate %s does not match private key %s", local_448, local_488, uVar4); sshkey_free(local_458); } else { iVar2 = sshkey_to_certified(local_460); if (iVar2 == 0) { iVar2 = sshkey_cert_copy(local_458, local_460); if (iVar2 == 0) { uVar4 = 0x10101a; sshkey_free(local_458); iVar2 = ssh_add_identity_constrained( param_1, local_460, local_450, lifetime, confirm, maxsign, local_498, param_6, param_7, uVar4); pvVar1 = local_448; if (iVar2 == 0) { if (param_4 == 0) { fprintf(stderr, "Certificate added: %s (%s)\n", local_448, *(undefined8 *)(*(long *)(local_460 + 0x80) + 0x18)); if (lifetime != 0) { fprintf(stderr, "Lifetime set to %d seconds\n", (ulong)lifetime); } if (confirm != 0) { fprintf( stderr, "The user must confirm each use of the key\n"); } } } else { uVar4 = *(undefined8 *)(*(long *)(local_460 + 0x80) + 0x18); uVar8 = 0x10109d; uVar7 = ssh_err(iVar2); sshlog("ssh-add.c", "add_file", 0x1a4, 0, 2, uVar7, "Certificate %s (%s) add failed", pvVar1, uVar4, uVar8); } } else { uVar7 = 0x100fbc; uVar4 = ssh_err(iVar2); sshlog("ssh-add.c", "add_file", 0x19b, 1, 2, uVar4, "sshkey_cert_copy", uVar7); sshkey_free(local_458); } } else { uVar7 = 0x100f38; uVar4 = ssh_err(iVar2); sshlog("ssh-add.c", "add_file", 0x196, 1, 2, uVar4, "sshkey_to_certified", uVar7); sshkey_free(local_458); } } } else if ((iVar2 != -0x18) || (piVar6 = __errno_location(), *piVar6 != 2)) { pvVar1 = local_448; uVar4 = ssh_err(iVar2); sshlog("ssh-add.c", "add_file", 0x189, 0, 2, uVar4, "Failed to load certificate \"%s\"", pvVar1); } } } else { fprintf(stderr, "Could not add filename to private key: %s (%s)\n", local_488, local_450); } LAB_0010117a: free(local_448); free(local_450); sshkey_free(local_460); goto LAB_001011ad; } clear_pass(); if (confirm == 0) { pcVar5 = ""; } else { pcVar5 = " (will confirm each use)"; } snprintf(local_428, 0x400, "Enter passphrase for %s%s: ", local_488, pcVar5); while (true) { pass = (char *)read_passphrase(local_428, 2); iVar2 = strcmp(pass, ""); if (iVar2 == 0) break; iVar2 = sshkey_parse_private_fileblob(local_440, pass, &local_460, &local_450); if (iVar2 == 0) goto LAB_00100a21; if (iVar2 != -0x2b) { uVar4 = ssh_err(iVar2); fprintf(stderr, "Error loading key \"%s\": %s\n", local_488, uVar4); break; } clear_pass(); snprintf(local_428, 0x400, "Bad passphrase, try again for %s%s: ", local_488); } } } else { uVar4 = ssh_err(iVar2); fprintf(stderr, "Error loading key \"%s\": %s\n", local_488, uVar4); } clear_pass(); sshbuf_free(local_440); local_46c = 0xffffffff; LAB_001011ad: if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return local_46c; }
openssh-portable
ghidra
static int check_offset(const struct sshbuf *buf, int wr, size_t offset, size_t len) { if (sshbuf_ptr(buf) == ((void *)0)) return -1; if (offset >= (18446744073709551615UL) - len) return -10; if (offset + len > sshbuf_len(buf)) { return wr ? -9 : -3; } return 0; }
long check_offset(long a1, int a2, unsigned long a3, long a4) { if (!sshbuf_ptr(a1)) return 0xFFFFFFFFLL; if (a3 >= ~a4) return 4294967286LL; if (a3 + a4 <= sshbuf_len(a1)) return 0LL; if (a2) return 4294967287LL; return 4294967293LL; }
openssh-portable
ida
static void long_pinky(const int argc_names, char *const argv_names[]) { for (int i = 0; i < argc_names; i++) print_long_entry(argv_names[i]); }
void long_pinky(unsigned long a0, unsigned long long *a1) { unsigned int v0; unsigned long long v2; v0 = 0; while (true) { v2 = v0; if (v0 >= a0) break; print_long_entry(a1[v0]); v0 += 1; } return; }
coreutils
angr_phoenix
pattern_file_name(idx_t lineno, idx_t *new_lineno) { idx_t i; for (i = 1; i < patlocs_used; i++) if (lineno < patloc[i].lineno) break; *new_lineno = lineno - patloc[i - 1].lineno + patloc[i - 1].fileline; return patloc[i - 1].filename; }
long long pattern_file_name(unsigned long a0, unsigned long long *a1) { unsigned long long v0; for (v0 = 1; v0 < patlocs_used; v0 += 1) { if (a0 < *((((v0 << 1) + v0 << 3) + patloc))) break; } *(a1) = a0 - *((v0 * 24 - 24 + patloc)) + *((v0 * 24 - 24 + patloc + 16)); return *((v0 * 24 - 24 + patloc + 8)); }
grep
angr_dream
static int ipstats_dump(struct ipstats_stat_enabled *enabled) { int rc = 0; if (rtnl_statsdump_req_filter(&rth, 0, 0, ipstats_req_add_filters, enabled) < 0) { perror("Cannot send dump request"); return -2; } if (rtnl_dump_filter_nc(&rth, ipstats_dump_one, enabled, 0) < 0) { fprintf(stderr, "Dump terminated\n"); rc = -2; } fflush(stdout); return rc; }
int ipstats_dump(unsigned long long a0) { unsigned int v0; unsigned int v2; v0 = 0; if (rtnl_statsdump_req_filter(0x5000f8, 0x0, 0x0, ipstats_req_add_filters, a0) < 0) { perror("Cannot send dump request"); v2 = -2; } else { if (rtnl_dump_filter_nc(0x5000f8, ipstats_dump_one, a0, 0x0) < 0) { fprintf(stderr, "Dump terminated\n"); v0 = -2; } fflush(stdout); v2 = v0; } return v2; }
iproute2-6.0.0
angr_phoenix
int waitforjob(struct job *jp) { int st; ; dowait(jp ? 1 : 0, jp); if (!jp) return exitstatus; st = getstatus(jp); if (jp->jobctl) { xtcsetpgrp(ttyfd, rootpid); if (jp->sigint) raise(2); } if (!1 || jp->state == 2) freejob(jp); return st; }
int waitforjob(char a0[32]) { unsigned int v0; unsigned int v2; dowait(a0, a0); if (!a0) { v2 = exitstatus; } else { v0 = getstatus(a0); if ((a0[31] & 2)) { xtcsetpgrp(ttyfd, rootpid); if ((a0[31] & 1)) raise(0x2); } if (a0[30] == 2) freejob(a0); v2 = v0; } return v2; }
dash-0.5.11+git20210903+057cd650a4ed
angr_dream
static void validate_case_classes(struct Spec_list *s1, struct Spec_list *s2) { size_t n_upper = 0; size_t n_lower = 0; int c1 = 0; int c2 = 0; count old_s1_len = s1->length; count old_s2_len = s2->length; struct List_element *s1_tail = s1->tail; struct List_element *s2_tail = s2->tail; _Bool s1_new_element = 1; _Bool s2_new_element = 1; if (complement || !s2->has_char_class) return; for (int i = 0; i < N_CHARS; i++) { if (((*__ctype_b_loc())[(int)((i))] & (unsigned short int)_ISupper)) n_upper++; if (((*__ctype_b_loc())[(int)((i))] & (unsigned short int)_ISlower)) n_lower++; } s1->state = ((18446744073709551615UL) - 1); s2->state = ((18446744073709551615UL) - 1); while (c1 != -1 && c2 != -1) { enum Upper_Lower_class class_s1, class_s2; c1 = get_next(s1, &class_s1); c2 = get_next(s2, &class_s2); if (s2_new_element && class_s2 != UL_NONE && !(s1_new_element && class_s1 != UL_NONE)) ((!!sizeof(struct { _Static_assert(1, "verify_expr (" "1" ", " "(error (1, 0, gettext (\"misaligned [:upper:] " "and/or [:lower:] construct\")), assume (false))" ")"); int _gl_dummy; })) ? ((error( 1, 0, gettext("misaligned [:upper:] and/or [:lower:] construct")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error( 1, 0, gettext("misaligned [:upper:] and/or [:lower:] construct")), ((0) ? (void)0 : __builtin_unreachable())))); if (class_s2 != UL_NONE) { skip_construct(s1); skip_construct(s2); s1->length -= (class_s1 == UL_UPPER ? n_upper : n_lower) - 1; s2->length -= (class_s2 == UL_UPPER ? n_upper : n_lower) - 1; } s1_new_element = s1->state == (((18446744073709551615UL) - 1) + 1); s2_new_element = s2->state == (((18446744073709551615UL) - 1) + 1); } ((void)sizeof((old_s1_len >= s1->length && old_s2_len >= s2->length) ? 1 : 0), __extension__({ if (old_s1_len >= s1->length && old_s2_len >= s2->length) ; else __assert_fail("old_s1_len >= s1->length && old_s2_len >= s2->length", "src/tr.c", 1224, __extension__ __PRETTY_FUNCTION__); })); s1->tail = s1_tail; s2->tail = s2_tail; }
void validate_case_classes(unsigned long long a0[4], struct_0 *a1) { char v0; char v1; char v2; char v3; unsigned int v4; unsigned int v5; unsigned int v6; void *v7; void *v8; unsigned long v9; unsigned long v10; unsigned long v11; unsigned long v12; char v13; unsigned int v16; unsigned int v17; unsigned long long *v20; unsigned long long v21; v7 = 0; v8 = 0; v4 = 0; v5 = 0; v9 = a0[3]; v10 = a1->field_18; v11 = a0[1]; v12 = a1->field_8; v0 = 1; v1 = 1; if (!(complement || (a1->field_31 ^ 1))) { for (v6 = 0; v6 <= 255; v6 += 1) { v16 = *((*(__ctype_b_loc()) + v6 * 2)) & 0x100; if (v16) v7 += 1; *(&v16) = *((*(__ctype_b_loc()) + v6 * 2)); v17 = v16 & 0x200; if (v17) v8 += 1; } a0[2] = -2; for (a1->field_10 = -2; !(v4 == -1) && !(v5 == -1); v1 = a1->field_10 == -1) { v4 = get_next(a0, &v2); v5 = get_next(a1, &v3); if (v1 && *(&v3) != 2 && (!(!(v0 ^ 1)) || !(*(&v2) != 2))) error(0x1, 0x0, gettext("misaligned [:upper:] and/or [:lower:] construct")); if (*(&v3) != 2) { skip_construct(a0); skip_construct(a1); a0[3] = a0[3] - (*(&v2) == 1 ? v8 - 1 : v7 - 1); a1->field_18 = a1->field_18 - (*(&v3) == 1 ? v8 - 1 : v7 - 1); } v0 = a0[2] == -1; } if (!(v9 >= a0[3]) || !(v10 >= a1->field_18)) __assert_fail(); a0[1] = v11; a1->field_8 = v12; } v21 = *(&v13) ^ v20[5]; return; }
coreutils
angr_sailr
char *fn_tilde_expand(const char *txt) { struct passwd pwres; char pwbuf[1024]; struct passwd *pass; const char *pos; char *temp; size_t len = 0; if (txt[0] != '~') return strdup(txt); pos = strchr(txt + 1, '/'); if (pos == ((void *)0)) { temp = strdup(txt + 1); if (temp == ((void *)0)) return ((void *)0); } else { len = (size_t)(pos - txt + 1); temp = calloc(len, sizeof(*temp)); if (temp == ((void *)0)) return ((void *)0); (void)strlcpy(temp, txt + 1, len - 1); } if (temp[0] == 0) { if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf), &pass) != 0) pass = ((void *)0); } else { if (getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf), &pass) != 0) pass = ((void *)0); } free(temp); if (pass == ((void *)0)) return strdup(txt); txt += len; len = strlen(pass->pw_dir) + 1 + strlen(txt) + 1; temp = calloc(len, sizeof(*temp)); if (temp == ((void *)0)) return ((void *)0); (void)snprintf(temp, len, "%s/%s", pass->pw_dir, txt); return temp; }
char *fn_tilde_expand(char *param_1) { __uid_t __uid; int iVar1; char *pcVar2; size_t sVar3; size_t sVar4; long in_FS_OFFSET; passwd *local_478; char *local_470; char *local_468; char *local_460; passwd local_458; char local_428[1032]; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_468 = (char *)0x0; if (*param_1 == '~') { local_460 = strchr(param_1 + 1, 0x2f); if (local_460 == (char *)0x0) { local_470 = strdup(param_1 + 1); if (local_470 == (char *)0x0) { pcVar2 = (char *)0x0; goto LAB_0010027d; } } else { local_468 = local_460 + (1 - (long)param_1); local_470 = (char *)calloc((size_t)local_468, 1); if (local_470 == (char *)0x0) { pcVar2 = (char *)0x0; goto LAB_0010027d; } strlcpy(local_470, param_1 + 1, local_468 + -1); } if (*local_470 == '\0') { __uid = getuid(); iVar1 = getpwuid_r(__uid, &local_458, local_428, 0x400, &local_478); if (iVar1 != 0) { local_478 = (passwd *)0x0; } } else { iVar1 = getpwnam_r(local_470, &local_458, local_428, 0x400, &local_478); if (iVar1 != 0) { local_478 = (passwd *)0x0; } } free(local_470); if (local_478 == (passwd *)0x0) { pcVar2 = strdup(param_1); } else { param_1 = param_1 + (long)local_468; sVar3 = strlen(local_478->pw_dir); sVar4 = strlen(param_1); local_468 = (char *)(sVar4 + sVar3 + 2); local_470 = (char *)calloc((size_t)local_468, 1); if (local_470 == (char *)0x0) { pcVar2 = (char *)0x0; } else { snprintf(local_470, (size_t)local_468, "%s/%s", local_478->pw_dir, param_1); pcVar2 = local_470; } } } else { pcVar2 = strdup(param_1); } LAB_0010027d: if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return pcVar2; }
libedit
ghidra
WORD_LIST *list_string(string, separators, quoted) register char *string, *separators; int quoted; { WORD_LIST *result; WORD_DESC *t; char *current_word, *s; int sindex, sh_style_split, whitesep, xflags, free_word; size_t slen; if (!string || !*string) return ((WORD_LIST *)((void *)0)); sh_style_split = separators && separators[0] == ' ' && separators[1] == '\t' && separators[2] == '\n' && separators[3] == '\0'; for (xflags = 0, s = ifs_value; s && *s; s++) { if (*s == '\001') xflags |= 0x0010; else if (*s == '\177') xflags |= 0x0020; } slen = 0; if (!quoted && separators && *separators) { for (s = string; *s && (((separators)[0]) ? ((separators)[1] ? (ifs_cmap[(unsigned char)(*s)] != 0) : (*s) == (separators)[0]) : 0) && (1 && ((*__ctype_b_loc())[(int)(((unsigned char)*s))] & (unsigned short int)_ISspace)); s++) ; if (!*s) return ((WORD_LIST *)((void *)0)); string = s; } slen = (((string) && (string)[0]) ? ((string)[1] ? ((string)[2] ? strlen(string) : 2) : 1) : 0); for (result = (WORD_LIST *)((void *)0), sindex = 0; string[sindex];) { current_word = string_extract_verbatim(string, slen, &sindex, separators, xflags); if (current_word == 0) break; free_word = 1; if (((current_word)[0] == '\177' && (current_word)[1] == '\0')) { t = alloc_word_desc(); t->word = make_quoted_char('\0'); t->flags |= (1 << 1) | (1 << 18); result = make_word_list(t, result); } else if (current_word[0] != '\0') { remove_quoted_nulls(current_word); t = alloc_word_desc(); t->word = current_word; result = make_word_list(t, result); free_word = 0; result->word->flags &= ~(1 << 18); if (quoted & (0x001 | 0x002)) result->word->flags |= (1 << 1); if (current_word == 0 || current_word[0] == '\0') result->word->flags |= (1 << 21); } else if (!sh_style_split && !(1 && ((*__ctype_b_loc())[(int)(((unsigned char)string[sindex]))] & (unsigned short int)_ISspace))) { t = alloc_word_desc(); t->word = make_quoted_char('\0'); t->flags |= (1 << 1) | (1 << 18); result = make_word_list(t, result); } if (free_word) sh_xfree((current_word), "subst.c", 3229); whitesep = string[sindex] && ((sh_style_split || separators == 0) ? ((string[sindex]) == ' ' || (string[sindex]) == '\t' || (string[sindex]) == '\n') : (1 && ((*__ctype_b_loc())[(int)(((unsigned char)string[sindex]))] & (unsigned short int)_ISspace))); if (string[sindex]) { mbstate_t state; memset(&state, '\0', sizeof(mbstate_t)); do { if (locale_mb_cur_max > 1) { mbstate_t state_bak; size_t mblength; int _f; _f = is_basic((string)[sindex]); if (_f) mblength = 1; else if (locale_utf8locale && (((string)[sindex] & 0x80) == 0)) mblength = (string)[sindex] != 0; else { state_bak = state; mblength = mbrlen((string) + (sindex), (slen) - (sindex), &state); } if (mblength == (size_t)-2 || mblength == (size_t)-1) { state = state_bak; (sindex)++; } else if (mblength == 0) (sindex)++; else (sindex) += mblength; } else (sindex)++; } while (0); } while (string[sindex] && ((sh_style_split || separators == 0) ? ((string[sindex]) == ' ' || (string[sindex]) == '\t' || (string[sindex]) == '\n') : (1 && ((*__ctype_b_loc())[(int)(((unsigned char)string[sindex]))] & (unsigned short int)_ISspace))) && (((separators)[0]) ? ((separators)[1] ? (ifs_cmap[(unsigned char)(string[sindex])] != 0) : (string[sindex]) == (separators)[0]) : 0)) sindex++; if (string[sindex] && whitesep && (((separators)[0]) ? ((separators)[1] ? (ifs_cmap[(unsigned char)(string[sindex])] != 0) : (string[sindex]) == (separators)[0]) : 0) && !((sh_style_split || separators == 0) ? ((string[sindex]) == ' ' || (string[sindex]) == '\t' || (string[sindex]) == '\n') : (1 && ((*__ctype_b_loc())[(int)(((unsigned char)string[sindex]))] & (unsigned short int)_ISspace)))) { sindex++; while ( string[sindex] && ((sh_style_split || separators == 0) ? ((string[sindex]) == ' ' || (string[sindex]) == '\t' || (string[sindex]) == '\n') : (1 && ((*__ctype_b_loc())[(int)(((unsigned char)string[sindex]))] & (unsigned short int)_ISspace))) && (ifs_cmap[(unsigned char)(string[sindex])] != 0)) sindex++; } } return (((result && result->next) ? (WORD_LIST *)list_reverse((GENERIC_LIST *)result) : (WORD_LIST *)(result))); }
int list_string(char a0[3], char a1[4], unsigned long a2, unsigned long a3, unsigned long a4, unsigned long long a5) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned int v5; unsigned long v6; char v7[3]; unsigned long long v8; unsigned long v9; char v10[2]; struct_0 *v11; unsigned long long v12; unsigned long long v13; char v15[3]; unsigned long v16; unsigned int v17; unsigned int v18; v15 = a0; if (!a0) { LABEL_407830: v16 = 0; } else { if (!a0[0]) goto LABEL_407830; if (a1 && a1[0] == 32 && a1[1] == 9 && a1[2] == 10 && !a1[3]) { v17 = 1; goto LABEL_407878; } v17 = 0; LABEL_407878: v3 = v17; v1 = 0; v7 = 425802354520363004; while (true) { if (!v7) break; if (!*(v7)) break; if (*(v7) == 1) { v1 |= 16; } else if (*(v7) == 127) { v1 |= 32; } v7 += 1; } v9 = 0; if (!a2 && a1 && a1[0]) { *(&v7) = a0; while (true) { if (!*(v7)) break; if (!a1[0]) break; if (a1[1]) { if (!*(v7[0] + &ifs_cmap)) break; } else { if (v7[0] != a1[0]) break; } *(&v17) = *((v7[0] * 2 + *(__ctype_b_loc()))); v18 = v17 & 0x2000; if (!v18) break; v7 += 1; } if (v7[0]) { v15 = v7; } else { v16 = 0; goto LABEL_40805c; } } if (v15 && v15[0]) { if (!v15[1]) { v16 = 1; goto LABEL_4079c5; } else if (!v15[2]) { v16 = 2; goto LABEL_4079c5; } else { v16 = strlen(v15); goto LABEL_4079c5; } } v16 = 0; LABEL_4079c5: v9 = v16; v6 = 0; v0 = 0; while (true) { if (!v15[v0]) { LABEL_408032: if (v6 && *(v6)) { v16 = list_reverse(v6); break; } *(&v16) = v6; break; } else { *(&v10) = string_extract_verbatim(v15, v9, &v0, a1, v1, a5); if (!v10) goto LABEL_408032; v2 = 1; if (v10[0] == 127 && !v10[1]) { v11 = alloc_word_desc(); v11->field_0 = make_quoted_char(0x0); v11->field_8 = v11->field_8 | 262146; v6 = make_word_list(v11, v6, v6); goto LABEL_407bac; } if (v10[0]) { remove_quoted_nulls(v10); v11 = alloc_word_desc(); *(v11) = v10; v6 = make_word_list(v11, v6, v6); v2 = 0; v6->field_8->field_8 = v6->field_8->field_8 & -262145; if ((a2 & 3)) v6->field_8->field_8 = v6->field_8->field_8 | 2; if (v10 && !(!v10[0])) goto LABEL_407bac; v6->field_8->field_8 = v6->field_8->field_8 | 0x200000; } else if (!v3) { *(&v16) = *((*(__ctype_b_loc()) + v15[v0] * 2)); *(&v16) = v16 & 0x2000; if (!v16) { v11 = alloc_word_desc(); v11->field_0 = make_quoted_char(0x0); v11->field_8 = v11->field_8 | 262146; v6 = make_word_list(v11, v6, v6); } } LABEL_407bac: if (v2) sh_xfree(v10, "subst.c", 0xc9d); if (!v15[v0]) { LABEL_407c5d: *(&v16) = 0; LABEL_407c62: v4 = v16; if (!v15[v0]) { while (true) { LABEL_407d81: if (!v15[v0]) break; if (v3) { LABEL_407d9f: if (v15[v0] != 32 && v15[v0] != 9 && v15[v0] != 10) { *(&v16) = 0; LABEL_407dd8: *(&v16) = v16 & 1; if (!v16) break; } *(&v16) = 1; goto LABEL_407dd8; } else { if (!a1) goto LABEL_407d9f; *(&v16) = *((*(__ctype_b_loc()) + v15[v0] * 2)); *(&v16) = v16 & 0x2000; if (!v16) break; if (!a1[0]) break; if (a1[1]) { if (!*(v15[v0] + &ifs_cmap)) break; } else { if (v15[v0] != a1[0]) break; } v0 += 1; } } if (!v15[v0]) continue; if (!v4) continue; if (!a1[0]) { *(&v16) = 0; } else if (a1[1]) { *(&v16) = *(v15[v0] + &ifs_cmap); } else { *(&v16) = v15[v0] == a1[0]; } if (!v16) continue; if (v3) { LABEL_407ee6: if (v15[v0] != 32 && v15[v0] != 9 && v15[v0] != 10) { *(&v16) = 1; goto LABEL_407f1f; } *(&v16) = 0; LABEL_407f1f: *(&v16) = v16 & 1; goto LABEL_407f51; } else { if (!a1) goto LABEL_407ee6; *(&v16) = *((*(__ctype_b_loc()) + v15[v0] * 2)); *(&v16) = v16 & 0x2000; *(&v16) = !v16; LABEL_407f51: if (v16) { v0 += 1; while (true) { if (!v15[v0]) break; if (v3) { LABEL_407f8b: if (v15[v0] != 32 && v15[v0] != 9 && v15[v0] != 10) { *(&v16) = 0; LABEL_407fc4: *(&v16) = v16 & 1; if (!v16) break; } *(&v16) = 1; goto LABEL_407fc4; } else { if (!a1) goto LABEL_407f8b; *(&v16) = *((*(__ctype_b_loc()) + v15[v0] * 2)); *(&v16) = v16 & 0x2000; if (!v16) break; if (!*(v15[v0] + &ifs_cmap)) break; v0 += 1; } } } } } else { memset(&v12, 0x0, 0x8); if (locale_mb_cur_max <= 1) { v0 += 1; LABEL_407d76: goto LABEL_407d81; } v5 = is_basic(v15[v0]); if (v5) { v8 = 1; goto LABEL_407d2a; } if (locale_utf8locale && v15[v0] >= 0) { v8 = v15[v0]; goto LABEL_407d2a; } v13 = v12; v8 = mbrlen(&v15[v0], v9 - v0, &v12, &v15[v0]); LABEL_407d2a: if (v8 != -2 && v8 != -1) { if (v8) { v0 += v8; goto LABEL_407d81; } else { v0 += 1; goto LABEL_407d81; } } v12 = v13; v0 += 1; goto LABEL_407d76; } } else { if (!v3 && a1) { *(&v16) = *((*(__ctype_b_loc()) + v15[v0] * 2)); *(&v16) = v16 & 0x2000; if (!(!v16)) goto LABEL_407c56; goto LABEL_407c5d; } if (v15[v0] != 32 && v15[v0] != 9 && v15[v0] != 10) { *(&v16) = 0; LABEL_407c21: *(&v16) = v16 & 1; if (!v16) goto LABEL_407c5d; LABEL_407c56: *(&v16) = 1; goto LABEL_407c62; } *(&v16) = 1; goto LABEL_407c21; } } } } LABEL_40805c: return v16; }
bash
angr_phoenix
int rl_vi_movement_mode(int count, int key) { if (rl_point > 0) rl_backward_char(1, key); _rl_keymap = vi_movement_keymap; _rl_vi_done_inserting(); if ((rl_readline_state & (0x0400000)) == 0) rl_free_undo_list(); if (_rl_show_mode_in_prompt) _rl_reset_prompt(); (rl_readline_state |= (0x0400000)); return (0); }
undefined8 rl_vi_movement_mode(undefined8 param_1, undefined4 param_2) { if (0 < rl_point) { rl_backward_char(1, param_2); } _rl_keymap = &vi_movement_keymap; _rl_vi_done_inserting(); if ((rl_readline_state & 0x400000) == 0) { rl_free_undo_list(); } if (_rl_show_mode_in_prompt != 0) { _rl_reset_prompt(); } rl_readline_state = rl_readline_state | 0x400000; return 0; }
bash
ghidra
static int redir_varvalue(redir) REDIRECT *redir; { SHELL_VAR *v; char *val, *w; intmax_t vmax; int i; char *sub; int len, vr; w = redir->redirector.filename->word; if (vr = valid_array_reference(w, 0)) { v = array_variable_part(w, 0, &sub, &len); } else { v = find_variable(w); if (v == 0) { v = find_variable_last_nameref(w, 0); if (v && ((((v)->attributes) & (0x0000800)))) { w = ((v)->value); if (vr = valid_array_reference(w, 0)) v = array_variable_part(w, 0, &sub, &len); else v = find_variable(w); } } } if (v == 0 || ((((v)->attributes) & (0x0001000)))) return -1; if (vr && (((((v)->attributes) & (0x0000004))) || ((((v)->attributes) & (0x0000040))))) val = get_array_value(w, 0, (array_eltstate_t *)((void *)0)); else val = get_variable_value(v); if (val == 0 || *val == 0) return -1; if (legal_number(val, &vmax) < 0) return -1; i = vmax; return i; }
int redir_varvalue(struct_0 *a0) { char v0; unsigned int v1; unsigned int v2; char v3; char v4; struct_2 *v5; char *v6; unsigned long long v7; unsigned int v9; v7 = a0->field_8->field_0; v1 = valid_array_reference(v7, 0x0); if (v1) { v5 = array_variable_part(v7, 0x0, &v4, &v0); } else { v5 = find_variable(v7); if (!v5) { v5 = find_variable_last_nameref(v7, 0x0); if (v5 && (v5->field_28 & 0x800)) { v7 = v5->field_8; v1 = valid_array_reference(v7, 0x0); if (!v1) v5 = find_variable(v7); else v5 = array_variable_part(v7, 0x0, &v4, &v0); } } } if (!v5) { LABEL_402735: v9 = -1; } else { if (!(!(v5->field_28 & 0x1000))) goto LABEL_402735; if (v1) { if ((v5->field_28 & 4)) { LABEL_402761: v6 = get_array_value(v7, 0x0, 0x0); goto LABEL_40278d; } else if (!(!(v5->field_28 & 64))) { goto LABEL_402761; } } v6 = get_variable_value(v5); LABEL_40278d: if (!v6) { LABEL_40279f: v9 = -1; } else { if (!*(v6)) goto LABEL_40279f; if (legal_number(v6, &v3, &v3) < 0) { v9 = -1; } else { v2 = *(&v3); v9 = v2; } } } return v9; }
bash
angr_phoenix
static const char *format_action_type(int action) { if (action < 0 || action > (__SEG6_LOCAL_ACTION_MAX - 1)) return "<invalid>"; return seg6_action_names[action] ?: "<unknown>"; }
int format_action_type(unsigned long a0) { unsigned int v1; if (a0 >= 0 && a0 <= 16) { v1 = seg6_action_names[a0]; if (!seg6_action_names[a0]) v1 = &g_406d58; } if (a0 < 0 || a0 > 16) v1 = &g_406e62; return v1; }
iproute2-6.0.0
angr_dream
xmax(size_t size1, size_t size2) { return (size1 >= size2 ? size1 : size2); }
void xmax(void) { halt_baddata(); }
gnutls
ghidra
static void nh_update(nh_ctx *hc, const UINT8 *buf, UINT32 nbytes) { UINT32 i, j; j = hc->next_data_empty; if ((j + nbytes) >= 64) { if (j) { i = 64 - j; memcpy(hc->data + j, buf, i); nh_transform(hc, hc->data, 64); nbytes -= i; buf += i; hc->bytes_hashed += 64; } if (nbytes >= 64) { i = nbytes & ~(64 - 1); nh_transform(hc, buf, i); nbytes -= i; buf += i; hc->bytes_hashed += i; } j = 0; } memcpy(hc->data + j, buf, nbytes); hc->next_data_empty = j + nbytes; }
long nh_update(long a1, char *a2, unsigned int a3) { long result; unsigned int v4; char *v5; unsigned int v6; unsigned int n; v5 = a2; v4 = a3; v6 = *(_DWORD *)(a1 + 1136); if (v6 + a3 > 0x3F) { if (v6) { memcpy((void *)(v6 + a1 + 1072), a2, 64 - v6); nh_transform(a1, a1 + 1072, 0x40u); v4 -= 64 - v6; v5 = &a2[64 - v6]; *(_DWORD *)(a1 + 1140) += 64; } if (v4 > 0x3F) { n = v4 & 0xFFFFFFC0; nh_transform(a1, (long)v5, v4 & 0xFFFFFFC0); v4 -= v4 & 0xFFFFFFC0; v5 += n; *(_DWORD *)(a1 + 1140) += n; } v6 = 0; } memcpy((void *)(v6 + a1 + 1072), v5, v4); result = a1; *(_DWORD *)(a1 + 1136) = v6 + v4; return result; }
openssh-portable
ida
void rl_deprep_terminal(void) { int tty; if (terminal_prepped == 0) return; _rl_block_sigint(); tty = rl_instream ? fileno(rl_instream) : fileno(stdin); if (terminal_prepped & 0x02) { fprintf(rl_outstream, "\033[?2004l\r"); _rl_last_c_pos = 0; if (rl_eof_found && ((rl_readline_state & (0x4000000)) == 0)) fprintf(rl_outstream, "\n"); else if (_rl_echoing_p == 0) fprintf(rl_outstream, "\n"); } if (_rl_enable_keypad) _rl_control_keypad(0); fflush(rl_outstream); if (set_tty_settings(tty, &otio) < 0) { _rl_release_sigint(); return; } terminal_prepped = 0; (rl_readline_state &= ~(0x0000004)); _rl_release_sigint(); }
long long rl_deprep_terminal() { unsigned int v0; unsigned long long v2; unsigned long long v3; v2 = terminal_prepped; if (terminal_prepped) { _rl_block_sigint(); if (rl_instream) v3 = fileno(rl_instream); else v3 = fileno(stdin); v0 = v3; if ((terminal_prepped & 2)) { fprintf(rl_outstream, &g_400f3e); _rl_last_c_pos = 0; if (rl_eof_found && !(rl_readline_state & 0x4000000)) fprintf(rl_outstream, "\n"); if ((!rl_eof_found || (rl_readline_state & 0x4000000)) && !_rl_echoing_p) fprintf(rl_outstream, "\n"); } if (_rl_enable_keypad) _rl_control_keypad(0x0); fflush(rl_outstream); if (set_tty_settings(v0, &otio) < 0) { v2 = _rl_release_sigint(); } else { terminal_prepped = 0; rl_readline_state = rl_readline_state & -5; v2 = _rl_release_sigint(); } } return v2; }
bash
angr_dream
static size_t hash_directory_canonical_name(void const *entry, size_t n_buckets) { struct directory const *directory = entry; return hash_string(directory->caname, n_buckets); }
void hash_directory_canonical_name(long param_1, undefined8 param_2) { hash_string(*(undefined8 *)(param_1 + 0x50), param_2); return; }
tar
ghidra
static int istrsenvisxl(char **mbdstp, size_t *dlen, const char *mbsrc, int flags, const char *mbextra, int *cerr_ptr) { return istrsenvisx(mbdstp, dlen, mbsrc, mbsrc != ((void *)0) ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr); }
void istrsenvisxl(unsigned int a0, unsigned long long *a1, char *a2, unsigned long a3, void *a4, unsigned int a5) { unsigned int v0; void *v2; unsigned long long v3; v0 = a3; if (!a2) v2 = 0; else v2 = strlen(a2); v3 = istrsenvisx(a0, a1, a2, v2, v0, a4, a5); return; }
libedit
angr_phoenix
static VALUE *str_value(char const *s) { VALUE *v = xmalloc(sizeof *v); v->type = string; v->u.s = xstrdup(s); return v; }
long str_value(long a1) { long v2; v2 = xmalloc(24LL); *(_DWORD *)v2 = 1; *(_QWORD *)(v2 + 8) = xstrdup(a1); return v2; }
coreutils
ida
size_t atomicio6(ssize_t (*f)(int, void *, size_t), int fd, void *_s, size_t n, int (*cb)(void *, size_t), void *cb_arg) { char *s = _s; size_t pos = 0; ssize_t res; struct pollfd pfd; pfd.fd = fd; pfd.events = f == read ? 0x001 : 0x004; while (n > pos) { res = (f)(fd, s + pos, n - pos); switch (res) { case -1: if ((*__errno_location()) == 4) { if (cb != ((void *)0) && cb(cb_arg, 0) == -1) { (*__errno_location()) = 4; return pos; } continue; } else if ((*__errno_location()) == 11 || (*__errno_location()) == 11) { (void)poll(&pfd, 1, -1); continue; } return 0; case 0: (*__errno_location()) = 32; return pos; default: pos += (size_t)res; if (cb != ((void *)0) && cb(cb_arg, (size_t)res) == -1) { (*__errno_location()) = 4; return pos; } } } return pos; }
unsigned long atomicio6(ssize_t (**a1)(int fd, void *buf, size_t nbytes), int a2, long a3, unsigned long a4, unsigned int (*a5)(long, long), long a6) { short v6; unsigned long v11; long v13; struct pollfd fds; unsigned long v15; v15 = __readfsqword(0x28u); v11 = 0LL; fds.fd = a2; if (a1 == &read) v6 = 1; else v6 = 4; fds.events = v6; while (a4 > v11) { v13 = ((long (*)(_QWORD, unsigned long, unsigned long))a1)( (unsigned int)a2, a3 + v11, a4 - v11); if (v13 == -1) { if (*_errno_location() == 4) { if (a5 && a5(a6, 0LL) == -1) { LABEL_11: *_errno_location() = 4; return v11; } } else { if (*_errno_location() != 11 && *_errno_location() != 11) return 0LL; poll(&fds, 1uLL, -1); } } else { if (!v13) { *_errno_location() = 32; return v11; } v11 += v13; if (a5 && a5(a6, v13) == -1) goto LABEL_11; } } return v11; }
openssh-portable
ida
static inline void emit_mandatory_arg_note(void) { fputs_unlocked(gettext("\nMandatory arguments to long options are mandatory " "for short options too.\n"), stdout) ; }
void emit_mandatory_arg_note() { unsigned long long v1; v1 = fputs_unlocked(gettext("\nMandatory arguments to long options are " "mandatory for short options too.\n"), stdout); return; }
coreutils
angr_sailr
void _generate_request(gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer, gnutls_datum_t *rdata, gnutls_datum_t *nonce) { gnutls_ocsp_req_t req; int ret; ret = gnutls_ocsp_req_init(&req); if (ret < 0) { fprintf(stderr, "ocsp_req_init: %s", gnutls_strerror(ret)); exit(1); } ret = gnutls_ocsp_req_add_cert(req, GNUTLS_DIG_SHA1, issuer, cert); if (ret < 0) { fprintf(stderr, "ocsp_req_add_cert: %s", gnutls_strerror(ret)); exit(1); } if (nonce) { ret = gnutls_ocsp_req_set_nonce(req, 0, nonce); if (ret < 0) { fprintf(stderr, "ocsp_req_set_nonce: %s", gnutls_strerror(ret)); exit(1); } } ret = gnutls_ocsp_req_export(req, rdata); if (ret != 0) { fprintf(stderr, "ocsp_req_export: %s", gnutls_strerror(ret)); exit(1); } gnutls_ocsp_req_deinit(req); return; }
void _generate_request(undefined8 param_1, undefined8 param_2, undefined8 param_3, long param_4) { int iVar1; undefined8 uVar2; long in_FS_OFFSET; undefined8 local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); iVar1 = gnutls_ocsp_req_init(&local_18); if (iVar1 < 0) { uVar2 = gnutls_strerror(iVar1); fprintf(stderr, "ocsp_req_init: %s", uVar2); exit(1); } iVar1 = gnutls_ocsp_req_add_cert(local_18, 3, param_2, param_1); if (iVar1 < 0) { uVar2 = gnutls_strerror(iVar1); fprintf(stderr, "ocsp_req_add_cert: %s", uVar2); exit(1); } if (param_4 != 0) { iVar1 = gnutls_ocsp_req_set_nonce(local_18, 0, param_4); if (iVar1 < 0) { uVar2 = gnutls_strerror(iVar1); fprintf(stderr, "ocsp_req_set_nonce: %s", uVar2); exit(1); } } iVar1 = gnutls_ocsp_req_export(local_18, param_3); if (iVar1 != 0) { uVar2 = gnutls_strerror(iVar1); fprintf(stderr, "ocsp_req_export: %s", uVar2); exit(1); } gnutls_ocsp_req_deinit(local_18); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return; }
gnutls
ghidra
int main(int argc, char **argv) { struct passwd *pw; uid_t uid; uid_t NO_UID = -1; ; set_program_name(argv[0]); setlocale(6, ""); bindtextdomain("coreutils", "/usr/local/share/locale"); textdomain("coreutils"); atexit(close_stdout); parse_gnu_standard_options_only(argc, argv, "whoami", "GNU coreutils", Version, 1, usage, ("Richard Mlynarik"), (char const *)((void *)0)); if (optind != argc) { error(0, 0, gettext("extra operand %s"), quote(argv[optind])); usage(1); } (*__errno_location()) = 0; uid = geteuid(); pw = (uid == NO_UID && (*__errno_location()) ? ((void *)0) : getpwuid(uid)); if (!pw) ((!!sizeof(struct { _Static_assert( 1, "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), gettext (\"cannot find name " "for user ID %lu\"), (unsigned long int) uid), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, (*__errno_location()), gettext("cannot find name for user ID %lu"), (unsigned long int)uid), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, (*__errno_location()), gettext("cannot find name for user ID %lu"), (unsigned long int)uid), ((0) ? (void)0 : __builtin_unreachable())))); puts(pw->pw_name); return 0; }
int main(unsigned long a0, unsigned long long *a1) { void *v0; unsigned int v1; unsigned int v2; void *v3; unsigned long long v5; void *v7; v1 = -1; set_program_name(*(a1)); setlocale(0x6, &g_400633); bindtextdomain("coreutils", "/usr/local/share/locale"); textdomain("coreutils"); atexit(got.close_stdout); v0 = 0; parse_gnu_standard_options_only(a0, a1, "whoami", "GNU coreutils", Version, 0x1, usage, "Richard Mlynarik"); if (a0 != optind) { v5 = quote(a1[optind]); error(0x0, 0x0, gettext("extra operand %s")); usage(0x1); } *(__errno_location()) = 0; v2 = geteuid(); if (v2 != v1 || !*(__errno_location())) v7 = getpwuid(v2); else v7 = 0; v3 = v7; if (v3) { puts(*(v3)); return 0; } error(0x1, *(__errno_location()), gettext("cannot find name for user ID %lu")); }
coreutils
angr_sailr
int sshbuf_get_u16(struct sshbuf *buf, u_int16_t *valp) { const u_char *p = sshbuf_ptr(buf); int r; if ((r = sshbuf_consume(buf, 2)) < 0) return r; if (valp != ((void *)0)) *valp = (((u_int16_t)(((const u_char *)(p))[0]) << 8) | (u_int16_t)(((const u_char *)(p))[1])); return 0; }
long long sshbuf_get_u16(unsigned long long a0, unsigned short *a1, unsigned long long a2) { unsigned int v0; char v1[2]; void *v3; *(&v1) = sshbuf_ptr(a0); v0 = sshbuf_consume(a0, 0x2, a2); if (v0 < 0) { v3 = v0; } else { if (a1) *(a1) = v1[1] | (v1[0] * 0x100); v3 = 0; } return v3; }
openssh-portable
angr_dream
static void process_opendir(u_int32_t id) { DIR *dirp = ((void *)0); char *path; int r, handle, status = 4; if ((r = sshbuf_get_cstring(iqueue, &path, ((void *)0))) != 0) sshfatal("sftp-server.c", __func__, 1106, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse"); sshlog("sftp-server.c", __func__, 1108, 0, SYSLOG_LEVEL_DEBUG3, ((void *)0), "request %u: opendir", id); sshlog("sftp-server.c", __func__, 1109, 0, SYSLOG_LEVEL_INFO, ((void *)0), "opendir \"%s\"", path); dirp = opendir(path); if (dirp == ((void *)0)) { status = errno_to_portable((*__errno_location())); } else { handle = handle_new(HANDLE_DIR, path, 0, 0, dirp); if (handle < 0) { closedir(dirp); } else { send_handle(id, handle); status = 0; } } if (status != 0) send_status(id, status); free(path); }
unsigned long process_opendir(unsigned int a1) { long v1; int *v2; unsigned int v4; unsigned int cstring; signed int v6; char *name; DIR *dirp; unsigned long v9; v9 = __readfsqword(0x28u); dirp = 0LL; v4 = 4; cstring = sshbuf_get_cstring(iqueue, &name, 0LL); if (cstring) { v1 = ssh_err(cstring); sshfatal("sftp-server.c", "process_opendir", 1106LL, 1LL, 1LL, v1, "parse"); } sshlog("sftp-server.c", "process_opendir", 1108LL, 0LL, 7LL, 0LL, "request %u: opendir", a1); sshlog("sftp-server.c", "process_opendir", 1109LL, 0LL, 3LL, 0LL, "opendir \"%s\"", name); dirp = opendir(name); if (dirp) { v6 = handle_new(1, (long)name, 0, 0, (long)dirp); if (v6 >= 0) { send_handle(a1, v6); v4 = 0; } else { closedir(dirp); } } else { v2 = _errno_location(); v4 = errno_to_portable(*v2); } if (v4) send_status(a1, v4); free(name); return __readfsqword(0x28u) ^ v9; }
openssh-portable
ida
static void nl_error(int status, int errnum, char const *fmt, ...) { if (0 < progress_len) { fputc_unlocked('\n', stderr); progress_len = 0; } va_list ap; __builtin_va_start(ap, fmt); verror(status, errnum, fmt, ap); __builtin_va_end(ap); }
void nl_error(undefined4 param_1, undefined4 param_2, undefined4 param_3, undefined4 param_4, undefined4 param_5, undefined4 param_6, undefined4 param_7, undefined4 param_8, undefined4 param_9, undefined4 param_10, undefined8 param_11, undefined8 param_12, undefined8 param_13, undefined8 param_14) { char in_AL; long in_FS_OFFSET; undefined4 local_d8; undefined4 local_d4; undefined *local_d0; undefined *local_c8; long local_c0; undefined local_b8[24]; undefined8 local_a0; undefined8 local_98; undefined8 local_90; undefined4 local_88; undefined4 local_78; undefined4 local_68; undefined4 local_58; undefined4 local_48; undefined4 local_38; undefined4 local_28; undefined4 local_18; if (in_AL != '\0') { local_88 = param_1; local_78 = param_2; local_68 = param_3; local_58 = param_4; local_48 = param_5; local_38 = param_6; local_28 = param_7; local_18 = param_8; } local_c0 = *(long *)(in_FS_OFFSET + 0x28); local_a0 = param_12; local_98 = param_13; local_90 = param_14; if (0 < progress_len) { fputc_unlocked(10, stderr); progress_len = 0; } local_d8 = 0x18; local_d4 = 0x30; local_d0 = &stack0x00000008; local_c8 = local_b8; verror(param_9, param_10, param_11, &local_d8); if (local_c0 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return; }
coreutils
ghidra
COMMAND *make_case_command(word, clauses, lineno) WORD_DESC *word; PATTERN_LIST *clauses; int lineno; { CASE_COM *temp; temp = (CASE_COM *)sh_xmalloc((sizeof(CASE_COM)), "make_cmd.c", 361); temp->flags = 0; temp->line = lineno; temp->word = word; temp->clauses = ((clauses && clauses->next) ? (PATTERN_LIST *)list_reverse((GENERIC_LIST *)clauses) : (PATTERN_LIST *)(clauses)); return (make_command(cm_case, (SIMPLE_COM *)temp)); }
void make_case_command(undefined8 param_1, long *param_2, undefined4 param_3) { undefined4 *puVar1; puVar1 = (undefined4 *)sh_xmalloc(0x18, "make_cmd.c", 0x169); *puVar1 = 0; puVar1[1] = param_3; *(undefined8 *)(puVar1 + 2) = param_1; if ((param_2 != (long *)0x0) && (*param_2 != 0)) { param_2 = (long *)list_reverse(param_2); } *(long **)(puVar1 + 4) = param_2; make_command(1, puVar1); return; }
bash
ghidra
static int bash_transpose_shellwords(count, key) int count, key; { char *word1, *word2; int w1_beg, w1_end, w2_beg, w2_end; int orig_point = rl_point; if (count == 0) return 0; bash_forward_shellword(count, key); w2_end = rl_point; bash_backward_shellword(1, key); w2_beg = rl_point; bash_backward_shellword(count, key); w1_beg = rl_point; bash_forward_shellword(1, key); w1_end = rl_point; if ((w1_beg == w2_beg) || (w2_beg < w1_end)) { rl_ding(); rl_point = orig_point; return 1; } word1 = rl_copy_text(w1_beg, w1_end); word2 = rl_copy_text(w2_beg, w2_end); rl_begin_undo_group(); rl_point = w2_beg; rl_delete_text(w2_beg, w2_end); rl_insert_text(word1); rl_point = w1_beg; rl_delete_text(w1_beg, w1_end); rl_insert_text(word2); rl_point = w2_end; rl_end_undo_group(); sh_xfree((word1), "bashline.c", 1334); sh_xfree((word2), "bashline.c", 1335); return 0; }
long long bash_transpose_shellwords(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 int v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned long long v5; unsigned long long v6; unsigned long long v8; v0 = rl_point; if (!a0) { v8 = 0; } else { bash_forward_shellword(a0, a1); v1 = rl_point; bash_backward_shellword(0x1, a1); v2 = rl_point; bash_backward_shellword(a0, a1); v3 = rl_point; bash_forward_shellword(0x1, a1); v4 = rl_point; if (v3 == v2) { LABEL_402827: rl_ding(); rl_point = v0; v8 = 1; } else { if (v2 < v4) goto LABEL_402827; v5 = rl_copy_text(v3, v4, v4); v6 = rl_copy_text(v2, v1, v1); rl_begin_undo_group(a0, a1, a2, a3, a4, a5); rl_point = v2; rl_delete_text(v2, v1, v1); rl_insert_text(v5); rl_point = v3; rl_delete_text(v3, v4, v4); rl_insert_text(v6); rl_point = v1; rl_end_undo_group(a0, a1, a2, a3, a4, a5); sh_xfree(v5, "bashline.c", 0x536); sh_xfree(v6, "bashline.c", 0x537); v8 = 0; } } return v8; }
bash
angr_phoenix