input
stringlengths
26
172k
output
stringlengths
18
318k
repo_name
stringclasses
23 values
decompiler
stringclasses
5 values
static void check_agent_present(void) { int r; if (options.forward_agent) { if ((r = ssh_get_authentication_socket(((void *)0))) != 0) { options.forward_agent = 0; if (r != -47) sshlog("ssh.c", __func__, 2017, 0, SYSLOG_LEVEL_DEBUG1, ssh_err(r), "ssh_get_authentication_socket"); } } }
void check_agent_present() { char v0; unsigned int v1; unsigned long long v3; unsigned long long v5; v3 = 1098421112831; v1 = ssh_get_authentication_socket(0x0); if (v1) { hostaddr = 0; if (v1 != -47) v5 = sshlog("ssh.c", "check_agent_present", 0x7e1, 0x0, 0x5, ssh_err(v1), "ssh_get_authentication_socket", *(&v0)); } return; }
openssh-portable
angr_phoenix
static void main_sigchld_handler(int sig) { int save_errno = (*__errno_location()); pid_t pid; int status; while ((pid = waitpid(-1, &status, 1)) > 0 || (pid == -1 && (*__errno_location()) == 4)) ; (*__errno_location()) = save_errno; }
long long main_sigchld_handler(unsigned long a0) { unsigned int v0; char v1; unsigned int v2; unsigned int v3; v0 = a0; v2 = *(__errno_location()); while (true) { v3 = waitpid(0xffffffff, &v1, 0x1); if (v3 > 0) continue; if (v3 != -1) break; if (*(__errno_location()) != 4) break; } *(__errno_location()) = v2; return 0; }
openssh-portable
angr_dream
void monitor_child_postauth(struct ssh *ssh, struct monitor *pmonitor) { close(pmonitor->m_recvfd); pmonitor->m_recvfd = -1; monitor_set_child_handler(pmonitor->m_pid); ssh_signal(1, &monitor_child_handler); ssh_signal(15, &monitor_child_handler); ssh_signal(2, &monitor_child_handler); ssh_signal(25, ((__sighandler_t)1)); mon_dispatch = mon_dispatch_postauth20; monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1); monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1); monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1); if (auth_opts->permit_pty_flag) { monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1); } for (;;) monitor_read(ssh, pmonitor, mon_dispatch, ((void *)0)); }
long long monitor_child_postauth() { unsigned int v1[7]; unsigned long long v2; close(v1[0]); v1[0] = -1; monitor_set_child_handler(v1[6]); ssh_signal(0x1, monitor_child_handler); ssh_signal(0xf, monitor_child_handler); ssh_signal(0x2, monitor_child_handler); ssh_signal(0x19, 0x1); mon_dispatch = &mon_dispatch_postauth20; monitor_permit(0x89f47589f87d8948, 0x0, 0x1); monitor_permit(0x89f47589f87d8948, 0x6, 0x1); monitor_permit(0x89f47589f87d8948, 0x32, 0x1); if (*((auth_opts + 12))) { monitor_permit(0x89f47589f87d8948, 0x1c, 0x1); monitor_permit(0x89f47589f87d8948, 0x1e, 0x1); } while (true) { monitor_read(v2, v1, 0x89f47589f87d8948, 0x0); } }
openssh-portable
angr_dream
char *bash_dequote_text(text) const char *text; { char *dtxt; int qc; qc = (text[0] == '"' || text[0] == '\'') ? text[0] : 0; dtxt = bash_dequote_filename((char *)text, qc); return (dtxt); }
long bash_dequote_text(const char *a1) { int v1; if (*a1 == 34 || *a1 == 39) v1 = *a1; else v1 = 0; return bash_dequote_filename(a1, v1); }
bash
ida
static void code_num(uintmax_t value, char const *keyword, struct xheader *xhdr) { code_signed_num(value, keyword, 0, (18446744073709551615UL), xhdr); }
void code_num(unsigned long long a0, unsigned long a1, void *a2) { unsigned long long v1; v1 = code_signed_num(a0, a1, 0x0, 0xffffffffffffffff, a2); return; }
tar
angr_sailr
static inline __u8 rta_getattr_u8(const struct rtattr *rta) { return *(__u8 *)(( void *)(((char *)(rta)) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))); }
int rta_getattr_u8(struct_0 *a0) { return a0->field_4; }
iproute2-6.0.0
angr_phoenix
int mm_is_monitor(void) { return (pmonitor && pmonitor->m_pid > 0); }
_BOOL8 mm_is_monitor() { return pmonitor && *(int *)(pmonitor + 24LL) > 0; }
openssh-portable
ida
(!iswspace(c) && (c < 33 || (c > 60 && c < 62) || c > 126)) || wcschr(L"#$@[\\]^`{|}~", c) !=
int iswspace(wint_t __wc) { halt_baddata(); }
libbsd-0.11.7
ghidra
{ return ext2fs_has_feature_metadata_csum(fs->super) || ext2fs_has_feature_gdt_csum(fs->super); }
int ext2fs_has_feature_metadata_csum(struct_0 *a0) { return (a0->field_64 & 0x400); }
e2fsprogs-1.46.5
angr_phoenix
int unquote_string(char *string) { int result = 1; char *source = string; char *destination = string; while (*source) if (*source == '\\') switch (*++source) { case '\\': *destination++ = '\\'; source++; break; case 'a': *destination++ = '\a'; source++; break; case 'b': *destination++ = '\b'; source++; break; case 'f': *destination++ = '\f'; source++; break; case 'n': *destination++ = '\n'; source++; break; case 'r': *destination++ = '\r'; source++; break; case 't': *destination++ = '\t'; source++; break; case 'v': *destination++ = '\v'; source++; break; case '?': *destination++ = 0177; source++; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': { int value = *source++ - '0'; if (*source < '0' || *source > '7') { *destination++ = value; break; } value = value * 8 + *source++ - '0'; if (*source < '0' || *source > '7') { *destination++ = value; break; } value = value * 8 + *source++ - '0'; *destination++ = value; break; } default: result = 0; *destination++ = '\\'; if (*source) *destination++ = *source++; break; } else if (source != destination) *destination++ = *source++; else source++, destination++; if (source != destination) *destination = '\0'; return result; }
long long unquote_string(unsigned long long a0) { unsigned int v0; int tmp_15; int tmp_29; int tmp_14; int tmp_10; unsigned int v1; char *v2; char *v3; char *v5; char *v7; char *v8; char *v9; char *v10; char *v11; char *v12; char *v13; char *v14; char *v15; char *v17; char *v19; char *v21; char *v23; v0 = 1; v2 = a0; v3 = a0; while (*(v2)) { if (*(v2) == 92) { v2 += 1; switch (*(v2)) { case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: tmp_15 = v2; v2 += 1; v1 = *(tmp_15)-48; if (*(v2) > 47 && *(v2) <= 55) { tmp_29 = v2; v2 += 1; v1 = *(tmp_29) + (v1 * 8) - 48; if (*(v2) > 47 && *(v2) <= 55) { tmp_29 = v2; v2 += 1; v1 = *(tmp_29) + (v1 * 8) - 48; v23 = v3; v3 += 1; *(v23) = v1; break; } if (*(v2) <= 47 || *(v2) > 55) { v21 = v3; v3 += 1; *(v21) = v1; break; } } if (*(v2) <= 47 || *(v2) > 55) { v19 = v3; v3 += 1; *(v19) = v1; break; } case 63: v10 = v3; v3 += 1; *(v10) = 127; v2 += 1; break; case 92: v8 = v3; v3 += 1; *(v8) = 92; v2 += 1; break; case 97: v15 = v3; v3 += 1; *(v15) = 7; v2 += 1; break; case 98: v13 = v3; v3 += 1; *(v13) = 8; v2 += 1; break; case 102: v11 = v3; v3 += 1; *(v11) = 12; v2 += 1; break; case 110: v9 = v3; v3 += 1; *(v9) = 10; v2 += 1; break; case 114: v7 = v3; v3 += 1; *(v7) = 13; v2 += 1; break; case 116: v14 = v3; v3 += 1; *(v14) = 9; v2 += 1; break; case 118: v12 = v3; v3 += 1; *(v12) = 11; v2 += 1; break; default: v0 = 0; tmp_14 = v3; v3 += 1; *(tmp_14) = 92; if (*(v2)) { tmp_10 = v2; v2 += 1; v17 = v3; v3 += 1; *(v17) = *(tmp_10); } break; } } else if (v2 != v3) { tmp_10 = v2; v2 += 1; v5 = v3; v3 += 1; *(v5) = *(tmp_10); } else { v2 += 1; v3 += 1; } } if (v2 != v3) *(v3) = 0; return v0; }
tar
angr_dream
_Bool *changed); static void fail_exit(int code) { if (spw_locked) { if (spw_unlock() == 0) { fprintf(stderr, gettext("%s: failed to " "unlock %s\n"), Prog, spw_dbname()); if (use_system_spw_file) { 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(3, "failed to unlock %s", spw_dbname()); if (((void *)0) != saved_locale) { (void)setlocale( 6, saved_locale); free(saved_locale); } } while (0); } } } if (pw_locked) { if (pw_unlock() == 0) { fprintf(stderr, gettext("%s: failed to " "unlock %s\n"), Prog, pw_dbname()); if (use_system_pw_file) { 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(3, "failed to unlock %s", pw_dbname()); if (((void *)0) != saved_locale) { (void)setlocale( 6, saved_locale); free(saved_locale); } } while (0); } } } closelog(); exit(code); }
void fail_exit(unsigned long a0) { void *v0; void *v1; char *v2; char *v3; unsigned long v4; unsigned long v5; unsigned long v7; unsigned long v8; unsigned long long v9; unsigned long long v10; v5 = v7; v4 = v8; if (spw_locked && !spw_unlock()) { v9 = spw_dbname(); fprintf(stderr, gettext("%s: failed to unlock %s\n")); if (use_system_spw_file) { v2 = setlocale(0x6, NULL); v0 = 0; if (v2) v0 = strdup(v2); if (v0) setlocale(0x6, "C"); spw_dbname(); syslog(0x3, "failed to unlock %s"); if (v0) { setlocale(0x6, v0); free(v0); } } } if (pw_locked && !pw_unlock()) { v10 = pw_dbname(); fprintf(stderr, gettext("%s: failed to unlock %s\n")); if (use_system_pw_file) { v3 = setlocale(0x6, NULL); v1 = 0; if (v3) v1 = strdup(v3); if (v1) setlocale(0x6, "C"); pw_dbname(); syslog(0x3, "failed to unlock %s"); if (v1) { setlocale(0x6, v1); free(v1); } } } closelog(); exit(a0); }
shadow
angr_sailr
static void makeMaps_e(EState *s) { Int32 i; s->nInUse = 0; for (i = 0; i < 256; i++) if (s->inUse[i]) { s->unseqToSeq[i] = s->nInUse; s->nInUse++; } }
void makeMaps_e(struct_2 *a0) { unsigned int v0; struct_2 *v2; unsigned long long v3; unsigned int v4; struct_2 *v5; v2 = a0; a0->field_7c = 0; for (v0 = 0; v0 <= 255; v0 += 1) { v3 = a0[1].padding_0[v0]; if (a0[1].padding_0[v0]) { v4 = a0->field_7c; a0[3].padding_0[v0] = a0->field_7c; v5 = a0; a0->field_7c = v4 + 1; } } return; }
bzip2
angr_phoenix
static SHELL_VAR *init_seconds_var() { SHELL_VAR *v; v = find_variable("SECONDS"); if (v) { if (legal_number(((v)->value), &seconds_value_assigned) == 0) seconds_value_assigned = 0; } do { v = bind_variable("SECONDS", ((v ? ((v)->value) : (char *)((void *)0))), 0); v->dynamic_value = get_seconds; v->assign_func = assign_seconds; } while (0); return v; }
int init_seconds_var(unsigned long a0, unsigned long a1, unsigned long long a2) { struct_0 *v0; void *v2; v0 = find_variable("SECONDS"); if (v0 && !legal_number(v0->field_8, &seconds_value_assigned, a2)) seconds_value_assigned = 0; if (!v0) v2 = 0; else v2 = v0->field_8; v0[0] = bind_variable("SECONDS", v2, 0x0); v0[3] = get_seconds; v0[4] = assign_seconds; return v0; }
bash
angr_phoenix
HIST_ENTRY *current_history(void) { HistEvent ev; if (history(h, &ev, 16, history_offset + 1) != 0) return ((void *)0); rl_he.line = ev.str; rl_he.data = ((void *)0); return &rl_he; }
void current_history(void) { long in_FS_OFFSET; undefined local_28[24]; undefined8 local_10; local_10 = *(undefined8 *)(in_FS_OFFSET + 0x28); history(h, local_28, 0x10, *piRam0000000000103e40 + 1); }
libedit
ghidra
static void channel_before_prepare_io_rdynamic(struct ssh *ssh, Channel *c) { const u_char *p; u_int have, len; int r, ret; have = sshbuf_len(c->output); sshlog("channels.c", __func__, 1610, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "channel %d: pre_rdynamic: have %d", c->self, have); if (c->flags & 0x08) { if ((r = sshbuf_consume(c->output, have)) != 0) sshfatal("channels.c", __func__, 1615, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "channel %d: consume", c->self); rdynamic_close(ssh, c); return; } if (have < 3) return; p = sshbuf_ptr(c->output); switch (p[0]) { case 0x04: ret = channel_decode_socks4(c, c->output, c->input); break; case 0x05: ret = channel_decode_socks5(c, c->output, c->input); break; default: ret = -1; break; } if (ret < 0) { rdynamic_close(ssh, c); } else if (ret == 0) { sshlog("channels.c", __func__, 1639, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "channel %d: pre_rdynamic: need more", c->self); len = sshbuf_len(c->input); if (len > 0 && len < c->remote_window) { if ((r = sshpkt_start(ssh, 94)) != 0 || (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || (r = sshpkt_put_stringb(ssh, c->input)) != 0 || (r = sshpkt_send(ssh)) != 0) { sshfatal("channels.c", __func__, 1647, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "channel %i: rdynamic", c->self); } if ((r = sshbuf_consume(c->input, len)) != 0) sshfatal("channels.c", __func__, 1650, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "channel %d: consume", c->self); c->remote_window -= len; } } else if (rdynamic_connect_finish(ssh, c) < 0) { rdynamic_close(ssh, c); } }
void channel_before_prepare_io_rdynamic(unsigned long long a0, struct_0 *a1) { unsigned long v0; unsigned long v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned int v5; char *v6; unsigned long long v7; unsigned long v8; unsigned long long v10; unsigned long long v11; unsigned long long v12; unsigned long long v15; unsigned long long v16; struct_0 *v17; v4 = sshbuf_len(a1->field_70); v0 = a1->field_4; sshlog("channels.c", "channel_before_prepare_io_rdynamic", 0x64a, 0x0, 0x6, 0x0, "channel %d: pre_rdynamic: have %d"); v10 = a1->field_18 & 8; if ((a1->field_18 & 8)) { v2 = sshbuf_consume(a1->field_70, v4, v4); if (v2) { v1 = a1->field_4; sshfatal("channels.c", "channel_before_prepare_io_rdynamic", 0x64f, 0x1, 0x1, ssh_err(v2)); } v11 = rdynamic_close(a0, a1); } else if (v4 > 2) { v6 = sshbuf_ptr(a1->field_70); if (*(v6) == 4) { v3 = channel_decode_socks4(a1, a1->field_70, a1->field_68); } else if (*(v6) == 5) { v3 = channel_decode_socks5(a1, a1->field_70, a1->field_68); } else { v3 = -1; } if (v3 < 0) { v12 = rdynamic_close(a0, a1); } else if (!v3) { v1 = a1->field_4; sshlog("channels.c", "channel_before_prepare_io_rdynamic", 0x667, 0x0, 0x6, 0x0, "channel %d: pre_rdynamic: need more"); v5 = sshbuf_len(a1->field_68); if (v5) { v16 = a1->field_a8; if (v5 < a1->field_a8) { v2 = sshpkt_start(a0, 0x5e); if (!v2) { v2 = sshpkt_put_u32(a0, a1->field_8, a1->field_8); if (!v2) { v2 = sshpkt_put_stringb(a0, a1->field_68, a1->field_68); if (!v2) v2 = sshpkt_send(a0); } } if (v2 || v2 || v2 || v2) { v1 = a1->field_4; sshfatal("channels.c", "channel_before_prepare_io_rdynamic", 0x66f, 0x1, 0x1, ssh_err(v2)); } v2 = sshbuf_consume(a1->field_68, v5, v5); if (v2) { v8 = a1->field_4; v7 = "channel %d: consume"; sshfatal("channels.c", "channel_before_prepare_io_rdynamic", 0x672, 0x1, 0x1, ssh_err(v2)); } v17 = a1; a1->field_a8 = a1->field_a8 - v5; } } } else if (rdynamic_connect_finish(a0, a1) < 0) { v15 = rdynamic_close(a0, a1); } } return; }
openssh-portable
angr_dream
char *get_word_from_string(stringp, separators, endptr) char **stringp, *separators, **endptr; { register char *s; char *current_word; int sindex, sh_style_split, whitesep, xflags; unsigned char local_cmap[(0x7f * 2 + 1) + 1]; size_t slen; if (!stringp || !*stringp || !**stringp) return ((char *)((void *)0)); sh_style_split = separators && separators[0] == ' ' && separators[1] == '\t' && separators[2] == '\n' && separators[3] == '\0'; memset(local_cmap, '\0', sizeof(local_cmap)); for (xflags = 0, s = separators; s && *s; s++) { if (*s == '\001') xflags |= 0x0010; if (*s == '\177') xflags |= 0x0020; local_cmap[(unsigned char)*s] = 1; } s = *stringp; slen = 0; if (sh_style_split || separators == 0) for (; *s && ((*s) == ' ' || (*s) == '\t' || (*s) == '\n') && (local_cmap[(unsigned char)(*s)] != 0); s++) ; else for (; *s && (1 && ((*__ctype_b_loc())[(int)(((unsigned char)*s))] & (unsigned short int)_ISspace)) && (local_cmap[(unsigned char)(*s)] != 0); s++) ; if (!*s) { *stringp = s; if (endptr) *endptr = s; return ((char *)((void *)0)); } sindex = 0; slen = (((s) && (s)[0]) ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0); current_word = string_extract_verbatim(s, slen, &sindex, separators, xflags); if (endptr) *endptr = s + sindex; whitesep = s[sindex] && ((sh_style_split || separators == 0) ? ((s[sindex]) == ' ' || (s[sindex]) == '\t' || (s[sindex]) == '\n') : (1 && ((*__ctype_b_loc())[(int)(((unsigned char)s[sindex]))] & (unsigned short int)_ISspace))); if (s[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((s)[sindex]); if (_f) mblength = 1; else if (locale_utf8locale && (((s)[sindex] & 0x80) == 0)) mblength = (s)[sindex] != 0; else { state_bak = state; mblength = mbrlen((s) + (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 (s[sindex] && ((s[sindex]) == ' ' || (s[sindex]) == '\t' || (s[sindex]) == '\n') && (local_cmap[(unsigned char)(s[sindex])] != 0)) sindex++; if (s[sindex] && whitesep && (local_cmap[(unsigned char)(s[sindex])] != 0) && !((sh_style_split || separators == 0) ? ((s[sindex]) == ' ' || (s[sindex]) == '\t' || (s[sindex]) == '\n') : (1 && ((*__ctype_b_loc())[(int)(((unsigned char)s[sindex]))] & (unsigned short int)_ISspace)))) { sindex++; while (s[sindex] && ((sh_style_split || separators == 0) ? ((s[sindex]) == ' ' || (s[sindex]) == '\t' || (s[sindex]) == '\n') : (1 && ((*__ctype_b_loc())[(int)(((unsigned char)s[sindex]))] & (unsigned short int)_ISspace))) && (local_cmap[(unsigned char)(s[sindex])] != 0)) sindex++; } *stringp = s + sindex; return (current_word); }
char *get_word_from_string(const char **a1, const char *a2, const char **a3) { _BOOL4 v4; const char *i; const char *v6; unsigned long v7; int v9; bool v10; signed int v13; int v14; _BOOL4 v15; int v16; unsigned long v18; unsigned long v19; char *v20; mbstate_t ps; mbstate_t v22; char s[264]; unsigned long v24; v24 = __readfsqword(0x28u); if (!a1 || !*a1 || !**a1) return 0LL; v4 = a2 && *a2 == 32 && a2[1] == 9 && a2[2] == 10 && !a2[3]; v15 = v4; memset(s, 0, 0x100uLL); v14 = 0; for (i = a2; i && *i; ++i) { if (*i == 1) v14 |= 0x10u; if (*i == 127) v14 |= 0x20u; s[*(unsigned char *)i] = 1; } v6 = *a1; v19 = 0LL; if (!v15 && a2) { while (*v6 && ((*_ctype_b_loc())[*(unsigned char *)v6] & 0x2000) != 0 && s[*(unsigned char *)v6]) ++v6; } else { while (*v6 && (*v6 == 32 || *v6 == 9 || *v6 == 10) && s[*(unsigned char *)v6]) ++v6; } if (!*v6) { *a1 = v6; if (a3) *a3 = v6; return 0LL; } v13 = 0; if (v6 && *v6) { if (v6[1]) { if (v6[2]) v7 = strlen(v6); else v7 = 2LL; } else { v7 = 1LL; } } else { v7 = 0LL; } v19 = v7; v20 = string_extract_verbatim((long)v6, v7, &v13, a2, v14); if (a3) *a3 = &v6[v13]; if (!v6[v13]) goto LABEL_60; if (v15 || !a2) { if (v6[v13] == 32 || v6[v13] == 9 || v6[v13] == 10) goto LABEL_59; LABEL_60: v9 = 0; goto LABEL_61; } if (((*_ctype_b_loc())[(unsigned char)v6[v13]] & 0x2000) == 0) goto LABEL_60; LABEL_59: v9 = 1; LABEL_61: v16 = v9; if (v6[v13]) { memset(&ps, 0, sizeof(ps)); if (locale_mb_cur_max <= 1) { ++v13; } else { if ((unsigned int)is_basic(v6[v13])) { v18 = 1LL; } else if (locale_utf8locale && v6[v13] >= 0) { v18 = v6[v13] != 0; } else { v22 = ps; v18 = mbrlen(&v6[v13], v19 - v13, &ps); } if (v18 < 0xFFFFFFFFFFFFFFFELL) { if (v18) v13 += v18; else ++v13; } else { ps = v22; ++v13; } } } while (v6[v13] && (v6[v13] == 32 || v6[v13] == 9 || v6[v13] == 10) && s[(unsigned char)v6[v13]]) ++v13; if (v6[v13] && v16 && s[(unsigned char)v6[v13]]) { if (!v15 && a2) v10 = ((*_ctype_b_loc())[(unsigned char)v6[v13]] & 0x2000) == 0; else v10 = v6[v13] != 32 && v6[v13] != 9 && v6[v13] != 10; if (v10) { ++v13; while (v6[v13]) { if (!v15 && a2) { if (((*_ctype_b_loc())[(unsigned char)v6[v13]] & 0x2000) == 0) break; } else if (v6[v13] != 32 && v6[v13] != 9 && v6[v13] != 10) { break; } if (!s[(unsigned char)v6[v13]]) break; ++v13; } } } *a1 = &v6[v13]; return v20; }
bash
ida
static int _rl_insert_next(int count) { int c; (rl_readline_state |= (0x0000040)); c = rl_read_key(); (rl_readline_state &= ~(0x0000040)); if (c < 0) return 1; if ((rl_readline_state & (0x0001000))) _rl_add_macro_char(c); if ((rl_readline_state & (0x0080000)) == 0) _rl_restore_tty_signals(); return (_rl_insert_char(count, c)); }
int _rl_insert_next(unsigned long a0) { unsigned int v0; unsigned int v2; rl_readline_state = rl_readline_state | 64; v0 = rl_read_key(); rl_readline_state = rl_readline_state & -65; if (v0 < 0) { v2 = 1; } else { if ((rl_readline_state & 0x1000)) _rl_add_macro_char(v0); if (!(rl_readline_state & 0x80000)) _rl_restore_tty_signals(); v2 = _rl_insert_char(a0, v0); } return v2; }
bash
angr_phoenix
static inline SHELL_VAR *set_int_value(SHELL_VAR *var, intmax_t value, int flags) { char *p; p = itos(value); do { if (((var)->value)) sh_xfree((((var)->value)), "variables.c", 1319); } while (0); ((var)->value = (p)); if (flags & 1) ((var)->attributes |= (0x0000010)); return (var); }
void set_int_value(struct_0 *a0, unsigned long long a1, unsigned long a2) { unsigned long v0; struct_0 *v2; v0 = itos(a1); if (a0->field_8) sh_xfree(a0->field_8, "variables.c", 0x527); a0->field_8 = v0; if ((a2 & 1)) a0->field_28 = a0->field_28 | 16; v2 = a0; return; }
bash
angr_sailr
const char *zlibVersion() { return "1.2.13"; }
const char *zlibVersion() { return "1.2.13"; }
zlib
ida
static _Bool check_label_pattern(const char *label) { char *string; _Bool result = 0; if (fnmatch(volume_label_option, label, 0) == 0) return 1; if (!multi_volume_option) return 0; string = drop_volume_label_suffix(label); if (string) { result = fnmatch(string, volume_label_option, 0) == 0; free(string); } return result; }
int check_label_pattern(void *a0) { char v0; void *v1; unsigned int v3; v0 = 0; v3 = fnmatch(volume_label_option, a0, 0x0); if (!v3) { v3 = 1; } else if ((multi_volume_option ^ 1)) { v3 = 0; } else { v1 = drop_volume_label_suffix(a0); if (v1) { v0 = !fnmatch(v1, volume_label_option, 0x0); free(v1); } v3 = v0; } return v3; }
tar
angr_dream
static Channel *client_request_x11(struct ssh *ssh, const char *request_type, int rchan) { Channel *c = ((void *)0); char *originator; u_int originator_port; int r, sock; if (!options.forward_x11) { sshlog("clientloop.c", __func__, 1551, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Warning: ssh server tried X11 forwarding."); sshlog("clientloop.c", __func__, 1552, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Warning: this is probably a break-in attempt by a " "malicious server."); return ((void *)0); } if (x11_refuse_time != 0 && (u_int)monotime() >= x11_refuse_time) { sshlog("clientloop.c", __func__, 1557, 0, SYSLOG_LEVEL_VERBOSE, ((void *)0), "Rejected X11 connection after ForwardX11Timeout " "expired"); return ((void *)0); } if ((r = sshpkt_get_cstring(ssh, &originator, ((void *)0))) != 0 || (r = sshpkt_get_u32(ssh, &originator_port)) != 0 || (r = sshpkt_get_end(ssh)) != 0) sshfatal("clientloop.c", __func__, 1564, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse packet"); sshlog("clientloop.c", __func__, 1567, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "client_request_x11: request from %s %u", originator, originator_port); free(originator); sock = x11_connect_display(ssh); if (sock < 0) return ((void *)0); c = channel_new(ssh, "x11", 7, sock, sock, -1, (64 * (32 * 1024)), (16 * 1024), 0, "x11", 1); c->force_drain = 1; return c; }
long client_request_x11(long a1) { long v2; unsigned int v3; unsigned int cstring; unsigned int v5; void *ptr; long v7; unsigned long v8; v8 = __readfsqword(0x28u); v7 = 0LL; if (options[4]) { if (x11_refuse_time && (unsigned int)monotime() >= x11_refuse_time) { sshlog("clientloop.c", "client_request_x11", 1557LL, 0LL, 4LL, 0LL, "Rejected X11 connection after ForwardX11Timeout expired"); return 0LL; } else { cstring = sshpkt_get_cstring(a1, &ptr, 0LL); if (cstring || (cstring = sshpkt_get_u32(a1, &v3)) != 0 || (cstring = sshpkt_get_end(a1)) != 0) { v2 = ssh_err(cstring); sshfatal("clientloop.c", "client_request_x11", 1564LL, 1LL, 1LL, v2, "parse packet"); } sshlog("clientloop.c", "client_request_x11", 1567LL, 0LL, 5LL, 0LL, "client_request_x11: request from %s %u", (const char *)ptr, v3); free(ptr); v5 = x11_connect_display(a1); if ((v5 & 0x80000000) == 0) { v7 = channel_new(a1, "x11", 7LL, v5, v5, 0xFFFFFFFFLL, 0x200000LL, 0x4000LL, 0LL, "x11", 1LL); *(_DWORD *)(v7 + 80) = 1; return v7; } else { return 0LL; } } } else { sshlog("clientloop.c", "client_request_x11", 1551LL, 0LL, 2LL, 0LL, "Warning: ssh server tried X11 forwarding."); sshlog( "clientloop.c", "client_request_x11", 1552LL, 0LL, 2LL, 0LL, "Warning: this is probably a break-in attempt by a malicious server."); return 0LL; } }
openssh-portable
ida
void sh_set_lines_and_columns(int lines, int cols) { sprintf(setenv_buf, "%d", lines); setenv("LINES", setenv_buf, 1); sprintf(setenv_buf, "%d", cols); setenv("COLUMNS", setenv_buf, 1); }
int sh_set_lines_and_columns(unsigned int a1, unsigned int a2) { sprintf(setenv_buf, "%d", a1); setenv("LINES", setenv_buf, 1); sprintf(setenv_buf, "%d", a2); return setenv("COLUMNS", setenv_buf, 1); }
bash
ida
const char *strxf_xfrmproto(__u8 proto) { static char str[16]; int i; for (i = 0;; i++) { const struct typeent *t = &xfrmproto_types[i]; if (!t->t_name || t->t_type == -1) break; if (t->t_type == proto) return t->t_name; } sprintf(str, "%u", proto); return str; }
undefined1 *strxf_xfrmproto(byte param_1) { long lVar1; int local_14; local_14 = 0; while (true) { lVar1 = (long)local_14 * 0x10; if ((*(long *)(xfrmproto_types + lVar1) == 0) || (*(int *)(xfrmproto_types + lVar1 + 8) == -1)) break; if (*(uint *)(xfrmproto_types + lVar1 + 8) == (uint)param_1) { return *(undefined1 **)(xfrmproto_types + lVar1); } local_14 = local_14 + 1; } sprintf(str_9239, "%u", (ulong)param_1); return str_9239; }
iproute2-6.0.0
ghidra
static int scpio(void *_cnt, size_t s) { off_t *cnt = (off_t *)_cnt; *cnt += s; refresh_progress_meter(0); if (limit_kbps > 0) bandwidth_limit(&bwlimit, s); return 0; }
long long scpio(unsigned long long *a0, unsigned long long a1) { *(a0) = a1 + *(a0); refresh_progress_meter(0x0); if (limit_kbps > 0) bandwidth_limit(&cmd, a1); return 0; }
openssh-portable
angr_dream
static _Bool decode_one_format(char const *s_orig, char const *s, char const **next, struct tspec *tspec) { enum size_spec size_spec; unsigned long int size; enum output_format fmt; void (*print_function)(size_t, size_t, void const *, char const *, int, int); char const *p; char c; int field_width; ((void)sizeof((tspec != ((void *)0)) ? 1 : 0), __extension__({ if (tspec != ((void *)0)) ; else __assert_fail("tspec != NULL", "src/od.c", 648, __extension__ __PRETTY_FUNCTION__); })); switch (*s) { case 'd': case 'o': case 'u': case 'x': c = *s; ++s; switch (*s) { case 'C': ++s; size = sizeof(char); break; case 'S': ++s; size = sizeof(short int); break; case 'I': ++s; size = sizeof(int); break; case 'L': ++s; size = sizeof(long int); break; default: if (!simple_strtoul(s, &p, &size)) { error(0, 0, gettext("invalid type string %s"), quote(s_orig)); return 0; } if (p == s) size = sizeof(int); else { if (sizeof(unsigned_long_long_int) < size || integral_type_size[size] == NO_SIZE) { error(0, 0, gettext("invalid type string %s;\nthis system" " doesn't provide a %lu-byte integral type"), quote(s_orig), size); return 0; } s = p; } break; } size_spec = integral_type_size[size]; switch (c) { case 'd': fmt = SIGNED_DECIMAL; field_width = bytes_to_signed_dec_digits[size]; sprintf(tspec->fmt_string, "%%*%s", ((size_spec) == LONG_LONG ? ("l" "d") : ((size_spec) == LONG ? ("ld") : ("d")))); break; case 'o': fmt = OCTAL; sprintf(tspec->fmt_string, "%%*.%d%s", (field_width = bytes_to_oct_digits[size]), ((size_spec) == LONG_LONG ? ("l" "o") : ((size_spec) == LONG ? ("lo") : ("o")))); break; case 'u': fmt = UNSIGNED_DECIMAL; field_width = bytes_to_unsigned_dec_digits[size]; sprintf(tspec->fmt_string, "%%*%s", ((size_spec) == LONG_LONG ? ("l" "u") : ((size_spec) == LONG ? ("lu") : ("u")))); break; case 'x': fmt = HEXADECIMAL; sprintf(tspec->fmt_string, "%%*.%d%s", (field_width = bytes_to_hex_digits[size]), ((size_spec) == LONG_LONG ? ("l" "x") : ((size_spec) == LONG ? ("lx") : ("x")))); break; default: abort(); } ((void)sizeof((strlen(tspec->fmt_string) < FMT_BYTES_ALLOCATED) ? 1 : 0), __extension__({ if (strlen(tspec->fmt_string) < FMT_BYTES_ALLOCATED) ; else __assert_fail("strlen (tspec->fmt_string) < FMT_BYTES_ALLOCATED", "src/od.c", 747, __extension__ __PRETTY_FUNCTION__); })); switch (size_spec) { case CHAR: print_function = (fmt == SIGNED_DECIMAL ? print_s_char : print_char); break; case SHORT: print_function = (fmt == SIGNED_DECIMAL ? print_s_short : print_short); break; case INT: print_function = print_int; break; case LONG: print_function = print_long; break; case LONG_LONG: print_function = print_long_long; break; default: abort(); } break; case 'f': fmt = FLOATING_POINT; ++s; switch (*s) { case 'F': ++s; size = sizeof(float); break; case 'D': ++s; size = sizeof(double); break; case 'L': ++s; size = sizeof(long double); break; default: if (!simple_strtoul(s, &p, &size)) { error(0, 0, gettext("invalid type string %s"), quote(s_orig)); return 0; } if (p == s) size = sizeof(double); else { if (size > sizeof(long double) || fp_type_size[size] == NO_SIZE) { error(0, 0, gettext("invalid type string %s;\n" "this system doesn't provide a %lu-byte" " floating point type") , quote(s_orig), size); return 0; } s = p; } break; } size_spec = fp_type_size[size]; { struct lconv const *locale = localeconv(); size_t decimal_point_len = (locale->decimal_point[0] ? strlen(locale->decimal_point) : 1); switch (size_spec) { case FLOAT_SINGLE: print_function = print_float; field_width = (1 + (((((24) * 1) * 146 + 484) / 485) + 1) + decimal_point_len + 1 + (-100 < ((-37)) && (38) < 100 ? 3 : -1000 < ((-37)) && (38) < 1000 ? 4 : -10000 < ((-37)) && (38) < 10000 ? 5 : -100000 < ((-37)) && (38) < 100000 ? 6 : -1000000 < ((-37)) && (38) < 1000000 ? 7 : (((((sizeof(int) * 8) - (!((__typeof__(int))0 < (__typeof__(int))-1))) * 146 + 484) / 485) + (!((__typeof__(int))0 < (__typeof__(int))-1))))); break; case FLOAT_DOUBLE: print_function = print_double; field_width = (1 + (((((53) * 1) * 146 + 484) / 485) + 1) + decimal_point_len + 1 + (-100 < ((-307)) && (308) < 100 ? 3 : -1000 < ((-307)) && (308) < 1000 ? 4 : -10000 < ((-307)) && (308) < 10000 ? 5 : -100000 < ((-307)) && (308) < 100000 ? 6 : -1000000 < ((-307)) && (308) < 1000000 ? 7 : (((((sizeof(int) * 8) - (!((__typeof__(int))0 < (__typeof__(int))-1))) * 146 + 484) / 485) + (!((__typeof__(int))0 < (__typeof__(int))-1))))); break; case FLOAT_LONG_DOUBLE: print_function = print_long_double; field_width = (1 + (((((64) * 1) * 146 + 484) / 485) + 1) + decimal_point_len + 1 + (-100 < ((-4931)) && (4932) < 100 ? 3 : -1000 < ((-4931)) && (4932) < 1000 ? 4 : -10000 < ((-4931)) && (4932) < 10000 ? 5 : -100000 < ((-4931)) && (4932) < 100000 ? 6 : -1000000 < ((-4931)) && (4932) < 1000000 ? 7 : (((((sizeof(int) * 8) - (!((__typeof__(int))0 < (__typeof__(int))-1))) * 146 + 484) / 485) + (!((__typeof__(int))0 < (__typeof__(int))-1))))); break; default: abort(); } break; } case 'a': ++s; fmt = NAMED_CHARACTER; size_spec = CHAR; print_function = print_named_ascii; field_width = 3; break; case 'c': ++s; fmt = CHARACTER; size_spec = CHAR; print_function = print_ascii; field_width = 3; break; default: error(0, 0, gettext("invalid character '%c' in type string %s"), *s, quote(s_orig)); return 0; } tspec->size = size_spec; tspec->fmt = fmt; tspec->print_function = print_function; tspec->field_width = field_width; tspec->hexl_mode_trailer = (*s == 'z'); if (tspec->hexl_mode_trailer) s++; if (next != ((void *)0)) *next = s; return 1; }
int decode_one_format(unsigned long long a0, unsigned long a1, unsigned long long *a2, struct_0 *a3) { char *v0; char v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned long long v5; char v6; unsigned long long v7; char **v8; unsigned long long v9; unsigned long long v11; unsigned long long v12; unsigned long long v14; unsigned long long v16; unsigned long long v17; unsigned long long v18; unsigned int v19; unsigned int v20; unsigned int v21; unsigned int v22; v0 = a1; if (!a3) __assert_fail(); switch (*(v0)) { case 97: v0 += 1; v3 = 5; v2 = 1; v7 = print_named_ascii; v4 = 3; case 99: v0 += 1; v3 = 6; v2 = 1; v7 = print_ascii; v4 = 3; case 100: case 111: case 117: case 120: v1 = *(v0); v0 += 1; if (*(v0) == 83) { v0 += 1; v5 = 2; break; v2 = integral_type_size[v5]; if (v1 != 120) { if (v1 <= 120) { if (v1 != 117) { if (v1 <= 117) { if (v1 == 100) { v3 = 0; v4 = *((4 * v5 + &bytes_to_signed_dec_digits)); if (v2 != 5) { if (v2 == 4) v21 = "ld"; else v21 = "d"; } else { v21 = &g_4056d5; } sprintf(&a3->padding_10, "%%*%s", v21); } if (v1 == 111) { v3 = 2; if (v2 != 5) { if (v2 == 4) v22 = "lo"; else v22 = "o"; } else { v22 = &g_4056e0; } v4 = *((4 * v5 + &bytes_to_oct_digits)); sprintf(&a3->padding_10, "%%*.%d%s", v4, v22); } } } else { v3 = 1; v4 = *((4 * v5 + &bytes_to_unsigned_dec_digits)); if (v2 != 5) { if (v2 == 4) v20 = "lu"; else v20 = "u"; } else { v20 = &g_4056ee; } sprintf(&a3->padding_10, "%%*%s", v20); } } if ((v1 != 117 || v1 > 120) && (v1 > 120 || v1 > 117 || v1 != 100) && (v1 > 120 || v1 > 117 || v1 != 111)) abort(); } else { v3 = 3; if (v2 != 5) { if (v2 == 4) v19 = "lx"; else v19 = "x"; } else { v19 = &g_4056f3; } v4 = *((4 * v5 + &bytes_to_hex_digits)); sprintf(&a3->padding_10, "%%*.%d%s", v4, v19); v12 = strlen(&a3->padding_10); if (v12 > 7) __assert_fail(); } } else if (*(v0) <= 83) { if (*(v0) == 76) { v0 += 1; v5 = 8; break; } else if (*(v0) <= 76) { if (*(v0) == 67) { v0 += 1; v5 = 1; break; } if (*(v0) == 73) { v0 += 1; v5 = 4; break; } } } else { if ((simple_strtoul(v0, &v6, &v5) ^ 1)) { v16 = quote(a0); error(0x0, 0x0, gettext("invalid type string %s")); v12 = 0; } else if (v0 == *(&v6)) { v5 = 4; break; } else { if (v5 <= 8 && integral_type_size[v5]) v0 = *(&v6); if (!integral_type_size[v5] || v5 > 8) { v18 = quote(a0); error(0x0, 0x0, gettext("invalid type string %s;\nthis system doesn't provide " "a %lu-byte integral type")); v12 = 0; } } } case 102: v3 = 4; v0 += 1; if (*(v0) == 76) { v0 += 1; v5 = 16; v2 = fp_type_size[v5]; v8 = &localeconv()->decimal_point; if (*(*(v8))) v12 = strlen(*(v8)); else v12 = 1; v9 = v12; if (v2 != 8) { if (v2 <= 8) { if (v2 == 6) { v7 = print_float; v4 = v9 + 14; } if (v2 == 7) { v7 = print_double; v4 = v9 + 23; } } if ((v2 > 8 || v2 != 6) && (v2 != 7 || v2 > 8)) abort(); } else { v7 = print_long_double; v4 = v9 + 28; } } else if (*(v0) <= 76) { if (*(v0) == 68) { v0 += 1; v5 = 8; } if (*(v0) == 70) { v0 += 1; v5 = 4; } } else if ((simple_strtoul(v0, &v6, &v5) ^ 1)) { v14 = quote(a0); error(0x0, 0x0, gettext("invalid type string %s")); v12 = 0; } else if (v0 == *(&v6)) { v5 = 8; } else { if (v5 <= 16 && fp_type_size[v5]) v0 = *(&v6); if (!fp_type_size[v5] || v5 > 16) { v17 = quote(a0); error(0x0, 0x0, gettext("invalid type string %s;\nthis system doesn't provide a " "%lu-byte floating point type")); v12 = 0; } } default: v11 = quote(a0); error(0x0, 0x0, gettext("invalid character '%c' in type string %s")); v12 = 0; } v7 = print_long_long; v7 = print_int; v7 = print_long; abort(); if (true) { if (!v3) v12 = print_s_char; else v12 = print_char; } v7 = v12; if (true) { if (!v3) v12 = print_s_short; else v12 = print_short; } v7 = v12; a3->field_4 = v2; a3->field_0 = v3; a3->field_8 = v7; a3->field_1c = v4; a3->field_18 = *(v0) == 122; if (a3->field_18) v0 += 1; if (a2) *(a2) = v0; v12 = 1; return v12; }
coreutils
angr_dream
static int check_selinux_attr(char const *name, struct error_context *ctx) { return strncmp(name, "" "security.selinux" "", sizeof("security.selinux") - 1) && attr_copy_check_permissions(name, ctx); }
long long check_selinux_attr(char *a0, unsigned long long a1) { unsigned long long v1; if (strncmp(a0, "security.selinux", 0x10) && attr_copy_check_permissions(a0, a1, a1)) { v1 = 1; goto LABEL_4012b7; } v1 = 0; LABEL_4012b7: return v1; }
coreutils
angr_phoenix
char *phash_search(filename) const char *filename; { register BUCKET_CONTENTS *item; char *path, *dotted_filename, *tail; int same; if (hashing_enabled == 0 || hashed_filenames == 0) return ((char *)((void *)0)); item = hash_search(filename, hashed_filenames, 0); if (item == ((void *)0)) return ((char *)((void *)0)); path = ((PATH_DATA *)(item)->data)->path; if (((PATH_DATA *)(item)->data)->flags & (0x02 | 0x01)) { tail = (((PATH_DATA *)(item)->data)->flags & 0x01) ? path : (char *)filename; if (tail[0] != '.' || tail[1] != '/') { dotted_filename = (char *)sh_xmalloc((3 + strlen(tail)), "hashcmd.c", 152); dotted_filename[0] = '.'; dotted_filename[1] = '/'; strcpy(dotted_filename + 2, tail); } else dotted_filename = (char *)strcpy( sh_xmalloc((1 + strlen(tail)), "hashcmd.c", 157), (tail)); if (executable_file(dotted_filename)) return (dotted_filename); sh_xfree((dotted_filename), "hashcmd.c", 162); if (*path == '.') { same = 0; tail = (char *)strrchr(path, '/'); if (tail) { *tail = '\0'; same = same_file(".", path, (struct stat *)((void *)0), (struct stat *)((void *)0)); *tail = '/'; } return same ? (char *)((void *)0) : (char *)strcpy( sh_xmalloc((1 + strlen(path)), "hashcmd.c", 190), (path)); } } return ( (char *)strcpy(sh_xmalloc((1 + strlen(path)), "hashcmd.c", 194), (path))); }
long long phash_search(unsigned long long a0) { unsigned int v0; char v1[2]; char *v2; char v3[2]; void *v5; struct_0 *v6; if (!hashing_enabled) { v5 = 0; return v5; } else if (!hashed_filenames) { v5 = 0; return v5; } else { v6 = hash_search(a0, hashed_filenames, 0x0, hashed_filenames); if (!v6) { v5 = 0; return v5; } v2 = v6->field_10->field_0; if ((v6->field_10->field_8 & 3)) { *(&v3) = (!(v6->field_10->field_8 & 1) ? v2 : a0); if (v3[0] != 46 || v3[1] != 47) { *(&v1) = sh_xmalloc(strlen(v3) + 3, "hashcmd.c", 0x98); v1[0] = 46; v1[1] = 47; strcpy(v1 + 1, v3); } else { *(&v1) = strcpy(sh_xmalloc(strlen(v3) + 1, "hashcmd.c", 0x9d), v3); } if (executable_file(v1)) { v5 = v1; return v5; } sh_xfree(v1, "hashcmd.c", 0xa2); if (*(v2) == 46) { v0 = 0; v3 = strrchr(v2, 0x2f); if (v3) { *(v3) = 0; v0 = same_file(".", v2, 0x0, 0x0); *(v3) = 47; } if (v0) { v5 = 0; return v5; } v5 = strcpy(sh_xmalloc(strlen(v2) + 1, "hashcmd.c", 0xbe), v2); return v5; } } v5 = strcpy(sh_xmalloc(strlen(v2) + 1, "hashcmd.c", 0xc2), v2); return v5; } }
bash
angr_sailr
int parse_absolute_time(const char *s, uint64_t *tp) { struct tm tm; time_t tt; char buf[32], *fmt; const char *cp; size_t l; int is_utc = 0; *tp = 0; l = strlen(s); if (l > 1 && strcasecmp(s + l - 1, "Z") == 0) { is_utc = 1; l--; } else if (l > 3 && strcasecmp(s + l - 3, "UTC") == 0) { is_utc = 1; l -= 3; } switch (l) { case 8: fmt = "%Y-%m-%d"; snprintf(buf, sizeof(buf), "%.4s-%.2s-%.2s", s, s + 4, s + 6); break; case 12: fmt = "%Y-%m-%dT%H:%M"; snprintf(buf, sizeof(buf), "%.4s-%.2s-%.2sT%.2s:%.2s", s, s + 4, s + 6, s + 8, s + 10); break; case 14: fmt = "%Y-%m-%dT%H:%M:%S"; snprintf(buf, sizeof(buf), "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", s, s + 4, s + 6, s + 8, s + 10, s + 12); break; default: return -4; } memset(&tm, 0, sizeof(tm)); if ((cp = strptime(buf, fmt, &tm)) == ((void *)0) || *cp != '\0') return -4; if (is_utc) { if ((tt = timegm(&tm)) < 0) return -4; } else { if ((tt = mktime(&tm)) < 0) return -4; } *tp = (uint64_t)tt; return 0; }
undefined8 parse_absolute_time(char *param_1, time_t *param_2) { bool bVar1; int iVar2; char *pcVar3; long in_FS_OFFSET; undefined8 uVar4; time_t local_98; char *local_90; ulong local_88; tm local_78; char local_38[40]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); bVar1 = false; *param_2 = 0; uVar4 = 0x1066cc; local_88 = strlen(param_1); if (local_88 < 2) { LAB_0010670d: if (3 < local_88) { uVar4 = 0x106735; iVar2 = strcasecmp(param_1 + (local_88 - 3), "UTC"); if (iVar2 == 0) { bVar1 = true; local_88 = local_88 - 3; } } } else { uVar4 = 0x1066f8; iVar2 = strcasecmp(param_1 + (local_88 - 1), "Z"); if (iVar2 != 0) goto LAB_0010670d; bVar1 = true; local_88 = local_88 - 1; } if (local_88 == 0xe) { local_90 = "%Y-%m-%dT%H:%M:%S"; snprintf(local_38, 0x20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", param_1, param_1 + 4, param_1 + 6, param_1 + 8, param_1 + 10, param_1 + 0xc, uVar4); } else { if (0xe < local_88) { LAB_001068b2: uVar4 = 0xfffffffc; goto LAB_00106970; } if (local_88 == 8) { local_90 = "%Y-%m-%d"; snprintf(local_38, 0x20, "%.4s-%.2s-%.2s", param_1, param_1 + 4, param_1 + 6); } else { if (local_88 != 0xc) goto LAB_001068b2; local_90 = "%Y-%m-%dT%H:%M"; snprintf(local_38, 0x20, "%.4s-%.2s-%.2sT%.2s:%.2s", param_1, param_1 + 4, param_1 + 6, param_1 + 8, param_1 + 10); } } memset(&local_78, 0, 0x38); pcVar3 = strptime(local_38, local_90, &local_78); if ((pcVar3 == (char *)0x0) || (*pcVar3 != '\0')) { uVar4 = 0xfffffffc; } else { if (bVar1) { local_98 = timegm(&local_78); if (local_98 < 0) { uVar4 = 0xfffffffc; goto LAB_00106970; } } else { local_98 = mktime(&local_78); if (local_98 < 0) { uVar4 = 0xfffffffc; goto LAB_00106970; } } *param_2 = local_98; uVar4 = 0; } LAB_00106970: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return uVar4; } __stack_chk_fail(); }
openssh-portable
ghidra
static int parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd, const char *startdir, int err_abort, int echo_command) { const char *ocmd = cmd; char *path1, *path2, *tmp; int ignore_errors = 0, disable_echo = 1; int aflag = 0, fflag = 0, hflag = 0, iflag = 0; int lflag = 0, pflag = 0, rflag = 0, sflag = 0; int cmdnum, i; unsigned long n_arg = 0; Attrib a, *aa; char path_buf[4096]; int err = 0; _ssh_compat_glob_t g; path1 = path2 = ((void *)0); cmdnum = parse_args(&cmd, &ignore_errors, &disable_echo, &aflag, &fflag, &hflag, &iflag, &lflag, &pflag, &rflag, &sflag, &n_arg, &path1, &path2); if (ignore_errors != 0) err_abort = 0; if (echo_command && !disable_echo) mprintf("sftp> %s\n", ocmd); memset(&g, 0, sizeof(g)); switch (cmdnum) { case 0: break; case -1: err = -1; break; case I_REGET: aflag = 1; case I_GET: err = process_get(conn, path1, path2, *pwd, pflag, rflag, aflag, fflag); break; case I_REPUT: aflag = 1; case I_PUT: err = process_put(conn, path1, path2, *pwd, pflag, rflag, aflag, fflag); break; case I_COPY: path1 = make_absolute(path1, *pwd); path2 = make_absolute(path2, *pwd); err = do_copy(conn, path1, path2); break; case I_RENAME: path1 = make_absolute(path1, *pwd); path2 = make_absolute(path2, *pwd); err = do_rename(conn, path1, path2, lflag); break; case I_SYMLINK: sflag = 1; case I_LINK: if (!sflag) path1 = make_absolute(path1, *pwd); path2 = make_absolute(path2, *pwd); err = (sflag ? do_symlink : do_hardlink)(conn, path1, path2); break; case I_RM: path1 = make_absolute_pwd_glob(path1, *pwd); remote_glob(conn, path1, 0x0010, ((void *)0), &g); for (i = 0; g.gl_pathv[i] && !interrupted; i++) { if (!quiet) mprintf("Removing %s\n", g.gl_pathv[i]); err = do_rm(conn, g.gl_pathv[i]); if (err != 0 && err_abort) break; } break; case I_MKDIR: path1 = make_absolute(path1, *pwd); attrib_clear(&a); a.flags |= 0x00000004; a.perm = 0777; err = do_mkdir(conn, path1, &a, 1); break; case I_RMDIR: path1 = make_absolute(path1, *pwd); err = do_rmdir(conn, path1); break; case I_CHDIR: if (path1 == ((void *)0) || *path1 == '\0') path1 = xstrdup(startdir); path1 = make_absolute(path1, *pwd); if ((tmp = do_realpath(conn, path1)) == ((void *)0)) { err = 1; break; } if ((aa = do_stat(conn, tmp, 0)) == ((void *)0)) { free(tmp); err = 1; break; } if (!(aa->flags & 0x00000004)) { sshlog("sftp.c", __func__, 1639, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Can't change directory: Can't check target"); free(tmp); err = 1; break; } if (!((((aa->perm)) & 0170000) == (0040000))) { sshlog("sftp.c", __func__, 1645, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Can't change directory: \"%s\" is not " "a directory", tmp); free(tmp); err = 1; break; } free(*pwd); *pwd = tmp; break; case I_LS: if (!path1) { do_ls_dir(conn, *pwd, *pwd, lflag); break; } tmp = ((void *)0); if (!path_absolute(path1)) tmp = *pwd; path1 = make_absolute_pwd_glob(path1, *pwd); err = do_globbed_ls(conn, path1, tmp, lflag); break; case I_DF: if (path1 == ((void *)0)) path1 = xstrdup(*pwd); path1 = make_absolute(path1, *pwd); err = do_df(conn, path1, hflag, iflag); break; case I_LCHDIR: if (path1 == ((void *)0) || *path1 == '\0') path1 = xstrdup("~"); tmp = tilde_expand_filename(path1, getuid()); free(path1); path1 = tmp; if (chdir(path1) == -1) { sshlog("sftp.c", __func__, 1682, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Couldn't change local directory to " "\"%s\": %s", path1, strerror((*__errno_location()))); err = 1; } break; case I_LMKDIR: if (mkdir(path1, 0777) == -1) { sshlog("sftp.c", __func__, 1689, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Couldn't create local directory " "\"%s\": %s", path1, strerror((*__errno_location()))); err = 1; } break; case I_LLS: local_do_ls(cmd); break; case I_SHELL: local_do_shell(cmd); break; case I_LUMASK: umask(n_arg); printf("Local umask: %03lo\n", n_arg); break; case I_CHMOD: path1 = make_absolute_pwd_glob(path1, *pwd); attrib_clear(&a); a.flags |= 0x00000004; a.perm = n_arg; remote_glob(conn, path1, 0x0010, ((void *)0), &g); for (i = 0; g.gl_pathv[i] && !interrupted; i++) { if (!quiet) mprintf("Changing mode on %s\n", g.gl_pathv[i]); err = (hflag ? do_lsetstat : do_setstat)(conn, g.gl_pathv[i], &a); if (err != 0 && err_abort) break; } break; case I_CHOWN: case I_CHGRP: path1 = make_absolute_pwd_glob(path1, *pwd); remote_glob(conn, path1, 0x0010, ((void *)0), &g); for (i = 0; g.gl_pathv[i] && !interrupted; i++) { if (!(aa = (hflag ? do_lstat : do_stat)(conn, g.gl_pathv[i], 0))) { if (err_abort) { err = -1; break; } else continue; } if (!(aa->flags & 0x00000002)) { sshlog("sftp.c", __func__, 1734, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Can't get current ownership of " "remote file \"%s\"", g.gl_pathv[i]); if (err_abort) { err = -1; break; } else continue; } aa->flags &= 0x00000002; if (cmdnum == I_CHOWN) { if (!quiet) mprintf("Changing owner on %s\n", g.gl_pathv[i]); aa->uid = n_arg; } else { if (!quiet) mprintf("Changing group on %s\n", g.gl_pathv[i]); aa->gid = n_arg; } err = (hflag ? do_lsetstat : do_setstat)(conn, g.gl_pathv[i], aa); if (err != 0 && err_abort) break; } break; case I_PWD: mprintf("Remote working directory: %s\n", *pwd); break; case I_LPWD: if (!getcwd(path_buf, sizeof(path_buf))) { sshlog("sftp.c", __func__, 1765, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Couldn't get local cwd: %s", strerror((*__errno_location()))); err = -1; break; } mprintf("Local working directory: %s\n", path_buf); break; case I_QUIT: break; case I_HELP: help(); break; case I_VERSION: printf("SFTP protocol version %u\n", sftp_proto_version(conn)); break; case I_PROGRESS: showprogress = !showprogress; if (showprogress) printf("Progress meter enabled\n"); else printf("Progress meter disabled\n"); break; default: sshfatal("sftp.c", __func__, 1788, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "%d is not implemented", cmdnum); } if (g.gl_pathc) _ssh__compat_globfree(&g); free(path1); free(path2); if (err_abort && err != 0) return (-1); else if (cmdnum == I_QUIT) return (1); return (0); }
int parse_dispatch_command(unsigned long long a0, unsigned long a1, unsigned long long *a2, unsigned long long a3, unsigned long a4, unsigned long a5) { unsigned int v0; char v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned int v5; unsigned int v6; unsigned int v7; unsigned int v8; unsigned int v9; unsigned int v10; unsigned int v11; unsigned int v12; unsigned int v13; unsigned int v14; void *v15; void *v16; void *v17; void *v18; unsigned int v19[7]; unsigned int v20; unsigned int v21; char v22; char v23; char v24; unsigned long long v25; unsigned int v27; unsigned long long v28; unsigned long long v29; unsigned long long v30; unsigned long long v31; unsigned long long v32; unsigned long long v33; unsigned long long v34; unsigned long long v35; v25 = *(&v25); v0 = a4; v2 = 0; v3 = 1; v4 = 0; v5 = 0; v6 = 0; v7 = 0; v8 = 0; v9 = 0; v10 = 0; v11 = 0; v17 = 0; v13 = 0; v16 = 0; v15 = v16; v14 = parse_args(&v1, &v2, &v3, &v4, &v5, &v6, &v7, &v8, &v9, &v10, &v11, &v17, &v15, &v16); if (v2) v0 = 0; if (a5 && !v3) mprintf("sftp> %s\n", a1, &v3); memset(&v22, 0x0, 0x60); v27 = __addvsi3(v14, 0x1); switch (v27) { case 0: v13 = -1; break; case 1: case 20: break; case 2: if (v15 && !(!*(v15))) goto LABEL_404a74; v15 = xstrdup(a3); LABEL_404a74: v15 = make_absolute(v15, *(a2), *(a2)); v18 = do_realpath(a0, v15, v15); if (!v18) { v13 = 1; break; } else { *(&v19[0]) = do_stat(a0); if (!v19) { free(v18); v13 = 1; break; } else if (!(v19[0] & 4)) { sshlog("sftp.c", "parse_dispatch_command", 0x667, 0x0, 0x2, 0x0, "Can't change directory: Can't check target", &v16); free(v18); v13 = 1; break; } else if ((v19[6] & 0xf000) == 0x4000) { free(*(a2)); *(a2) = v18; break; } else { sshlog("sftp.c", "parse_dispatch_command", 0x66d, 0x0, 0x2, 0x0, "Can\'t change directory: \"%s\" is not a directory", v18); free(v18); v13 = 1; break; } } case 3: case 5: v15 = make_absolute_pwd_glob(v15, *(a2)); remote_glob(a0, v15, 0x10, 0x0, &v22); v12 = 0; while (true) { if (!*((*(&v23) + (v12 << 3)))) break; if (*(&interrupted)) break; if (v6) v28 = got.do_lstat; else v29 = got.do_stat; *(&v19[0]) = reg_80(a0, *((*(&v23) + v12 * 8)), 0, *((*(&v23) + v12 * 8))); if (v19) { if ((v19[0] & 2)) { v19[0] = v19[0] & 2; if (v14 != 4) { if (!*(&quiet)) mprintf("Changing group on %s\n", *((*(&v23) + v12 * 8)), v12 * 8); v19[5] = v17; } else { if (!*(&quiet)) mprintf("Changing owner on %s\n", *((*(&v23) + v12 * 8)), v12 * 8); v19[4] = v17; } if (v6) v30 = *(&got.do_lsetstat); else v31 = *(&got.do_setstat); v13 = reg_80(a0, *((*(&v23) + v12 * 8)), v19, *((*(&v23) + v12 * 8))); if (v13 && !(!v0)) goto LABEL_405357; } else { sshlog("sftp.c", "parse_dispatch_command", 0x6c6, 0x0, 0x2, 0x0, "Can\'t get current ownership of remote file \"%s\"", *((*(&v23) + v12 * 8))); if (v0) { v13 = -1; LABEL_405357: break; } } } else { if (v0) { v13 = -1; goto LABEL_405357; } } v12 = __addvsi3(v12, 0x1); } break; case 4: v15 = make_absolute_pwd_glob(v15, *(a2)); attrib_clear(&v20); v20 |= 4; v21 = v17; remote_glob(a0, v15, 0x10, 0x0, &v22); v12 = 0; while (true) { if (!*((*(&v23) + (v12 << 3)))) break; if (*(&interrupted)) break; if (!*(&quiet)) mprintf("Changing mode on %s\n", *((*(&v23) + v12 * 8)), v12 * 8); if (v6) v32 = *(&got.do_lsetstat); else v33 = *(&got.do_setstat); v13 = reg_80(a0, *((*(&v23) + v12 * 8)), &v20, *((*(&v23) + v12 * 8))); if (v13 && v0) break; v12 = __addvsi3(v12, 0x1); } break; case 6: v15 = make_absolute(v15, *(a2), *(a2)); v16 = make_absolute(v16, *(a2), *(a2)); v13 = do_copy(a0, v15, v16, v15); break; case 7: if (!v15) v15 = xstrdup(*(a2)); v15 = make_absolute(v15, *(a2), *(a2)); v13 = do_df(a0, v15, v6, v7); break; case 9: help(); break; case 10: if (v15 && !(!*(v15))) goto LABEL_404d81; v15 = xstrdup("~"); LABEL_404d81: v27 = getuid(); v18 = tilde_expand_filename(v15, v27, v27); free(v15); v15 = v18; if (chdir(v15) == -1) { strerror(*(__errno_location())); sshlog("sftp.c", "parse_dispatch_command", 0x692, 0x0, 0x2, 0x0, "Couldn\'t change local directory to \"%s\": %s", v15); v13 = 1; } break; case 12: local_do_ls(a1); break; case 13: if (mkdir(v15, 0x1ff) == -1) { strerror(*(__errno_location())); sshlog("sftp.c", "parse_dispatch_command", 0x699, 0x0, 0x2, 0x0, "Couldn\'t create local directory \"%s\": %s", v15); v13 = 1; } break; case 14: if (getcwd(&v24, 0x1000)) { mprintf("Local working directory: %s\n", &v24, &g_40a0b4); break; } else { sshlog("sftp.c", "parse_dispatch_command", 0x6e5, 0x0, 0x2, 0x0, "Couldn't get local cwd: %s", strerror(*(__errno_location()))); v13 = -1; break; } case 15: if (!v15) { do_ls_dir(a0, *(a2), *(a2), v8); break; } else { v18 = 0; if (!path_absolute(v15)) v18 = *(a2); v15 = make_absolute_pwd_glob(v15, *(a2)); v13 = do_globbed_ls(a0, v15, v18, v8); break; } case 16: umask(v17); printf("Local umask: %03lo\n", v17); break; case 17: v15 = make_absolute(v15, *(a2), *(a2)); attrib_clear(&v20); v20 = *(&v20) | 4; v21 = 511; v13 = do_mkdir(a0, v15, &v20, 0x1); break; case 19: mprintf("Remote working directory: %s\n", *(a2), &g_40a0b4); break; case 22: v15 = make_absolute(v15, *(a2), *(a2)); v16 = make_absolute(v16, *(a2), *(a2)); v13 = do_rename(a0, v15, v16, v8); break; case 24: v15 = make_absolute_pwd_glob(v15, *(a2)); remote_glob(a0, v15, 0x10, 0x0, &v22); v12 = 0; while (true) { if (!*((*(&v23) + (v12 << 3)))) break; if (*(&interrupted)) break; if (!*(&quiet)) mprintf("Removing %s\n", *((*(&v23) + v12 * 8)), v12 * 8); v13 = do_rm(a0, *((*(&v23) + v12 * 8)), *((*(&v23) + v12 * 8))); if (v13 && v0) break; v12 = __addvsi3(v12, 0x1); } break; case 25: v15 = make_absolute(v15, *(a2), *(a2)); v13 = do_rmdir(a0, v15, v15); break; case 26: local_do_shell(a1); break; case 28: printf("SFTP protocol version %u\n", sftp_proto_version(a0)); break; case 29: showprogress = !showprogress; if (!showprogress) { printf("Progress meter disabled\n"); break; } else { printf("Progress meter enabled\n"); break; } case 21: v4 = 1; case 8: v13 = process_get(a0, v15, v16, *(a2), v9, v10, v4, v5); break; case 23: v4 = 1; case 18: v13 = process_put(a0, v15, v16, *(a2), v9, v10, v4, v5); break; case 27: v11 = 1; case 11: if (!v11) v15 = make_absolute(v15, *(a2), *(a2)); v16 = make_absolute(v16, *(a2), *(a2)); if (v11) v34 = got.do_symlink; else v35 = got.do_hardlink; v13 = reg_80(a0, v15, v16, v15); break; default: sshfatal("sftp.c", "parse_dispatch_command", 0x6fc, 0x0, 0x1, 0x0, "%d is not implemented"); } if (*(&v22)) _ssh__compat_globfree(&v22); free(v15); free(v16); if (v0 && v13) { v27 = -1; goto LABEL_405539; } if (v14 == 19) v27 = 1; else v27 = 0; LABEL_405539: return v27; }
openssh-portable
angr_phoenix
static int cmdloop(int top) { union node *n; struct stackmark smark; int inter; int status = 0; int numeof = 0; ; for (;;) { int skip; setstackmark(&smark); if (jobctl) showjobs(out2, 0x08); inter = 0; if (optlist[3] && top) { inter++; chkmail(); } n = parsecmd(inter); if (n == ((union node *)&tokpushback)) { if (!top || numeof >= 50) break; if (!stoppedjobs()) { if (!optlist[2]) { if (optlist[3]) { outcslow(('\n'), out2); } break; } outstr(("\nUse \"exit\" to leave shell.\n"), out2); } numeof++; } else { int i; job_warning = (job_warning == 2) ? 1 : 0; numeof = 0; i = evaltree(n, 0); if (n) status = i; } popstackmark(&smark); skip = evalskip; if (skip) { evalskip &= ~((1 << 2) | (1 << 3)); break; } } return status; }
void cmdloop(unsigned long a0) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned long long v5; char v6; unsigned long long v8; v1 = 0; v2 = 0; do { setstackmark(&v6); if (jobctl) showjobs(out2, 0x8); v0 = 0; if (g_50002b && a0) { v0 += 1; chkmail(); } v5 = parsecmd(v0); if (v5 != 5243088) { job_warning = job_warning == 2; v2 = 0; v3 = evaltree(v5, 0x0); if (v5) v1 = v3; } else { if (!a0) goto LABEL_4003a9; if (v2 > 49) goto LABEL_4003a9; if (!stoppedjobs()) { if (g_50002a) { outstr("\nUse \"exit\" to leave shell.\n", out2); } else { if (g_50002b) outcslow(0xa, out2); goto LABEL_4003a9; } } v2 += 1; } popstackmark(&v6); v4 = evalskip; } while (!v4); evalskip = evalskip & -13; LABEL_4003a9: v8 = v1; return; }
dash-0.5.11+git20210903+057cd650a4ed
angr_phoenix
static int ipvrf_show(int argc, char **argv) { struct nlmsg_chain linfo = {((void *)0), ((void *)0)}; int rc = 0; vrf_filter.kind = "vrf"; if (argc > 1) usage(); if (argc == 1) { __u32 tb_id; tb_id = ipvrf_get_table(argv[0]); if (!tb_id) { fprintf(stderr, "Invalid VRF\n"); return 1; } printf("%s %u\n", argv[0], tb_id); return 0; } if (ip_link_list(ipvrf_filter_req, &linfo) == 0) { struct nlmsg_list *l; unsigned nvrf = 0; new_json_obj(json); print_string(PRINT_FP, ((void *)0), "%-16s", "Name"); print_string(PRINT_FP, ((void *)0), " %5s\n", "Table"); print_string(PRINT_FP, ((void *)0), "%s\n", "-----------------------"); for (l = linfo.head; l; l = l->next) nvrf += ipvrf_print(&l->h); if (!nvrf) print_string(PRINT_FP, ((void *)0), "%s\n", "No VRF has been configured"); delete_json_obj(); } else rc = 1; free_nlmsg_chain(&linfo); return rc; }
undefined4 ipvrf_show(int param_1, undefined8 *param_2) { uint uVar1; int iVar2; long in_FS_OFFSET; undefined4 local_3c; int local_38; undefined8 *local_30; undefined8 *local_28; undefined8 local_20; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_28 = (undefined8 *)0x0; local_20 = 0; local_3c = 0; vrf_filter._344_8_ = &DAT_00141c6c; if (1 < param_1) { usage(); } if (param_1 == 1) { uVar1 = ipvrf_get_table(*param_2); if (uVar1 == 0) { fprintf(stderr, "Invalid VRF\n"); local_3c = 1; } else { printf("%s %u\n", *param_2, (ulong)uVar1); local_3c = 0; } } else { iVar2 = ip_link_list(ipvrf_filter_req, &local_28); if (iVar2 == 0) { local_38 = 0; new_json_obj(json); print_string(1, 0, "%-16s", &DAT_00141f08); print_string(1, 0, " %5s\n", "Table"); print_string(1, 0, &DAT_00141c0a, "-----------------------"); for (local_30 = local_28; local_30 != (undefined8 *)0x0; local_30 = (undefined8 *)*local_30) { iVar2 = ipvrf_print(local_30 + 1); local_38 = local_38 + iVar2; } if (local_38 == 0) { print_string(1, 0, &DAT_00141c0a, "No VRF has been configured"); } delete_json_obj(); } else { local_3c = 1; } free_nlmsg_chain(&local_28); } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return local_3c; }
iproute2-6.0.0
ghidra
map_get_editor(EditLine *el, const wchar_t **editor) { if (editor == ((void *)0)) return -1; switch (el->el_map.type) { case 0: *editor = L"emacs"; return 0; case 1: *editor = L"vi"; return 0; } return -1; }
long long map_get_editor(struct_0 *a0, unsigned long long *a1) { unsigned long long v1; if (!a1) { v1 = 4294967295; return v1; } switch (a0->field_420) { case 0: *(a1) = "e"; v1 = 0; return v1; case 1: *(a1) = "v"; v1 = 0; return v1; default: v1 = 4294967295; return v1; } }
libedit
angr_sailr
static int add_passwd(struct passwd *pwd, const char *password) { const struct spwd *sp; struct spwd spent; char *cp; void *crypt_arg = ((void *)0); if (((void *)0) != crypt_method) { if (sflg) { if ((0 == strcmp(crypt_method, "SHA256")) || (0 == strcmp(crypt_method, "SHA512"))) { crypt_arg = &sha_rounds; } } } if (!is_shadow) { return update_passwd(pwd, password); } sp = spw_locate(pwd->pw_name); if (((void *)0) != sp) { spent = *sp; if ((((void *)0) != crypt_method) && (0 == strcmp(crypt_method, "NONE"))) { spent.sp_pwdp = (char *)password; } else { const char *salt = crypt_make_salt(crypt_method, crypt_arg); cp = pw_encrypt(password, salt); if (((void *)0) == cp) { fprintf(stderr, gettext("%s: failed to crypt password with salt '%s': %s\n"), Prog, salt, strerror((*__errno_location()))); return 1; } spent.sp_pwdp = cp; } spent.sp_lstchg = (long)gettime() / (24L * 3600L); if (0 == spent.sp_lstchg) { spent.sp_lstchg = -1; } return (spw_update(&spent) == 0); } if (strcmp(pwd->pw_passwd, "x") != 0) { return update_passwd(pwd, password); } spent.sp_namp = pwd->pw_name; if ((crypt_method != ((void *)0)) && (0 == strcmp(crypt_method, "NONE"))) { spent.sp_pwdp = (char *)password; } else { const char *salt = crypt_make_salt(crypt_method, crypt_arg); cp = pw_encrypt(password, salt); if (((void *)0) == cp) { fprintf(stderr, gettext("%s: failed to crypt password with salt '%s': %s\n"), Prog, salt, strerror((*__errno_location()))); return 1; } spent.sp_pwdp = cp; } spent.sp_lstchg = (long)gettime() / (24L * 3600L); if (0 == spent.sp_lstchg) { spent.sp_lstchg = -1; } spent.sp_min = getdef_num("PASS_MIN_DAYS", 0); spent.sp_max = getdef_num("PASS_MAX_DAYS", 10000); spent.sp_warn = getdef_num("PASS_WARN_AGE", -1); spent.sp_inact = -1; spent.sp_expire = -1; spent.sp_flag = ((unsigned long int)-1); return (spw_update(&spent) == 0); }
int add_passwd(void *a0, unsigned long a1) { unsigned long long v0; unsigned long long v1[9]; unsigned long long v2; unsigned long v3; unsigned long long v4; unsigned long v5; unsigned long v6; unsigned long v7; unsigned long v8; unsigned long v9; unsigned long v10; unsigned long v11; unsigned long v12; unsigned long v13; unsigned int v15; v0 = 0; if (crypt_method && sflg) { if (strcmp(crypt_method, "SHA256") && !(!strcmp(crypt_method, "SHA512"))) goto LABEL_400e57; v0 = &sha_rounds; } LABEL_400e57: if ((is_shadow ^ 1)) { v15 = update_passwd(a0, a1); } else { v1[0] = spw_locate(*(a0)); if (v1) { v5 = v1[0]; v6 = v1[1]; v7 = v1[2]; v8 = v1[3]; v9 = v1[4]; v10 = v1[5]; v11 = v1[6]; v12 = v1[7]; v13 = v1[8]; if (crypt_method && !strcmp(crypt_method, "NONE")) { v6 = a1; goto LABEL_400fbd; } v4 = crypt_make_salt(crypt_method, v0, v0); v3 = pw_encrypt(a1, v4, v4); if (v3) { v6 = v3; } else { strerror(*(__errno_location())); fprintf(*(&stderr), gettext("%s: failed to crypt password with salt '%s': %s\n")); v15 = 1; goto LABEL_4011db; } LABEL_400fbd: v15 = gettime(); v7 = (v15 * 1749024623285053783 >> 64 >> 13) - (v15 >> 63); if (!v7) v7 = -1; v15 = !spw_update(&v5); } else if (strcmp(a0[8], "x")) { v15 = update_passwd(a0, a1); } else { v5 = *(a0); if (crypt_method && !strcmp(crypt_method, "NONE")) { v6 = a1; goto LABEL_40112c; } v2 = crypt_make_salt(crypt_method, v0, v0); v3 = pw_encrypt(a1, v2, v2); if (v3) { v6 = v3; } else { strerror(*(__errno_location())); fprintf(*(&stderr), gettext("%s: failed to crypt password with salt '%s': %s\n")); v15 = 1; goto LABEL_4011db; } LABEL_40112c: v15 = gettime(); v7 = (v15 * 1749024623285053783 >> 64 >> 13) - (v15 >> 63); if (!v7) v7 = -1; v8 = getdef_num("PASS_MIN_DAYS", 0x0); v9 = getdef_num("PASS_MAX_DAYS", 0x2710); v10 = getdef_num("PASS_WARN_AGE", 0xffffffff); v11 = -1; v12 = -1; v13 = -1; v15 = !spw_update(&v5); } } LABEL_4011db: return v15; }
shadow
angr_phoenix
static int is_addr(const char *name) { char strport[32]; struct addrinfo hints, *res; if (is_addr_fast(name)) return 1; snprintf(strport, sizeof strport, "%u", default_ssh_port()); memset(&hints, 0, sizeof(hints)); hints.ai_family = options.address_family == -1 ? 0 : options.address_family; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = 0x0004 | 0x0400; if (getaddrinfo(name, strport, &hints, &res) != 0) return 0; if (res == ((void *)0) || res->ai_next != ((void *)0)) { freeaddrinfo(res); return 0; } freeaddrinfo(res); return 1; }
long is_addr(const char *a1) { unsigned int v2; int v3; struct addrinfo *pai; struct addrinfo req; char s[40]; unsigned long v7; v7 = __readfsqword(0x28u); if (is_addr_fast(a1)) return 1LL; v2 = default_ssh_port(); snprintf(s, 0x20uLL, "%u", v2); memset(&req, 0, sizeof(req)); if (options[35] == -1) v3 = 0; else v3 = options[35]; req.ai_family = v3; req.ai_socktype = 1; req.ai_flags = 1028; if (getaddrinfo(a1, s, &req, &pai)) return 0LL; if (pai && !pai->ai_next) { freeaddrinfo(pai); return 1LL; } else { freeaddrinfo(pai); return 0LL; } }
openssh-portable
ida
int hostkeys_foreach(const char *path, hostkeys_foreach_fn *callback, void *ctx, const char *host, const char *ip, u_int options, u_int note) { FILE *f; int r, oerrno; if ((f = fopen(path, "r")) == ((void *)0)) return -24; sshlog("hostfile.c", __func__, 930, 1, SYSLOG_LEVEL_DEBUG3, ((void *)0), "reading file \"%s\"", path); r = hostkeys_foreach_file(path, f, callback, ctx, host, ip, options, note); oerrno = (*__errno_location()); fclose(f); (*__errno_location()) = oerrno; return r; }
int hostkeys_foreach(unsigned long a0, unsigned long long a1, unsigned long long a2, unsigned long long a3, unsigned long long a4, unsigned long a5, unsigned int v3) { unsigned int v0; unsigned int v1; void *v2; unsigned int v4; v2 = fopen(a0, "r"); if (!v2) { v4 = -24; return v4; } sshlog("hostfile.c", "hostkeys_foreach", 0x3a2, 0x1, 0x7, 0x0); v0 = hostkeys_foreach_file(a0, v2, a1, a2, a3, a4, a5, v3); v1 = *(__errno_location()); fclose(v2); *(__errno_location()) = v1; v4 = v0; return v4; }
openssh-portable
angr_sailr
static void maybe_close_stdout(void) { if (!stdout_closed) close_stdout(); else if (close_stream(stderr) != 0) _exit(1); }
long long maybe_close_stdout() { unsigned long long v1; if ((stdout_closed ^ 1)) { v1 = close_stdout(); return v1; } v1 = close_stream(stderr); if (!v1) return v1; _exit(0x1); }
coreutils
angr_sailr
static int diversion_listpackage(const char *const *argv) { const char *filename = argv[0]; struct fsys_namenode *namenode; if (!filename || argv[1]) badusage(gettext("--%s needs a single argument"), cipaction->olong); diversion_check_filename(filename); namenode = fsys_hash_find_node(filename, FHFF_NONE); if (namenode == ((void *)0) || namenode->divert == ((void *)0)) return 0; if (namenode->divert->pkgset == ((void *)0)) printf("LOCAL\n"); else printf("%s\n", namenode->divert->pkgset->name); return 0; }
long long diversion_listpackage(unsigned long long a0[2], unsigned long a1, unsigned long long a2) { char *v0; struct_0 *v1; v0 = a0[0]; if (!v0 || a0[1]) badusage(gettext("--%s needs a single argument"), *(cipaction), a2); diversion_check_filename(v0); v1 = fsys_hash_find_node(v0, 0x2); if (v1 && v1->field_18) { if (!v1->field_18->field_10) printf("LOCAL\n"); else printf("%s\n", v1->field_18->field_10->field_8); } return 0; }
dpkg
angr_dream
static void nh_reset(nh_ctx *hc) { hc->bytes_hashed = 0; hc->next_data_empty = 0; hc->state[0] = 0; hc->state[1] = 0; hc->state[2] = 0; hc->state[3] = 0; }
void nh_reset(struct_0 *a0) { char v0; struct_0 *v2; unsigned long long v3; a0->field_474 = 0; a0->field_470 = 0; a0->field_478 = 0; a0->field_480 = 0; a0->field_488 = 0; v2 = a0; a0->field_490 = 0; v3 = *(&v0); return; }
openssh-portable
angr_phoenix
static inline char *_STPUTC(int c, char *p) { if (p == sstrend) p = growstackstr(); *p++ = c; return p; }
undefined *_STPUTC(undefined param_1, undefined *param_2) { undefined *local_18; local_18 = param_2; if (param_2 == sstrend) { local_18 = (undefined *)growstackstr(); } *local_18 = param_1; return local_18 + 1; }
dash-0.5.11+git20210903+057cd650a4ed
ghidra
bmexec_trans(kwset_t kwset, char const *text, idx_t size) { ((0 <= size) ? (void)0 : __builtin_unreachable()); unsigned char const *d1; char const *ep, *sp, *tp; int d; idx_t len = kwset->mind; char const *trans = kwset->trans; if (len == 0) return 0; if (len > size) return -1; if (len == 1) { tp = memchr_kwset(text, size, kwset); return tp ? tp - text : -1; } d1 = kwset->delta; sp = kwset->target + len; tp = text + len; char gc1 = kwset->gc1; char gc2 = kwset->gc2; idx_t len12; if (!__builtin_mul_overflow(len, 12, &len12) && len12 < size) for (ep = text + size - 11 * len; tp <= ep;) { char const *tp0 = tp; d = d1[U(tp[-1])], tp += d; d = d1[U(tp[-1])], tp += d; if (d != 0) { d = d1[U(tp[-1])], tp += d; d = d1[U(tp[-1])], tp += d; d = d1[U(tp[-1])], tp += d; if (d != 0) { d = d1[U(tp[-1])], tp += d; d = d1[U(tp[-1])], tp += d; d = d1[U(tp[-1])], tp += d; if (d != 0) { d = d1[U(tp[-1])], tp += d; d = d1[U(tp[-1])], tp += d; int advance_heuristic = 16 * sizeof(long); if (advance_heuristic <= tp - tp0) continue; tp--; tp = memchr_kwset(tp, text + size - tp, kwset); if (!tp) return -1; tp++; if (ep <= tp) break; } } } if (bm_delta2_search(&tp, ep, sp, len, trans, gc1, gc2, d1, kwset)) return tp - text; } ep = text + size; d = d1[U(tp[-1])]; while (d <= ep - tp) { d = d1[U((tp += d)[-1])]; if (d != 0) continue; if (bm_delta2_search(&tp, ep, sp, len, trans, gc1, gc2, ((void *)0), kwset)) return tp - text; } return -1; }
int bmexec_trans(struct_0 *a0, unsigned long long a1, unsigned int a2) { unsigned int v0; char v1; char v2; unsigned int v3; unsigned int v4; unsigned long v5; unsigned long v6; unsigned int v7; char *v8; char *v9; unsigned long long v10; unsigned int v11; unsigned long v12; unsigned int v14; unsigned long v15; v0 = a2; *(&v7) = a0->field_68; v8 = a0->field_980; if (!*(&v7)) { v14 = 0; return v14; } else if (*(&v7) > *(&v0)) { v14 = -1; return v14; } else if (*(&v7) != 1) { v9 = &a0->padding_70[0]; v10 = *(&v7) + a0->field_970; v5 = a1 + *(&v7); v1 = a0->field_988; v2 = a0->field_990; v15 = 0; if ([D] amd64g_calculate_condition( 0x0 < 64 >, 0x34 < 64 >, Load(addr = stack_base - 64, size = 8, endness = Iend_LE), 0xc < 64 >, cc_ndep<8>)) *(&v15) = 1; v6 = *(&v7) * 12; if ((v15 & 1 ^ 1) && *(&v0) > v6) { *(&v11) = a1 + *(&v0) - *(&v7) * 11; while (true) { if (*(&v11) < v5) break; v12 = v5; v3 = v9[U(*((v5 - 1)))]; v5 = v3 + v5; v3 = v9[U(*((v5 - 1)))]; v5 = v3 + v5; if (v3) { v3 = v9[U(*((v5 - 1)))]; v5 = v3 + v5; v3 = v9[U(*((v5 - 1)))]; v5 = v3 + v5; v3 = v9[U(*((v5 - 1)))]; v5 = v3 + v5; if (v3) { v3 = v9[U(*((v5 - 1)))]; v5 = v3 + v5; v3 = v9[U(*((v5 - 1)))]; v5 = v3 + v5; v3 = v9[U(*((v5 - 1)))]; v5 = v3 + v5; if (v3) { v3 = v9[U(*((v5 - 1)))]; v5 = v3 + v5; v3 = v9[U(*((v5 - 1)))]; v5 = v3 + v5; v4 = 128; if (v4 <= v5 - v12) continue; v5 -= 1; v5 = memchr_kwset(v5, *(&v0) + a1 + -0x1 * v5, a0); if (!v5) { v14 = -1; return v14; } v5 += 1; if (*(&v11) <= v5) break; } } } if (bm_delta2_search(&v5, *(&v11), v10, *(&v7), v8, v1, v2, v9, a0)) { v14 = v5 - a1; return v14; } } } *(&v11) = a1 + *(&v0); v3 = v9[U(*((v5 - 1)))]; do { do { if (v3 > *(&v11) - v5) { v14 = -1; return v14; } } while ((v5 = v3 + v5, v3 = U(*((v5 - 1))), v3)); } while (!bm_delta2_search(&v5, *(&v11), v10, *(&v7), v8, v1, v2, 0x0, a0)); v14 = v5 - a1; return v14; } else { v5 = memchr_kwset(a1, *(&v0), a0); v14 = (!v5 ? (v5 - a1) : -1); return v14; } }
grep
angr_sailr
size_t strlcpy(char *dst, const char *src, size_t siz) { char *d = dst; const char *s = src; size_t n = siz; ; ; if (n != 0 && --n != 0) { do { if ((*d++ = *s++) == 0) break; } while (--n != 0); } if (n == 0) { if (siz != 0) *d = '\0'; while (*s++) ; } return (s - src - 1); }
long long strlcpy(unsigned long a0, unsigned long a1, char a2) { char *v0; int tmp_14; int tmp_22; int tmp_9; char *v1; unsigned long v2; v0 = a0; v1 = a1; *(&v2) = a2; if (v2) { v2 -= 1; if (v2) { while (true) { tmp_14 = v1; v1 += 1; tmp_22 = v0; v0 += 1; a2 = *(tmp_14); *(tmp_22) = a2; if (!*(tmp_22)) break; v2 -= 1; if (!v2) break; } } } if (!v2) { if (a2) *(v0) = 0; do { tmp_9 = v1; v1 += 1; } while (*(tmp_9)); } return &v1[-1 * a1 + 1]; }
libedit
angr_phoenix
static int sh_open_fail(const char *pathname, int flags, int e) { const char *word; int action; word = "open"; action = 01; if (flags & 0100) { word = "create"; action = 02; } sh_error("cannot %s %s: %s", word, pathname, errmsg(e, action)); }
long sh_open_fail(const char *a1, char a2, unsigned int a3) { const char *v3; int v4; unsigned int v6; const char *v7; v7 = "open"; v6 = 1; if ((a2 & 0x40) != 0) { v7 = "create"; v6 = 2; } v3 = (const char *)errmsg(a3, v6); sh_error("cannot %s %s: %s", v7, a1, v3); return sh_open("cannot %s %s: %s", (char)v7, v4); }
dash-0.5.11+git20210903+057cd650a4ed
ida
static long parse_number(const char *arg) { char *endptr = ((void *)0); (*__errno_location()) = 0; long result; if (strncmp(arg, "0x", 2) == 0) result = strtol(arg + 2, &endptr, 16); else if (strncmp(arg, "0", 1) == 0 && strspn(arg, "012345678") == strlen(optarg)) result = strtol(arg + 1, &endptr, 8); else result = strtol(arg, &endptr, 10); if ((*__errno_location()) != 0 || (endptr && *endptr != '\0')) error(1, (*__errno_location()), "'%s' is not a recognizable number.", arg); return result; }
int parse_number(char *a0) { void *v0; unsigned long v1; v0 = 0; *(__errno_location()) = 0; if (!strncmp(a0, "0x", 0x2)) { v1 = strtol(a0 + 2, &v0, 0x10); } else { if (!strncmp(a0, "0", 0x1) && strspn(a0, "012345678") == strlen(*(got.optarg))) { v1 = strtol(a0 + 1, &v0, 0x8); goto LABEL_400211; } v1 = strtol(a0, &v0, 0xa); } LABEL_400211: if (!*(__errno_location())) { if (!v0) { LABEL_400256: return v1; } else if (!*(v0)) { goto LABEL_400256; } } error(0x1, *(__errno_location()), "'%s' is not a recognizable number."); }
gnutls
angr_phoenix
void xheader_write(char type, char *name, time_t t, struct xheader *xhdr) { union block *header; size_t size; char *p; size = xhdr->size; switch (type) { case 'g': if (globexthdr_mtime_option) t = globexthdr_mtime; break; case 'x': if (exthdr_mtime_option) t = exthdr_mtime; break; } header = start_private_header(name, size, t); header->header.typeflag = type; simple_finish_header(header); p = xhdr->buffer; do { size_t len; header = find_next_block(); len = 512; if (len > size) len = size; memcpy(header->buffer, p, len); if (len < 512) memset(header->buffer + len, 0, 512 - len); p += len; size -= len; set_next_block_after(header); } while (size > 0); xheader_destroy(xhdr); if (type == 'g') global_header_count++; }
void xheader_write(unsigned long a0, unsigned long long a1, unsigned long long a2, unsigned long long a3[3]) { unsigned long long v0; unsigned long v1; void *v2; unsigned long long v3; struct_0 *v4; unsigned long long v6; unsigned long long v7; v0 = a2; v1 = a3[1]; switch (a0) { case 103: if (globexthdr_mtime_option) v0 = globexthdr_mtime; break; case 120: if (exthdr_mtime_option) v0 = exthdr_mtime; break; default: goto LABEL_400e2f; } LABEL_400e2f: v4 = start_private_header(a1, v1, v0, v1); v4->field_9c = a0; simple_finish_header(v4); v2 = a3[2]; do { v4 = find_next_block(); v3 = 0x200; if (v3 > v1) v3 = v1; memcpy(v4, v2, v3); if (v3 <= 511) memset(v4 + v3, 0x0, 0x200 - v3); v2 += v3; v1 -= v3; set_next_block_after(v4); } while (v1); v6 = xheader_destroy(a3); if (a0 == 103) { v7 = global_header_count + 1; global_header_count = global_header_count + 1; return; } return; }
tar
angr_sailr
static void _print_word_list(list, separator, pfunc) WORD_LIST *list; char *separator; PFUNC *pfunc; { WORD_LIST *w; for (w = list; w; w = w->next) (*pfunc)("%s%s", w->word->word, w->next ? separator : ""); }
void _print_word_list(unsigned long long a0, unsigned long long a1, unsigned long long a2) { struct_0 *v0; unsigned long long v2; unsigned long long v3; unsigned long long v4; v2 = a0; for (v0 = a0; v0; v0 = v0->field_0) { if (v0->field_0) v3 = a1; else v3 = &g_403583; (stack_base)[48]("%s%s", v0->field_8->field_0, v3, v0->field_8->field_0, a2); v4 = v0->field_0; } return; }
bash
angr_dream
WORD_LIST *strvec_to_word_list(array, alloc, starting_index) char **array; int alloc, starting_index; { WORD_LIST *list; WORD_DESC *w; int i, count; if (array == 0 || array[0] == 0) return (WORD_LIST *)((void *)0); for (count = 0; array[count]; count++) ; for (i = starting_index, list = (WORD_LIST *)((void *)0); i < count; i++) { w = make_bare_word(alloc ? array[i] : ""); if (alloc == 0) { sh_xfree((w->word), "stringvec.c", 266); w->word = array[i]; } list = make_word_list(w, list); } return (((list && list->next) ? (WORD_LIST *)list_reverse((GENERIC_LIST *)list) : (WORD_LIST *)(list))); }
long *strvec_to_word_list(long *param_1, int param_2, int param_3) { undefined *puVar1; long *plVar2; int local_20; int local_1c; long *local_18; if ((param_1 == (long *)0x0) || (*param_1 == 0)) { local_18 = (long *)0x0; } else { for (local_1c = 0; param_1[local_1c] != 0; local_1c = local_1c + 1) { } local_18 = (long *)0x0; for (local_20 = param_3; local_20 < local_1c; local_20 = local_20 + 1) { if (param_2 == 0) { puVar1 = &DAT_0010080b; } else { puVar1 = (undefined *)param_1[local_20]; } plVar2 = (long *)make_bare_word(puVar1); if (param_2 == 0) { sh_xfree(*plVar2, "stringvec.c", 0x10a); *plVar2 = param_1[local_20]; } local_18 = (long *)make_word_list(plVar2, local_18); } if ((local_18 != (long *)0x0) && (*local_18 != 0)) { local_18 = (long *)list_reverse(local_18); } } return local_18; }
bash
ghidra
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"); } }
void sshbuf_dump_data(void *a0, unsigned long a1, void *a2) { void *v0; void *v1; void *v3; v0 = 0; while (true) { v3 = v0; if (v0 >= a1) break; fprintf(a2, "%.4zu: ", v0); for (v1 = v0; v1 < v0 + 16; v1 += 1) { if (v1 < a1) fprintf(a2, "%02x ", *((v1 + a0))); else fprintf(a2, " "); } fprintf(a2, " "); for (v1 = v0; v1 < v0 + 16; v1 += 1) { if (v1 < a1) { if ((*((v1 + a0)) & 128) || (*(&v3) = *((*(__ctype_b_loc()) + *((v1 + a0)) * 2)), *(&v3) = (v3 & 0x4000), !v3)) fprintf(a2, "."); else fprintf(a2, "%c", *((v1 + a0))); } } fprintf(a2, "\n"); v0 += 16; } return; }
openssh-portable
angr_sailr
static void geneve_print_help(struct link_util *lu, int argc, char **argv, FILE *f) { print_explain(f); }
long long geneve_print_help(unsigned long a0, unsigned long a1, unsigned long a2, void *a3) { unsigned long v0; unsigned int v1; unsigned long v2; v2 = a0; v1 = a1; v0 = a2; return print_explain(a3); }
iproute2-6.0.0
angr_sailr
static int getentropy_getrandom(void *buf, size_t len) { int pre_errno = (*__errno_location()); int ret; if (len > 256) return (-1); do { ret = syscall(318, buf, len, 0x0001); } while (ret == -1 && (*__errno_location()) == 4); if (ret != (int)len) return (-1); (*__errno_location()) = pre_errno; return (0); }
int getentropy_getrandom(unsigned long a0, unsigned long a1) { unsigned long v0; unsigned int v1; unsigned int v2; unsigned int v5; v0 = a0; v1 = *(__errno_location()); if (a1 > 0x100) { v5 = -1; return v5; } do { } while ((v2 = syscall(0x13e), v2 == -1 && *(__errno_location()) == 4)); if (v2 != a1) { v5 = -1; return v5; } *(__errno_location()) = v1; v5 = 0; return v5; }
libbsd-0.11.7
angr_sailr
static int cmp_mtime(struct fileinfo const *a, struct fileinfo const *b, int (*cmp)(char const *, char const *)) { int diff = timespec_cmp(get_stat_mtime(&b->stat), get_stat_mtime(&a->stat)); return diff ? diff : cmp(a->name, b->name); }
void cmp_mtime(unsigned long long *a0, unsigned long long *a1, unsigned long long a2) { unsigned int v0; unsigned long long v2; unsigned long long v3; v0 = timespec_cmp(get_stat_mtime(a1 + 3), a2, get_stat_mtime(a0 + 3), a2); if (v0) { v2 = v0; return; } v3 = (stack_base)[80](*(a0), *(a1), *(a1), a2); return; }
coreutils
angr_sailr
int kex_c25519_keypair(struct kex *kex) { struct sshbuf *buf = ((void *)0); u_char *cp = ((void *)0); int r; if ((buf = sshbuf_new()) == ((void *)0)) return -2; if ((r = sshbuf_reserve(buf, 32, &cp)) != 0) goto out; kexc25519_keygen(kex->c25519_client_key, cp); kex->client_pub = buf; buf = ((void *)0); out: sshbuf_free(buf); return r; }
int kex_c25519_keypair(long param_1) { int iVar1; long in_FS_OFFSET; undefined8 local_20; long local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_18 = 0; local_20 = 0; local_18 = sshbuf_new(); if (local_18 == 0) { iVar1 = -2; } else { iVar1 = sshbuf_reserve(local_18, 0x20, &local_20); if (iVar1 == 0) { kexc25519_keygen(param_1 + 0x140, local_20); *(long *)(param_1 + 0x868) = local_18; local_18 = 0; } sshbuf_free(local_18); } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return iVar1; }
openssh-portable
ghidra
static void list_format_print_header(struct list_format *fmt) { int l; if (fmt->head) return; fputs(gettext("Desired=Unknown/Install/Remove/Purge/Hold\n| " "Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/" "trig-aWait/Trig-pend\n|/ Err?=(none)/Reinst-required " "(Status,Err: uppercase=bad)\n") , stdout); list_format_print(fmt, '|', '|', '/', gettext("Name"), gettext("Version"), gettext("Architecture"), gettext("Description"), fmt->dw); printf("+++-"); for (l = 0; l < fmt->nw; l++) printf("="); printf("-"); for (l = 0; l < fmt->vw; l++) printf("="); printf("-"); for (l = 0; l < fmt->aw; l++) printf("="); printf("-"); for (l = 0; l < fmt->dw; l++) printf("="); printf("\n"); fmt->head = 1; }
void list_format_print_header(struct_0 *a0) { unsigned int v0; unsigned long long v2; struct_0 *v3; v2 = a0->field_0; if (!a0->field_0) { fputs(gettext("Desired=Unknown/Install/Remove/Purge/Hold\n| " "Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/" "trig-aWait/Trig-pend\n|/ Err?=(none)/Reinst-required " "(Status,Err: uppercase=bad)\n"), stdout); list_format_print(a0, 0x7c, 0x7c, 0x2f, gettext("Name"), gettext("Version"), gettext("Architecture"), gettext("Description"), a0->field_10); printf("+++-"); for (v0 = 0; v0 < a0->field_4; v0 += 1) { printf("="); } printf("-"); for (v0 = 0; v0 < a0->field_8; v0 += 1) { printf("="); } printf("-"); for (v0 = 0; v0 < a0->field_c; v0 += 1) { printf("="); } printf("-"); for (v0 = 0; v0 < a0->field_10; v0 += 1) { printf("="); } printf("\n"); v3 = a0; a0->field_0 = 1; } return; }
dpkg
angr_phoenix
static __inline unsigned int __get_cpuid_max(unsigned int __ext, unsigned int *__sig) { unsigned int __eax, __ebx, __ecx, __edx; __asm__ __volatile__("cpuid\n\t" : "=a"(__eax), "=b"(__ebx), "=c"(__ecx), "=d"(__edx) : "0"(__ext)); if (__sig) *__sig = __ebx; return __eax; }
int __get_cpuid_max(unsigned long a0, unsigned int *a1, unsigned long a2, unsigned long a3) { unsigned int v0; unsigned int v1; unsigned int v3; [D] t4294967295 = DIRTY 1 TODO(effects):: : amd64g_dirtyhelper_CPUID_avx2( GSPTR)[D] MBusEvent - Imbe_Fence v0 = a3; v1 = a2; if (a1) *(a1) = v3; return a0; }
coreutils
angr_phoenix
void get_tlsfeatures_set(int type, void *crt) { int ret, i; unsigned int feature; if (batch) { if (!cfg.tls_features) return; gnutls_x509_tlsfeatures_t features; ret = gnutls_x509_tlsfeatures_init(&features); if (ret < 0) { fprintf(stderr, "gnutls_x509_tlsfeatures_init: %s\n", gnutls_strerror(ret)); exit(1); } for (i = 0; cfg.tls_features[i]; ++i) { feature = strtoul(cfg.tls_features[i], 0, 10); ret = gnutls_x509_tlsfeatures_add(features, feature); if (ret < 0) { fprintf(stderr, "gnutls_x509_tlsfeatures_add: %s\n", gnutls_strerror(ret)); exit(1); } } if (type == 1) { ret = gnutls_x509_crt_set_tlsfeatures(crt, features); if (ret < 0) { fprintf(stderr, "gnutls_x509_crt_set_tlsfeatures: %s\n", gnutls_strerror(ret)); exit(1); } } else { ret = gnutls_x509_crq_set_tlsfeatures(crt, features); if (ret < 0) { fprintf(stderr, "gnutls_x509_crq_set_tlsfeatures: %s\n", gnutls_strerror(ret)); exit(1); } } gnutls_x509_tlsfeatures_deinit(features); } }
void get_tlsfeatures_set(int param_1, undefined8 param_2) { int iVar1; ulong uVar2; long in_FS_OFFSET; int local_24; undefined8 local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); if ((*piRam0000000000109b89 != 0) && (*(long *)(lRam0000000000109b9a + 0x2a0) != 0)) { iVar1 = gnutls_x509_tlsfeatures_init(&local_18); if (iVar1 < 0) { gnutls_strerror(iVar1); } local_24 = 0; while (*(long *)(*(long *)(lRam0000000000109c8d + 0x2a0) + (long)local_24 * 8) != 0) { uVar2 = strtoul(*(char **)(*(long *)(lRam0000000000109c07 + 0x2a0) + (long)local_24 * 8), (char **)0x0, 10); iVar1 = gnutls_x509_tlsfeatures_add(local_18, uVar2 & 0xffffffff); if (iVar1 < 0) { gnutls_strerror(iVar1); } local_24 = local_24 + 1; } if (param_1 == 1) { iVar1 = gnutls_x509_crt_set_tlsfeatures(param_2, local_18); if (iVar1 < 0) { gnutls_strerror(iVar1); } } else { iVar1 = gnutls_x509_crq_set_tlsfeatures(param_2, local_18); if (iVar1 < 0) { gnutls_strerror(iVar1); } } gnutls_x509_tlsfeatures_deinit(local_18); } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return; }
gnutls
ghidra
int exportable_function_name(string) const char *string; { if (absolute_program(string)) return 0; if (mbschr(string, '=') != 0) return 0; return 1; }
_BOOL8 exportable_function_name(long a1) { return !absolute_program(a1) && mbschr(a1, 61LL) == 0; }
bash
ida
void crypto_sign_ed25519_ref_fe25519_neg( crypto_sign_ed25519_ref_fe25519 *r, const crypto_sign_ed25519_ref_fe25519 *x) { crypto_sign_ed25519_ref_fe25519 t; int i; for (i = 0; i < 32; i++) t.v[i] = x->v[i]; crypto_sign_ed25519_ref_fe25519_setzero(r); crypto_sign_ed25519_ref_fe25519_sub(r, r, &t); }
long long crypto_sign_ed25519_ref_fe25519_neg(void *a0, unsigned int *a1) { unsigned int v0; char v1; for (v0 = 0; v0 <= 31; v0 = __addvsi3(v0, 0x1, a1[v0])) { *(&(&v1)[4 * v0]) = a1[v0]; } crypto_sign_ed25519_ref_fe25519_setzero(a0); crypto_sign_ed25519_ref_fe25519_sub(a0, a0, &v1); return 0; }
openssh-portable
angr_phoenix
void uid_to_uname(uid_t uid, char **uname) { struct passwd *passwd; if (uid != 0 && uid == cached_no_such_uid) { *uname = xstrdup(""); return; } if (!cached_uname || uid != cached_uid) { passwd = getpwuid(uid); if (passwd) { cached_uid = uid; assign_string(&cached_uname, passwd->pw_name); } else { cached_no_such_uid = uid; *uname = xstrdup(""); return; } } *uname = xstrdup(cached_uname); }
long long uid_to_uname(unsigned long a0, unsigned long long *a1) { unsigned long long *v0; unsigned long long *v2; if (a0 && a0 == cached_no_such_uid) { v2 = a1; *(a1) = xstrdup(&g_404344); } if (!a0 || a0 != cached_no_such_uid) { if (!cached_uname || a0 != cached_uid) { v0 = &getpwuid(a0)->pw_name; if (v0) { cached_uid = a0; assign_string(&cached_uname, *(v0)); } else { cached_no_such_uid = a0; v2 = a1; *(a1) = xstrdup(&g_404344); } } if (v0 || a0 == cached_uid && cached_uname) { v2 = a1; *(a1) = xstrdup(cached_uname); } } return v2; }
tar
angr_dream
void rsyslogdDoDie(int sig) { static int iRetries = 0; r_dbgprintf("rsyslogd.c", "DoDie called.\n"); if (Debug == 2) { if (write(1, "DoDie called.\n", sizeof("DoDie called.\n") - 1) == -1) { r_dbgprintf("rsyslogd.c", "%s:%d: write failed\n", "rsyslogd.c", 1822); } } if (iRetries++ == 4) { if (Debug == 2) { if (write(1, "DoDie called 5 times - unconditional exit\n", sizeof("DoDie called 5 times - unconditional exit\n") - 1) == -1) { r_dbgprintf("rsyslogd.c", "%s:%d: write failed\n", "rsyslogd.c", 1828); } } abort(); } bFinished = sig; if (runConf->globals.debugOnShutdown) { debugging_on = 0; rsyslogdDebugSwitch(); } r_dbgprintf("rsyslogd.c", "awaking mainthread\n"); pthread_kill(mainthread, 21); }
long long rsyslogdDoDie(unsigned long a0, unsigned long a1, unsigned long long a2) { unsigned long long v1; r_dbgprintf("rsyslogd.c", "DoDie called.\n", a2); if (Debug == 2 && write(0x1, "DoDie called.\n", 0xe) == -1) r_dbgprintf("rsyslogd.c", "%s:%d: write failed\n", "rsyslogd.c"); v1 = iRetries.10713; iRetries.10713 = iRetries.10713 + 1; if (v1 != 4) { bFinished = a0; if (*((runConf + 112))) { debugging_on = 0; rsyslogdDebugSwitch(); } r_dbgprintf("rsyslogd.c", "awaking mainthread\n", v1 + 1); return pthread_kill(mainthread, 0x15); } else { if (Debug == 2 && write(0x1, "DoDie called 5 times - unconditional exit\n", 0x2a) == -1) r_dbgprintf("rsyslogd.c", "%s:%d: write failed\n", "rsyslogd.c"); abort(); } }
rsyslog-8.2210.0
angr_phoenix
static void print_owner(FILE *f, uid_t uid) { struct passwd *pw = getpwuid(uid); if (pw) print_string(PRINT_ANY, "user", "user %s ", pw->pw_name); else print_uint(PRINT_ANY, "user", "user %u ", uid); }
long print_owner(long a1, __uid_t a2) { long *v3; v3 = (long *)getpwuid(a2); if (v3) return print_string(4u, (long)"user", "user %s ", *v3); else return print_uint(4u, (long)"user", (long)"user %u ", a2); }
iproute2-6.0.0
ida
static void mux_confirm_remote_forward(struct ssh *ssh, int type, u_int32_t seq, void *ctxt) { struct mux_channel_confirm_ctx *fctx = ctxt; char *failmsg = ((void *)0); struct Forward *rfwd; Channel *c; struct sshbuf *out; u_int port; int r; if ((c = channel_by_id(ssh, fctx->cid)) == ((void *)0)) { sshlog("mux.c", __func__, 607, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "unknown channel"); return; } if ((out = sshbuf_new()) == ((void *)0)) sshfatal("mux.c", __func__, 611, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new"); if (fctx->fid >= options.num_remote_forwards || (options.remote_forwards[fctx->fid].connect_path == ((void *)0) && options.remote_forwards[fctx->fid].connect_host == ((void *)0))) { xasprintf(&failmsg, "unknown forwarding id %d", fctx->fid); goto fail; } rfwd = &options.remote_forwards[fctx->fid]; sshlog("mux.c", __func__, 619, 1, SYSLOG_LEVEL_DEBUG1, ((void *)0), "%s for: listen %d, connect %s:%d", type == 81 ? "success" : "failure", rfwd->listen_port, rfwd->connect_path ? rfwd->connect_path : rfwd->connect_host, rfwd->connect_port) ; if (type == 81) { if (rfwd->listen_port == 0) { if ((r = sshpkt_get_u32(ssh, &port)) != 0) sshfatal("mux.c", __func__, 626, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse port"); if (port > 65535) { sshfatal("mux.c", __func__, 628, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "Invalid allocated port %u for " "mux remote forward to %s:%d", port, rfwd->connect_host, rfwd->connect_port) ; } rfwd->allocated_port = (int)port; sshlog("mux.c", __func__, 633, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "Allocated port %u for mux remote forward" " to %s:%d", rfwd->allocated_port, rfwd->connect_host, rfwd->connect_port) ; if ((r = sshbuf_put_u32(out, 0x80000007)) != 0 || (r = sshbuf_put_u32(out, fctx->rid)) != 0 || (r = sshbuf_put_u32(out, rfwd->allocated_port)) != 0) sshfatal("mux.c", __func__, 641, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "reply"); channel_update_permission(ssh, rfwd->handle, rfwd->allocated_port); } else { reply_ok(out, fctx->rid); } goto out; } else { if (rfwd->listen_port == 0) channel_update_permission(ssh, rfwd->handle, -1); if (rfwd->listen_path != ((void *)0)) xasprintf(&failmsg, "remote port forwarding failed for " "listen path %s", rfwd->listen_path); else xasprintf(&failmsg, "remote port forwarding failed for " "listen port %d", rfwd->listen_port); sshlog("mux.c", __func__, 658, 1, SYSLOG_LEVEL_DEBUG2, ((void *)0), "clearing registered forwarding for listen %d, " "connect %s:%d", rfwd->listen_port, rfwd->connect_path ? rfwd->connect_path : rfwd->connect_host, rfwd->connect_port) ; free(rfwd->listen_host); free(rfwd->listen_path); free(rfwd->connect_host); free(rfwd->connect_path); memset(rfwd, 0, sizeof(*rfwd)); } fail: sshlog("mux.c", __func__, 670, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "%s", failmsg); reply_error(out, 0x80000003, fctx->rid, failmsg); free(failmsg); out: if ((r = sshbuf_put_stringb(c->output, out)) != 0) sshfatal("mux.c", __func__, 675, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "enqueue"); sshbuf_free(out); if (c->mux_pause <= 0) sshfatal("mux.c", __func__, 678, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "mux_pause %d", c->mux_pause); c->mux_pause = 0; }
void mux_confirm_remote_forward(undefined8 param_1, int param_2, undefined4 param_3, long param_4) { undefined4 uVar1; uint uVar2; undefined4 uVar3; void *pvVar4; undefined8 uVar5; char *pcVar6; undefined *puVar7; undefined *puVar8; char **ppcVar9; long in_FS_OFFSET; char *apcStack224[2]; ulong uStack208; char *pcStack200; ulong uStack192; char *pcStack184; ulong uStack176; char *pcStack168; ulong uStack160; void *pvStack152; ulong auStack144[3]; char *pcStack120; undefined8 uStack112; undefined auStack104[8]; long local_60; undefined4 local_58; int local_54; undefined8 local_50; uint local_40; int local_3c; void *local_38; long local_30; long local_28; long local_20; void **local_18; long local_10; ppcVar9 = (char **)auStack104; puVar7 = auStack104; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_38 = (void *)0x0; uStack112 = 0x1018b0; local_60 = param_4; local_58 = param_3; local_54 = param_2; local_50 = param_1; local_30 = param_4; local_28 = channel_by_id(param_1); if (local_28 == 0) { pcStack120 = "unknown channel"; sshlog("mux.c", "mux_confirm_remote_forward", 0x25f, 1, 2, 0); goto LAB_00101edf; } uStack112 = 0x101903; local_20 = sshbuf_new(); if (local_20 == 0) { ppcVar9 = &pcStack120; pcStack120 = "sshbuf_new"; sshfatal("mux.c", "mux_confirm_remote_forward", 0x263, 1, 1, 0); } if ((*(int *)(local_30 + 8) < _DAT_0010c348) && ((*(long *)((long)*(int *)(local_30 + 8) * 0x38 + _DAT_0010c350 + 0x28) != 0 || (*(long *)((long)*(int *)(local_30 + 8) * 0x38 + _DAT_0010c350 + 0x18) != 0)))) { local_18 = (void **)((long)*(int *)(local_30 + 8) * 0x38 + _DAT_0010c350); if (local_18[5] == (void *)0x0) { pvVar4 = local_18[3]; } else { pvVar4 = local_18[5]; } uVar2 = *(uint *)(local_18 + 1); if (local_54 == 0x51) { pcVar6 = "success"; } else { pcVar6 = "failure"; } *(ulong *)((long)ppcVar9 + -0x10) = (ulong) * (uint *)(local_18 + 4); *(void **)((long)ppcVar9 + -0x18) = pvVar4; *(ulong *)((long)ppcVar9 + -0x20) = (ulong)uVar2; *(char **)((long)ppcVar9 + -0x28) = pcVar6; *(char **)((long)ppcVar9 + -0x30) = "%s for: listen %d, connect %s:%d"; *(undefined8 *)((long)ppcVar9 + -0x38) = 0x101a7a; sshlog("mux.c", "mux_confirm_remote_forward", 0x26b, 1, 5, 0); if (local_54 != 0x51) { if (*(int *)(local_18 + 1) == 0) { uVar1 = *(undefined4 *)((long)local_18 + 0x34); *(undefined8 *)((long)ppcVar9 + -8) = 0x101ca1; channel_update_permission(local_50, uVar1, 0xffffffff); } if (local_18[2] == (void *)0x0) { uVar1 = *(undefined4 *)(local_18 + 1); *(undefined8 *)((long)ppcVar9 + -8) = 0x101cef; xasprintf(&local_38, "remote port forwarding failed for listen port %d", uVar1); } else { pvVar4 = local_18[2]; *(undefined8 *)((long)ppcVar9 + -8) = 0x101cce; xasprintf(&local_38, "remote port forwarding failed for listen path %s", pvVar4); } if (local_18[5] == (void *)0x0) { pvVar4 = local_18[3]; } else { pvVar4 = local_18[5]; } uVar2 = *(uint *)(local_18 + 1); *(ulong *)((long)ppcVar9 + -8) = (ulong) * (uint *)(local_18 + 4); *(void **)((long)ppcVar9 + -0x10) = pvVar4; *(ulong *)((long)ppcVar9 + -0x18) = (ulong)uVar2; *(char **)((long)ppcVar9 + -0x20) = "clearing registered forwarding for listen %d, connect %s:%d"; *(undefined8 *)((long)ppcVar9 + -0x28) = 0x101d55; sshlog("mux.c", "mux_confirm_remote_forward", 0x292, 1, 6, 0); pvVar4 = *local_18; *(undefined8 *)((long)ppcVar9 + -8) = 0x101d68; free(pvVar4); pvVar4 = local_18[2]; *(undefined8 *)((long)ppcVar9 + -8) = 0x101d78; free(pvVar4); pvVar4 = local_18[3]; *(undefined8 *)((long)ppcVar9 + -8) = 0x101d88; free(pvVar4); pvVar4 = local_18[5]; *(undefined8 *)((long)ppcVar9 + -8) = 0x101d98; free(pvVar4); *(undefined8 *)((long)ppcVar9 + -8) = 0x101dae; memset(local_18, 0, 0x38); goto LAB_00101dae; } if (*(int *)(local_18 + 1) == 0) { *(undefined8 *)((long)ppcVar9 + -8) = 0x101aaa; local_3c = sshpkt_get_u32(local_50, &local_40); puVar7 = (undefined *)ppcVar9; if (local_3c != 0) { *(undefined8 *)((long)ppcVar9 + -8) = 0x101abd; uVar5 = ssh_err(local_3c); puVar7 = (undefined *)((long)ppcVar9 + -0x10); *(char **)((long)ppcVar9 + -0x10) = "parse port"; *(undefined8 *)((long)ppcVar9 + -0x18) = 0x101af4; sshfatal("mux.c", "mux_confirm_remote_forward", 0x272, 1, 1, uVar5); } puVar8 = puVar7; if (0xffff < local_40) { pvVar4 = local_18[3]; *(ulong *)(puVar7 + -8) = (ulong) * (uint *)(local_18 + 4); *(void **)(puVar7 + -0x10) = pvVar4; *(ulong *)(puVar7 + -0x18) = (ulong)local_40; puVar8 = puVar7 + -0x20; *(char **)(puVar7 + -0x20) = "Invalid allocated port %u for mux remote forward to %s:%d"; *(undefined8 *)(puVar7 + -0x28) = 0x101b49; sshfatal("mux.c", "mux_confirm_remote_forward", 0x274, 0, 1, 0); } *(uint *)(local_18 + 6) = local_40; pvVar4 = local_18[3]; uVar2 = *(uint *)(local_18 + 6); *(ulong *)(puVar8 + -8) = (ulong) * (uint *)(local_18 + 4); *(void **)(puVar8 + -0x10) = pvVar4; *(ulong *)(puVar8 + -0x18) = (ulong)uVar2; *(char **)(puVar8 + -0x20) = "Allocated port %u for mux remote forward to %s:%d"; *(undefined8 *)(puVar8 + -0x28) = 0x101ba4; sshlog("mux.c", "mux_confirm_remote_forward", 0x279, 0, 5, 0); *(undefined8 *)(puVar8 + -8) = 0x101bb9; local_3c = sshbuf_put_u32(local_20, 0x80000007); if (local_3c == 0) { uVar1 = *(undefined4 *)(local_30 + 4); *(undefined8 *)(puVar8 + -8) = 0x101bd7; local_3c = sshbuf_put_u32(local_20, uVar1); if (local_3c != 0) goto LAB_00101c00; uVar1 = *(undefined4 *)(local_18 + 6); *(undefined8 *)(puVar8 + -8) = 0x101bf7; local_3c = sshbuf_put_u32(local_20, uVar1); ppcVar9 = (char **)puVar8; if (local_3c != 0) goto LAB_00101c00; } else { LAB_00101c00: *(undefined8 *)(puVar8 + -8) = 0x101c0a; uVar5 = ssh_err(local_3c); ppcVar9 = (char **)(puVar8 + -0x10); *(char **)(puVar8 + -0x10) = "reply"; *(undefined8 *)(puVar8 + -0x18) = 0x101c41; sshfatal("mux.c", "mux_confirm_remote_forward", 0x281, 1, 1, uVar5); } uVar1 = *(undefined4 *)(local_18 + 6); uVar3 = *(undefined4 *)((long)local_18 + 0x34); *(undefined8 *)((long)ppcVar9 + -8) = 0x101c5d; channel_update_permission(local_50, uVar3, uVar1); } else { uVar1 = *(undefined4 *)(local_30 + 4); *(undefined8 *)((long)ppcVar9 + -8) = 0x101c77; reply_ok(local_20, uVar1); } } else { uVar1 = *(undefined4 *)(local_30 + 8); *(undefined8 *)((long)ppcVar9 + -8) = 0x1019ce; xasprintf(&local_38, "unknown forwarding id %d", uVar1); LAB_00101dae: *(void **)((long)ppcVar9 + -8) = local_38; *(undefined **)((long)ppcVar9 + -0x10) = &DAT_0010951c; *(undefined8 *)((long)ppcVar9 + -0x18) = 0x101de9; sshlog("mux.c", "mux_confirm_remote_forward", 0x29e, 1, 2, 0); uVar1 = *(undefined4 *)(local_30 + 4); *(undefined8 *)((long)ppcVar9 + -8) = 0x101e09; reply_error(local_20, 0x80000003, uVar1, local_38); *(undefined8 *)((long)ppcVar9 + -8) = 0x101e15; free(local_38); } uVar5 = *(undefined8 *)(local_28 + 0x70); *(undefined8 *)((long)ppcVar9 + -8) = 0x101e2c; local_3c = sshbuf_put_stringb(uVar5, local_20); puVar8 = (undefined *)ppcVar9; if (local_3c != 0) { *(undefined8 *)((long)ppcVar9 + -8) = 0x101e3f; uVar5 = ssh_err(local_3c); puVar8 = (undefined *)((long)ppcVar9 + -0x10); *(char **)((long)ppcVar9 + -0x10) = "enqueue"; *(undefined8 *)((long)ppcVar9 + -0x18) = 0x101e76; sshfatal("mux.c", "mux_confirm_remote_forward", 0x2a3, 1, 1, uVar5); } *(undefined8 *)(puVar8 + -8) = 0x101e82; sshbuf_free(local_20); puVar7 = puVar8; if (*(int *)(local_28 + 0x158) < 1) { *(ulong *)(puVar8 + -8) = (ulong) * (uint *)(local_28 + 0x158); puVar7 = puVar8 + -0x10; *(char **)(puVar8 + -0x10) = "mux_pause %d"; *(undefined8 *)(puVar8 + -0x18) = 0x101ed1; sshfatal("mux.c", "mux_confirm_remote_forward", 0x2a6, 1, 1, 0); } *(undefined4 *)(local_28 + 0x158) = 0; LAB_00101edf: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { *(undefined8 *)(puVar7 + -8) = 0x101ef3; __stack_chk_fail(); } return; }
openssh-portable
ghidra
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
vi_zero(EditLine *el, wint_t c) { if (el->el_state.doingarg) return ed_argument_digit(el, c); el->el_line.cursor = el->el_line.buffer; if (el->el_chared.c_vcmd.action != 0x00) { cv_delfini(el); return 4; } return 5; }
long long vi_zero(struct_0 *a0, unsigned long a1) { unsigned long long v1; if (a0->field_74) { v1 = ed_argument_digit(a0, a1, a1); } else { a0->field_58 = a0->field_50; if (a0->field_3c0) { cv_delfini(a0); v1 = 4; } else { v1 = 5; } } return v1; }
libedit
angr_dream
LogLevel log_level_number(char *name) { int i; if (name != ((void *)0)) for (i = 0; log_levels[i].name; i++) if (strcasecmp(log_levels[i].name, name) == 0) return log_levels[i].val; return SYSLOG_LEVEL_NOT_SET; }
long long log_level_number(char *a0) { unsigned int v0; unsigned long long v2; unsigned long long v3; if (a0) { for (v0 = 0; log_levels[2 * v0]; v0 = __addvsi3(v0, 0x1)) { v2 = strcasecmp(log_levels[2 * v0], a0); if (!v2) { v3 = (&g_401308)[2 * v0]; break; } } } if (!log_levels[2 * v0] || !a0 || v2) v3 = 4294967295; return v3; }
openssh-portable
angr_dream
static _Bool parse_cmin(const struct parser_table *entry, char **argv, int *arg_ptr) { return do_parse_xmin(entry, argv, arg_ptr, XVAL_CTIME); }
void parse_cmin(undefined8 param_1, undefined8 param_2, undefined8 param_3) { do_parse_xmin(param_1, param_2, param_3, 2); return; }
findutils
ghidra
static _Bool tail_bytes(char const *pretty_filename, int fd, uintmax_t n_bytes, uintmax_t *read_pos) { struct stat stats; if (fstat(fd, &stats)) { error(0, (*__errno_location()), gettext("cannot fstat %s"), quotearg_style(shell_escape_always_quoting_style, pretty_filename)); return 0; } if (from_start) { if (!presume_input_pipe && n_bytes <= ((off_t)(!(!((off_t)0 < (off_t)-1)) ? (off_t)-1 : ((((off_t)1 << ((sizeof(off_t) * 8) - 2)) - 1) * 2 + 1))) && ((((((stats.st_mode)) & 0170000) == (0100000)) && xlseek(fd, n_bytes, 1, pretty_filename) >= 0) || lseek(fd, n_bytes, 1) != -1)) *read_pos += n_bytes; else { int t = start_bytes(pretty_filename, fd, n_bytes, read_pos); if (t) return t < 0; } n_bytes = (18446744073709551615UL); } else { off_t end_pos = -1; off_t current_pos = -1; if (!presume_input_pipe && n_bytes <= ((off_t)(!(!((off_t)0 < (off_t)-1)) ? (off_t)-1 : ((((off_t)1 << ((sizeof(off_t) * 8) - 2)) - 1) * 2 + 1)))) { if (usable_st_size(&stats)) end_pos = stats.st_size; else if ((current_pos = lseek(fd, -n_bytes, 2)) != -1) end_pos = current_pos + n_bytes; } if (end_pos <= (off_t)((0 < (stats).st_blksize && (stats).st_blksize <= ((size_t)-1) / 8 + 1) ? (stats).st_blksize : 512)) return pipe_bytes(pretty_filename, fd, n_bytes, read_pos); if (current_pos == -1) current_pos = xlseek(fd, 0, 1, pretty_filename); if (current_pos < end_pos) { off_t bytes_remaining = end_pos - current_pos; if (n_bytes < bytes_remaining) { current_pos = end_pos - n_bytes; xlseek(fd, current_pos, 0, pretty_filename); } } *read_pos = current_pos; } *read_pos += dump_remainder(0, pretty_filename, fd, n_bytes); return 1; }
void tail_bytes(unsigned long long a0, unsigned long a1, unsigned long a2, unsigned long long *a3) { unsigned long long *v0; unsigned long long v1; char v2; unsigned int v3; unsigned long long v4; unsigned long long v5; unsigned long v6; char v7; char v8; char v9; char v10; unsigned long long v13; unsigned long long v15; void *v16; unsigned long long v17; unsigned long long v18; unsigned long long v19; unsigned long long v20; unsigned long long v22; v1 = a2; v0 = a3; if (fstat(a1, &v7)) { v13 = quotearg_style(0x4, a0); error(0x0, *(__errno_location()), gettext("cannot fstat %s")); v16 = 0; } else { if (from_start) { if ((presume_input_pipe ^ 1) && v1 >= 0) { if ((*(&v8) & 0xf000) == 0x8000) v15 = xlseek(*(&v2), v1, 0x1, a0); if (v15 < 0 || (*(&v8) & 0xf000) != 0x8000) v17 = lseek(*(&v2), v1, 0x1); if (((*(&v8) & 0xf000) == 0x8000 || v17 != -1) && (v15 >= 0 || v17 != -1)) *(a3) = *(a3) + v1; } if (v1 < 0 || !(presume_input_pipe ^ 1) || v15 < 0 && v17 == -1 || v17 == -1 && (*(&v8) & 0xf000) != 0x8000) { v3 = start_bytes(a0, *(&v2), v1, a3); if (v3) v19 = v3 >> 31; } if ((!v3 || v1 >= 0) && (!v3 || (presume_input_pipe ^ 1)) && ((*(&v8) & 0xf000) == 0x8000 || !v3 || v17 != -1) && (!v3 || v15 >= 0 || v17 != -1)) v1 = -1; } else { v4 = -1; v5 = -1; if ((presume_input_pipe ^ 1) && v1 >= 0) { if (usable_st_size(&v7)) { v4 = *(&v9); } else { v5 = lseek(*(&v2), -(v1), 0x2); if (v5 != -1) v4 = v1 + v5; } } if (*(&v10) > 0 && *(&v10) <= 0x2000000000000000) v18 = *(&v10); if (*(&v10) <= 0 || *(&v10) > 0x2000000000000000) v18 = 0x200; if (v18 >= v4) { v20 = pipe_bytes(a0, *(&v2), v1, a3); } else { if (v5 == -1) v5 = xlseek(*(&v2), 0x0, 0x1, a0); if (v5 < v4) { v6 = v4 - v5; if (v1 < v6) { v5 = v4 - v1; xlseek(*(&v2), v5, 0x0, a0); } } *(a3) = v5; } } if (v18 < v4 && !from_start || from_start && (!v3 || v1 >= 0) && (!v3 || (presume_input_pipe ^ 1)) && ((*(&v8) & 0xf000) == 0x8000 || !v3 || v17 != -1) && (!v3 || v15 >= 0 || v17 != -1)) { *(a3) = *(a3) + dump_remainder(0x0, a0, *(&v2), v1); v22 = 1; } } return; }
coreutils
angr_dream
int main(int argc, char **argv) { char buf[8192]; char *name; char *newpwd; char *cp; const struct sgrp *sg; struct sgrp newsg; const struct group *gr; struct group newgr; int errors = 0; int line = 0; Prog = Basename(argv[0]); log_set_progname(Prog); log_set_logfd(stderr); (void)setlocale(6, ""); (void)bindtextdomain("shadow", "/usr/share/locale"); (void)textdomain("shadow"); process_root_flag("-R", argc, argv); process_flags(argc, argv); openlog("chgpasswd", (0x01), (10 << 3)); check_perms(); is_shadow_grp = sgr_file_present(); open_files(); while (fgets(buf, (int)sizeof buf, stdin) != (char *)0) { line++; cp = strrchr(buf, '\n'); if (((void *)0) != cp) { *cp = '\0'; } else { fprintf(stderr, gettext("%s: line %d: line too long\n"), Prog, line); errors++; continue; } name = buf; cp = strchr(name, ':'); if (((void *)0) != cp) { *cp = '\0'; cp++; } else { fprintf(stderr, gettext("%s: line %d: missing new password\n"), Prog, line); errors++; continue; } newpwd = cp; if ((!eflg) && ((((void *)0) == crypt_method) || (0 != strcmp(crypt_method, "NONE")))) { void *arg = ((void *)0); const char *salt; if (md5flg) { crypt_method = "MD5"; } if (sflg) { if ((0 == strcmp(crypt_method, "SHA256")) || (0 == strcmp(crypt_method, "SHA512"))) { arg = &sha_rounds; } } salt = crypt_make_salt(crypt_method, arg); cp = pw_encrypt(newpwd, salt); if (((void *)0) == cp) { fprintf(stderr, gettext("%s: failed to crypt password with salt '%s': %s\n"), Prog, salt, strerror((*__errno_location()))); fail_exit(1); } } gr = gr_locate(name); if (((void *)0) == gr) { fprintf(stderr, gettext("%s: line %d: group '%s' does not exist\n"), Prog, line, name); errors++; continue; } if (is_shadow_grp) { sg = sgr_locate(name); if ((((void *)0) == sg) && (strcmp(gr->gr_passwd, "x") == 0)) { static char *empty = ((void *)0); newsg.sg_name = name; newsg.sg_adm = &empty; newsg.sg_mem = dup_list(gr->gr_mem); sg = &newsg; } } else { sg = ((void *)0); } if (((void *)0) != sg) { newsg = *sg; newsg.sg_passwd = cp; } if ((((void *)0) == sg) || (strcmp(gr->gr_passwd, "x") != 0)) { newgr = *gr; newgr.gr_passwd = cp; } if (((void *)0) != sg) { if (sgr_update(&newsg) == 0) { fprintf( stderr, gettext("%s: line %d: failed to prepare the new %s entry '%s'\n"), Prog, line, sgr_dbname(), newsg.sg_name); errors++; continue; } } if ((((void *)0) == sg) || (strcmp(gr->gr_passwd, "x") != 0)) { if (gr_update(&newgr) == 0) { fprintf( stderr, gettext("%s: line %d: failed to prepare the new %s entry '%s'\n"), Prog, line, gr_dbname(), newgr.gr_name); errors++; continue; } } } if (0 != errors) { fprintf(stderr, gettext("%s: error detected, changes ignored\n"), Prog); fail_exit(1); } close_files(); nscd_flush_cache("group"); sssd_flush_cache(0x002); return (0); }
undefined8 main(undefined4 param_1, undefined8 *param_2) { int iVar1; undefined8 uVar2; int *piVar3; char *pcVar4; undefined8 *puVar5; undefined8 uVar6; undefined8 uVar7; char *pcVar8; long in_FS_OFFSET; int local_20b8; uint local_20b4; char *local_20b0; char **local_20a8; undefined8 *local_20a0; char *local_2078; char *local_2070; undefined8 *local_2068; char *local_2060; undefined8 local_2058; char *local_2050; undefined8 local_2048; undefined8 local_2040; char local_2038[8200]; long local_30; local_30 = *(long *)(in_FS_OFFSET + 0x28); local_20b8 = 0; local_20b4 = 0; Prog = Basename(*param_2); log_set_progname(Prog); log_set_logfd(stderr); setlocale(6, ""); bindtextdomain("shadow", "/usr/share/locale"); textdomain("shadow"); process_root_flag(&DAT_001016ee, param_1, param_2); process_flags(param_1, param_2); openlog("chgpasswd", 1, 0x50); check_perms(); is_shadow_grp = sgr_file_present(); open_files(); do { while (true) { while (true) { while (true) { pcVar8 = fgets(local_2038, 0x2000, stdin); uVar2 = Prog; if (pcVar8 == (char *)0x0) { if (local_20b8 != 0) { pcVar8 = (char *)gettext("%s: error detected, changes ignored\n"); fprintf(stderr, pcVar8, uVar2); fail_exit(1); } close_files(); nscd_flush_cache("group"); sssd_flush_cache(2); if (local_30 == *(long *)(in_FS_OFFSET + 0x28)) { return 0; } __stack_chk_fail(); } local_20b4 = local_20b4 + 1; pcVar8 = strrchr(local_2038, 10); uVar2 = Prog; if (pcVar8 != (char *)0x0) break; pcVar8 = (char *)gettext("%s: line %d: line too long\n"); fprintf(stderr, pcVar8, uVar2, (ulong)local_20b4); local_20b8 = local_20b8 + 1; } *pcVar8 = '\0'; local_20b0 = strchr(local_2038, 0x3a); uVar2 = Prog; if (local_20b0 != (char *)0x0) break; pcVar8 = (char *)gettext("%s: line %d: missing new password\n"); fprintf(stderr, pcVar8, uVar2, (ulong)local_20b4); local_20b8 = local_20b8 + 1; } *local_20b0 = '\0'; local_20b0 = local_20b0 + 1; if ((eflg != '\x01') && ((crypt_method == (char *)0x0 || (iVar1 = strcmp(crypt_method, "NONE"), iVar1 != 0)))) { local_20a0 = (undefined8 *)0x0; if (md5flg != '\0') { crypt_method = "MD5"; } if ((sflg != '\0') && ((iVar1 = strcmp(crypt_method, "SHA256"), iVar1 == 0 || (iVar1 = strcmp(crypt_method, "SHA512"), iVar1 == 0)))) { local_20a0 = &sha_rounds; } uVar2 = crypt_make_salt(crypt_method, local_20a0); local_20b0 = (char *)pw_encrypt(local_20b0, uVar2); if (local_20b0 == (char *)0x0) { piVar3 = __errno_location(); pcVar8 = strerror(*piVar3); uVar6 = Prog; pcVar4 = (char *)gettext( "%s: failed to crypt password with salt \'%s\': %s\n"); fprintf(stderr, pcVar4, uVar6, uVar2, pcVar8); fail_exit(1); } } puVar5 = (undefined8 *)gr_locate(local_2038); uVar2 = Prog; if (puVar5 != (undefined8 *)0x0) break; pcVar8 = (char *)gettext("%s: line %d: group \'%s\' does not exist\n"); fprintf(stderr, pcVar8, uVar2, (ulong)local_20b4, local_2038); local_20b8 = local_20b8 + 1; } if (is_shadow_grp == '\0') { local_20a8 = (char **)0x0; } else { local_20a8 = (char **)sgr_locate(local_2038); if ((local_20a8 == (char **)0x0) && (iVar1 = strcmp((char *)puVar5[1], "x"), iVar1 == 0)) { local_2068 = &empty_5713; local_2078 = local_2038; local_2060 = (char *)dup_list(puVar5[3]); local_20a8 = &local_2078; } } if (local_20a8 == (char **)0x0) { LAB_0010103f: local_2058 = *puVar5; local_2048 = puVar5[2]; local_2040 = puVar5[3]; local_2050 = local_20b0; } else { local_2078 = *local_20a8; local_2068 = (undefined8 *)local_20a8[2]; local_2060 = local_20a8[3]; local_2070 = local_20b0; iVar1 = strcmp((char *)puVar5[1], "x"); if (iVar1 != 0) goto LAB_0010103f; } if ((local_20a8 == (char **)0x0) || (iVar1 = sgr_update(&local_2078), pcVar8 = local_2078, iVar1 != 0)) { if (((local_20a8 == (char **)0x0) || (iVar1 = strcmp((char *)puVar5[1], "x"), iVar1 != 0)) && (iVar1 = gr_update(&local_2058), uVar2 = local_2058, iVar1 == 0)) { uVar7 = gr_dbname(); uVar6 = Prog; pcVar8 = (char *)gettext( "%s: line %d: failed to prepare the new %s entry \'%s\'\n"); fprintf(stderr, pcVar8, uVar6, (ulong)local_20b4, uVar7, uVar2); local_20b8 = local_20b8 + 1; } } else { uVar6 = sgr_dbname(); uVar2 = Prog; pcVar4 = (char *)gettext( "%s: line %d: failed to prepare the new %s entry \'%s\'\n"); fprintf(stderr, pcVar4, uVar2, (ulong)local_20b4, uVar6, pcVar8); local_20b8 = local_20b8 + 1; } } while (true); }
shadow
ghidra
void errc(int status, int code, const char *format, ...) { va_list ap; __builtin_va_start(ap, format); verrc(status, code, format, ap); __builtin_va_end(ap); }
long long errc(unsigned long a0, unsigned long a1) { unsigned long v0; unsigned int v1; unsigned int v2; unsigned long v3; unsigned long v4; unsigned long v5; char v6; unsigned long v7; unsigned long v8; unsigned long v9; int v10; int v11; int v12; int v13; int v14; int v15; int v16; int v17; unsigned long v18; unsigned long v19; unsigned long v20; unsigned long v21; unsigned long v22; char v23; int v24; int v25; int v26; int v27; int v28; int v29; int v30; int v31; unsigned long long *v32; v0 = v19; v7 = v20; v8 = v21; v9 = v22; if (v23) { v10 = v24; v11 = v25; v12 = v26; v13 = v27; v14 = v28; v15 = v29; v16 = v30; v17 = v31; } v5 = v32[5]; v1 = 24; v2 = 48; v3 = &v18; v4 = &v6; verrc(a0, a1); }
libbsd-0.11.7
angr_phoenix
static time_t reaper(void) { time_t deadline = 0, now = monotime(); Identity *id, *nxt; for (id = ((&idtab->idlist)->tqh_first); id; id = nxt) { nxt = ((id)->next.tqe_next); if (id->death == 0) continue; if (now >= id->death) { sshlog("ssh-agent.c", __func__, 940, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "expiring key '%s'", id->comment); do { if (((id)->next.tqe_next) != ((void *)0)) (id)->next.tqe_next->next.tqe_prev = (id)->next.tqe_prev; else (&idtab->idlist)->tqh_last = (id)->next.tqe_prev; *(id)->next.tqe_prev = (id)->next.tqe_next; ; ; } while (0); free_identity(id); idtab->nentries--; } else deadline = (deadline == 0) ? id->death : (((deadline) < (id->death)) ? (deadline) : (id->death)); } if (deadline == 0 || deadline <= now) return 0; else return (deadline - now); }
long reaper() { long v0; long v2; long i; long v4; long v5; v2 = 0LL; v4 = monotime(); for (i = *(_QWORD *)(idtab + 8); i; i = v5) { v5 = *(_QWORD *)i; if (*(_QWORD *)(i + 40)) { if (v4 < *(_QWORD *)(i + 40)) { if (v2) { v0 = *(_QWORD *)(i + 40); if (v2 <= v0) v0 = v2; } else { v0 = *(_QWORD *)(i + 40); } v2 = v0; } else { sshlog("ssh-agent.c", "reaper", 940LL, 0LL, 5LL, 0LL, "expiring key '%s'", *(const char **)(i + 24)); if (*(_QWORD *)i) *(_QWORD *)(*(_QWORD *)i + 8LL) = *(_QWORD *)(i + 8); else *(_QWORD *)(idtab + 16) = *(_QWORD *)(i + 8); **(_QWORD **)(i + 8) = *(_QWORD *)i; free_identity(i); --*(_DWORD *)idtab; } } } if (v2 && v2 > v4) return v2 - v4; else return 0LL; }
openssh-portable
ida
_Bool pred_anewer (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr) { (void)&pathname; ((void)sizeof((COMP_GT == pred_ptr->args.reftime.kind) ? 1 : 0), __extension__({ if (COMP_GT == pred_ptr->args.reftime.kind) ; else __assert_fail("COMP_GT == pred_ptr->args.reftime.kind", "pred.c", 166, __extension__ __PRETTY_FUNCTION__); })); return compare_ts(get_stat_atime(stat_buf), pred_ptr->args.reftime.ts) > 0; }
long long pred_anewer(unsigned long a0, unsigned long long a1, struct_0 *a2) { unsigned long v0; unsigned long long v2; v0 = a0; if (a2->field_3c) __assert_fail(); v2 = compare_ts(get_stat_atime(a1), a2, a2->field_40, a2->field_48); *(&v2) = v2 > 0; return v2; }
findutils
angr_phoenix
int pkcs11_add_provider(char *name, char *pin, struct sshkey ***keysp, char ***labelsp) { struct sshkey *k; int r, type; u_char *blob; char *label; size_t blen; u_int nkeys, i; struct sshbuf *msg; if (fd < 0 && pkcs11_start_helper() < 0) return (-1); if ((msg = sshbuf_new()) == ((void *)0)) sshfatal("ssh-pkcs11-client.c", __func__, 330, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new failed"); if ((r = sshbuf_put_u8(msg, 20)) != 0 || (r = sshbuf_put_cstring(msg, name)) != 0 || (r = sshbuf_put_cstring(msg, pin)) != 0) sshfatal("ssh-pkcs11-client.c", __func__, 334, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "compose"); send_msg(msg); sshbuf_reset(msg); type = recv_msg(msg); if (type == 12) { if ((r = sshbuf_get_u32(msg, &nkeys)) != 0) sshfatal("ssh-pkcs11-client.c", __func__, 341, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse nkeys"); *keysp = xcalloc(nkeys, sizeof(struct sshkey *)); if (labelsp) *labelsp = xcalloc(nkeys, sizeof(char *)); for (i = 0; i < nkeys; i++) { if ((r = sshbuf_get_string(msg, &blob, &blen)) != 0 || (r = sshbuf_get_cstring(msg, &label, ((void *)0))) != 0) sshfatal("ssh-pkcs11-client.c", __func__, 349, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse key"); if ((r = sshkey_from_blob(blob, blen, &k)) != 0) sshfatal("ssh-pkcs11-client.c", __func__, 351, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "decode key"); wrap_key(k); (*keysp)[i] = k; if (labelsp) (*labelsp)[i] = label; else free(label); free(blob); } } else if (type == 30) { if ((r = sshbuf_get_u32(msg, &nkeys)) != 0) nkeys = -1; } else { nkeys = -1; } sshbuf_free(msg); return (nkeys); }
long long pkcs11_add_provider(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 int v2; unsigned int v3; unsigned int v4; unsigned int v5; char v6; char v7; char v8; char v9; unsigned long long v10; unsigned long long v11; unsigned long long v13; v1 = a0; if (fd < 0 && pkcs11_start_helper(a0, a1, a2, a3, a4, a5) < 0) { v13 = 4294967295; return v13; } v10 = sshbuf_new(); if (!v10) { v0 = "sshbuf_new failed"; sshfatal("ssh-pkcs11-client.c", "pkcs11_add_provider", 0x14a, 0x1, 0x1, 0x0); } v3 = sshbuf_put_u8(v10, 0x14); if (v3) { LABEL_4011c7: v11 = "compose"; sshfatal("ssh-pkcs11-client.c", "pkcs11_add_provider", 0x14e, 0x1, 0x1, ssh_err(v3)); } else { v3 = sshbuf_put_cstring(v10, v1, v1); if (v3 || (v3 = sshbuf_put_cstring(v10, a1, a1), v3)) goto LABEL_4011c7; } send_msg(v10); sshbuf_reset(v10); v5 = recv_msg(v10); switch (v5) { case 12: v3 = sshbuf_get_u32(v10, &v2, &v2); if (v3) { v11 = "parse nkeys"; sshfatal("ssh-pkcs11-client.c", "pkcs11_add_provider", 0x155, 0x1, 0x1, ssh_err(v3)); } *(a2) = xcalloc(v2, 0x8); if (a3) *(a3) = xcalloc(v2, 0x8); for (v4 = 0; v4 < v2; v4 += 1) { v3 = sshbuf_get_string(v10, &v7, &v9, &v7); if (v3 || (v3 = sshbuf_get_cstring(v10, &v8, 0x0, &v8), v3)) { v11 = "parse key"; sshfatal("ssh-pkcs11-client.c", "pkcs11_add_provider", 0x15d, 0x1, 0x1, ssh_err(v3)); } v3 = sshkey_from_blob(*(&v7), *(&v9), &v6, *(&v9)); if (v3) { v11 = "decode key"; sshfatal("ssh-pkcs11-client.c", "pkcs11_add_provider", 0x15f, 0x1, 0x1, ssh_err(v3)); } wrap_key(*(&v6)); *((v4 * 8 + *(a2))) = *(&v6); if (a3) *((v4 * 8 + *(a3))) = *(&v8); else free(*(&v8)); free(*(&v7)); } case 30: v3 = sshbuf_get_u32(v10, &v2, &v2); if (v3) { v2 = -1; break; } default: v2 = -1; break; } sshbuf_free(v10); v13 = v2; return v13; }
openssh-portable
angr_sailr
void init_mail_dates() { if (mailfiles == 0) remember_mail_dates(); }
void init_mail_dates(void) { if (mailfiles == 0) { remember_mail_dates(); } return; }
bash
ghidra
int sh_chkwrite(s) int s; { do { if (terminating_signal) termsig_handler(terminating_signal); if (interrupt_state) throw_to_top_level(); } while (0); fflush(stdout); do { if (terminating_signal) termsig_handler(terminating_signal); if (interrupt_state) throw_to_top_level(); } while (0); if (ferror(stdout)) { sh_wrerror(); fpurge(stdout); clearerr(stdout); return (1); } return (s); }
long long sh_chkwrite(unsigned long a0) { unsigned long long v2; if (terminating_signal) termsig_handler(terminating_signal); if (interrupt_state) throw_to_top_level(); fflush(stdout); if (terminating_signal) termsig_handler(terminating_signal); if (interrupt_state) throw_to_top_level(); if (ferror(stdout)) { sh_wrerror(); fpurge(stdout); clearerr(stdout); v2 = 1; } else { v2 = a0; } return v2; }
bash
angr_dream
static int isnbspace(int c) { return iswnbspace(btowc(c)); }
int isnbspace(unsigned long a0) { return iswnbspace(btowc(a0)); }
coreutils
angr_sailr
static void postproc_subst_rhs(void) { char *new; int i, j, new_size; new = (char *)xmalloc(new_size = subst_rhs_len + subst_lhs_len); for (i = j = 0; i < subst_rhs_len; i++) { if (subst_rhs[i] == '&') { if (j + subst_lhs_len >= new_size) new = (char *)xrealloc(new, (new_size = new_size * 2 + subst_lhs_len)); strcpy(new + j, subst_lhs); j += subst_lhs_len; } else { if (subst_rhs[i] == '\\' && subst_rhs[i + 1] == '&') i++; if (j >= new_size) new = (char *)xrealloc(new, new_size *= 2); new[j++] = subst_rhs[i]; } } new[j] = '\0'; xfree(subst_rhs); subst_rhs = new; subst_rhs_len = j; }
void postproc_subst_rhs() { unsigned int v0; int tmp_26; unsigned int v1; unsigned int v2; char *v3; unsigned long long v5; v2 = subst_lhs_len + subst_rhs_len; v3 = xmalloc(v2); v1 = 0; for (v0 = v1; v0 < subst_rhs_len; v0 += 1) { switch (subst_rhs[v0]) { case 38: if (v2 <= v1 + subst_lhs_len) { v2 = subst_lhs_len + (v2 * 2); v3 = xrealloc(v3, v2, v2); } strcpy(&v3[v1], subst_lhs); v1 += subst_lhs_len; break; case 92: if (subst_rhs[1 + v0] == 38) { v0 += 1; goto LABEL_400be6; } default: LABEL_400be6: if (v1 >= v2) { v2 *= 2; v3 = xrealloc(v3, v2, v2); } tmp_26 = v1; v1 += 1; v3[tmp_26] = subst_rhs[v0]; break; } } v3[v1] = 0; xfree(subst_rhs); subst_rhs = v3; v5 = v1; subst_rhs_len = v1; return; }
bash
angr_sailr
static void set_join_field(size_t *var, size_t val) { if (*var != (18446744073709551615UL) && *var != val) { unsigned long int var1 = *var + 1; unsigned long int val1 = val + 1; ((!!sizeof(struct { _Static_assert(1, "verify_expr (" "1" ", " "(error (1, 0, gettext (\"incompatible join fields " "%lu, %lu\"), var1, val1), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, 0, gettext("incompatible join fields %lu, %lu"), var1, val1), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, 0, gettext("incompatible join fields %lu, %lu"), var1, val1), ((0) ? (void)0 : __builtin_unreachable())))); } *var = val; }
void set_join_field(long *param_1, long param_2) { long lVar1; undefined8 uVar2; if ((*param_1 != -1) && (param_2 != *param_1)) { lVar1 = *param_1; uVar2 = gettext("incompatible join fields %lu, %lu"); error(1, 0, uVar2, lVar1 + 1, param_2 + 1); } *param_1 = param_2; return; }
coreutils
ghidra
static void file_failure(_Bool serious, char const *message, char const *file) { error(0, (*__errno_location()), message, quotearg_style(shell_escape_always_quoting_style, file)); set_exit_status(serious); }
long file_failure(unsigned char a1, const char *a2, long a3) { long v3; int *v4; v3 = quotearg_style(4LL, a3); v4 = _errno_location(); error(0, *v4, a2, v3); return set_exit_status(a1); }
coreutils
ida
char *get_force_string(void) { const struct forceinfo *fip; struct varbuf vb = {0, 0, ((void *)0)}; for (fip = forceinfos; fip->name; fip++) { if ((enum force_flags)fip->flag == FORCE_ALL || (fip->flag & force_mask) != fip->flag || !in_force(fip->flag)) continue; if (vb.used) varbuf_add_char(&vb, ','); varbuf_add_buf(&vb, fip->name, strlen(fip->name)); } varbuf_end_str(&vb); return varbuf_detach(&vb); }
void get_force_string(void) { char cVar1; size_t sVar2; long in_FS_OFFSET; undefined1 *local_30; long local_28; undefined8 local_20; undefined8 local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_28 = 0; local_20 = 0; local_18 = 0; for (local_30 = forceinfos; *(char **)local_30 != (char *)0x0; local_30 = (undefined1 *)((long)local_30 + 0x18)) { if ((*(int *)((long)local_30 + 8) != -1) && ((*(uint *)((long)local_30 + 8) & force_mask) == *(uint *)((long)local_30 + 8))) { cVar1 = in_force(*(undefined4 *)((long)local_30 + 8)); if (cVar1 == '\x01') { if (local_28 != 0) { varbuf_add_char(&local_28, 0x2c); } sVar2 = strlen(*(char **)local_30); varbuf_add_buf(&local_28, *(char **)local_30, sVar2); } } } varbuf_end_str(&local_28); varbuf_detach(&local_28); if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return; }
dpkg
ghidra
static void xattr_selinux_decoder(struct tar_stat_info *st, char const *keyword, char const *arg, size_t size) { decode_string(&st->cntx_name, arg); }
long long xattr_selinux_decoder(unsigned long a0, unsigned long a1, unsigned long long a2, unsigned long a3) { unsigned long v0; unsigned long v1; v1 = a1; v0 = a3; return decode_string(a0 + 48, a2); }
tar
angr_phoenix
static inline const char *rta_getattr_str(const struct rtattr *rta) { return (const char *)(( void *)(((char *)(rta)) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))); }
int rta_getattr_str(unsigned long a0) { return a0 + 4; }
iproute2-6.0.0
angr_sailr
int ssh_msg_recv(int fd, struct sshbuf *m) { u_char buf[4], *p; u_int msg_len; int r; sshlog("msg.c", __func__, 72, 0, SYSLOG_LEVEL_DEBUG3, ((void *)0), "ssh_msg_recv entering"); if (atomicio(read, fd, buf, sizeof(buf)) != sizeof(buf)) { if ((*__errno_location()) != 32) sshlog("msg.c", __func__, 76, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "read header: %s", strerror((*__errno_location()))); return (-1); } msg_len = get_u32(buf); if (msg_len > sshbuf_max_size(m)) { sshlog("msg.c", __func__, 81, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "read: bad msg_len %u", msg_len); return (-1); } sshbuf_reset(m); if ((r = sshbuf_reserve(m, msg_len, &p)) != 0) { sshlog("msg.c", __func__, 86, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "reserve"); return -1; } if (atomicio(read, fd, p, msg_len) != msg_len) { sshlog("msg.c", __func__, 90, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "read: %s", strerror((*__errno_location()))); return (-1); } return (0); }
long long ssh_msg_recv(unsigned long a0, unsigned long long a1) { unsigned long v0; unsigned int v1; unsigned int v2; char v3; char v4; unsigned long long v7; sshlog("msg.c", "ssh_msg_recv", 0x48, 0x0, 0x7, 0x0, "ssh_msg_recv entering"); if (atomicio(got.read, a0, &v4, 0x4) != 4) { if (*(__errno_location()) != 32) { v0 = strerror(*(__errno_location())); sshlog("msg.c", "ssh_msg_recv", 0x4c, 0x1, 0x2, 0x0, "read header: %s"); } v7 = 4294967295; } else { v1 = get_u32(&v4); if (v1 > sshbuf_max_size(a1)) { v0 = v1; sshlog("msg.c", "ssh_msg_recv", 0x51, 0x1, 0x2, 0x0, "read: bad msg_len %u"); v7 = 4294967295; } else { sshbuf_reset(a1); v2 = sshbuf_reserve(a1, v1, &v3, v1); if (v2) { sshlog("msg.c", "ssh_msg_recv", 0x56, 0x1, 0x2, ssh_err(v2), "reserve"); v7 = 4294967295; } else if (atomicio(got.read, a0, *(&v3), v1) == v1) { v7 = 0; } else { v0 = strerror(*(__errno_location())); sshlog("msg.c", "ssh_msg_recv", 0x5a, 0x1, 0x2, 0x0, "read: %s"); v7 = 4294967295; } } } return v7; }
openssh-portable
angr_phoenix
int main(int argc, char **argv) { int ret; if ((ret = gnutls_global_init()) < 0) { fprintf(stderr, "global_init: %s\n", gnutls_strerror(ret)); app_exit(1); } process_options(argc, argv); gnutls_global_set_log_function(tls_log_func); gnutls_global_set_log_level(ocsptool_options.value.debug); if (ocsptool_options.enabled.inder) incert_format = GNUTLS_X509_FMT_DER; else incert_format = GNUTLS_X509_FMT_PEM; if (ocsptool_options.present.outpem) outcert_format = GNUTLS_X509_FMT_PEM; else outcert_format = GNUTLS_X509_FMT_DER; if (ocsptool_options.present.verify_allow_broken) vflags |= (GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2 | GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5); if (ocsptool_options.present.outfile) { outfile = fopen(ocsptool_options.arg.outfile, "wb"); if (outfile == ((void *)0)) { fprintf(stderr, "%s\n", ocsptool_options.arg.outfile); app_exit(1); } outfile_name = ocsptool_options.arg.outfile; } else outfile = stdout; if (ocsptool_options.present.infile) { infile = fopen(ocsptool_options.arg.infile, "rb"); if (infile == ((void *)0)) { fprintf(stderr, "%s\n", ocsptool_options.arg.infile); app_exit(1); } } else infile = stdin; if (ocsptool_options.enabled.inder) encoding = GNUTLS_X509_FMT_DER; else encoding = GNUTLS_X509_FMT_PEM; if (ocsptool_options.present.request_info) request_info(); else if (ocsptool_options.present.response_info) response_info(); else if (ocsptool_options.present.generate_request) generate_request(((void *)0)); else if (ocsptool_options.present.verify_response) verify_response(((void *)0)); else if (ocsptool_options.present.ask) { if ((!ocsptool_options.present.load_cert) && (!ocsptool_options.present.load_chain)) { fprintf(stderr, "This option required --load-chain or --load-cert\n"); app_exit(1); } ask_server(ocsptool_options.arg.ask); } else { usage(stdout, (1)); } if (infile != stdin) fclose(infile); gnutls_global_deinit(); return 0; }
int main(int argc, const char **argv, const char **envp) { const char *v3; int v5; v5 = gnutls_global_init(argc, argv, envp); if (v5 < 0) { v3 = (const char *)gnutls_strerror((unsigned int)v5); fprintf(stderr, "global_init: %s\n", v3); app_exit(1); } process_options((unsigned int)argc, argv); gnutls_global_set_log_function(tls_log_func); gnutls_global_set_log_level(*(unsigned int *)&ocsptool_options[128]); incert_format = ocsptool_options[147] == 0; outcert_format = ocsptool_options[17] != 0; if (ocsptool_options[21]) vflags |= 0x30u; if (ocsptool_options[3]) { outfile = fopen(*(const char **)&ocsptool_options[48], "wb"); if (!outfile) { fprintf(stderr, "%s\n", *(const char **)&ocsptool_options[48]); app_exit(1); } outfile_name = *(char **)&ocsptool_options[48]; } else { outfile = stdout; } if (ocsptool_options[2]) { infile = fopen(*(const char **)&ocsptool_options[40], "rb"); if (!infile) { fprintf(stderr, "%s\n", *(const char **)&ocsptool_options[40]); app_exit(1); } } else { infile = stdin; } encoding = ocsptool_options[147] == 0; if (ocsptool_options[6]) { request_info(); } else if (ocsptool_options[7]) { response_info(); } else if (ocsptool_options[8]) { generate_request(0LL); } else if (ocsptool_options[5]) { verify_response(0LL); } else if (ocsptool_options[4]) { if (ocsptool_options[12] != 1 && ocsptool_options[10] != 1) { fprintf(stderr, "This option required --load-chain or --load-cert\n"); app_exit(1); } ask_server(*(_QWORD *)&ocsptool_options[56]); } else { usage(stdout, 1LL); } if (infile != stdin) fclose(infile); gnutls_global_deinit(); return 0; }
gnutls
ida
PIDQ_HEAD *init_pid_q(PIDQ_HEAD *q) { q->head = q->next = q->tail = ((void *)0); return q; }
undefined8 *init_pid_q(undefined8 *param_1) { param_1[1] = 0; param_1[2] = param_1[1]; *param_1 = param_1[2]; return param_1; }
sysvinit
ghidra
int bindresvport_sa(int sd, struct sockaddr *sa) { int error, af; struct sockaddr_storage myaddr; struct sockaddr_in *in; struct sockaddr_in6 *in6; u_int16_t *portp; u_int16_t port; socklen_t salen; int i; if (sa == ((void *)0)) { memset(&myaddr, 0, sizeof(myaddr)); sa = (struct sockaddr *)&myaddr; salen = sizeof(myaddr); if (getsockname(sd, sa, &salen) == -1) return -1; af = sa->sa_family; memset(&myaddr, 0, salen); } else af = sa->sa_family; if (af == 2) { in = (struct sockaddr_in *)sa; salen = sizeof(struct sockaddr_in); portp = &in->sin_port; } else if (af == 10) { in6 = (struct sockaddr_in6 *)sa; salen = sizeof(struct sockaddr_in6); portp = &in6->sin6_port; } else { (*__errno_location()) = 96; return (-1); } sa->sa_family = af; port = ntohs(*portp); if (port == 0) port = arc4random_uniform(((1024 - 1) - 600 + 1)) + 600; error = -1; for (i = 0; i < ((1024 - 1) - 600 + 1); i++) { *portp = htons(port); error = bind(sd, sa, salen); if (error == 0) break; if ((error < 0) && !(((*__errno_location()) == 98) || ((*__errno_location()) == 22))) break; port++; if (port > (1024 - 1)) port = 600; } return (error); }
int bindresvport_sa(int param_1, sockaddr *param_2) { short sVar1; uint16_t uVar2; int iVar3; int *piVar4; long in_FS_OFFSET; sockaddr *local_d8; ushort local_c2; uint local_c0; int local_bc; uint local_b8; int local_b4; char *local_b0; sockaddr *local_a8; sockaddr *local_a0; sockaddr local_98[8]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); if (param_2 == (sockaddr *)0x0) { memset(local_98, 0, 0x80); local_d8 = local_98; local_c0 = 0x80; iVar3 = getsockname(param_1, local_d8, &local_c0); if (iVar3 == -1) { iVar3 = -1; goto LAB_0010027b; } local_b8 = (uint)local_98[0].sa_family; memset(local_98, 0, (ulong)local_c0); } else { local_b8 = (uint)param_2->sa_family; local_d8 = param_2; } if (local_b8 == 2) { local_a0 = local_d8; local_c0 = 0x10; } else { if (local_b8 != 10) { piVar4 = __errno_location(); *piVar4 = 0x60; iVar3 = -1; goto LAB_0010027b; } local_a8 = local_d8; local_c0 = 0x1c; } local_b0 = local_d8->sa_data; local_d8->sa_family = (sa_family_t)local_b8; local_c2 = ntohs(*(uint16_t *)local_b0); if (local_c2 == 0) { sVar1 = arc4random_uniform(); local_c2 = sVar1 + 600; } local_bc = -1; for (local_b4 = 0; iVar3 = local_bc, local_b4 < 0x1a8; local_b4 = __addvsi3(local_b4, 1)) { uVar2 = htons(local_c2); *(uint16_t *)local_b0 = uVar2; local_bc = bind(param_1, local_d8, local_c0); iVar3 = local_bc; if ((local_bc == 0) || (((local_bc < 0 && (piVar4 = __errno_location(), *piVar4 != 0x62)) && (piVar4 = __errno_location(), iVar3 = local_bc, *piVar4 != 0x16)))) break; local_c2 = local_c2 + 1; if (0x3ff < local_c2) { local_c2 = 600; } } LAB_0010027b: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return iVar3; } __stack_chk_fail(); }
openssh-portable
ghidra
static ssize_t server_push(gnutls_transport_ptr_t tr, const void *data, size_t len) { size_t newlen; ; len = ((len) < (sizeof(to_client) - to_client_len) ? (len) : (sizeof(to_client) - to_client_len)); newlen = to_client_len + len; memcpy(to_client + to_client_len, data, len); to_client_len = newlen; return len; }
size_t server_push(long a1, const void *a2, char *a3) { char *v3; size_t n; long v6; v3 = (char *)&unk_10000 - to_client_len; if (a3 <= (char *)&unk_10000 - to_client_len) v3 = a3; n = (size_t)v3; v6 = (long)&v3[to_client_len]; memcpy((char *)&to_client + to_client_len, a2, (size_t)v3); to_client_len = v6; return n; }
gnutls
ida
void e2fsck_rehash_dir_later(e2fsck_t ctx, ext2_ino_t ino) { if (!ctx->dirs_to_hash) ext2fs_u32_list_create(&ctx->dirs_to_hash, 50); if (ctx->dirs_to_hash) ext2fs_u32_list_add(ctx->dirs_to_hash, ino); }
long e2fsck_rehash_dir_later(long a1, unsigned int a2) { long result; if (!*(_QWORD *)(a1 + 584)) ext2fs_u32_list_create(a1 + 584, 50LL); result = *(_QWORD *)(a1 + 584); if (result) return ext2fs_u32_list_add(*(_QWORD *)(a1 + 584), a2); return result; }
e2fsprogs-1.46.5
ida
static _Bool insert_path_check(const struct parser_table *entry, char **argv, int *arg_ptr, const char *predicate_name, PREDICATEFUNCTION pred) { const char *name; _Bool foldcase = 0; if (pred == pred_ipath) foldcase = 1; fnmatch_sanitycheck(); if (collect_arg(argv, arg_ptr, &name)) { struct predicate *our_pred = insert_primary_withpred(entry, pred, name); our_pred->need_stat = our_pred->need_type = 0; our_pred->args.str = name; our_pred->est_success_rate = estimate_pattern_match_rate(name, 0); if (!options.posixly_correct && !is_feasible_path_argument(name, foldcase)) { error(0, 0, gettext("warning: -%s %s will not match anything " "because it ends with /."), predicate_name, name); our_pred->est_success_rate = 1.0e-8; } return 1; } return 0; }
void insert_path_check(unsigned long long a0, unsigned long long *a1, unsigned int *a2, unsigned long a3, unsigned long long a4) { unsigned long v0; char v1; char v2; struct_0 *v3; void *v5; unsigned int v6; unsigned long long v8; v0 = a3; v1 = 0; if (a4 == got.pred_ipath) v1 = 1; fnmatch_sanitycheck(); if (!collect_arg(a1, a2, &v2)) { v5 = 0; } else { v3 = insert_primary_withpred(a0, a4, *(&v2), a4); v3->field_1b = 0; v3->field_1a = v3->field_1b; v3->field_38 = *(&v2); estimate_pattern_match_rate(*(&v2), 0x0); v3->field_24 = v6; if ((g_500019 ^ 1) && (is_feasible_path_argument(*(&v2), v1) ^ 1)) { error(0x0, 0x0, gettext("warning: -%s %s will not match anything because it ends " "with /.")); v3->field_24 = 4575556342058306679; } v8 = 1; } return; }
findutils
angr_phoenix
static int handle_error(socket_st *hd, int err) { int alert, ret; const char *err_type, *str; if (err >= 0 || err == -28 || err == -52) return 0; if (gnutls_error_is_fatal(err) == 0) { ret = 0; err_type = "Non fatal"; } else { ret = err; err_type = "Fatal"; } str = gnutls_strerror(err); if (str == ((void *)0)) str = str_unknown; fprintf(stderr, "*** %s error: %s\n", err_type, str); if (err == -16 || err == -12) { alert = gnutls_alert_get(hd->session); str = gnutls_alert_get_name(alert); if (str == ((void *)0)) str = str_unknown; log_msg(stdout, "*** Received alert [%d]: %s\n", alert, str); } check_server_cmd(hd, err); return ret; }
int handle_error(struct_0 *a0, unsigned long a1) { unsigned int v0; unsigned int v1; unsigned long long v2; unsigned long long v3; unsigned int v5; if (a1 < 0 && a1 != -28 && a1 != -52) { v5 = gnutls_error_is_fatal(a1); if (!v5) { v0 = 0; v2 = "Non fatal"; } else { v0 = a1; v2 = "Fatal"; } v3 = gnutls_strerror(a1); if (!v3) v3 = &str_unknown; fprintf(stderr, "*** %s error: %s\n", v2, v3); if (a1 == -12 || a1 == -0x10) { v1 = gnutls_alert_get(a0->field_8); v3 = gnutls_alert_get_name(v1); if (!v3) v3 = &str_unknown; log_msg(stdout, "*** Received alert [%d]: %s\n", v1); } check_server_cmd(a0, a1, a1); v5 = v0; } if (a1 == -28 || a1 == -52 || a1 >= 0) v5 = 0; return v5; }
gnutls
angr_dream
static void x_obstack_1grow(struct xheader *xhdr, char c) { __extension__({ struct obstack *__o = (xhdr->stk); if (__extension__({ struct obstack const *__o1 = (__o); (size_t)(__o1->chunk_limit - __o1->next_free); }) < 1) _obstack_newchunk(__o, 1); ((void)(*((__o)->next_free)++ = (c))); }); xhdr->size++; }
void x_obstack_1grow(unsigned long long a0[2], unsigned long a1) { struct_0 *v0; int tmp_22; unsigned long long v1[5]; unsigned long long v3[2]; v0 = a0[0]; v1[0] = v0; if (!v1[4] - v1[3]) _obstack_newchunk(v0, 0x1, v1[4] - v1[3]); tmp_22 = v0->field_18; v0->field_18 = v0->field_18 + 1; *(tmp_22) = a1; v3 = a0; a0[1] = a0[1] + 1; return; }
tar
angr_sailr
static uintmax_t powm(uintmax_t b, uintmax_t e, uintmax_t n, uintmax_t ni, uintmax_t one) { uintmax_t y = one; if (e & 1) y = b; while (e != 0) { b = mulredc(b, b, n, ni); e >>= 1; if (e & 1) y = mulredc(y, b, n, ni); } return y; }
int powm(unsigned int a0, unsigned long a1, unsigned int a2, unsigned int a3, unsigned int a4) { unsigned long long v0; unsigned int v1; unsigned int v2; v1 = a0; v0 = a1; v2 = a4; if ((v0 & 1)) *(&v2) = *(&v1); while (true) { if (v0) { *(&v1) = mulredc(*(&v1), *(&v1), a2, a3); v0 >>= 1; if (!(v0 & 1)) continue; *(&v2) = mulredc(*(&v2), *(&v1), a2, a3); } else { return *(&v2); } } }
coreutils
angr_dream
static void hostkeys_update_ctx_free(struct hostkeys_update_ctx *ctx) { size_t i; if (ctx == ((void *)0)) return; for (i = 0; i < ctx->nkeys; i++) sshkey_free(ctx->keys[i]); free(ctx->keys); free(ctx->keys_match); free(ctx->keys_verified); for (i = 0; i < ctx->nold; i++) sshkey_free(ctx->old_keys[i]); free(ctx->old_keys); free(ctx->host_str); free(ctx->ip_str); free(ctx); }
void hostkeys_update_ctx_free(unsigned long long a0[10]) { void *v0; unsigned long long v2; if (a0) { for (v0 = 0; v0 < a0[5]; v0 += 1) { sshkey_free(*((a0[2] + v0 * 8))); } free(a0[2]); free(a0[3]); free(a0[4]); for (v0 = 0; v0 < a0[9]; v0 += 1) { sshkey_free(*((a0[8] + v0 * 8))); } free(a0[8]); free(a0[0]); free(a0[1]); v2 = free(a0); } return; }
openssh-portable
angr_phoenix
void temporarily_use_uid(struct passwd *pw) { saved_euid = geteuid(); saved_egid = getegid(); sshlog("uidswap.c", __func__, 67, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "temporarily_use_uid: %u/%u (e=%u/%u)", (u_int)pw->pw_uid, (u_int)pw->pw_gid, (u_int)saved_euid, (u_int)saved_egid) ; if (saved_euid != 0) { privileged = 0; return; } privileged = 1; temporarily_use_uid_effective = 1; saved_egroupslen = getgroups(0, ((void *)0)); if (saved_egroupslen == -1) sshfatal("uidswap.c", __func__, 88, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "getgroups: %.100s", strerror((*__errno_location()))); if (saved_egroupslen > 0) { saved_egroups = xreallocarray(saved_egroups, saved_egroupslen, sizeof(gid_t)); if (getgroups(saved_egroupslen, saved_egroups) == -1) sshfatal("uidswap.c", __func__, 93, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "getgroups: %.100s", strerror((*__errno_location()))); } else { free(saved_egroups); saved_egroups = ((void *)0); } if (user_groupslen == -1 || user_groups_uid != pw->pw_uid) { if (initgroups(pw->pw_name, pw->pw_gid) == -1) sshfatal("uidswap.c", __func__, 102, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "initgroups: %s: %.100s", pw->pw_name, strerror((*__errno_location()))); user_groupslen = getgroups(0, ((void *)0)); if (user_groupslen == -1) sshfatal("uidswap.c", __func__, 107, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "getgroups: %.100s", strerror((*__errno_location()))); if (user_groupslen > 0) { user_groups = xreallocarray(user_groups, user_groupslen, sizeof(gid_t)); if (getgroups(user_groupslen, user_groups) == -1) sshfatal("uidswap.c", __func__, 112, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "getgroups: %.100s", strerror((*__errno_location()))); } else { free(user_groups); user_groups = ((void *)0); } user_groups_uid = pw->pw_uid; } if (setgroups(user_groupslen, user_groups) == -1) sshfatal("uidswap.c", __func__, 121, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "setgroups: %.100s", strerror((*__errno_location()))); if (setegid(pw->pw_gid) == -1) sshfatal("uidswap.c", __func__, 131, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "setegid %u: %.100s", (u_int)pw->pw_gid, strerror((*__errno_location()))); if (seteuid(pw->pw_uid) == -1) sshfatal("uidswap.c", __func__, 134, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "seteuid %u: %.100s", (u_int)pw->pw_uid, strerror((*__errno_location()))); }
long long temporarily_use_uid(unsigned long a0) { unsigned long long v0; unsigned long v1; unsigned long long v2; unsigned long v3; char v4; unsigned long long v6; unsigned long long v7; unsigned long long v9; v2 = a0; saved_euid = geteuid(); saved_egid = getegid(); sshlog("uidswap.c", "temporarily_use_uid", 0x43, 0x0, 0x5, 0x0, "temporarily_use_uid: %u/%u (e=%u/%u)", v2->field_10, v2->field_14, saved_euid); v6 = saved_euid; if (saved_euid) { privileged = 0; } else { privileged = 1; temporarily_use_uid_effective = 1; saved_egroupslen = getgroups(0x0, NULL); if (saved_egroupslen == -1) { v0 = strerror(*(__errno_location())); sshfatal("uidswap.c", "temporarily_use_uid", 0x58, 0x0, 0x1, 0x0, "getgroups: %.100s"); } if (saved_egroupslen > 0) { saved_egroups = xreallocarray(saved_egroups, saved_egroupslen, 0x4, saved_egroupslen); v7 = getgroups(saved_egroupslen, saved_egroups); if (v7 == -1) { v3 = strerror(*(__errno_location())); v2 = "getgroups: %.100s"; sshfatal("uidswap.c", "temporarily_use_uid", 0x5d, 0x0, 0x1, 0x0, *(&v4)); } } if (v7 == -1 || saved_egroupslen <= 0) { free(saved_egroups); saved_egroups = 0; } if (user_groupslen == -1 || v2->field_10 != user_groups_uid) { if (initgroups(v2->field_0, v2->field_14) == -1) { v2 = &strerror(*(__errno_location())); v1 = *(v2); v0 = "initgroups: %s: %.100s"; sshfatal("uidswap.c", "temporarily_use_uid", 0x66, 0x0, 0x1, 0x0, *(&v4)); } user_groupslen = getgroups(0x0, NULL); if (user_groupslen == -1) { v3 = strerror(*(__errno_location())); v2 = "getgroups: %.100s"; sshfatal("uidswap.c", "temporarily_use_uid", 0x6b, 0x0, 0x1, 0x0, *(&v4)); } if (user_groupslen > 0) { user_groups = xreallocarray(user_groups, user_groupslen, 0x4, user_groupslen); v9 = getgroups(user_groupslen, user_groups); if (v9 == -1) { v3 = strerror(*(__errno_location())); v2 = "getgroups: %.100s"; sshfatal("uidswap.c", "temporarily_use_uid", 0x70, 0x0, 0x1, 0x0, *(&v4)); } } if (user_groupslen <= 0 || v9 == -1) { free(user_groups); user_groups = 0; } user_groups_uid = v2->field_10; } if (setgroups(user_groupslen, user_groups) == -1) { v3 = strerror(*(__errno_location())); v2 = "setgroups: %.100s"; sshfatal("uidswap.c", "temporarily_use_uid", 0x79, 0x0, 0x1, 0x0, *(&v4)); } if (setegid(*((v2 + 20))) == -1) { v2 = strerror(*(__errno_location())); v1 = v2->field_14; v0 = "setegid %u: %.100s"; sshfatal("uidswap.c", "temporarily_use_uid", 0x83, 0x0, 0x1, 0x0, *(&v4)); } v6 = seteuid(*((v2 + 16))); if (v6 == -1) { v2 = &strerror(*(__errno_location())); v1 = v2->field_10; v0 = "seteuid %u: %.100s"; v6 = sshfatal("uidswap.c", "temporarily_use_uid", 0x86, 0x0, 0x1, 0x0, *(&v4)); } } return v6; }
openssh-portable
angr_dream
static int send_userauth_info_request(struct ssh *ssh) { Authctxt *authctxt = ssh->authctxt; KbdintAuthctxt *kbdintctxt; char *name, *instr, **prompts; u_int r, i, *echo_on; kbdintctxt = authctxt->kbdintctxt; if (kbdintctxt->device->query(kbdintctxt->ctxt, &name, &instr, &kbdintctxt->nreq, &prompts, &echo_on)) return 0; if ((r = sshpkt_start(ssh, 60)) != 0 || (r = sshpkt_put_cstring(ssh, name)) != 0 || (r = sshpkt_put_cstring(ssh, instr)) != 0 || (r = sshpkt_put_cstring(ssh, "")) != 0 || (r = sshpkt_put_u32(ssh, kbdintctxt->nreq)) != 0) sshfatal("auth2-chall.c", __func__, 270, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "start packet"); for (i = 0; i < kbdintctxt->nreq; i++) { if ((r = sshpkt_put_cstring(ssh, prompts[i])) != 0 || (r = sshpkt_put_u8(ssh, echo_on[i])) != 0) sshfatal("auth2-chall.c", __func__, 274, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "assemble packet"); } if ((r = sshpkt_send(ssh)) != 0 || (r = ssh_packet_write_wait(ssh)) != 0) sshfatal("auth2-chall.c", __func__, 278, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "send packet"); for (i = 0; i < kbdintctxt->nreq; i++) free(prompts[i]); free(prompts); free(echo_on); free(name); free(instr); return 1; }
undefined8 send_userauth_info_request(long param_1) { uint uVar1; void *__ptr; int iVar2; undefined8 uVar3; char **ppcVar4; undefined *puVar5; undefined *puVar6; long in_FS_OFFSET; char *pcStack104; undefined8 uStack96; undefined auStack88[8]; long local_50; int local_48; uint local_44; void *local_40; void *local_38; void *local_30; void *local_28; long local_20; long local_18; long local_10; ppcVar4 = (char **)auStack88; puVar6 = auStack88; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_20 = *(long *)(param_1 + 0x860); local_18 = *(long *)(local_20 + 0x58); uStack96 = 0x10085f; local_50 = param_1; iVar2 = (**(code **)(*(long *)(local_18 + 0x10) + 0x10))( *(undefined8 *)(local_18 + 8), &local_40, &local_38, local_18 + 0x18, &local_30, &local_28); if (iVar2 != 0) { uVar3 = 0; goto LAB_00100ac0; } uStack96 = 0x10087e; local_48 = sshpkt_start(local_50, 0x3c); if (local_48 == 0) { uStack96 = 0x10089a; local_48 = sshpkt_put_cstring(local_50, local_40); if (local_48 != 0) goto LAB_001008f9; uStack96 = 0x1008b6; local_48 = sshpkt_put_cstring(local_50, local_38); if (local_48 != 0) goto LAB_001008f9; uStack96 = 0x1008d2; local_48 = sshpkt_put_cstring(local_50, &DAT_00100f60); if (local_48 != 0) goto LAB_001008f9; uStack96 = 0x1008f0; local_48 = sshpkt_put_u32(local_50, *(undefined4 *)(local_18 + 0x18)); if (local_48 != 0) goto LAB_001008f9; } else { LAB_001008f9: uStack96 = 0x100903; uVar3 = ssh_err(local_48); ppcVar4 = &pcStack104; pcStack104 = "start packet"; sshfatal("auth2-chall.c", "send_userauth_info_request", 0x10e, 1, 1, uVar3); } puVar5 = (undefined *)ppcVar4; for (local_44 = 0; local_44 < *(uint *)(local_18 + 0x18); local_44 = local_44 + 1) { uVar3 = *(undefined8 *)((long)local_30 + (ulong)local_44 * 8); *(undefined8 *)(puVar5 + -8) = 0x100966; local_48 = sshpkt_put_cstring(local_50, uVar3); if (local_48 == 0) { uVar1 = *(uint *)((long)local_28 + (ulong)local_44 * 4); *(undefined8 *)(puVar5 + -8) = 0x100990; local_48 = sshpkt_put_u8(local_50, uVar1 & 0xff); puVar6 = puVar5; if (local_48 != 0) goto LAB_00100999; } else { LAB_00100999: *(undefined8 *)(puVar5 + -8) = 0x1009a3; uVar3 = ssh_err(local_48); puVar6 = puVar5 + -0x10; *(char **)(puVar5 + -0x10) = "assemble packet"; *(undefined8 *)(puVar5 + -0x18) = 0x1009da; sshfatal("auth2-chall.c", "send_userauth_info_request", 0x112, 1, 1, uVar3); } puVar5 = puVar6; } *(undefined8 *)(puVar5 + -8) = 0x1009fa; local_48 = sshpkt_send(local_50); if (local_48 == 0) { *(undefined8 *)(puVar5 + -8) = 0x100a0f; local_48 = ssh_packet_write_wait(local_50); puVar6 = puVar5; if (local_48 != 0) goto LAB_00100a18; } else { LAB_00100a18: *(undefined8 *)(puVar5 + -8) = 0x100a22; uVar3 = ssh_err(local_48); puVar6 = puVar5 + -0x10; *(char **)(puVar5 + -0x10) = "send packet"; *(undefined8 *)(puVar5 + -0x18) = 0x100a59; sshfatal("auth2-chall.c", "send_userauth_info_request", 0x116, 1, 1, uVar3); } for (local_44 = 0; local_44 < *(uint *)(local_18 + 0x18); local_44 = local_44 + 1) { __ptr = *(void **)((long)local_30 + (ulong)local_44 * 8); *(undefined8 *)(puVar6 + -8) = 0x100a7b; free(__ptr); } *(undefined8 *)(puVar6 + -8) = 0x100a97; free(local_30); *(undefined8 *)(puVar6 + -8) = 0x100aa3; free(local_28); *(undefined8 *)(puVar6 + -8) = 0x100aaf; free(local_40); *(undefined8 *)(puVar6 + -8) = 0x100abb; free(local_38); uVar3 = 1; LAB_00100ac0: if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { *(undefined8 *)(puVar6 + -8) = 0x100ad4; __stack_chk_fail(); } return uVar3; }
openssh-portable
ghidra
long get_clk_tck() { static long retval = 0; if (retval != 0) return (retval); retval = sysconf(_SC_CLK_TCK); return (retval); }
long long get_clk_tck() { unsigned long long v1; if (retval.3359) { v1 = retval.3359; return v1; } retval.3359 = sysconf(0x2); v1 = retval.3359; return v1; }
bash
angr_sailr
static void assert_matching_dev_ino(char const *name, struct dev_ino di) { struct stat sb; ((void)sizeof((name) ? 1 : 0), __extension__({ if (name) ; else __assert_fail("name", "src/ls.c", 1064, __extension__ __PRETTY_FUNCTION__); })); ((void)sizeof((0 <= stat(name, &sb)) ? 1 : 0), __extension__({ if (0 <= stat(name, &sb)) ; else __assert_fail("0 <= stat (name, &sb)", "src/ls.c", 1065, __extension__ __PRETTY_FUNCTION__); })); ((void)sizeof((sb.st_dev == di.st_dev) ? 1 : 0), __extension__({ if (sb.st_dev == di.st_dev) ; else __assert_fail("sb.st_dev == di.st_dev", "src/ls.c", 1066, __extension__ __PRETTY_FUNCTION__); })); ((void)sizeof((sb.st_ino == di.st_ino) ? 1 : 0), __extension__({ if (sb.st_ino == di.st_ino) ; else __assert_fail("sb.st_ino == di.st_ino", "src/ls.c", 1067, __extension__ __PRETTY_FUNCTION__); })); }
void assert_matching_dev_ino(char *param_1, __ino_t param_2, __dev_t param_3) { int iVar1; long in_FS_OFFSET; stat local_a8; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); if (param_1 == (char *)0x0) { __assert_fail("name", "src/ls.c", 0x428, "assert_matching_dev_ino"); } iVar1 = stat(param_1, &local_a8); if (iVar1 < 0) { __assert_fail("0 <= stat (name, &sb)", "src/ls.c", 0x429, "assert_matching_dev_ino"); } if (local_a8.st_dev != param_3) { __assert_fail("sb.st_dev == di.st_dev", "src/ls.c", 0x42a, "assert_matching_dev_ino"); } if (local_a8.st_ino != param_2) { __assert_fail("sb.st_ino == di.st_ino", "src/ls.c", 0x42b, "assert_matching_dev_ino"); } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return; }
coreutils
ghidra
static int restore_handler(struct rtnl_ctrl_data *ctrl, struct nlmsghdr *n, void *arg) { int ret; n->nlmsg_flags |= 0x01 | 0x400 | 0x04; ll_init_map(&rth); ret = rtnl_talk(&rth, n, ((void *)0)); if ((ret < 0) && ((*__errno_location()) == 17)) ret = 0; return ret; }
long long restore_handler(unsigned long a0, struct_0 *a1, unsigned long a2, unsigned long long a3) { unsigned long v0; unsigned long v1; unsigned int v2; v1 = a0; v0 = a2; a1->field_6 = a1->field_6 | 1029; ll_init_map(0x5001a0); v2 = rtnl_talk(0x5001a0, a1, 0x0, a3); if (v2 < 0 && *(__errno_location()) == 17) v2 = 0; return v2; }
iproute2-6.0.0
angr_dream
static int cmp(void) { _Bool at_line_start = 1; off_t line_number = 1; off_t byte_number = 1; intmax_t remaining = bytes; size_t read0, read1; size_t first_diff; size_t smaller; size_t *buffer0 = buffer[0]; size_t *buffer1 = buffer[1]; char *buf0 = (char *)buffer0; char *buf1 = (char *)buffer1; int differing = 0; int f; int offset_width; if (comparison_type == type_all_diffs) { off_t byte_number_max = (0 <= bytes && bytes <= ((off_t)(!(!((off_t)0 < (off_t)-1)) ? (off_t)-1 : ((((off_t)1 << ((sizeof(off_t) * 8) - 2)) - 1) * 2 + 1))) ? bytes : ((off_t)(!(!((off_t)0 < (off_t)-1)) ? (off_t)-1 : ((((off_t)1 << ((sizeof(off_t) * 8) - 2)) - 1) * 2 + 1)))); for (f = 0; f < 2; f++) if (((((stat_buf[f].st_mode)) & 0170000) == (0100000))) { off_t file_bytes = stat_buf[f].st_size - file_position(f); if (file_bytes < byte_number_max) byte_number_max = file_bytes; } for (offset_width = 1; (byte_number_max /= 10) != 0; offset_width++) continue; } for (f = 0; f < 2; f++) { off_t ig = ignore_initial[f]; if (ig && file_position(f) == -1) { do { size_t bytes_to_read = ((ig) <= (buf_size) ? (ig) : (buf_size)); size_t r = block_read(file_desc[f], buf0, bytes_to_read); if (r != bytes_to_read) { if (r == (18446744073709551615UL)) ((!!sizeof(struct { _Static_assert(2, "verify_expr (" "2" ", " "(error (2, (*__errno_location ()), \"%s\", " "file[f]), assume (false))" ")"); int _gl_dummy; })) ? ((error(2, (*__errno_location()), "%s", file[f]), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(2, (*__errno_location()), "%s", file[f]), ((0) ? (void)0 : __builtin_unreachable())))); break; } ig -= r; } while (ig); } } do { size_t bytes_to_read = buf_size; if (0 <= remaining) { if (remaining < bytes_to_read) bytes_to_read = remaining; remaining -= bytes_to_read; } read0 = block_read(file_desc[0], buf0, bytes_to_read); if (read0 == (18446744073709551615UL)) ((!!sizeof(struct { _Static_assert(2, "verify_expr (" "2" ", " "(error (2, (*__errno_location ()), \"%s\", " "file[0]), assume (false))" ")"); int _gl_dummy; })) ? ((error(2, (*__errno_location()), "%s", file[0]), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(2, (*__errno_location()), "%s", file[0]), ((0) ? (void)0 : __builtin_unreachable())))); read1 = block_read(file_desc[1], buf1, bytes_to_read); if (read1 == (18446744073709551615UL)) ((!!sizeof(struct { _Static_assert(2, "verify_expr (" "2" ", " "(error (2, (*__errno_location ()), \"%s\", " "file[1]), assume (false))" ")"); int _gl_dummy; })) ? ((error(2, (*__errno_location()), "%s", file[1]), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(2, (*__errno_location()), "%s", file[1]), ((0) ? (void)0 : __builtin_unreachable())))); smaller = ((read0) <= (read1) ? (read0) : (read1)); if (memcmp(buf0, buf1, smaller) == 0) first_diff = smaller; else { if (read0 >= read1) buf1[read0] = 0x55; if (read1 >= read0) buf0[read1] = 0x79; buf0[read0] = ~buf1[read0]; buf1[read1] = ~buf0[read1]; memset(buf0 + read0 + 1, 0, sizeof(size_t) - read0 % sizeof(size_t) - 1); memset(buf1 + read1 + 1, 0, sizeof(size_t) - read1 % sizeof(size_t) - 1); first_diff = block_compare(buffer0, buffer1); } byte_number += first_diff; if (comparison_type == type_first_diff && first_diff != 0) { line_number += count_newlines(buf0, first_diff); at_line_start = buf0[first_diff - 1] == '\n'; } if (first_diff < smaller) { switch (comparison_type) { case type_first_diff: { char byte_buf[((((((sizeof(off_t) * 8) - (!((__typeof__(off_t))0 < (__typeof__(off_t))-1))) * 146 + 484) / 485) + (!((__typeof__(off_t))0 < (__typeof__(off_t))-1))) + 1)]; char line_buf[((((((sizeof(off_t) * 8) - (!((__typeof__(off_t))0 < (__typeof__(off_t))-1))) * 146 + 484) / 485) + (!((__typeof__(off_t))0 < (__typeof__(off_t))-1))) + 1)]; char const *byte_num = offtostr(byte_number, byte_buf); char const *line_num = offtostr(line_number, line_buf); if (!opt_print_bytes) { static char const char_message[] = "%s %s differ: char %s, line %s\n"; static char const byte_msgid[] = "%s %s differ: byte %s, line %s\n"; char const *byte_message = gettext(byte_msgid); _Bool use_byte_message = (byte_message != byte_msgid || hard_locale(5)); printf(use_byte_message ? byte_message : char_message, file[0], file[1], byte_num, line_num); } else { unsigned char c0 = buf0[first_diff]; unsigned char c1 = buf1[first_diff]; char s0[5]; char s1[5]; sprintc(s0, c0); sprintc(s1, c1); printf(gettext("%s %s differ: byte %s, line %s is %3o %s %3o %s\n"), file[0], file[1], byte_num, line_num, c0, s0, c1, s1); } } __attribute__((__fallthrough__)); case type_status: return 1; case type_all_diffs: do { unsigned char c0 = buf0[first_diff]; unsigned char c1 = buf1[first_diff]; if (c0 != c1) { char byte_buf[( (((((sizeof(off_t) * 8) - (!((__typeof__(off_t))0 < (__typeof__(off_t))-1))) * 146 + 484) / 485) + (!((__typeof__(off_t))0 < (__typeof__(off_t))-1))) + 1)]; char const *byte_num = offtostr(byte_number, byte_buf); if (!opt_print_bytes) { printf("%*s %3o %3o\n", offset_width, byte_num, c0, c1); } else { char s0[5]; char s1[5]; sprintc(s0, c0); sprintc(s1, c1); printf("%*s %3o %-4s %3o %s\n", offset_width, byte_num, c0, s0, c1, s1); } } byte_number++; first_diff++; } while (first_diff < smaller); differing = -1; break; case type_no_stdout: differing = 1; break; } } if (read0 != read1) { if (differing <= 0 && comparison_type != type_status) { char const *shorter_file = file[read1 < read0]; if (byte_number == 1) fprintf(stderr, gettext("cmp: EOF on %s which is empty\n"), shorter_file); else { char byte_buf[((((((sizeof(off_t) * 8) - (!((__typeof__(off_t))0 < (__typeof__(off_t))-1))) * 146 + 484) / 485) + (!((__typeof__(off_t))0 < (__typeof__(off_t))-1))) + 1)]; char const *byte_num = offtostr(byte_number - 1, byte_buf); if (comparison_type == type_first_diff) { char line_buf[( (((((sizeof(off_t) * 8) - (!((__typeof__(off_t))0 < (__typeof__(off_t))-1))) * 146 + 484) / 485) + (!((__typeof__(off_t))0 < (__typeof__(off_t))-1))) + 1)]; char const *line_num = offtostr(line_number - at_line_start, line_buf); fprintf(stderr, (at_line_start ? gettext("cmp: EOF on %s after byte %s, line %s\n") : gettext("cmp: EOF on %s after byte %s," " in line %s\n")), shorter_file, byte_num, line_num); } else fprintf(stderr, gettext("cmp: EOF on %s after byte %s\n"), shorter_file, byte_num); } } return 1; } } while (differing <= 0 && read0 == buf_size); return differing == 0 ? 0 : 1; }
int cmp() { unsigned long v0; unsigned long v1; unsigned long v2; char v3; char v4; char v5; char v6; char v7; char v8; unsigned int v9; unsigned int v10; unsigned int v11; unsigned long long v12; unsigned long long v13; unsigned long long v14; unsigned long long v15; unsigned long long v16; unsigned long long v17; unsigned long long v18; unsigned long long v19; unsigned long long v20; unsigned long long v21; unsigned long long v22; unsigned long v23; unsigned long long v24; unsigned long long v25; unsigned long long v26; unsigned long v27; unsigned long v28; unsigned long v29; char *v30; unsigned long v31; unsigned long v32; unsigned long v33; unsigned long long v34; unsigned long v35; char v36; char v37; char v38; char v39; unsigned long long v41; unsigned long long v43; unsigned long long v44; unsigned int v45; v3 = 1; v12 = 1; v13 = 1; v14 = bytes; v19 = buffer; v20 = g_401c08; v21 = v19; v22 = v20; v9 = 0; if (comparison_type == 1) { if (bytes >= 0) v41 = bytes; else v41 = 9223372036854775807; v16 = v41; for (v10 = 0; v10 <= 1; v10 += 1) { if ((g_401af8[32 * v10 + 4 * v10] & 0xf000) == 0x8000) { v23 = (&g_401b10)[18 * v10] - file_position(v10); if (v23 < v16) v16 = v23; } } v11 = 1; while (true) { v16 = (v16 * 7378697629483820647 >> 64 >> 2) - (v16 >> 63); if (!v16) break; v11 += 1; } } for (v10 = 0; v10 <= 1; v10 += 1) { v17 = (&ignore_initial)[v10]; if (v17 && file_position(v10) == -1) { while (true) { v43 = buf_size; if (v17 <= buf_size) v43 = v17; v34 = v43; v35 = block_read(*((4 * v10 + &file_desc)), v21, v34, v21); if (v35 != v34) { if (v35 != -1) break; if (v35 == -1) error(0x2, *(__errno_location()), "%s"); } else { v17 -= v35; if (!v17) break; } } } } while (true) { v18 = buf_size; if (!((v14 - 0 >> 63))) { if (v18 > v14) v18 = v14; v14 -= v18; } v24 = block_read(file_desc, v21, v18, v21); if (v24 == -1) error(0x2, *(__errno_location()), "%s"); v25 = block_read(g_401ad4, v22, v18, v22); if (v25 == -1) error(0x2, *(__errno_location()), "%s"); v44 = v25; if (v24 <= v25) v44 = v24; v26 = v44; v45 = memcmp(v21, v22, v26); if (!v45) { v15 = v26; } else { if (v24 >= v25) *((v24 + v22)) = 85; if (v25 >= v24) *((v25 + v21)) = 121; *((v24 + v21)) = !(*((v24 + v22))); *((v25 + v22)) = !(*((v25 + v21))); memset(v21 + v24 + 1, 0x0, !(v24)); memset(v22 + v25 + 1, 0x0, !(v25)); v15 = block_compare(v19, v20); } v13 = v15 + v13; if (!comparison_type && v15) { v12 = count_newlines(v21, v15) + v12; v3 = *((v21 + v15 - 1)) == 10; } if (v15 < v26) { if (comparison_type != 3 && comparison_type <= 3) { if (comparison_type == 2) { v9 = 1; } else if (comparison_type <= 2) { if (!comparison_type) { v28 = offtostr(v13, &v38, &v38); v29 = offtostr(v12, &v39, &v39); if ((opt_print_bytes ^ 1)) { v30 = gettext("%s %s differ: byte %s, line %s\n"); if (v30 == "%s %s differ: byte %s, line %s\n") { v45 = hard_locale(0x5); if (!v45) v45 = 0; } if (v30 != "%s %s differ: byte %s, line %s\n" || v45) v45 = 1; v8 = v45; v8 &= 1; if (v8) v45 = v30; else v45 = "%s %s differ: char %s, line %s\n"; printf(v45); } else { v6 = *((v15 + v21)); v7 = *((v15 + v22)); sprintc(&v36, v6); sprintc(&v37, v7); v2 = &v37; v1 = v7; v0 = &v36; printf( gettext("%s %s differ: byte %s, line %s is %3o %s %3o %s\n")); } } else if (comparison_type == 1) { do { v4 = *((v15 + v21)); v5 = *((v15 + v22)); if (v4 != v5) { v27 = offtostr(v13, &v39, &v39); if ((opt_print_bytes ^ 1)) { printf("%*s %3o %3o\n", v11, v27); } else { sprintc(&v37, v4); sprintc(&v38, v5); v2 = &v38; printf("%*s %3o %-4s %3o %s\n", v11, v27, v4); } } v13 += 1; v15 += 1; } while (v15 < v26); v9 = -1; } } } if ((comparison_type == 3 || !comparison_type) && (comparison_type == 3 || comparison_type <= 2) && (comparison_type == 3 || comparison_type <= 3) && (comparison_type == 3 || comparison_type != 2)) { v45 = 1; break; } } if (v15 >= v26 || comparison_type == 2 || comparison_type != 3 && comparison_type || comparison_type != 3 && comparison_type > 2 || comparison_type != 3 && comparison_type > 3) { if (v24 != v25) { if (v9 <= 0 && comparison_type != 3) { v31 = (&file)[v25 < v24]; if (v13 == 1) { fprintf(*(&stderr), gettext("cmp: EOF on %s which is empty\n")); } else { v32 = offtostr(v13 - 1, &v38, v13 - 1); if (!comparison_type) { v33 = offtostr(v12 - v3, &v39, v12 - v3); if (v3) v45 = gettext("cmp: EOF on %s after byte %s, line %s\n"); else v45 = gettext("cmp: EOF on %s after byte %s, in line %s\n"); fprintf(*(&stderr), v45); } else { fprintf(*(&stderr), gettext("cmp: EOF on %s after byte %s\n")); } } } v45 = 1; break; } else { if (v9 > 0) continue; v45 = v9; break; } } } return v45; }
diffutils
angr_dream
static int undoablefd(fd) int fd; { int clexec; clexec = fcntl(fd, 1, 0); if (clexec == -1 || (fd >= 10 && clexec == 1)) return 0; return 1; }
long long undoablefd(unsigned long a0) { char v0; unsigned int v1; unsigned long long v3; v1 = fcntl(a0, 0x1); if (v1 == -1) { v3 = 0; return v3; } else if (*(&v0) <= 9) { v3 = 1; return v3; } else if (v1 != 1) { v3 = 1; return v3; } else { v3 = 0; return v3; } }
bash
angr_sailr
static size_t hash_link(void const *entry, size_t n_buckets) { struct link const *l = entry; uintmax_t num = l->dev ^ l->ino; return num % n_buckets; }
ulong hash_link(ulong *param_1, ulong param_2) { return (param_1[1] ^ *param_1) % param_2; }
tar
ghidra
static void mark_buffer_clean(struct buffer_head *bh) { bh->b_dirty = 0; }
long mark_buffer_clean(long a1) { long result; result = a1; *(_BYTE *)(a1 + 24) &= ~1u; return result; }
e2fsprogs-1.46.5
ida
static _Bool basename_is_dot_or_dotdot(char const *name) { char const *base = last_component(name); return dot_or_dotdot(base); }
_BOOL8 basename_is_dot_or_dotdot(long a1) { _BYTE *component; component = (_BYTE *)last_component(a1); return dot_or_dotdot(component); }
coreutils
ida