input
stringlengths
26
172k
output
stringlengths
18
318k
repo_name
stringclasses
23 values
decompiler
stringclasses
5 values
void ssh_packet_set_input_hook(struct ssh *ssh, ssh_packet_hook_fn *hook, void *ctx) { ssh->state->hook_in = hook; ssh->state->hook_in_ctx = ctx; }
long long ssh_packet_set_input_hook(unsigned long long *a0[64], unsigned long a1, unsigned long a2) { char v0; unsigned long long v2[64]; (*(a0))[62] = a1; v2 = *(a0); (*(a0))[63] = *(&v0); return v2; }
openssh-portable
angr_dream
int do_exec_pty(struct ssh *ssh, Session *s, const char *command) { int fdout, ptyfd, ttyfd, ptymaster; pid_t pid; if (s == ((void *)0)) sshfatal("session.c", __func__, 564, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "do_exec_pty: no session"); ptyfd = s->ptyfd; ttyfd = s->ttyfd; if ((fdout = dup(ptyfd)) == -1) { sshlog("session.c", __func__, 576, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "dup #1: %s", strerror((*__errno_location()))); close(ttyfd); close(ptyfd); return -1; } if ((ptymaster = dup(ptyfd)) == -1) { sshlog("session.c", __func__, 583, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "dup #2: %s", strerror((*__errno_location()))); close(ttyfd); close(ptyfd); close(fdout); return -1; } switch ((pid = fork())) { case -1: sshlog("session.c", __func__, 593, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "fork: %.100s", strerror((*__errno_location()))); close(fdout); close(ptymaster); close(ttyfd); close(ptyfd); return -1; case 0: is_child = 1; close(fdout); close(ptymaster); close(ptyfd); pty_make_controlling_tty(&ttyfd, s->tty); if (dup2(ttyfd, 0) == -1) sshlog("session.c", __func__, 613, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "dup2 stdin: %s", strerror((*__errno_location()))); if (dup2(ttyfd, 1) == -1) sshlog("session.c", __func__, 615, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "dup2 stdout: %s", strerror((*__errno_location()))); if (dup2(ttyfd, 2) == -1) sshlog("session.c", __func__, 617, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "dup2 stderr: %s", strerror((*__errno_location()))); close(ttyfd); do_login(ssh, s, command); do_child(ssh, s, command); default: break; } s->pid = pid; close(ttyfd); s->ptymaster = ptymaster; ssh_packet_set_interactive(ssh, 1, options.ip_qos_interactive, options.ip_qos_bulk); session_set_fds(ssh, s, ptyfd, fdout, -1, 1, 1); return 0; }
int do_exec_pty(unsigned long long a0, unsigned int a1[15], unsigned long long a2) { unsigned long long v0; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned int v5; unsigned long long v6; unsigned long v7; char v8; unsigned int v10; unsigned long long v11; unsigned long long v12; if (!a1) { v0 = "do_exec_pty: no session"; sshfatal("session.c", "do_exec_pty", 0x234, 0x0, 0x1, 0x0); } v2 = a1[12]; v1 = a1[13]; v3 = dup(v2); if (v3 == -1) { v7 = strerror(*(__errno_location())); v6 = "dup #1: %s"; sshlog("session.c", "do_exec_pty", 0x240, 0x1, 0x2, 0x0); close(v1); close(v2); v10 = -1; } else { v4 = dup(v2); if (v4 == -1) { v7 = strerror(*(__errno_location())); v6 = "dup #2: %s"; sshlog("session.c", "do_exec_pty", 0x247, 0x1, 0x2, 0x0); close(v1); close(v2); close(v3); v10 = -1; } else { v5 = fork(); if (v5 == -1) { v7 = strerror(*(__errno_location())); v6 = "fork: %.100s"; sshlog("session.c", "do_exec_pty", 0x251, 0x1, 0x2, 0x0); close(v3); close(v4); close(v1); close(v2); v10 = -1; } else if (v5) { a1[8] = v5; close(v1); a1[14] = v4; ssh_packet_set_interactive(a0, 0x1, g_500570, g_500574); v6 = 1; session_set_fds(a0, a1, v2, v3, 0xffffffff, 0x1, *(&v8)); v10 = 0; } else { is_child = 1; close(v3); close(v4); close(v2); pty_make_controlling_tty(&v1, &a1[1 + 4], &a1[1 + 4]); if (dup2(v1, 0x0) == -1) { v7 = strerror(*(__errno_location())); v6 = "dup2 stdin: %s"; sshlog("session.c", "do_exec_pty", 0x265, 0x0, 0x2, 0x0); } if (dup2(v1, 0x1) == -1) { v7 = strerror(*(__errno_location())); v6 = "dup2 stdout: %s"; sshlog("session.c", "do_exec_pty", 0x267, 0x0, 0x2, 0x0); } if (dup2(v1, 0x2) == -1) { v7 = strerror(*(__errno_location())); v6 = "dup2 stderr: %s"; sshlog("session.c", "do_exec_pty", 0x269, 0x0, 0x2, 0x0); } close(v1); do_login(a0, a1, a2); do_child(a0, a1, a2, a1, v11, v12); } } } return v10; }
openssh-portable
angr_phoenix
static char *escape_glob(const char *s) { size_t i, o, len; char *ret; len = strlen(s); ret = xcalloc(2, len + 1); for (i = o = 0; i < len; i++) { if (strchr("[]?*\\", s[i]) != ((void *)0)) ret[o++] = '\\'; ret[o++] = s[i]; } ret[o++] = '\0'; return ret; }
int escape_glob(void *a0) { void *v0; int tmp_10; int tmp_28; int tmp_16; void *v1; unsigned long v2; void *v3; v2 = strlen(a0); v3 = xcalloc(0x2, v2 + 1); v1 = 0; for (v0 = v1; v0 < v2; v0 += 1) { if (strchr("[]?*\\", *((v0 + a0)))) { tmp_10 = v1; v1 += 1; *(tmp_10 + v3) = 92; } tmp_28 = v1; v1 += 1; *(v3 + tmp_28) = *((a0 + v0)); } tmp_16 = v1; v1 += 1; *(tmp_16 + v3) = 0; return v3; }
openssh-portable
angr_sailr
int auth_process_principals(FILE *f, const char *file, const struct sshkey_cert *cert, struct sshauthopt **authoptsp) { char loc[256], *line = ((void *)0), *cp, *ep; size_t linesize = 0; u_long linenum = 0, nonblank = 0; u_int found_principal = 0; if (authoptsp != ((void *)0)) *authoptsp = ((void *)0); while (getline(&line, &linesize, f) != -1) { linenum++; if (found_principal) continue; for (cp = line; *cp == ' ' || *cp == '\t'; cp++) ; if ((ep = strchr(cp, '#')) != ((void *)0)) *ep = '\0'; if (!*cp || *cp == '\n') continue; nonblank++; snprintf(loc, sizeof(loc), "%.200s:%lu", file, linenum); if (auth_check_principals_line(cp, cert, loc, authoptsp) == 0) found_principal = 1; } sshlog("auth2-pubkeyfile.c", __func__, 254, 1, SYSLOG_LEVEL_DEBUG2, ((void *)0), "%s: processed %lu/%lu lines", file, nonblank, linenum); free(line); return found_principal; }
long auth_process_principals(FILE *a1, const char *a2, long a3, _QWORD *a4) { unsigned int v7; char *lineptr; size_t n; char *s; long v11; long v12; char *v13; char v14[264]; unsigned long v15; v15 = __readfsqword(0x28u); lineptr = 0LL; n = 0LL; v11 = 0LL; v12 = 0LL; v7 = 0; if (a4) *a4 = 0LL; while (getline(&lineptr, &n, a1) != -1) { ++v11; if (!v7) { for (s = lineptr; *s == 32 || *s == 9; ++s) ; v13 = strchr(s, 35); if (v13) *v13 = 0; if (*s) { if (*s != 10) { ++v12; snprintf(v14, 0x100uLL, "%.200s:%lu", a2, v11); if (!(unsigned int)auth_check_principals_line(s, a3, v14, a4)) v7 = 1; } } } } sshlog("auth2-pubkeyfile.c", "auth_process_principals", 254LL, 1LL, 6LL, 0LL, "%s: processed %lu/%lu lines", a2, v12, v11); free(lineptr); return v7; }
openssh-portable
ida
static void depmod_modules_sort(struct depmod *depmod) { char line[4096]; const char *order_file = "modules.order"; FILE *fp; unsigned idx = 0, total = 0; fp = dfdopen(depmod->cfg->dirname, order_file, 00, "r"); if (fp == ((void *)0)) return; while (fgets(line, sizeof(line), fp) != ((void *)0)) { size_t len = strlen(line); idx++; if (len == 0) continue; if (line[len - 1] != '\n') { log_printf(3, "%s/%s:%u corrupted line misses '\\n'\n", depmod->cfg->dirname, order_file, idx); goto corrupted; } } total = idx + 1; idx = 0; fseek(fp, 0, 0); while (fgets(line, sizeof(line), fp) != ((void *)0)) { size_t len = strlen(line); struct mod *mod; idx++; if (len == 0) continue; line[len - 1] = '\0'; mod = hash_find(depmod->modules_by_uncrelpath, line); if (mod == ((void *)0)) continue; mod->sort_idx = idx - total; } array_sort(&depmod->modules, mod_cmp); for (idx = 0; idx < depmod->modules.count; idx++) { struct mod *m = depmod->modules.array[idx]; m->idx = idx; } corrupted: fclose(fp); }
void depmod_modules_sort(unsigned long long a0[7], unsigned long a1, unsigned long a2, unsigned long a3, unsigned long long a4) { unsigned int v0; unsigned int v1; unsigned long long v2; void *v3; struct_0 *v4; char *v5; struct_1 *v6; char *v7; char v8; char v9; char v10; unsigned long long *v14; unsigned long long v15; v9 = *(&v9); v2 = "modules."; v0 = 0; v1 = 0; v3 = dfdopen(a0[0] + 8, v2, 0x0, "r", a4); if (v3) { while (true) { if (fgets(&v8, 0x1000, v3)) { v7 = strlen(&v8); v0 += 1; if (!v7) continue; if (*((&v7 + v7)) == 10) continue; log_printf(0x3, "%s/%s:%u corrupted line misses '\\n'\n", a0[0] + 8, v2, v0); break; } else { v1 = v0 + 1; v0 = 0; fseek(v3, 0x0, 0x0); while (true) { if (fgets(&v8, 0x1000, v3)) { v5 = strlen(&v8); v0 += 1; if (!v5) continue; *((&v7 + v5)) = 0; v6 = hash_find(a0[6], &v8, &v8); if (!v6) continue; v6->field_60 = v0 - v1; } else { array_sort(&a0[2], mod_cmp); for (v0 = 0; v0 < a0[3]; v0 += 1) { v4 = *((a0[2] + v0 * 8)); v4->field_68 = v0; } } } } } fclose(v3); } v15 = *(&v10) ^ v14[5]; return; }
kmod
angr_dream
tty_noquotemode(EditLine *el) { if (el->el_tty.t_mode != 2) return 0; if (tty_setty(el, 1, &el->el_tty.t_ed) == -1) { return -1; } el->el_tty.t_mode = 1; return 0; }
long tty_noquotemode(long a1) { if (*(_BYTE *)(a1 + 776) != 2) return 0LL; if ((unsigned int)tty_setty(a1, 1, (const struct termios *)(a1 + 644)) == -1) return 0xFFFFFFFFLL; *(_BYTE *)(a1 + 776) = 1; return 0LL; }
libedit
ida
static _Bool path_prefix(char const *prefix, char const *path) { prefix++; path++; if (!*prefix) return *path != '/'; if (*prefix == '/' && !prefix[1]) return *path == '/'; while (*prefix && *path) { if (*prefix != *path) break; prefix++; path++; } return (!*prefix && (*path == '/' || !*path)); }
int path_prefix(unsigned long a0, unsigned long a1) { char *v0; char v1[2]; unsigned int v3; unsigned int v4; v1 = a0; v0 = a1; *(&v1) = v1 + 1; v0 += 1; if (!v1[0]) { v3 = *(v0); *(&v3) = *(v0) != 47; } else { if (v1[0] == 47 && !v1[1]) { v3 = *(v0); *(&v3) = *(v0) == 47; } if (v1[0] != 47 || v1[1]) { for (; v1[0]; v0 += 1) { if (!*(v0)) break; if (*(v0)) { if (v1[0] != *(v0)) break; } *(&v1) = v1 + 1; } if (!v1[0] && (!*(v0) || *(v0) == 47)) v4 = 1; if (v1[0] || *(v0) && *(v0) != 47) v4 = 0; v3 = v4 & 1; } } return v3; }
coreutils
angr_dream
static int ecdsa_generate_private_key(u_int bits, int *nid, EC_KEY **ecdsap) { EC_KEY *private; int ret = -1; if (nid == ((void *)0) || ecdsap == ((void *)0)) return -10; if ((*nid = sshkey_ecdsa_bits_to_nid(bits)) == -1) return -56; *ecdsap = ((void *)0); if ((private = EC_KEY_new_by_curve_name(*nid)) == ((void *)0)) { ret = -2; goto out; } if (EC_KEY_generate_key(private) != 1) { ret = -22; goto out; } EC_KEY_set_asn1_flag(private, 0x001); *ecdsap = private; private = ((void *)0); ret = 0; out: EC_KEY_free(private); return ret; }
int ecdsa_generate_private_key(unsigned long a0, unsigned int *a1, unsigned long long *a2) { unsigned int v0; void *v1; unsigned int v3; v0 = -1; if (!a1) { LABEL_4037de: v3 = -10; } else { if (!a2) goto LABEL_4037de; *(a1) = sshkey_ecdsa_bits_to_nid(a0); if (*(a1) == -1) { v3 = -56; } else { *(a2) = 0; v1 = EC_KEY_new_by_curve_name(*(a1)); if (!v1) { v0 = -2; } else if (EC_KEY_generate_key(v1) != 1) { v0 = -22; } else { EC_KEY_set_asn1_flag(v1, 0x1); *(a2) = v1; v1 = 0; v0 = 0; } EC_KEY_free(v1); v3 = v0; } } return v3; }
openssh-portable
angr_phoenix
static int uhash_update(uhash_ctx_t ctx, const u_char *input, long len) { UWORD bytes_hashed, bytes_remaining; UINT64 result_buf[(8 / 4)]; UINT8 *nh_result = (UINT8 *)&result_buf; if (ctx->msg_len + len <= 1024) { nh_update(&ctx->hash, (const UINT8 *)input, len); ctx->msg_len += len; } else { bytes_hashed = ctx->msg_len % 1024; if (ctx->msg_len == 1024) bytes_hashed = 1024; if (bytes_hashed + len >= 1024) { if (bytes_hashed) { bytes_remaining = (1024 - bytes_hashed); nh_update(&ctx->hash, (const UINT8 *)input, bytes_remaining); nh_final(&ctx->hash, nh_result); ctx->msg_len += bytes_remaining; poly_hash(ctx, (UINT32 *)nh_result); len -= bytes_remaining; input += bytes_remaining; } while (len >= 1024) { nh(&ctx->hash, (const UINT8 *)input, 1024, 1024, nh_result); ctx->msg_len += 1024; len -= 1024; input += 1024; poly_hash(ctx, (UINT32 *)nh_result); } } if (len) { nh_update(&ctx->hash, (const UINT8 *)input, len); ctx->msg_len += len; } } return (1); }
void uhash_update(struct_0 *a0, void *a1, unsigned long a2) { unsigned long v0; void *v1; unsigned int v2; unsigned int v3; void *v4; char v5; unsigned long long v9; v1 = a1; v0 = a2; v4 = &v5; if (__addvdi3(a0->field_4d0, v0) <= 0x400) { nh_update(a0, v1, v0); a0->field_4d0 = v0 + a0->field_4d0; } else { v2 = a0->field_4d0 & 1023; if (a0->field_4d0 == 0x400) v2 = 0x400; if (__addvdi3(v2, v0) > 1023) { if (v2) { v3 = 0x400 - v2; nh_update(a0, v1, v3); nh_final(a0, v4); a0->field_4d0 = a0->field_4d0 + v3; poly_hash(a0, v4); v0 = __subvdi3(v0, v3); v1 += v3; } while (v0 > 1023) { nh(a0, v1, 0x400, 0x400, v4); a0->field_4d0 = a0->field_4d0 + 0x400; v0 = __addvdi3(v0, 0xfffffffffffffc00); v1 += 0x400; poly_hash(a0, v4); } } if (v0) { nh_update(a0, v1, v0); a0->field_4d0 = v0 + a0->field_4d0; } } v9 = 1; return; }
openssh-portable
angr_dream
int time_to_check_mail() { char *temp; time_t now; intmax_t seconds; temp = get_string_value("MAILCHECK"); if (temp == 0 || legal_number(temp, &seconds) == 0 || seconds < 0) return (0); now = ((time_t)time((time_t *)0)); return (seconds == 0 || ((now - last_time_mail_checked) >= seconds)); }
long long time_to_check_mail() { char v0; unsigned long long v1; unsigned long v2; unsigned long long v4; v1 = get_string_value("MAILCHECK"); if (!v1) { v4 = 0; return v4; } else if (!legal_number(v1, &v0, &v0)) { v4 = 0; return v4; } else if (*(&v0) < 0) { v4 = 0; return v4; } else { v2 = time(NULL); if (!*(&v0)) { v4 = 1; return v4; } else if (v2 - last_time_mail_checked >= *(&v0)) { v4 = 1; return v4; } else { v4 = 0; return v4; } } }
bash
angr_sailr
int fmtstr(char *outbuf, size_t length, const char *fmt, ...) { va_list ap; int ret; __builtin_va_start(ap, fmt); ret = xvsnprintf(outbuf, length, fmt, ap); __builtin_va_end(ap); return ret > (int)length ? length : ret; }
ulong fmtstr(undefined4 param_1, undefined4 param_2, undefined4 param_3, undefined4 param_4, undefined4 param_5, undefined4 param_6, undefined4 param_7, undefined4 param_8, undefined8 param_9, ulong param_10, undefined8 param_11, undefined8 param_12, undefined8 param_13, undefined8 param_14) { char in_AL; uint uVar1; ulong uVar2; long in_FS_OFFSET; undefined4 local_d8; undefined4 local_d4; undefined *local_d0; undefined *local_c8; long local_c0; undefined local_b8[24]; undefined8 local_a0; undefined8 local_98; undefined8 local_90; undefined4 local_88; undefined4 local_78; undefined4 local_68; undefined4 local_58; undefined4 local_48; undefined4 local_38; undefined4 local_28; undefined4 local_18; if (in_AL != '\0') { local_88 = param_1; local_78 = param_2; local_68 = param_3; local_58 = param_4; local_48 = param_5; local_38 = param_6; local_28 = param_7; local_18 = param_8; } local_c0 = *(long *)(in_FS_OFFSET + 0x28); local_d8 = 0x18; local_d4 = 0x30; local_d0 = &stack0x00000008; local_c8 = local_b8; local_a0 = param_12; local_98 = param_13; local_90 = param_14; uVar1 = xvsnprintf(param_9, param_10, param_11, &local_d8); uVar2 = param_10 & 0xffffffff; if ((int)uVar1 <= (int)param_10) { uVar2 = (ulong)uVar1; } if (local_c0 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return uVar2; }
dash-0.5.11+git20210903+057cd650a4ed
ghidra
void bashline_reinitialize() { bash_readline_initialized = 0; }
long long bashline_reinitialize() { unsigned long v1; bash_readline_initialized = 0; return v1; }
bash
angr_phoenix
static void merge_pred(struct predicate *beg_list, struct predicate *end_list, struct predicate **last_p) { end_list->pred_left = *last_p; *last_p = beg_list; }
_QWORD *merge_pred(long a1, long a2, _QWORD *a3) { _QWORD *result; *(_QWORD *)(a2 + 272) = *a3; result = a3; *a3 = a1; return result; }
findutils
ida
ssize_t zread(fd, buf, len) int fd; char *buf; size_t len; { ssize_t r; check_signals(); while (((r = read_builtin_timeout(fd)) < 0 || (r = read(fd, buf, len)) < 0) && (*__errno_location()) == 4) { int t; t = (*__errno_location()); if (executing_builtin) check_signals_and_traps(); else check_signals(); (*__errno_location()) = t; } return r; }
ssize_t zread(int a1, void *a2, size_t a3) { int v5; ssize_t builtin_timeout; check_signals(); while (1) { builtin_timeout = (int)read_builtin_timeout((unsigned int)a1); if (builtin_timeout >= 0) { builtin_timeout = read(a1, a2, a3); if (builtin_timeout >= 0) break; } if (*_errno_location() != 4) break; v5 = *_errno_location(); if (executing_builtin) check_signals_and_traps(); else check_signals(); *_errno_location() = v5; } return builtin_timeout; }
bash
ida
static void diff_special(void) { struct stat stat_data; if (!get_stat_data(current_stat_info.file_name, &stat_data)) return; if (current_header->header.typeflag == '3' ? !((((stat_data.st_mode)) & 0170000) == (0020000)) : current_header->header.typeflag == '4' ? !((((stat_data.st_mode)) & 0170000) == (0060000)) : !((((stat_data.st_mode)) & 0170000) == (0010000))) { report_difference(&current_stat_info, gettext("File type differs")); return; } if ((current_header->header.typeflag == '3' || current_header->header.typeflag == '4') && current_stat_info.stat.st_rdev != stat_data.st_rdev) { report_difference(&current_stat_info, gettext("Device number differs")); return; } if ((current_stat_info.stat.st_mode & (04000 | 02000 | 01000 | (0100 | (0100 >> 3) | ((0100 >> 3) >> 3) | (0200 | (0200 >> 3) | ((0200 >> 3) >> 3) | (0400 | (0400 >> 3) | ((0400 >> 3) >> 3)))))) != (stat_data.st_mode & (04000 | 02000 | 01000 | (0100 | (0100 >> 3) | ((0100 >> 3) >> 3) | (0200 | (0200 >> 3) | ((0200 >> 3) >> 3) | (0400 | (0400 >> 3) | ((0400 >> 3) >> 3))))))) report_difference(&current_stat_info, gettext("Mode differs")); }
unsigned long diff_special() { bool v0; char *v1; long v2; long v3; long v4; long v5; char *v6; long v7; long v8; long v9; long v10; char *v11; long v12; long v13; long v14; long v15; char v17[24]; int v18; long v19; unsigned long v20; v20 = __readfsqword(0x28u); if ((unsigned int)get_stat_data(current_stat_info[1], (long)v17)) { if (*(_BYTE *)(current_header + 156LL) == 51) { v0 = (v18 & 0xF000) != 0x2000; } else if (*(_BYTE *)(current_header + 156LL) == 52) { v0 = (v18 & 0xF000) != 24576; } else { v0 = (v18 & 0xF000) != 4096; } if (v0) { v1 = gettext("File type differs"); report_difference((long)current_stat_info, v1, v2, v3, v4, v5); } else if ((*(_BYTE *)(current_header + 156LL) == 51 || *(_BYTE *)(current_header + 156LL) == 52) && current_stat_info[16] != v19) { v6 = gettext("Device number differs"); report_difference((long)current_stat_info, v6, v7, v8, v9, v10); } else if ((((unsigned short)LODWORD(current_stat_info[14]) ^ (unsigned short)v18) & 0xFFF) != 0) { v11 = gettext("Mode differs"); report_difference((long)current_stat_info, v11, v12, v13, v14, v15); } } return __readfsqword(0x28u) ^ v20; }
tar
ida
int addr_match_cidr_list(const char *addr, const char *_list) { char *list, *cp, *o; struct xaddr try_addr, match_addr; u_int masklen; int ret = 0, r; if (addr != ((void *)0) && addr_pton(addr, &try_addr) != 0) { sshlog("addrmatch.c", __func__, 117, 1, SYSLOG_LEVEL_DEBUG2, ((void *)0), "couldn't parse address %.100s", addr); return 0; } if ((o = list = strdup(_list)) == ((void *)0)) return -1; while ((cp = strsep(&list, ",")) != ((void *)0)) { if (*cp == '\0') { sshlog("addrmatch.c", __func__, 124, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "empty entry in list \"%.100s\"", o); ret = -1; break; } if (strlen(cp) > 46 + 3) { sshlog("addrmatch.c", __func__, 137, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "list entry \"%.100s\" too long", cp); ret = -1; break; } if (strspn(cp, "0123456789abcdefABCDEF.:/") != strlen(cp)) { sshlog("addrmatch.c", __func__, 143, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "list entry \"%.100s\" contains invalid " "characters", cp); ret = -1; } r = addr_pton_cidr(cp, &match_addr, &masklen); if (r == -1) { sshlog("addrmatch.c", __func__, 151, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Invalid network entry \"%.100s\"", cp); ret = -1; break; } else if (r == -2) { sshlog("addrmatch.c", __func__, 155, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Inconsistent mask length for " "network \"%.100s\"", cp); ret = -1; break; } else if (r == 0 && addr != ((void *)0)) { if (addr_netmatch(&try_addr, &match_addr, masklen) == 0) ret = 1; continue; } } free(o); return ret; }
long addr_match_cidr_list(const char *a1, const char *a2) { size_t v3; unsigned int v4; unsigned int v5; int v6; char *stringp; void *ptr; char *v9; char v10[32]; char v11[24]; unsigned long v12; v12 = __readfsqword(0x28u); v5 = 0; if (a1 && (unsigned int)addr_pton(a1, v10)) { sshlog("addrmatch.c", "addr_match_cidr_list", 117LL, 1LL, 6LL, 0LL, "couldn't parse address %.100s", a1); return 0LL; } else { stringp = strdup(a2); ptr = stringp; if (stringp) { while (1) { v9 = strsep(&stringp, ","); if (!v9) break; if (!*v9) { sshlog("addrmatch.c", "addr_match_cidr_list", 124LL, 1LL, 2LL, 0LL, "empty entry in list \"%.100s\"", (const char *)ptr); v5 = -1; break; } if (strlen(v9) > 0x31) { sshlog("addrmatch.c", "addr_match_cidr_list", 137LL, 1LL, 2LL, 0LL, "list entry \"%.100s\" too long", v9); v5 = -1; break; } v3 = strspn(v9, "0123456789abcdefABCDEF.:/"); if (v3 != strlen(v9)) { sshlog("addrmatch.c", "addr_match_cidr_list", 143LL, 1LL, 2LL, 0LL, "list entry \"%.100s\" contains invalid characters", v9); v5 = -1; } v6 = addr_pton_cidr(v9, v11, &v4); if (v6 == -1) { sshlog("addrmatch.c", "addr_match_cidr_list", 151LL, 0LL, 2LL, 0LL, "Invalid network entry \"%.100s\"", v9); v5 = -1; break; } if (v6 == -2) { sshlog("addrmatch.c", "addr_match_cidr_list", 155LL, 0LL, 2LL, 0LL, "Inconsistent mask length for network \"%.100s\"", v9); v5 = -1; break; } if (!v6 && a1 && !(unsigned int)addr_netmatch(v10, v11, v4)) v5 = 1; } free(ptr); return v5; } else { return 0xFFFFFFFFLL; } } }
openssh-portable
ida
static int handle_permit(const char **optsp, int allow_bare_port, char ***permitsp, size_t *npermitsp, const char **errstrp) { char *opt, *tmp, *cp, *host, **permits = *permitsp; size_t npermits = *npermitsp; const char *errstr = "unknown error"; if (npermits > 4096) { *errstrp = "too many permission directives"; return -1; } if ((opt = opt_dequote(optsp, &errstr)) == ((void *)0)) { return -1; } if (allow_bare_port && strchr(opt, ':') == ((void *)0)) { if (asprintf(&tmp, "*:%s", opt) == -1) { free(opt); *errstrp = "memory allocation failed"; return -1; } free(opt); opt = tmp; } if ((tmp = strdup(opt)) == ((void *)0)) { free(opt); *errstrp = "memory allocation failed"; return -1; } cp = tmp; host = hpdelim2(&cp, ((void *)0)); if (host == ((void *)0) || strlen(host) >= 1025) { free(tmp); free(opt); *errstrp = "invalid permission hostname"; return -1; } if (cp == ((void *)0) || (strcmp(cp, "*") != 0 && a2port(cp) <= 0)) { free(tmp); free(opt); *errstrp = "invalid permission port"; return -1; } free(tmp); if ((permits = recallocarray(permits, npermits, npermits + 1, sizeof(*permits))) == ((void *)0)) { free(opt); *errstrp = "memory allocation failed"; return -1; } permits[npermits++] = opt; *permitsp = permits; *npermitsp = npermits; return 0; }
int handle_permit(unsigned long long a0, unsigned long a1, unsigned long long *a2, unsigned long long *a3, unsigned long long *a4) { char v0; int tmp_18; char *v1; unsigned long long v2; unsigned long long v3; unsigned long long v4; unsigned long long *v5; char *v6; unsigned int v8; v4 = *(a2); v5 = *(a3); v2 = "unknown error"; if (v5 > 0x1000) { *(a4) = "too many permission directives"; v8 = -1; } else { v3 = opt_dequote(a0, &v2, &v2); if (!v3) { v8 = -1; } else { if (a1) { v8 = strchr(v3, 0x3a); if (!v8) { v8 = asprintf(&v0, "*:%s", v3); if (v8 == -1) { free(v3); *(a4) = "memory allocation failed"; v8 = -1; } else { free(v3); v3 = *(&v0); } } } if (!a1 || v8 != -1 || v8) { v0 = strdup(v3); if (!v0) { free(v3); *(a4) = "memory allocation failed"; v8 = -1; } else { v1 = v0; v6 = hpdelim2(&v1, 0x0); if (v6) { v8 = strlen(v6); if (v8 <= 0x400) { if (v1) { v8 = strcmp(v1, "*"); if (v8) v8 = a2port(v1); if (!v8 || v8 > 0) { free(v0); v4 = recallocarray(v4, v5, v5 + 1, 0x8); if (!v4) { free(v3); *(a4) = "memory allocation failed"; v8 = -1; } else { tmp_18 = v5; v5 = v5 + 1; v4[tmp_18] = v3; *(a2) = v4; *(a3) = v5; v8 = 0; } } } if (!v1 || v8 <= 0 && v8) { free(v0); free(v3); *(a4) = "invalid permission port"; v8 = -1; } } } if (!v6 || v8 > 0x400) { free(v0); free(v3); *(a4) = "invalid permission hostname"; v8 = -1; } } } } } return v8; }
openssh-portable
angr_dream
static size_t count_ampersands(char const *str) { size_t count = 0; do { if (*str == '&') count++; } while (*str++); return count; }
int count_ampersands(unsigned long a0) { char *v0; int tmp_9; void *v1; v0 = a0; v1 = 0; do { if (*(v0) == 38) v1 += 1; tmp_9 = v0; v0 += 1; } while (*(tmp_9)); return v1; }
coreutils
angr_dream
int sshkey_enable_maxsign(struct sshkey *k, u_int32_t maxsign) { return -10; }
long long sshkey_enable_maxsign(unsigned long a0, unsigned long a1) { unsigned int v0; unsigned long v1; v1 = a0; v0 = a1; return 4294967286; }
openssh-portable
angr_dream
static int depmod_calculate_dependencies(struct depmod *depmod) { const struct mod **itrm; uint16_t *users, *roots, *sorted; uint16_t i, n_roots = 0, n_sorted = 0, n_mods = depmod->modules.count; int ret = 0; users = malloc(sizeof(uint16_t) * n_mods * 3); if (users == ((void *)0)) return -12; roots = users + n_mods; sorted = roots + n_mods; log_printf(7, "calculate dependencies and ordering (%hu modules)\n", n_mods); ((void)sizeof((depmod->modules.count < (65535)) ? 1 : 0), __extension__({ if (depmod->modules.count < (65535)) ; else __assert_fail("depmod->modules.count < UINT16_MAX", "tools/depmod.c", 1954, __extension__ __PRETTY_FUNCTION__); })); itrm = (const struct mod **)depmod->modules.array; for (i = 0; i < n_mods; i++, itrm++) { const struct mod *m = *itrm; users[i] = m->users; if (users[i] == 0) { roots[n_roots] = i; n_roots++; } } while (n_roots > 0) { const struct mod **itr_dst, **itr_dst_end; struct mod *src; uint16_t src_idx = roots[--n_roots]; src = depmod->modules.array[src_idx]; src->dep_sort_idx = n_sorted; sorted[n_sorted] = src_idx; n_sorted++; itr_dst = (const struct mod **)src->deps.array; itr_dst_end = itr_dst + src->deps.count; for (; itr_dst < itr_dst_end; itr_dst++) { const struct mod *dst = *itr_dst; uint16_t dst_idx = dst->idx; ((void)sizeof((users[dst_idx] > 0) ? 1 : 0), __extension__({ if (users[dst_idx] > 0) ; else __assert_fail("users[dst_idx] > 0", "tools/depmod.c", 1983, __extension__ __PRETTY_FUNCTION__); })); users[dst_idx]--; if (users[dst_idx] == 0) { roots[n_roots] = dst_idx; n_roots++; } } } if (n_sorted < n_mods) { depmod_report_cycles(depmod, n_mods, users); ret = -22; goto exit; } depmod_sort_dependencies(depmod); log_printf(7, "calculated dependencies and ordering (%hu modules)\n", n_mods); exit: free(users); return ret; }
int depmod_calculate_dependencies(unsigned long long a0[4], unsigned long a1, unsigned long a2, unsigned long long a3, unsigned long long a4) { unsigned short v0; unsigned short v1; unsigned short v2; unsigned short v3; unsigned short v4; unsigned short v5; unsigned int v6; unsigned long long *v7; unsigned long long *v8; unsigned short *v9; unsigned short *v10; unsigned short *v11; struct_1 *v12; unsigned long v13; struct_0 *v14; struct_2 *v15; unsigned int v17; v1 = 0; v2 = 0; v3 = a0[3]; v6 = 0; v9 = malloc(v3 * 6); if (!v9) { v17 = -12; return v17; } v10 = &v9[v3]; v11 = &v10[v3]; log_printf(0x7, "calculate dependencies and ordering (%hu modules)\n", v3, a3, a4); if (a0[3] > 65534) __assert_fail(); v7 = a0[2]; for (v0 = 0;[D] amd64g_calculate_condition( 0x2 < 64 >, 0x6 < 64 >, Conv(16->64, Load(addr = stack_base - 92, size = 2, endness = Iend_LE)), Conv(16->64, Load(addr = stack_base - 90, size = 2, endness = Iend_LE)), cc_ndep<8>); v7 += 1) { v15 = *(v7); v9[v0] = v15->field_6a; if (!v9[v0]) { v10[v1] = v0; v1 += 1; } v0 += 1; } while (v1) { v1 -= 1; v4 = v10[v1]; v12 = *((a0[2] + v4 * 8)); v12->field_64 = v2; v11[v2] = v4; v2 += 1; v8 = v12->field_30; for (v13 = &v8[v12->field_38]; v8 < v13; v8 += 1) { v14 = *(v8); v5 = v14->field_68; if (!v9[v5]) __assert_fail(); v9[v5] = v9[v5] - 1; if (!v9[v5]) { v10[v1] = v5; v1 += 1; } } } if ([D] amd64g_calculate_condition( 0x2 < 64 >, 0x6 < 64 >, Conv(16->64, Load(addr = stack_base - 92, size = 2, endness = Iend_LE)), Conv(16->64, Load(addr = stack_base - 90, size = 2, endness = Iend_LE)), cc_ndep<8>)) { depmod_report_cycles(a0, v3, v9, v3, a4); v6 = -22; } else { depmod_sort_dependencies(a0); log_printf(0x7, "calculated dependencies and ordering (%hu modules)\n", v3, a3, a4); } free(v9); v17 = v6; return v17; }
kmod
angr_sailr
void _rl_output_some_chars(const char *string, int count) { fwrite(string, 1, count, _rl_out_stream); }
long long _rl_output_some_chars(void *a0, unsigned long a1) { return fwrite(a0, 0x1, a1, _rl_out_stream); }
bash
angr_phoenix
void load_history() { char *hf; set_if_not("HISTSIZE", "500"); sv_histsize("HISTSIZE"); set_if_not("HISTFILESIZE", get_string_value("HISTSIZE")); sv_histsize("HISTFILESIZE"); hf = get_string_value("HISTFILE"); if (hf && *hf && file_exists(hf)) { read_history(hf); history_lines_in_file = history_lines_read_from_file; using_history(); } }
long load_history() { long string_value; long result; long v2; set_if_not("HISTSIZE", "500"); sv_histsize("HISTSIZE"); string_value = get_string_value("HISTSIZE"); set_if_not("HISTFILESIZE", string_value); sv_histsize("HISTFILESIZE"); result = get_string_value("HISTFILE"); v2 = result; if (result) { result = *(unsigned char *)result; if ((_BYTE)result) { result = file_exists(v2); if ((_DWORD)result) { read_history(v2); history_lines_in_file = history_lines_read_from_file; return using_history(); } } } return result; }
bash
ida
static _Bool all_digits_p(char const *s) { size_t n = strlen(s); return ((unsigned int)(s[0]) - '0' <= 9) && n == strspn(s, "0123456789"); }
_BOOL8 all_digits_p(const char *a1) { size_t v3; v3 = strlen(a1); return (unsigned int)(*a1 - 48) <= 9 && v3 == strspn(a1, "0123456789"); }
coreutils
ida
static int release_inode_block(ext2_filsys fs, blk64_t *block_nr, e2_blkcnt_t blockcnt, blk64_t ref_blk __attribute__((unused)), int ref_offset __attribute__((unused)), void *priv_data) { struct process_block_struct *pb; e2fsck_t ctx; struct problem_context *pctx; blk64_t blk = *block_nr; blk64_t cluster = ((*block_nr) >> (fs)->cluster_ratio_bits); int retval = 0; pb = (struct process_block_struct *)priv_data; ctx = pb->ctx; pctx = pb->pctx; pctx->blk = blk; pctx->blkcount = blockcnt; if (blk == 0) return 0; if (pb->last_cluster == cluster) return 0; pb->last_cluster = cluster; if ((blk < fs->super->s_first_data_block) || (blk >= ext2fs_blocks_count(fs->super))) { fix_problem(ctx, 0x000021, pctx); return_abort: pb->abort = 1; return 2; } if (!ext2fs_test_block_bitmap2(fs->block_map, blk)) { fix_problem(ctx, 0x000022, pctx); goto return_abort; } if (pb->truncating) { if (blockcnt < 0) { int i, limit; blk_t *bp; pb->errcode = io_channel_read_blk64(fs->io, blk, 1, pb->buf); if (pb->errcode) goto return_abort; limit = fs->blocksize >> 2; for (i = 0, bp = (blk_t *)pb->buf; i < limit; i++, bp++) if (*bp) return 0; } if (blockcnt >= 0 && blockcnt < pb->truncate_block) return 0; if ((blockcnt == pb->truncate_block) && pb->truncate_offset) { pb->errcode = io_channel_read_blk64(fs->io, blk, 1, pb->buf); if (pb->errcode) goto return_abort; memset(pb->buf + pb->truncate_offset, 0, fs->blocksize - pb->truncate_offset); pb->errcode = io_channel_write_blk64(fs->io, blk, 1, pb->buf); if (pb->errcode) goto return_abort; } pb->truncated_blocks++; *block_nr = 0; retval |= 1; } if (ctx->qctx) quota_data_sub(ctx->qctx, pb->inode, 0, ctx->fs->blocksize); ext2fs_block_alloc_stats2(fs, blk, -1); ctx->free_blocks++; return retval; }
long long release_inode_block(struct_0 *a0, unsigned long long *a1, unsigned long a2, unsigned long a3, unsigned long a4, struct_2 *a5) { unsigned int v0; unsigned long v1; unsigned int v2; unsigned int v3; unsigned int v4; unsigned int *v5; unsigned long long v6; unsigned long v7; struct_3 *v8; unsigned long long v9[8]; unsigned long long v11; unsigned long long v12; unsigned long long v13; v1 = a3; v0 = a4; v6 = *(a1); v7 = *(a1) >> (a0->field_c0 & 63); v2 = 0; v8 = a5->field_0; v9[0] = a5->field_10; v9[5] = v6; v9[7] = a2; if (!v6) { v11 = 0; } else if (v7 == a5->field_38) { v11 = 0; } else { a5->field_38 = v7; if (v6 >= a0->field_20->field_14) { v12 = ext2fs_blocks_count(a0->field_20); if (v6 < v12) { v13 = ext2fs_test_block_bitmap2(a0->field_58, v6, v6); if (!v13) { fix_problem(v8, 0x22, v9); } else if (a5->field_18 && (a2 - 0 >> 63)) { a5->field_30 = io_channel_read_blk64(a0->field_8, v6, 0x1, a5->field_8); if (!a5->field_30) { v4 = a0->field_28 >> 2; v3 = 0; for (v5 = a5->field_8; v3 < v4; v5 += 1) { if (*(v5)) { v11 = 0; break; } else { v3 += 1; } } } } } } if (v6 < a0->field_20->field_14 || v6 >= v12) fix_problem(v8, 0x21, v9); if ((v6 < v12 && !a5->field_30 && (a2 - 0 >> 63) && v6 >= a0->field_20->field_14 && v13 && a5->field_18 && (!(v3 < v4) || !(*(v5))) || v6 < v12 && v6 >= a0->field_20->field_14 && v13 && a5->field_18 && !((a2 - 0 >> 63))) && !((a2 - 0 >> 63)) && a2 < a5->field_20) v11 = 0; if (((v6 < v12 && !a5->field_30 && (a2 - 0 >> 63) && v6 >= a0->field_20->field_14 && v13 && a5->field_18 && (!(v3 < v4) || !(*(v5))) || v6 < v12 && v6 >= a0->field_20->field_14 && v13 && a5->field_18 && !((a2 - 0 >> 63))) && !((a2 - 0 >> 63)) && a2 >= a5->field_20 || (v6 < v12 && !a5->field_30 && (a2 - 0 >> 63) && v6 >= a0->field_20->field_14 && v13 && a5->field_18 && (!(v3 < v4) || !(*(v5))) || v6 < v12 && v6 >= a0->field_20->field_14 && v13 && a5->field_18 && !((a2 - 0 >> 63))) && (a2 - 0 >> 63)) && a2 == a5->field_20 && a5->field_1c) { a5->field_30 = io_channel_read_blk64(a0->field_8, v6, 0x1, a5->field_8); if (!a5->field_30) { memset(a5->field_1c + a5->field_8, 0x0, a0->field_28 - a5->field_1c); a5->field_30 = io_channel_write_blk64(a0->field_8, v6, 0x1, a5->field_8); } } if (...) { a5->field_2c = 1; v11 = 2; } if (...) { a5->field_28 = a5->field_28 + 1; *(a1) = 0; v2 |= 1; } if (...) { if (v8->field_278) quota_data_sub(v8->field_278, a5->field_40, 0x0, v8->field_0->field_28); ext2fs_block_alloc_stats2(a0, v6, 0xffffffff, v6); v8->field_70 = v8->field_70 + 1; v11 = v2; } } return v11; }
e2fsprogs-1.46.5
angr_dream
char *argv_assemble(int argc, char **argv) { int i, j, ws, r; char c, *ret; struct sshbuf *buf, *arg; if ((buf = sshbuf_new()) == ((void *)0) || (arg = sshbuf_new()) == ((void *)0)) sshfatal("misc.c", __func__, 2068, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new failed"); for (i = 0; i < argc; i++) { ws = 0; sshbuf_reset(arg); for (j = 0; argv[i][j] != '\0'; j++) { r = 0; c = argv[i][j]; switch (c) { case ' ': case '\t': ws = 1; r = sshbuf_put_u8(arg, c); break; case '\\': case '\'': case '"': if ((r = sshbuf_put_u8(arg, '\\')) != 0) break; default: r = sshbuf_put_u8(arg, c); break; } if (r != 0) sshfatal("misc.c", __func__, 2093, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "sshbuf_put_u8"); } if ((i != 0 && (r = sshbuf_put_u8(buf, ' ')) != 0) || (ws != 0 && (r = sshbuf_put_u8(buf, '"')) != 0) || (r = sshbuf_putb(buf, arg)) != 0 || (ws != 0 && (r = sshbuf_put_u8(buf, '"')) != 0)) sshfatal("misc.c", __func__, 2099, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "assemble"); } if ((ret = malloc(sshbuf_len(buf) + 1)) == ((void *)0)) sshfatal("misc.c", __func__, 2102, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "malloc failed"); memcpy(ret, sshbuf_ptr(buf), sshbuf_len(buf)); ret[sshbuf_len(buf)] = '\0'; sshbuf_free(buf); sshbuf_free(arg); return ret; }
void *argv_assemble(int param_1, long param_2) { int iVar1; void *__dest; undefined8 uVar2; long lVar3; size_t __n; void *__src; long lVar4; char **ppcVar5; undefined *puVar6; undefined *puVar7; char *pcStack104; undefined8 uStack96; long local_58; int local_4c; char local_41; int local_40; int local_3c; int local_38; int local_34; long local_30; long local_28; void *local_20; ppcVar5 = (char **)&local_58; uStack96 = 0x1056b1; local_58 = param_2; local_4c = param_1; local_30 = sshbuf_new(); if (local_30 != 0) { uStack96 = 0x1056c1; local_28 = sshbuf_new(); if (local_28 != 0) goto LAB_00105706; } ppcVar5 = &pcStack104; pcStack104 = "sshbuf_new failed"; sshfatal("misc.c", "argv_assemble", 0x814, 1, 1, 0); LAB_00105706: local_40 = 0; puVar6 = (undefined *)ppcVar5; do { lVar4 = local_28; lVar3 = local_30; if (local_4c <= local_40) { *(undefined8 *)(puVar6 + -8) = 0x105945; lVar3 = sshbuf_len(lVar3); *(undefined8 *)(puVar6 + -8) = 0x105951; local_20 = malloc(lVar3 + 1); puVar7 = puVar6; if (local_20 == (void *)0x0) { puVar7 = puVar6 + -0x10; *(char **)(puVar6 + -0x10) = "malloc failed"; *(undefined8 *)(puVar6 + -0x18) = 0x105996; sshfatal("misc.c", "argv_assemble", 0x836, 1, 1, 0); } lVar3 = local_30; *(undefined8 *)(puVar7 + -8) = 0x1059a2; __n = sshbuf_len(lVar3); lVar3 = local_30; *(undefined8 *)(puVar7 + -8) = 0x1059b1; __src = (void *)sshbuf_ptr(lVar3); __dest = local_20; *(undefined8 *)(puVar7 + -8) = 0x1059c6; memcpy(__dest, __src, __n); lVar3 = local_30; *(undefined8 *)(puVar7 + -8) = 0x1059d2; lVar4 = sshbuf_len(lVar3); lVar3 = local_30; *(undefined *)(lVar4 + (long)local_20) = 0; *(undefined8 *)(puVar7 + -8) = 0x1059e8; sshbuf_free(lVar3); lVar3 = local_28; *(undefined8 *)(puVar7 + -8) = 0x1059f4; sshbuf_free(lVar3); return local_20; } local_38 = 0; *(undefined8 *)(puVar6 + -8) = 0x105725; sshbuf_reset(lVar4); for (local_3c = 0; *(char *)((long)local_3c + *(long *)(local_58 + (long)local_40 * 8)) != '\0'; local_3c = __addvsi3(local_3c)) { local_34 = 0; local_41 = *(char *)((long)local_3c + *(long *)(local_58 + (long)local_40 * 8)); if (local_41 == '\\') { LAB_001057aa: *(undefined8 *)(puVar6 + -8) = 0x1057bb; local_34 = sshbuf_put_u8(local_28, 0x5c); if (local_34 == 0) { LAB_001057c4: *(undefined8 *)(puVar6 + -8) = 0x1057d9; local_34 = sshbuf_put_u8(local_28, local_41); } } else { if ('\\' < local_41) goto LAB_001057c4; if (local_41 == '\'') goto LAB_001057aa; if ('\'' < local_41) goto LAB_001057c4; if (local_41 == '\"') goto LAB_001057aa; if (('\"' < local_41) || ((local_41 != '\t' && (local_41 != ' ')))) goto LAB_001057c4; local_38 = 1; *(undefined8 *)(puVar6 + -8) = 0x1057a5; local_34 = sshbuf_put_u8(local_28, local_41); } if (local_34 != 0) { *(undefined8 *)(puVar6 + -8) = 0x1057ef; uVar2 = ssh_err(local_34); *(char **)(puVar6 + -0x10) = "sshbuf_put_u8"; *(undefined8 *)(puVar6 + -0x18) = 0x105826; sshfatal("misc.c", "argv_assemble", 0x82d, 1, 1, uVar2); puVar6 = puVar6 + -0x10; } *(undefined8 *)(puVar6 + -8) = 0x105833; } if (local_40 == 0) { LAB_00105880: if (local_38 != 0) { *(undefined8 *)(puVar6 + -8) = 0x105897; local_34 = sshbuf_put_u8(local_30, 0x22); if (local_34 != 0) goto LAB_001058dc; } *(undefined8 *)(puVar6 + -8) = 0x1058b3; local_34 = sshbuf_putb(local_30, local_28); if (local_34 != 0) goto LAB_001058dc; puVar7 = puVar6; if (local_38 != 0) { *(undefined8 *)(puVar6 + -8) = 0x1058d3; local_34 = sshbuf_put_u8(local_30, 0x22); if (local_34 != 0) goto LAB_001058dc; } } else { *(undefined8 *)(puVar6 + -8) = 0x105877; local_34 = sshbuf_put_u8(local_30, 0x20); if (local_34 == 0) goto LAB_00105880; LAB_001058dc: *(undefined8 *)(puVar6 + -8) = 0x1058e6; uVar2 = ssh_err(local_34); puVar7 = puVar6 + -0x10; *(char **)(puVar6 + -0x10) = "assemble"; *(undefined8 *)(puVar6 + -0x18) = 0x10591d; sshfatal("misc.c", "argv_assemble", 0x833, 1, 1, uVar2); } iVar1 = local_40; *(undefined8 *)(puVar7 + -8) = 0x10592a; local_40 = __addvsi3(iVar1); puVar6 = puVar7; } while (true); }
openssh-portable
ghidra
static void set_filter(const struct cmdinfo *cip, const char *value) { filter_add(value, cip->arg_int); }
void set_filter(long param_1, undefined8 param_2) { filter_add(param_2, *(int *)(param_1 + 0x28) != 0); return; }
dpkg
ghidra
int ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) { struct session_state *state = ssh->state; int len, r, ms_remain; struct pollfd pfd; char buf[8192]; struct timeval start; struct timespec timespec, *timespecp = ((void *)0); ; if ((r = ssh_packet_write_wait(ssh)) != 0) goto out; for (;;) { r = ssh_packet_read_poll_seqnr(ssh, typep, seqnr_p); if (r != 0) break; if (*typep != 0) break; pfd.fd = state->connection_in; pfd.events = 0x001; if (state->packet_timeout_ms > 0) { ms_remain = state->packet_timeout_ms; timespecp = &timespec; } for (;;) { if (state->packet_timeout_ms > 0) { ms_to_timespec(&timespec, ms_remain); monotime_tv(&start); } if ((r = ppoll(&pfd, 1, timespecp, ((void *)0))) >= 0) break; if ((*__errno_location()) != 11 && (*__errno_location()) != 4 && (*__errno_location()) != 11) { r = -24; goto out; } if (state->packet_timeout_ms <= 0) continue; ms_subtract_diff(&start, &ms_remain); if (ms_remain <= 0) { r = 0; break; } } if (r == 0) { r = -53; goto out; } len = read(state->connection_in, buf, sizeof(buf)); if (len == 0) { r = -52; goto out; } if (len == -1) { r = -24; goto out; } if ((r = ssh_packet_process_incoming(ssh, buf, len)) != 0) goto out; } out: return r; }
long ssh_packet_read_seqnr(int **a1, unsigned char *a2, _DWORD *a3) { unsigned int v5; unsigned int i; unsigned int v7; struct timespec *timeout; int *v9; struct pollfd fds; char v11[16]; char v12[16]; char buf[16]; unsigned long v14; v14 = __readfsqword(0x28u); v9 = *a1; timeout = 0LL; for (i = ssh_packet_write_wait((long *)a1); !i; i = ssh_packet_process_incoming((unsigned int **)a1, (long)buf, v7)) { i = ssh_packet_read_poll_seqnr((unsigned int **)a1, a2, a3); if (i || *a2) break; fds.fd = *v9; fds.events = 1; if (v9[84] > 0) { v5 = v9[84]; timeout = (struct timespec *)v12; } while (1) { if (v9[84] > 0) { ms_to_timespec(v12, v5); monotime_tv(v11); } i = ppoll(&fds, 1uLL, timeout, 0LL); if ((i & 0x80000000) == 0) break; if (*_errno_location() != 11 && *_errno_location() != 4 && *_errno_location() != 11) return (unsigned int)-24; if (v9[84] > 0) { ms_subtract_diff(v11, &v5); if ((int)v5 <= 0) { i = 0; break; } } } if (!i) return (unsigned int)-53; v7 = read(*v9, buf, 0x2000uLL); if (!v7) return (unsigned int)-52; if (v7 == -1) return (unsigned int)-24; } return i; }
openssh-portable
ida
static int netns_map_add(int nsid, const char *name) { struct nsid_cache *c; uint32_t h; if (netns_map_get_by_nsid(nsid) != ((void *)0)) return -17; c = malloc(sizeof(*c) + strlen(name) + 1); if (c == ((void *)0)) { perror("malloc"); return -12; } c->nsid = nsid; strcpy(c->name, name); h = (nsid & (128 - 1)); hlist_add_head(&c->nsid_hash, &nsid_head[h]); h = (namehash(name) & (128 - 1)); hlist_add_head(&c->name_hash, &name_head[h]); return 0; }
void netns_map_add(unsigned long a0, char *a1) { unsigned int v0; struct_0 *v1; unsigned long long v3; unsigned long long v4; void *v5; if (netns_map_get_by_nsid(a0)) { v3 = 4294967279; return; } v1 = malloc(strlen(a1) + 41); if (!v1) { perror("malloc"); v4 = 4294967284; return; } v1->field_20 = a0; strcpy(v1 + 1, a1); v0 = a0 & 127; hlist_add_head(v1, &(&nsid_head)[v0]); v0 = namehash(a1) & 127; hlist_add_head(&v1->padding_0[16], &(&name_head)[v0]); v5 = 0; return; }
iproute2-6.0.0
angr_sailr
void usage(int status) { if (status != 0) { fprintf(stderr, gettext("Try '%s --help' for more information.\n"), program_name); exit(status); } fprintf(stdout, gettext("Usage: %s [-H] [-L] [-P] [-Olevel] [-D debugopts] [path...] " "[expression]\n"), program_name); fputs(gettext("\nDefault path is the current directory; default expression " "is -print.\nExpression may consist of: operators, options, " "tests, and actions.\n"), stdout); ; fputs(gettext("\nOperators (decreasing precedence; -and is implicit where no " "others are given):\n ( EXPR ) ! EXPR -not EXPR " "EXPR1 -a EXPR2 EXPR1 -and EXPR2\n EXPR1 -o EXPR2 " "EXPR1 -or EXPR2 EXPR1 , EXPR2\n"), stdout); ; fputs(gettext("\nPositional options (always true):\n -daystart -follow " "-nowarn -regextype -warn\n"), stdout); ; fputs(gettext("\nNormal options (always true, specified before other " "expressions):\n -depth -files0-from FILE -maxdepth " "LEVELS -mindepth LEVELS\n -mount -noleaf -xdev " "-ignore_readdir_race -noignore_readdir_race\n"), stdout); ; fputs(gettext( "\nTests (N can be +N or -N or N):\n -amin N -anewer FILE " "-atime N -cmin N -cnewer FILE -context CONTEXT\n -ctime N " "-empty -false -fstype TYPE -gid N -group NAME -ilname PATTERN\n " " -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN\n " " -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer " "FILE\n -nouser -nogroup -path PATTERN -perm [-/]MODE -regex " "PATTERN\n -readable -writable -executable\n -wholename " "PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n " "-used N -user NAME -xtype [bcdpfls]\n"), stdout); ; fputs(gettext("\nActions:\n -delete -print0 -printf FORMAT -fprintf " "FILE FORMAT -print \n -fprint0 FILE -fprint FILE -ls " "-fls FILE -prune -quit\n -exec COMMAND ; -exec COMMAND " "{} + -ok COMMAND ;\n -execdir COMMAND ; -execdir COMMAND " "{} + -okdir COMMAND ;\n"), stdout); ; fputs(gettext("\nOther common options:\n"), stdout); ; fputs(gettext(" --help display this help and exit\n"), stdout); ; fputs(gettext(" --version output version information and " "exit\n\n"), stdout); ; show_valid_debug_options(0); fputs(gettext("\nUse '-D help' for a description of the options, or see " "find(1)\n\n"), stdout); ; explain_how_to_report_bugs(stdout, program_name); exit(status); }
void usage(unsigned long a0) { unsigned long v0; unsigned long v2; v0 = v2; if (a0) { fprintf(stderr, gettext("Try '%s --help' for more information.\n")); exit(a0); } fprintf(stdout, gettext("Usage: %s [-H] [-L] [-P] [-Olevel] [-D debugopts] " "[path...] [expression]\n")); fputs(gettext("\nDefault path is the current directory; default expression " "is -print.\nExpression may consist of: operators, options, " "tests, and actions.\n"), stdout); fputs(gettext("\nOperators (decreasing precedence; -and is implicit where no " "others are given):\n ( EXPR ) ! EXPR -not EXPR " "EXPR1 -a EXPR2 EXPR1 -and EXPR2\n EXPR1 -o EXPR2 " "EXPR1 -or EXPR2 EXPR1 , EXPR2\n"), stdout); fputs(gettext("\nPositional options (always true):\n -daystart -follow " "-nowarn -regextype -warn\n"), stdout); fputs(gettext("\nNormal options (always true, specified before other " "expressions):\n -depth -files0-from FILE -maxdepth " "LEVELS -mindepth LEVELS\n -mount -noleaf -xdev " "-ignore_readdir_race -noignore_readdir_race\n"), stdout); fputs(gettext( "\nTests (N can be +N or -N or N):\n -amin N -anewer FILE " "-atime N -cmin N -cnewer FILE -context CONTEXT\n -ctime N " "-empty -false -fstype TYPE -gid N -group NAME -ilname PATTERN\n " " -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN\n " " -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer " "FILE\n -nouser -nogroup -path PATTERN -perm [-/]MODE -regex " "PATTERN\n -readable -writable -executable\n -wholename " "PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n " "-used N -user NAME -xtype [bcdpfls]\n"), stdout); fputs(gettext("\nActions:\n -delete -print0 -printf FORMAT -fprintf " "FILE FORMAT -print \n -fprint0 FILE -fprint FILE -ls " "-fls FILE -prune -quit\n -exec COMMAND ; -exec COMMAND " "{} + -ok COMMAND ;\n -execdir COMMAND ; -execdir COMMAND " "{} + -okdir COMMAND ;\n"), stdout); fputs(gettext("\nOther common options:\n"), stdout); fputs(gettext(" --help display this help and exit\n"), stdout); fputs(gettext(" --version output version information and " "exit\n\n"), stdout); show_valid_debug_options(0x0); fputs(gettext("\nUse '-D help' for a description of the options, or see " "find(1)\n\n"), stdout); explain_how_to_report_bugs(stdout, program_name, program_name); exit(a0); }
findutils
angr_dream
static struct var **hashvar(const char *p) { unsigned int hashval; hashval = ((unsigned char)*p) << 4; while (*p && *p != '=') hashval += (unsigned char)*p++; return &vartab[hashval % 39]; }
int hashvar(unsigned long a0) { char *v0; int tmp_10; unsigned int v1; v0 = a0; v1 = *(v0) * 16; while (true) { switch (*(v0)) { case 0: case 61: break; default: tmp_10 = v0; v0 += 1; v1 += *(tmp_10); continue; } } return &(&vartab)[v1 + -39 * ((v1 * 2753184165 >> 32) + (v1 - (v1 * 2753184165 >> 32) >> 1) >> 5)]; }
dash-0.5.11+git20210903+057cd650a4ed
angr_sailr
static int redir_varvalue(redir) REDIRECT *redir; { SHELL_VAR *v; char *val, *w; intmax_t vmax; int i; char *sub; int len, vr; w = redir->redirector.filename->word; if (vr = valid_array_reference(w, 0)) { v = array_variable_part(w, 0, &sub, &len); } else { v = find_variable(w); if (v == 0) { v = find_variable_last_nameref(w, 0); if (v && ((((v)->attributes) & (0x0000800)))) { w = ((v)->value); if (vr = valid_array_reference(w, 0)) v = array_variable_part(w, 0, &sub, &len); else v = find_variable(w); } } } if (v == 0 || ((((v)->attributes) & (0x0001000)))) return -1; if (vr && (((((v)->attributes) & (0x0000004))) || ((((v)->attributes) & (0x0000040))))) val = get_array_value(w, 0, (array_eltstate_t *)((void *)0)); else val = get_variable_value(v); if (val == 0 || *val == 0) return -1; if (legal_number(val, &vmax) < 0) return -1; i = vmax; return i; }
long redir_varvalue(long a1) { char v2[4]; int valid; long v4; char v5[8]; long variable; _BYTE *array_value; long v8; unsigned long v9; v9 = __readfsqword(0x28u); v8 = **(_QWORD **)(a1 + 8); valid = valid_array_reference(v8, 0LL); if (valid) { LABEL_2: variable = array_variable_part(v8, 0LL, v5, v2); goto LABEL_8; } variable = find_variable(v8); if (!variable) { variable = find_variable_last_nameref(v8, 0LL); if (variable) { if ((*(_DWORD *)(variable + 40) & 0x800) != 0) { v8 = *(_QWORD *)(variable + 8); valid = valid_array_reference(v8, 0LL); if (!valid) { variable = find_variable(v8); goto LABEL_8; } goto LABEL_2; } } } LABEL_8: if (!variable || (*(_DWORD *)(variable + 40) & 0x1000) != 0) return 0xFFFFFFFFLL; if (valid && ((*(_DWORD *)(variable + 40) & 4) != 0 || (*(_DWORD *)(variable + 40) & 0x40) != 0)) array_value = (_BYTE *)get_array_value(v8, 0LL, 0LL); else array_value = (_BYTE *)get_variable_value(variable); if (!array_value || !*array_value) return 0xFFFFFFFFLL; if ((int)legal_number(array_value, &v4) >= 0) return (unsigned int)v4; return 0xFFFFFFFFLL; }
bash
ida
void showjobs(struct output *out, int mode) { struct job *jp; ; dowait(0, ((void *)0)); for (jp = curjob; jp; jp = jp->prev_job) { if (!(mode & 0x08) || jp->changed) showjob(out, jp, mode); } }
void showjobs(undefined8 param_1, uint param_2) { long local_10; dowait(0, 0); for (local_10 = curjob; local_10 != 0; local_10 = *(long *)(local_10 + 0x20)) { if (((param_2 & 8) == 0) || ((*(byte *)(local_10 + 0x1f) & 0x10) != 0)) { showjob(param_1, local_10, param_2); } } return; }
dash-0.5.11+git20210903+057cd650a4ed
ghidra
static inline void emit_mandatory_arg_note(void) { fputs_unlocked(gettext("\nMandatory arguments to long options are mandatory " "for short options too.\n"), stdout) ; }
void emit_mandatory_arg_note() { unsigned long long v1; v1 = fputs_unlocked(gettext("\nMandatory arguments to long options are " "mandatory for short options too.\n"), stdout); return; }
coreutils
angr_dream
static int ipstats_process_ifsm(struct nlmsghdr *answer, struct ipstats_stat_enabled *enabled) { struct ipstats_stat_show_attrs show_attrs = {}; const char *dev; int err = 0; int i; show_attrs.ifsm = ((void *)(((char *)answer) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))))); show_attrs.len = (answer->nlmsg_len - ((sizeof(*show_attrs.ifsm)) + ((int)(((sizeof(struct nlmsghdr)) + 4U - 1) & ~(4U - 1))))); if (show_attrs.len < 0) { fprintf(stderr, "BUG: wrong nlmsg len %d\n", show_attrs.len); return -22; } err = ipstats_stat_show_attrs_alloc_tb(&show_attrs, 0); if (err != 0) { fprintf(stderr, "Error parsing netlink answer: %s\n", strerror(err)); return err; } dev = ll_index_to_name(show_attrs.ifsm->ifindex); for (i = 0; i < enabled->nenabled; i++) { const struct ipstats_stat_desc *desc = enabled->enabled[i].desc; open_json_object(((void *)0)); print_int(PRINT_ANY, "ifindex", "%d:", show_attrs.ifsm->ifindex); print_color_string(PRINT_ANY, COLOR_IFNAME, "ifname", " %s:", dev); ipstats_show_group(&enabled->enabled[i].sel); err = desc->show(&show_attrs, desc); if (err != 0) goto out; close_json_object(); print_nl(); } out: ipstats_stat_show_attrs_free(&show_attrs); return err; }
int ipstats_process_ifsm(unsigned int *a0, unsigned long long a1[2], unsigned long long a2, unsigned long long a3, unsigned long long a4, unsigned long long a5) { unsigned int v0; unsigned int v1; unsigned long long v2; struct_0 *v3; struct_1 *v4; unsigned int v5; void *v6; void *v7; void *v8; void *v9; void *v10; void *v11; unsigned int v13; v4 = 0; v5 = 0; v6 = 0; v7 = 0; v8 = 0; v9 = 0; v10 = 0; v11 = 0; v0 = 0; v4 = &a0[4]; v5 = *(a0)-28; if (v5 < 0) { fprintf(*(&stderr), "BUG: wrong nlmsg len %d\n", v5); v13 = -22; } else { v0 = ipstats_stat_show_attrs_alloc_tb(&v4, 0x0); if (v0) { fprintf(*(&stderr), "Error parsing netlink answer: %s\n", strerror(v0)); v13 = v0; } else { v2 = ll_index_to_name(v4->field_4); v1 = 0; while (true) { if (v1 >= a1[1]) break; v3 = *((a1[0] + v1 * 32)); open_json_object(0x0); print_int(0x4, "ifindex", "%d:", v4->field_4); print_color_string(0x4, 0x0, "ifname", " %s:", v2); ipstats_show_group(a1[0] + v1 * 32 + 8); v0 = v3->field_18(&v4, v3, v3, v3->field_18); if (v0) break; close_json_object(&v4, a1, a2, a3, a4, a5); print_nl(); v1 += 1; } ipstats_stat_show_attrs_free(&v4); v13 = v0; } } return v13; }
iproute2-6.0.0
angr_phoenix
static unsigned bi_reverse(code, len) unsigned code; int len; { register unsigned res = 0; do { res |= code & 1; code >>= 1, res <<= 1; } while (--len > 0); return res >> 1; }
int bi_reverse(unsigned long a0, unsigned long a1) { unsigned int v0; int tmp_39; unsigned int v1; void *v3; v1 = a0; v0 = a1; v3 = 0; do { tmp_39 = v3 | v1 & 1; v1 >>= 1; v3 = tmp_39 * 2; v0 -= 1; } while (v0 > 0); return v3 / 2; }
zlib
angr_dream
static inline intmax_t getn(const char *s) { return atomax10(s); }
int getn(unsigned long long a0) { return atomax10(a0); }
dash-0.5.11+git20210903+057cd650a4ed
angr_phoenix
_Bool pred_ctime (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr) { (void)&pathname; return pred_timewindow(get_stat_ctime(stat_buf), pred_ptr, 86400); }
long long pred_ctime(unsigned long a0, unsigned long long a1, void *a2) { unsigned long v0; v0 = a0; return pred_timewindow(get_stat_ctime(a1), a2, a2, 0x15180); }
findutils
angr_phoenix
void kwsfree(kwset_t kwset) { __extension__({ struct obstack *__o = (&kwset->obstack); void *__obj = (void *)(((void *)0)); if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) __o->next_free = __o->object_base = (char *)__obj; else _obstack_free(__o, __obj); }); free(kwset); }
void kwsfree(void *param_1) { _obstack_free(param_1, 0); free(param_1); return; }
grep
ghidra
int main(int argc, char **argv) { char *tty = ((void *)0); struct passwd *pwd; int c, status = 0; int reconnect = 0; int opt_e = 0; struct console *con; pid_t pid; if ((pid = getpid()) == 1) { setsid(); (void)ioctl(0, 0x540E, (char *)1); } opterr = 0; while ((c = getopt(argc, argv, "ept:")) != (-1)) switch (c) { case 't': timeout = atoi(optarg); break; case 'p': profile = 1; break; case 'e': opt_e = 1; break; default: usage(); break; } if (geteuid() != 0) { fprintf(stderr, "sulogin: only root can run sulogin.\n\r"); exit(1); } saved_sigint = signal(2, ((__sighandler_t)1)); saved_sigquit = signal(3, ((__sighandler_t)1)); saved_sigtstp = signal(20, ((__sighandler_t)1)); saved_sighup = signal(1, ((__sighandler_t)1)); if (optind < argc) tty = argv[optind]; if (!tty || *tty == '\0') tty = getenv("CONSOLE"); reconnect = detect_consoles(tty, 0); if (!consoles) { if (!(*__errno_location())) (*__errno_location()) = 12; fprintf(stderr, "sulogin: cannot open console: %m\n\r"); exit(1); } if (reconnect) { if (isatty(1) == 0) dup2(0, 1); if (isatty(2) == 0) dup2(0, 2); } if ((pwd = getrootpwent(opt_e)) == ((void *)0)) { fprintf(stderr, "sulogin: cannot open password database!\n\r"); sleep(2); } for (con = consoles; con && con->id < 16; con = con->next) { if (con->fd >= 0) { openfd |= (1 << con->fd); tcinit(con); continue; } if ((con->fd = open(con->tty, 02 | 0400 | 04000)) < 0) continue; openfd |= (1 << con->fd); tcinit(con); } con = consoles; usemask = (uint32_t *)mmap(((void *)0), sizeof(uint32_t), 0x1 | 0x2, 0x20 | 0x01, -1, 0); if (con->next == (struct console *)0) goto nofork; signal(17, chld_handler); do { switch ((con->pid = fork())) { case 0: signal(17, ((__sighandler_t)0)); nofork: setup(con); while (1) { char *passwd = pwd->pw_passwd; char *answer; int failed = 0, doshell = 0; doprompt(passwd, con); if ((answer = getpasswd(con)) == ((void *)0)) break; if (passwd[0] == '\0') doshell++; else { char *cryptbuf; cryptbuf = crypt(answer, passwd); if (cryptbuf == ((void *)0)) fprintf(stderr, "sulogin: crypt failed: %m\n\r"); else if (strcmp(cryptbuf, pwd->pw_passwd) == 0) doshell++; } if (doshell) { *usemask |= (1 << con->id); sushell(pwd); *usemask &= ~(1 << con->id); failed++; } signal(3, ((__sighandler_t)1)); signal(20, ((__sighandler_t)1)); signal(2, ((__sighandler_t)1)); if (failed) { fprintf(stderr, "sulogin: can not execute su shell.\n\r"); break; } fprintf(stderr, "Login incorrect.\n\r"); sleep(3); } if (alarm_rised) { tcfinal(con); fprintf(stderr, "Timed out.\n\r"); } exit(0); case -1: fprintf(stderr, "sulogin: can not fork: %m\n\r"); default: break; } } while ((con = con->next) && (con->id < 16)); while ((pid = wait(&status))) { if ((*__errno_location()) == 10) break; if (pid < 0) continue; for (con = consoles; con && con->id < 16; con = con->next) { if (con->pid == pid) { *usemask &= ~(1 << con->id); continue; } if (kill(con->pid, 0) < 0) { *usemask &= ~(1 << con->id); continue; } if (*usemask & (1 << con->id)) continue; kill(con->pid, 1); usleep(5000); kill(con->pid, 9); } } signal(17, ((__sighandler_t)0)); return 0; }
int main(int argc, const char **argv, const char **envp) { int v3; __WAIT_STATUS stat_loc; int v6; int v7; int v8; __pid_t v9; int v10; char *v11; long i; long *v13; char *salt; char *key; char *s1; unsigned long v17; v17 = __readfsqword(0x28u); v11 = 0LL; stat_loc.__uptr = 0LL; v8 = 0; v9 = getpid(); if (v9 == 1) { setsid(); ioctl(0, 0x540EuLL, 1LL); } opterr = 0; while (1) { v10 = getopt(argc, (char *const *)argv, "ept:"); if (v10 == -1) break; if (v10 == 116) { timeout = atoi(optarg); } else { if (v10 > 116) goto LABEL_12; if (v10 == 101) { HIDWORD(stat_loc.__iptr) = 1; } else if (v10 == 112) { profile = 1; } else { LABEL_12: usage(); } } } if (geteuid()) { fprintf(stderr, "sulogin: only root can run sulogin.\n\r"); exit(1); } saved_sigint = signal(2, (__sighandler_t)((char *)tcinit + 1)); saved_sigquit = signal(3, (__sighandler_t)((char *)tcinit + 1)); saved_sigtstp = signal(20, (__sighandler_t)((char *)tcinit + 1)); saved_sighup = signal(1, (__sighandler_t)((char *)tcinit + 1)); if (argc > optind) v11 = (char *)argv[optind]; if (!v11 || !*v11) v11 = getenv("CONSOLE"); v8 = detect_consoles(v11, 0LL); if (!consoles) { if (!*_errno_location()) *_errno_location() = 12; fprintf(stderr, "sulogin: cannot open console: %m\n\r"); exit(1); } if (v8) { if (!isatty(1)) dup2(0, 1); if (!isatty(2)) dup2(0, 2); } v13 = getrootpwent(SHIDWORD(stat_loc.__iptr)); if (!v13) { fprintf(stderr, "sulogin: cannot open password database!\n\r"); sleep(2u); } for (i = consoles; i && *(int *)(i + 24) <= 15; i = *(_QWORD *)(i + 96)) { if (*(int *)(i + 20) < 0) { *(_DWORD *)(i + 20) = open(*(const char **)i, 2306); if (*(int *)(i + 20) < 0) continue; } openfd |= 1 << *(_DWORD *)(i + 20); tcinit(i); } i = consoles; usemask = (long)mmap(0LL, 4uLL, 3, 33, -1, 0LL); if (!*(_QWORD *)(i + 96)) goto LABEL_44; signal(17, (__sighandler_t)chld_handler); do { *(_DWORD *)(i + 28) = fork(); v3 = *(_DWORD *)(i + 28); if (v3 == -1) { fprintf(stderr, "sulogin: can not fork: %m\n\r"); } else if (!v3) { signal(17, 0LL); LABEL_44: setup(i); while (1) { salt = (char *)v13[1]; v6 = 0; v7 = 0; doprompt(salt, i); key = getpasswd(i); if (!key) goto LABEL_57; if (*salt) { s1 = crypt(key, salt); if (s1) { if (!strcmp(s1, (const char *)v13[1])) ++v7; } else { fprintf(stderr, "sulogin: crypt failed: %m\n\r"); } } else { ++v7; } if (v7) { *(_DWORD *)usemask |= 1 << *(_DWORD *)(i + 24); sushell((long)v13); *(_DWORD *)usemask &= ~(1 << *(_DWORD *)(i + 24)); ++v6; } signal(3, (__sighandler_t)((char *)tcinit + 1)); signal(20, (__sighandler_t)((char *)tcinit + 1)); signal(2, (__sighandler_t)((char *)tcinit + 1)); if (v6) break; fprintf(stderr, "Login incorrect.\n\r"); sleep(3u); } fprintf(stderr, "sulogin: can not execute su shell.\n\r"); LABEL_57: if (alarm_rised) { tcfinal(i); fprintf(stderr, "Timed out.\n\r"); } exit(0); } i = *(_QWORD *)(i + 96); } while (i && *(int *)(i + 24) <= 15); while (1) { v9 = wait((__WAIT_STATUS)&stat_loc); if (!v9 || *_errno_location() == 10) break; if (v9 >= 0) { for (i = consoles; i && *(int *)(i + 24) <= 15; i = *(_QWORD *)(i + 96)) { if (v9 == *(_DWORD *)(i + 28)) { *(_DWORD *)usemask &= ~(1 << *(_DWORD *)(i + 24)); } else if (kill(*(_DWORD *)(i + 28), 0) >= 0) { if ((*(_DWORD *)usemask & (1 << *(_DWORD *)(i + 24))) == 0) { kill(*(_DWORD *)(i + 28), 1); usleep(0x1388u); kill(*(_DWORD *)(i + 28), 9); } } else { *(_DWORD *)usemask &= ~(1 << *(_DWORD *)(i + 24)); } } } } signal(17, 0LL); return 0; }
sysvinit
ida
static char *component_start(char *f) { while (*f == '/') f++; return f; }
int component_start(unsigned long a0) { char *v0; for (v0 = a0; *(v0) == 47; v0 += 1) ; return v0; }
coreutils
angr_phoenix
static _Bool cwrite(_Bool new_file_flag, char const *bp, size_t bytes) { if (new_file_flag) { if (!bp && bytes == 0 && elide_empty_files) return 1; closeout(((void *)0), output_desc, filter_pid, outfile); next_file_name(); output_desc = create(outfile); if (output_desc < 0) ((!!sizeof(struct { _Static_assert( 1, "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon " "(0, shell_escape_quoting_style, outfile)), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, (*__errno_location()), "%s", quotearg_n_style_colon(0, shell_escape_quoting_style, outfile)), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, (*__errno_location()), "%s", quotearg_n_style_colon(0, shell_escape_quoting_style, outfile)), ((0) ? (void)0 : __builtin_unreachable())))); } if (full_write(output_desc, bp, bytes) == bytes) return 1; else { if (!ignorable((*__errno_location()))) ((!!sizeof(struct { _Static_assert( 1, "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon " "(0, shell_escape_quoting_style, outfile)), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, (*__errno_location()), "%s", quotearg_n_style_colon(0, shell_escape_quoting_style, outfile)), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, (*__errno_location()), "%s", quotearg_n_style_colon(0, shell_escape_quoting_style, outfile)), ((0) ? (void)0 : __builtin_unreachable())))); return 0; } }
int cwrite(unsigned long a0, unsigned long long a1, unsigned long long a2) { unsigned int v1; unsigned long long v2; unsigned long long v3; if (a0) { if (!a1 && !a2 && elide_empty_files) v1 = 1; if (!elide_empty_files || a2 || a1) { closeout(0x0, output_desc, filter_pid, outfile); next_file_name(); output_desc = create(outfile); if (output_desc < 0) { v2 = quotearg_n_style_colon(0x0, 0x3, outfile); error(0x1, *(__errno_location()), "%s"); } } } if (output_desc >= 0 || !elide_empty_files) v1 = full_write(output_desc, a1, a2, a1); if ((!a0 || output_desc >= 0) && (!a0 || !elide_empty_files || a2 || a1)) { if (a2 == v1) { v1 = 1; } else { *(&v1) = ignorable(*(__errno_location())) ^ 1; if (v1) { v3 = quotearg_n_style_colon(0x0, 0x3, outfile); error(0x1, *(__errno_location()), "%s"); } v1 = 0; } } if (!a0 && a2 == v1 || !a0 && !v1 || a2 == v1 && output_desc >= 0 || !v1 && output_desc >= 0 || !a2 && !a1 && a0 && elide_empty_files) return v1; }
coreutils
angr_dream
static int do_times(int fd, int verb, const struct stat *sb) { char buf[(20 + 7 + 2) * 2 + 2]; (void)snprintf( buf, sizeof(buf), "T%llu 0 %llu 0\n", (unsigned long long)(sb->st_mtim.tv_sec < 0 ? 0 : sb->st_mtim.tv_sec), (unsigned long long)(sb->st_atim.tv_sec < 0 ? 0 : sb->st_atim.tv_sec)); if (verb) { fprintf(stderr, "File mtime %lld atime %lld\n", (long long)sb->st_mtim.tv_sec, (long long)sb->st_atim.tv_sec); fprintf(stderr, "Sending file timestamps: %s", buf); } (void)atomicio((ssize_t (*)(int, void *, size_t))write, fd, buf, strlen(buf)); return (response()); }
int do_times(unsigned long a0, unsigned long a1, unsigned long long a2[12]) { char v0; unsigned long v2; unsigned long v3; v2 = a2[9]; if (a2[9] < 0) v2 = 0; v3 = v2; *(&v2) = *((v2 + 88)); if (v3 < 0) *(&v2) = 0; snprintf(&v0, 0x3c, "T%llu 0 %llu 0\n", v2, v3); if (a1) { fprintf(stderr, "File mtime %lld atime %lld\n", a2[11], a2[9]); fprintf(stderr, "Sending file timestamps: %s", &v0); } atomicio(got.write, a0, &v0, strlen(&v0)); return response(); }
openssh-portable
angr_sailr
int u32toutf8(wc, s) unsigned int wc; char *s; { int l; if (wc < 0x0080) { s[0] = (char)wc; l = 1; } else if (wc < 0x0800) { s[0] = (wc >> 6) | 0xc0; s[1] = (wc & 0x3f) | 0x80; l = 2; } else if (wc < 0x10000) { s[0] = (wc >> 12) | 0xe0; s[1] = ((wc >> 6) & 0x3f) | 0x80; s[2] = (wc & 0x3f) | 0x80; l = 3; } else if (wc < 0x200000) { s[0] = (wc >> 18) | 0xf0; s[1] = ((wc >> 12) & 0x3f) | 0x80; s[2] = ((wc >> 6) & 0x3f) | 0x80; s[3] = (wc & 0x3f) | 0x80; l = 4; } else if (wc < 0x04000000) { s[0] = (wc >> 24) | 0xf8; s[1] = ((wc >> 18) & 0x3f) | 0x80; s[2] = ((wc >> 12) & 0x3f) | 0x80; s[3] = ((wc >> 6) & 0x3f) | 0x80; s[4] = (wc & 0x3f) | 0x80; l = 5; } else if (wc < 0x080000000) { s[0] = (wc >> 30) | 0xfc; s[1] = ((wc >> 24) & 0x3f) | 0x80; s[2] = ((wc >> 18) & 0x3f) | 0x80; s[3] = ((wc >> 12) & 0x3f) | 0x80; s[4] = ((wc >> 6) & 0x3f) | 0x80; s[5] = (wc & 0x3f) | 0x80; l = 6; } else l = 0; s[l] = '\0'; return l; }
long u32toutf8(unsigned int a1, _BYTE *a2) { unsigned int v3; if (a1 > 0x7F) { if (a1 > 0x7FF) { if (a1 > 0xFFFF) { if (a1 > 0x1FFFFF) { if (a1 > 0x3FFFFFF) { if ((a1 & 0x80000000) != 0) { v3 = 0; } else { *a2 = (a1 >> 30) | 0xFC; a2[1] = HIBYTE(a1) & 0x3F | 0x80; a2[2] = (a1 >> 18) & 0x3F | 0x80; a2[3] = (a1 >> 12) & 0x3F | 0x80; a2[4] = (a1 >> 6) & 0x3F | 0x80; a2[5] = a1 & 0x3F | 0x80; v3 = 6; } } else { *a2 = HIBYTE(a1) | 0xF8; a2[1] = (a1 >> 18) & 0x3F | 0x80; a2[2] = (a1 >> 12) & 0x3F | 0x80; a2[3] = (a1 >> 6) & 0x3F | 0x80; a2[4] = a1 & 0x3F | 0x80; v3 = 5; } } else { *a2 = (a1 >> 18) | 0xF0; a2[1] = (a1 >> 12) & 0x3F | 0x80; a2[2] = (a1 >> 6) & 0x3F | 0x80; a2[3] = a1 & 0x3F | 0x80; v3 = 4; } } else { *a2 = (a1 >> 12) | 0xE0; a2[1] = (a1 >> 6) & 0x3F | 0x80; a2[2] = a1 & 0x3F | 0x80; v3 = 3; } } else { *a2 = (a1 >> 6) | 0xC0; a2[1] = a1 & 0x3F | 0x80; v3 = 2; } } else { *a2 = a1; v3 = 1; } a2[v3] = 0; return v3; }
bash
ida
int main(int argc, char *argv[]) { FILE *log_file = ((void *)0); char *log_filename = "/var/log/boot"; char line[256]; char output[256]; char *status; int c; while ((c = getopt(argc, argv, "hf:")) != (-1)) { switch (c) { case 'h': print_usage(); exit(0); case 'f': log_filename = optarg; break; default: print_usage(); exit(1); } } log_file = fopen(log_filename, "r"); if (log_file) { status = fgets(line, 256, log_file); while (status) { memset(output, '\0', 256); if (Clean_Line(line, output)) { printf("%s", output); } status = fgets(line, 256, log_file); } fclose(log_file); } else { fprintf(stderr, "Unable to open file %s\n", log_filename); return 1; } return 0; }
undefined8 main(int param_1, char **param_2) { int iVar1; FILE *__stream; undefined8 uVar2; long in_FS_OFFSET; char *local_230; char *local_228; char local_218[256]; undefined local_118[264]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); local_230 = "/var/log/boot"; while (true) { iVar1 = getopt(param_1, param_2, "hf:"); if (iVar1 == -1) break; if (iVar1 != 0x66) { if (iVar1 == 0x68) { print_usage(); exit(0); } print_usage(); exit(1); } local_230 = optarg; } __stream = fopen(local_230, "r"); if (__stream == (FILE *)0x0) { fprintf(stderr, "Unable to open file %s\n", local_230); uVar2 = 1; } else { local_228 = fgets(local_218, 0x100, __stream); while (local_228 != (char *)0x0) { memset(local_118, 0, 0x100); iVar1 = Clean_Line(local_218, local_118); if (iVar1 != 0) { printf("%s", local_118); } local_228 = fgets(local_218, 0x100, __stream); } fclose(__stream); uVar2 = 0; } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return uVar2; }
sysvinit
ghidra
char * mbschr(const char *s, int c) { char *pos; mbstate_t state; size_t strlength, mblength; if (locale_utf8locale && c < 0x80) return (utf8_mbschr(s, c)); if ((unsigned char)c >= '0' && locale_mb_cur_max > 1) { pos = (char *)s; memset(&state, '\0', sizeof(mbstate_t)); strlength = strlen(s); while (strlength > 0) { if (is_basic(*pos)) mblength = 1; else { mblength = mbrlen(pos, strlength, &state); if (mblength == (size_t)-2 || mblength == (size_t)-1 || mblength == (size_t)0) mblength = 1; } if (mblength == 1 && c == (unsigned char)*pos) return pos; strlength -= mblength; pos += mblength; } return ((char *)((void *)0)); } else return (strchr(s, c)); }
long long mbschr(char *a0, unsigned long a1) { void *v0; unsigned long long v1; unsigned long long v2; char v3; void *v5; if (locale_utf8locale && a1 <= 127) { v5 = utf8_mbschr(a0, a1, a1); return v5; } if (a1 > 47 && locale_mb_cur_max > 1) { v0 = a0; memset(&v3, 0x0, 0x8); v1 = strlen(a0); while (true) { if (v1) { if (is_basic(*(v0))) { v2 = 1; } else { v2 = mbrlen(v0, v1, &v3, v1); if (v2 == -2 || v2 == -1 || !v2) v2 = 1; } if (v2 == 1 && a1 == *(v0)) { v5 = v0; return v5; } v1 -= v2; v0 += v2; } else { v5 = 0; return v5; } } } v5 = strchr(a0, a1); return v5; }
bash
angr_sailr
static int pem_passphrase_cb(char *buf, int size, int rwflag, void *u) { char *p = (char *)u; size_t len; if (p == ((void *)0) || (len = strlen(p)) == 0) return -1; if (size < 0 || len > (size_t)size) return -1; memcpy(buf, p, len); return (int)len; }
long long pem_passphrase_cb(void *a0, unsigned long a1, unsigned long a2, void *a3) { unsigned int v0; unsigned long v1; unsigned long long v3; v0 = a2; if (!a3) { LABEL_40b693: v3 = 4294967295; } else { v1 = strlen(a3); if (!v1) goto LABEL_40b693; if (a1 < 0) { LABEL_40b6ab: v3 = 4294967295; } else { if (!(v1 <= a1)) goto LABEL_40b6ab; memcpy(a0, a3, v1); v3 = v1; } } return v3; }
openssh-portable
angr_phoenix
_Bool hash_table_ok (const Hash_table *table) { struct hash_entry const *bucket; size_t n_buckets_used = 0; size_t n_entries = 0; for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) { if (bucket->data) { struct hash_entry const *cursor = bucket; n_buckets_used++; n_entries++; while (cursor = cursor->next, cursor) n_entries++; } } if (n_buckets_used == table->n_buckets_used && n_entries == table->n_entries) return 1; return 0; }
long long hash_table_ok(unsigned long long a0[5]) { unsigned long long *v0; void *v1; unsigned long v2; unsigned long long v3[2]; unsigned long long v5; v1 = 0; v2 = 0; for (v0 = a0[0]; v0 < a0[1]; v0 += 2) { if (*(v0)) { v3[0] = v0; v1 += 1; v2 += 1; while (true) { v3[0] = v3[1]; if (!v3) break; v2 += 1; } } } if (v1 == a0[3] && v2 == a0[4]) v5 = 1; if (v1 != a0[3] || v2 != a0[4]) v5 = 0; return v5; }
gnutls
angr_dream
static int sshsk_ed25519_sig(struct sk_sign_response *resp, struct sshbuf *sig) { int r = -1; if (resp->sig_r == ((void *)0)) { sshlog("ssh-sk.c", __func__, 614, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "sk_sign response invalid"); r = -4; goto out; } if ((r = sshbuf_put_string(sig, resp->sig_r, resp->sig_r_len)) != 0 || (r = sshbuf_put_u8(sig, resp->flags)) != 0 || (r = sshbuf_put_u32(sig, resp->counter)) != 0) { sshlog("ssh-sk.c", __func__, 622, 1, SYSLOG_LEVEL_ERROR, ssh_err(r), "compose"); goto out; } r = 0; out: return r; }
int sshsk_ed25519_sig(struct_0 *a0, unsigned long long a1) { unsigned long long v0; unsigned int v1; v1 = -1; if (!a0->field_8) { v0 = "sk_sign response invalid"; sshlog("ssh-sk.c", "sshsk_ed25519_sig", 0x266, 0x1, 0x2, 0x0); v1 = -0x4; } else { v1 = sshbuf_put_string(a1, a0->field_8, a0->field_10, a0->field_8); if (!v1) { v1 = sshbuf_put_u8(a1, a0->field_0, a0->field_0); if (!v1) { v1 = sshbuf_put_u32(a1, a0->field_4); if (!v1) v1 = 0; } } if (v1 || v1 || v1) { v0 = "compose"; sshlog("ssh-sk.c", "sshsk_ed25519_sig", 0x26e, 0x1, 0x2, ssh_err(v1)); } } return v1; }
openssh-portable
angr_dream
static void add_listen_addr(ServerOptions *options, const char *addr, const char *rdomain, int port) { u_int i; if (port > 0) add_one_listen_addr(options, addr, rdomain, port); else { for (i = 0; i < options->num_ports; i++) { add_one_listen_addr(options, addr, rdomain, options->ports[i]); } } }
void add_listen_addr(unsigned long long a0, unsigned long long a1, unsigned long long a2, unsigned long a3) { unsigned int v0; unsigned long long v2; unsigned long long v3; if (a3 > 0) { v2 = add_one_listen_addr(a0, a1, a2, a3); } else { v0 = 0; while (true) { v3 = *(a0); if (v0 >= *(a0)) break; add_one_listen_addr(a0, a1, a2, *((a0 + v0 * 4 + 8))); v0 += 1; } } return; }
openssh-portable
angr_dream
static void parse_options(int argc, char **argv, uintmax_t *n_units, enum header_mode *header_mode, double *sleep_interval) { int c; while ((c = getopt_long(argc, argv, "c:n:fFqs:vz0123456789", long_options, ((void *)0))) != -1) { switch (c) { case 'F': forever = 1; follow_mode = Follow_name; reopen_inaccessible_files = 1; break; case 'c': case 'n': count_lines = (c == 'n'); if (*optarg == '+') from_start = 1; else if (*optarg == '-') ++optarg; *n_units = xdectoumax(optarg, 0, (18446744073709551615UL), "bkKmMGTPEZY0", count_lines ? gettext("invalid number of lines") : gettext("invalid number of bytes"), 0); break; case 'f': case LONG_FOLLOW_OPTION: forever = 1; if (optarg == ((void *)0)) follow_mode = Follow_descriptor; else follow_mode = ((follow_mode_map)[__xargmatch_internal( "--follow", optarg, follow_mode_string, (void const *)(follow_mode_map), sizeof *(follow_mode_map), argmatch_die, 1)]); break; case RETRY_OPTION: reopen_inaccessible_files = 1; break; case MAX_UNCHANGED_STATS_OPTION: max_n_unchanged_stats_between_opens = xdectoumax( optarg, 0, (18446744073709551615UL), "", gettext("invalid maximum number of unchanged stats between opens"), 0); break; case DISABLE_INOTIFY_OPTION: disable_inotify = 1; break; case PID_OPTION: pid = xdectoumax( optarg, 0, ((pid_t)(!(!((pid_t)0 < (pid_t)-1)) ? (pid_t)-1 : ((((pid_t)1 << ((sizeof(pid_t) * 8) - 2)) - 1) * 2 + 1))), "", gettext("invalid PID"), 0); break; case PRESUME_INPUT_PIPE_OPTION: presume_input_pipe = 1; break; case 'q': *header_mode = never; break; case 's': { double s; if (!(xstrtod(optarg, ((void *)0), &s, cl_strtod) && 0 <= s)) ((!!sizeof(struct { _Static_assert(1, "verify_expr (" "1" ", " "(error (1, 0, gettext (\"invalid number of " "seconds: %s\"), quote (optarg)), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, 0, gettext("invalid number of seconds: %s"), quote(optarg)), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, 0, gettext("invalid number of seconds: %s"), quote(optarg)), ((0) ? (void)0 : __builtin_unreachable())))); *sleep_interval = s; } break; case 'v': *header_mode = always; break; case 'z': line_end = '\0'; break; case GETOPT_HELP_CHAR: usage(0); break; ; case GETOPT_VERSION_CHAR: version_etc(stdout, "tail", "GNU coreutils", Version, ("Paul Rubin"), ("David MacKenzie"), ("Ian Lance Taylor"), ("Jim Meyering"), (char *)((void *)0)); exit(0); break; ; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ((!!sizeof(struct { _Static_assert(1, "verify_expr (" "1" ", " "(error (1, 0, gettext (\"option used in invalid " "context -- %c\"), c), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, 0, gettext("option used in invalid context -- %c"), c), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, 0, gettext("option used in invalid context -- %c"), c), ((0) ? (void)0 : __builtin_unreachable())))); default: usage(1); } } if (reopen_inaccessible_files) { if (!forever) { reopen_inaccessible_files = 0; error(0, 0, gettext("warning: --retry ignored; --retry is useful" " only when following")); } else if (follow_mode == Follow_descriptor) error(0, 0, gettext("warning: --retry only effective for the initial open")); } if (pid && !forever) error(0, 0, gettext( "warning: PID ignored; --pid=PID is useful only when following")); else if (pid && kill(pid, 0) != 0 && (*__errno_location()) == 38) { error(0, 0, gettext("warning: --pid=PID is not supported on this system")); pid = 0; } }
unsigned long parse_options(int a1, char *const *a2, _QWORD *a3, _DWORD *a4, double *a5) { int v5; char *v6; char *v7; char *v8; long v9; char *v10; char *v11; char *v12; char *v13; char *v14; char *v15; unsigned int v20; double v21; unsigned long v22; v22 = __readfsqword(0x28u); v5 = getopt_long(a1, a2, "c:n:fFqs:vz0123456789", &long_options, 0LL); while (2) { v20 = v5; if (v5 != -1) { if (v5 <= 133) { if (v5 >= 48) { switch (v5) { case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: v11 = gettext("option used in invalid context -- %c"); error(1, 0, v11, v20); goto LABEL_35; case 70: forever = 1; follow_mode = 1; reopen_inaccessible_files = 1; goto LABEL_36; case 99: case 110: count_lines = v5 == 110; if (*optarg == 43) { from_start = 1; } else if (*optarg == 45) { ++optarg; } if (count_lines) v6 = gettext("invalid number of lines"); else v6 = gettext("invalid number of bytes"); *a3 = xdectoumax(optarg, 0LL, -1LL, "bkKmMGTPEZY0", v6, 0LL); goto LABEL_36; case 102: case 132: forever = 1; if (optarg) follow_mode = follow_mode_map[_xargmatch_internal( "--follow", optarg, follow_mode_string, follow_mode_map, 4LL, argmatch_die, 1LL)]; else follow_mode = 2; goto LABEL_36; case 113: *a4 = 2; goto LABEL_36; case 115: if ((unsigned char)xstrtod(optarg, 0LL, &v21, &cl_strtod) != 1 || v21 < 0.0) { v9 = quote(optarg); v10 = gettext("invalid number of seconds: %s"); error(1, 0, v10, v9); } *a5 = v21; goto LABEL_36; case 118: *a4 = 1; goto LABEL_36; case 122: line_end = 0; goto LABEL_36; case 128: reopen_inaccessible_files = 1; goto LABEL_36; case 129: v7 = gettext( "invalid maximum number of unchanged stats between opens"); max_n_unchanged_stats_between_opens = xdectoumax(optarg, 0LL, -1LL, locale, v7, 0LL); goto LABEL_36; case 130: v8 = gettext("invalid PID"); pid = xdectoumax(optarg, 0LL, 0x7FFFFFFFLL, locale, v8, 0LL); goto LABEL_36; case 131: presume_input_pipe = 1; goto LABEL_36; case 133: disable_inotify = 1; LABEL_36: v5 = getopt_long(a1, a2, "c:n:fFqs:vz0123456789", &long_options, 0LL); continue; default: goto LABEL_35; } } if (v5 == -131) { version_etc(stdout, "tail", "GNU coreutils", Version, "Paul Rubin", "David MacKenzie", "Ian Lance Taylor", "Jim Meyering", 0LL); exit(0); } if (v5 == -130) usage(0); } LABEL_35: usage(1); } break; } if (reopen_inaccessible_files) { if (forever != 1) { reopen_inaccessible_files = 0; v12 = gettext( "warning: --retry ignored; --retry is useful only when following"); error(0, 0, v12); } else if (follow_mode == 2) { v13 = gettext("warning: --retry only effective for the initial open"); error(0, 0, v13); } } if (pid && forever != 1) { v14 = gettext( "warning: PID ignored; --pid=PID is useful only when following"); error(0, 0, v14); } else if (pid && kill(pid, 0) && *_errno_location() == 38) { v15 = gettext("warning: --pid=PID is not supported on this system"); error(0, 0, v15); pid = 0; } return __readfsqword(0x28u) ^ v22; }
coreutils
ida
static void history_def_clear(void *p, HistEvent *ev) { history_t *h = (history_t *)p; while (h->list.prev != &h->list) history_def_delete(h, ev, h->list.prev); h->cursor = &h->list; h->eventid = 0; h->cur = 0; }
void history_def_clear(long param_1, undefined8 param_2) { while (*(long *)(param_1 + 0x20) != param_1) { history_def_delete(param_1, param_2, *(undefined8 *)(param_1 + 0x20)); } *(long *)(param_1 + 0x28) = param_1; *(undefined4 *)(param_1 + 0x38) = 0; *(undefined4 *)(param_1 + 0x34) = 0; return; }
libedit
ghidra
int sh_unset_nodelay_mode(fd) int fd; { int flags, bflags; if ((flags = fcntl(fd, 3, 0)) < 0) return -1; bflags = 0; bflags |= 04000; bflags |= 04000; if (flags & bflags) { flags &= ~bflags; return (fcntl(fd, 4, flags)); } return 0; }
long long sh_unset_nodelay_mode(unsigned long a0) { char v0; unsigned int v1; unsigned int v2; unsigned long long v4; v1 = fcntl(a0, 0x3); if (v1 < 0) { v4 = 4294967295; } else { v2 = 0; v2 |= 0x800; v2 |= 0x800; if (!(v1 & v2)) { v4 = 0; } else { v1 &= !(v2); v4 = fcntl(*(&v0), 0x4); } } return v4; }
bash
angr_phoenix
int main(int argc, char **argv) { int c; _Bool ok; _Bool make_backups = 0; char const *backup_suffix = ((void *)0); char *version_control_string = ((void *)0); struct cp_options x; _Bool remove_trailing_slashes = 0; char const *target_directory = ((void *)0); _Bool no_target_directory = 0; int n_files; char **file; _Bool selinux_enabled = (0 < is_selinux_enabled()); ; set_program_name(argv[0]); setlocale(6, ""); bindtextdomain("coreutils", "/usr/local/share/locale"); textdomain("coreutils"); atexit(close_stdin); cp_option_init(&x); priv_set_remove_linkdir(); while ((c = getopt_long(argc, argv, "bfint:uvS:TZ", long_options, ((void *)0))) != -1) { switch (c) { case 'b': make_backups = 1; if (optarg) version_control_string = optarg; break; case 'f': x.interactive = I_ALWAYS_YES; break; case 'i': x.interactive = I_ASK_USER; break; case 'n': x.interactive = I_ALWAYS_NO; break; case STRIP_TRAILING_SLASHES_OPTION: remove_trailing_slashes = 1; break; case 't': if (target_directory) ((!!sizeof(struct { _Static_assert(1, "verify_expr (" "1" ", " "(error (1, 0, gettext (\"multiple target " "directories specified\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, 0, gettext("multiple target directories specified")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, 0, gettext("multiple target directories specified")), ((0) ? (void)0 : __builtin_unreachable())))); target_directory = optarg; break; case 'T': no_target_directory = 1; break; case 'u': x.update = 1; break; case 'v': x.verbose = 1; break; case 'S': make_backups = 1; backup_suffix = optarg; break; case 'Z': if (selinux_enabled) { x.preserve_security_context = 0; x.set_security_context = selabel_open(0, ((void *)0), 0); if (!x.set_security_context) error(0, (*__errno_location()), gettext("warning: ignoring --context")); } break; case GETOPT_HELP_CHAR: usage(0); break; ; case GETOPT_VERSION_CHAR: version_etc(stdout, "mv", "GNU coreutils", Version, ("Mike Parker"), ("David MacKenzie"), ("Jim Meyering"), (char *)((void *)0)); exit(0); break; ; default: usage(1); } } n_files = argc - optind; file = argv + optind; if (n_files <= !target_directory) { if (n_files <= 0) error(0, 0, gettext("missing file operand")); else error(0, 0, gettext("missing destination file operand after %s"), quotearg_style(shell_escape_always_quoting_style, file[0])); usage(1); } struct stat sb; sb.st_mode = 0; int target_dirfd = -100; if (no_target_directory) { if (target_directory) ((!!sizeof(struct { _Static_assert( 1, "verify_expr (" "1" ", " "(error (1, 0, gettext (\"cannot combine --target-directory " "(-t) \" \"and --no-target-directory (-T)\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, 0, gettext("cannot combine --target-directory (-t) " "and --no-target-directory (-T)")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, 0, gettext("cannot combine --target-directory (-t) " "and --no-target-directory (-T)")), ((0) ? (void)0 : __builtin_unreachable())))) ; if (2 < n_files) { error(0, 0, gettext("extra operand %s"), quotearg_style(shell_escape_always_quoting_style, file[2])); usage(1); } } else if (target_directory) { target_dirfd = target_directory_operand(target_directory, &sb); if (!target_dirfd_valid(target_dirfd)) ((!!sizeof(struct { _Static_assert( 1, "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), gettext (\"target directory " "%s\"), quotearg_style (shell_escape_always_quoting_style, " "target_directory)), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, (*__errno_location()), gettext("target directory %s"), quotearg_style(shell_escape_always_quoting_style, target_directory)), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, (*__errno_location()), gettext("target directory %s"), quotearg_style(shell_escape_always_quoting_style, target_directory)), ((0) ? (void)0 : __builtin_unreachable())))); } else { char const *lastfile = file[n_files - 1]; if (n_files == 2) x.rename_errno = (renameatu(-100, file[0], -100, lastfile, (1 << 0)) ? (*__errno_location()) : 0); if (x.rename_errno != 0) { int fd = target_directory_operand(lastfile, &sb); if (target_dirfd_valid(fd)) { x.rename_errno = -1; target_dirfd = fd; target_directory = lastfile; n_files--; } else { int err = (*__errno_location()); if (2 < n_files || (O_PATHSEARCH == 00 && err == 13 && (sb.st_mode != 0 || stat(lastfile, &sb) == 0) && ((((sb.st_mode)) & 0170000) == (0040000)))) ((!!sizeof(struct { _Static_assert(1, "verify_expr (" "1" ", " "(error (1, err, gettext (\"target %s\"), " "quotearg_style (shell_escape_always_quoting_style, " "lastfile)), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, err, gettext("target %s"), quotearg_style(shell_escape_always_quoting_style, lastfile)), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, err, gettext("target %s"), quotearg_style(shell_escape_always_quoting_style, lastfile)), ((0) ? (void)0 : __builtin_unreachable())))); } } } if (remove_trailing_slashes) for (int i = 0; i < n_files; i++) strip_trailing_slashes(file[i]); if (x.interactive == I_ALWAYS_NO) x.update = 0; if (make_backups && x.interactive == I_ALWAYS_NO) { error(0, 0, gettext("options --backup and --no-clobber are mutually exclusive")); usage(1); } x.backup_type = (make_backups ? xget_version(gettext("backup type"), version_control_string) : no_backups); set_simple_backup_suffix(backup_suffix); hash_init(); if (target_directory) { if (2 <= n_files) dest_info_init(&x); ok = 1; for (int i = 0; i < n_files; ++i) { x.last_file = i + 1 == n_files; char const *source = file[i]; char const *source_basename = last_component(source); char *dest_relname; char *dest = file_name_concat(target_directory, source_basename, &dest_relname); strip_trailing_slashes(dest_relname); ok &= do_move(source, dest, target_dirfd, dest_relname, &x); free(dest); } } else { x.last_file = 1; ok = do_move(file[0], file[1], -100, file[1], &x); } return ok ? 0 : 1; }
byte main(int param_1, undefined8 *param_2) { bool bVar1; bool bVar2; bool bVar3; char cVar4; byte bVar5; int iVar6; int iVar7; undefined4 uVar8; undefined8 uVar9; undefined8 uVar10; int *piVar11; long in_FS_OFFSET; byte local_181; int local_17c; undefined4 local_178; int local_174; int local_170; undefined8 local_160; long local_158; long local_150; long local_148; undefined8 *local_140; long local_138; undefined8 local_130; undefined8 local_128; void *local_120; undefined4 local_118[2]; int local_110; long local_f0; undefined local_e5; undefined local_dd; undefined local_dc; undefined local_d9; int local_d8; undefined local_b8[24]; undefined4 local_a0; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); bVar3 = false; local_158 = 0; local_150 = 0; bVar2 = false; local_148 = 0; bVar1 = false; iVar6 = is_selinux_enabled(); set_program_name(*param_2); setlocale(6, ""); bindtextdomain("coreutils", "/usr/local/share/locale"); textdomain("coreutils"); atexit(p_Ram0000000000100877); cp_option_init(local_118); priv_set_remove_linkdir(); while (iVar7 = getopt_long(param_1, param_2, "bfint:uvS:TZ", long_options, 0), iVar7 != -1) { if (iVar7 < 0x81) { if (iVar7 < 0x53) { if (iVar7 == -0x83) { LAB_00100a61: version_etc(stdout, &DAT_00101ad1, "GNU coreutils", Version, "Mike Parker", "David MacKenzie", "Jim Meyering", 0); exit(0); } if (iVar7 == -0x82) { usage(0); goto LAB_00100a61; } goto switchD_00100908_caseD_55; } switch (iVar7) { case 0x53: bVar3 = true; local_158 = optarg; break; case 0x54: bVar1 = true; break; default: goto switchD_00100908_caseD_55; case 0x5a: if (0 < iVar6) { local_e5 = 0; local_f0 = selabel_open(0, 0, 0); if (local_f0 == 0) { uVar9 = gettext("warning: ignoring --context"); piVar11 = __errno_location(); error(0, *piVar11, uVar9); } } break; case 0x62: bVar3 = true; if (optarg != 0) { local_150 = optarg; } break; case 0x66: local_110 = 1; break; case 0x69: local_110 = 3; break; case 0x6e: local_110 = 2; break; case 0x74: if (local_148 != 0) { uVar9 = gettext("multiple target directories specified"); error(1, 0, uVar9); } local_148 = optarg; break; case 0x75: local_dd = 1; break; case 0x76: local_dc = 1; break; case 0x80: bVar2 = true; } } else { switchD_00100908_caseD_55: usage(); } } local_17c = param_1 - optind; local_140 = param_2 + optind; if (local_17c <= (int)(uint)(local_148 == 0)) { if (local_17c < 1) { uVar9 = gettext("missing file operand"); error(0, 0, uVar9); } else { uVar9 = quotearg_style(4, *local_140); uVar10 = gettext("missing destination file operand after %s"); error(0, 0, uVar10, uVar9); } usage(1); } local_a0 = 0; local_178 = 0xffffff9c; if (bVar1) { if (local_148 != 0) { uVar9 = gettext("cannot combine --target-directory (-t) and " "--no-target-directory (-T)"); error(1, 0, uVar9); } if (local_17c < 3) goto LAB_00100e1d; uVar9 = quotearg_style(4, local_140[2]); uVar10 = gettext("extra operand %s"); error(0, 0, uVar10, uVar9); usage(1); } if (local_148 != 0) { local_178 = target_directory_operand(local_148, local_b8); cVar4 = target_dirfd_valid(local_178); if (cVar4 == '\x01') goto LAB_00100e1d; uVar9 = quotearg_style(4, local_148); uVar10 = gettext("target directory %s"); piVar11 = __errno_location(); error(1, *piVar11, uVar10, uVar9); } local_138 = local_140[(long)local_17c + -1]; if (local_17c == 2) { iVar6 = renameatu(0xffffff9c, *local_140, 0xffffff9c, local_138, 1); if (iVar6 == 0) { local_d8 = 0; } else { piVar11 = __errno_location(); local_d8 = *piVar11; } } if (local_d8 != 0) { uVar8 = target_directory_operand(local_138, local_b8); cVar4 = target_dirfd_valid(uVar8); if (cVar4 == '\0') { piVar11 = __errno_location(); iVar6 = *piVar11; if (2 < local_17c) { uVar9 = quotearg_style(4, local_138); uVar10 = gettext("target %s"); error(1, iVar6, uVar10, uVar9); } } else { local_d8 = -1; local_148 = local_138; local_17c = local_17c + -1; local_178 = uVar8; } } LAB_00100e1d: if (bVar2) { for (local_174 = 0; local_174 < local_17c; local_174 = local_174 + 1) { strip_trailing_slashes(local_140[local_174]); } } if (local_110 == 2) { local_dd = 0; } if ((bVar3) && (local_110 == 2)) { uVar9 = gettext("options --backup and --no-clobber are mutually exclusive"); error(0, 0, uVar9); usage(1); } if (bVar3) { uVar9 = gettext("backup type"); local_118[0] = xget_version(uVar9, local_150); } else { local_118[0] = 0; } set_simple_backup_suffix(local_158); hash_init(); if (local_148 == 0) { local_d9 = 1; local_181 = do_move(*local_140, local_140[1], 0xffffff9c, local_140[1], local_118); } else { if (1 < local_17c) { dest_info_init(local_118); } local_181 = true; for (local_170 = 0; local_170 < local_17c; local_170 = local_170 + 1) { local_d9 = local_17c == local_170 + 1; local_130 = local_140[local_170]; local_128 = last_component(local_130); local_120 = (void *)file_name_concat(local_148, local_128, &local_160); strip_trailing_slashes(local_160); bVar5 = do_move(local_130, local_120, local_178, local_160, local_118); local_181 = (bVar5 & local_181) != 0; free(local_120); } } if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { __stack_chk_fail(); } return local_181 ^ 1; }
coreutils
ghidra
static void divertdb_write(void) { char *dbname; struct atomic_file *file; struct fsys_hash_iter *iter; struct fsys_namenode *namenode; dbname = dpkg_db_get_path("diversions"); file = atomic_file_new(dbname, ATOMIC_FILE_BACKUP); atomic_file_open(file); iter = fsys_hash_iter_new(); while ((namenode = fsys_hash_iter_next(iter))) { struct fsys_diversion *d = namenode->divert; if (d == ((void *)0) || d->useinstead == ((void *)0)) continue; fprintf(file->fp, "%s\n%s\n%s\n", d->useinstead->divert->camefrom->name, d->useinstead->name, diversion_pkg_name(d)); } fsys_hash_iter_free(iter); atomic_file_sync(file); atomic_file_close(file); atomic_file_commit(file); atomic_file_free(file); free(dbname); }
void divertdb_write(unsigned long long a0, unsigned long a1, unsigned long long a2, unsigned long long a3, unsigned long long a4, unsigned long long a5) { void *v0; struct_0 *v1; unsigned long long v2; struct_0 *v3; unsigned long long *v4[4]; unsigned long long v6; v0 = dpkg_db_get_path("diversions"); v1 = atomic_file_new(v0, 0x1); atomic_file_open(v1); v2 = fsys_hash_iter_new(a0, 0x1, a2, a3, a4, a5); while (true) { do { while (true) { v3 = fsys_hash_iter_next(v2); if (v3) { v4 = v3->field_18; if (v4) break; } else { fsys_hash_iter_free(v2); atomic_file_sync(v1); atomic_file_close(v1); atomic_file_commit(v1); atomic_file_free(v1); v6 = free(v0); return; } } } while (!*(v4)); fprintf(v1->field_18, "%s\n%s\n%s\n", *((*(((*(v4))[3] + 8)) + 8)), (*(v4))[1], diversion_pkg_name(v4)); } }
dpkg
angr_dream
static int send_open(struct sftp_conn *conn, const char *path, const char *tag, u_int openmode, Attrib *a, u_char **handlep, size_t *handle_lenp) { Attrib junk; u_char *handle; size_t handle_len; struct sshbuf *msg; int r; u_int id; sshlog("sftp-client.c", __func__, 1541, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "Sending SSH2_FXP_OPEN \"%s\"", path); *handlep = ((void *)0); *handle_lenp = 0; if (a == ((void *)0)) { attrib_clear(&junk); a = &junk; } if ((msg = sshbuf_new()) == ((void *)0)) sshfatal("sftp-client.c", __func__, 1552, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new failed"); id = conn->msg_id++; if ((r = sshbuf_put_u8(msg, 3)) != 0 || (r = sshbuf_put_u32(msg, id)) != 0 || (r = sshbuf_put_cstring(msg, path)) != 0 || (r = sshbuf_put_u32(msg, openmode)) != 0 || (r = encode_attrib(msg, a)) != 0) sshfatal("sftp-client.c", __func__, 1559, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "compose %s open", tag); send_msg(conn, msg); sshbuf_free(msg); sshlog("sftp-client.c", __func__, 1562, 0, SYSLOG_LEVEL_DEBUG3, ((void *)0), "Sent %s message SSH2_FXP_OPEN I:%u P:%s M:0x%04x", tag, id, path, openmode); if ((handle = get_handle(conn, id, &handle_len, "%s open \"%s\"", tag, path)) == ((void *)0)) return -1; *handlep = handle; *handle_lenp = handle_len; return 0; }
int send_open(struct_0 *a0, unsigned long a1, unsigned int a2, unsigned long a3, unsigned long long a4, unsigned long long *a5, unsigned long v17) { unsigned long v0; int tmp_14; unsigned long long *v1; unsigned long long v2; struct_0 *v3; unsigned int v4; unsigned int v5; char v6; unsigned long long v7; unsigned long v8; char v9; unsigned long long v10; unsigned long v11; unsigned long v12; unsigned long v13; unsigned long long v14; unsigned long v15; char v16; unsigned int v18; v3 = a0; v2 = a4; v1 = v17; v0 = a1; sshlog("sftp-client.c", "send_open", 0x605, 0x0, 0x6, 0x0, "Sending SSH2_FXP_OPEN \"%s\""); *(a5) = 0; *(v1) = 0; if (!v2) { attrib_clear(&v9); v2 = &v9; } v7 = sshbuf_new(); if (!v7) sshfatal("sftp-client.c", "send_open", 0x610, 0x1, 0x1, 0x0, "sshbuf_new failed"); tmp_14 = a0->field_18; a0->field_18 = a0->field_18 + 1; v5 = tmp_14; v4 = sshbuf_put_u8(v7, 0x3, a0); if (!v4) { v4 = sshbuf_put_u32(v7, v5, v5); if (!v4) { v4 = sshbuf_put_cstring(v7, a1); if (!v4) { v4 = sshbuf_put_u32(v7, a3, a3); if (!v4) v4 = encode_attrib(v7, v2, v2); } } } if (v4 || v4 || v4 || v4 || v4) { *(&v15) = a2; v14 = "compose %s open"; sshfatal("sftp-client.c", "send_open", 0x617, 0x1, 0x1, ssh_err(v4), *(&v16)); } send_msg(a0, v7); sshbuf_free(v7); v14 = a3; v13 = a1; v12 = v5; *(&v11) = a2; v10 = "Sent %s message SSH2_FXP_OPEN I:%u P:%s M:0x%04x"; sshlog("sftp-client.c", "send_open", 0x61a, 0x0, 0x7, 0x0, *(&v16)); v8 = get_handle(a0, v5, &v6, "%s open \"%s\"", a2, a1); if (!v8) { v18 = -1; } else { *(a5) = v8; *(v1) = *(&v6); v18 = 0; } return v18; }
openssh-portable
angr_dream
void notify_complete(struct notifier_ctx *, const char *, ...) __attribute__((format(printf, 2, 3))); typedef void (*sshsig_t)(int); sshsig_t ssh_signal(int, sshsig_t); const char *ssh_err(int n); typedef enum { SYSLOG_FACILITY_DAEMON, SYSLOG_FACILITY_USER, SYSLOG_FACILITY_AUTH, SYSLOG_FACILITY_LOCAL0, SYSLOG_FACILITY_LOCAL1, SYSLOG_FACILITY_LOCAL2, SYSLOG_FACILITY_LOCAL3, SYSLOG_FACILITY_LOCAL4, SYSLOG_FACILITY_LOCAL5, SYSLOG_FACILITY_LOCAL6, SYSLOG_FACILITY_LOCAL7, SYSLOG_FACILITY_NOT_SET = -1 } SyslogFacility;
long long notify_complete() { unsigned long long v0; unsigned long v1; unsigned int v2; void *v3; unsigned int v4; unsigned int v5; unsigned long v6; unsigned long v7; unsigned long v8; char v9; unsigned long v10; unsigned long v11; unsigned long v12; unsigned long v13; int v14; int v15; int v16; int v17; int v18; int v19; int v20; int v21; unsigned long v22; unsigned long v23; unsigned long v24; unsigned long v25; unsigned long v26; char v27; int v28; int v29; int v30; int v31; int v32; int v33; int v34; int v35; unsigned long long *v36; struct_0 *v37; unsigned long long v38; v10 = v23; v11 = v24; v12 = v25; v13 = v26; if (v27) { v14 = v28; v15 = v29; v16 = v30; v17 = v31; v18 = v32; v19 = v33; v20 = v34; v21 = v35; } v8 = v36[5]; v3 = 0; if (v37 && v38 && v37->field_0 == -1) { v4 = 16; v5 = 48; v6 = &v22; v7 = &v9; xvasprintf(&v3, v38, &v4, v38); writemsg(v3); free(v3); } if (!v37 || v37->field_0 <= 0) { free(v37); } else { kill(v37->field_0, 0xf); do { } while ((v2 = waitpid(v37->field_0, NULL, 0x0), v2 == -1 && *(__errno_location()) == 4)); if (v2 == -1) { v1 = strerror(*(__errno_location())); v0 = "waitpid: %s"; sshfatal("readpass.c", "notify_complete", 0x149, 0x1, 0x1, 0x0); } ssh_signal(0x11, v37->field_8); free(v37); } if ((v8 ^ v36[5])) __stack_chk_fail(); return 0; }
openssh-portable
angr_sailr
void xheader_store(char const *keyword, struct tar_stat_info *st, void const *data) { struct xhdr_tab const *t; if (st->xhdr.buffer) return; t = locate_handler(keyword); if (!t || !t->coder) return; if (xheader_keyword_deleted_p(keyword)) return; xheader_init(&st->xhdr); if (!xheader_keyword_override_p(keyword)) t->coder(st, keyword, &st->xhdr, data); }
long long xheader_store(char *a0, struct_0 *a1, unsigned long long a2) { struct_1 *v0; unsigned long long v2; v2 = a1->field_178; if (a1->field_178) return v2; v2 = locate_handler(a0); v0 = v2; if (!v0) return v2; v2 = v0->field_8; if (!v0->field_8) return v2; v2 = xheader_keyword_deleted_p(a0); if (v2) return v2; xheader_init(&a1->padding_0[360]); v2 = xheader_keyword_override_p(a0) ^ 1; if (v2) { v2 = v0->field_8(a1, a0, &a1->padding_0[360], a2, v0->field_8); return v2; } return v2; }
tar
angr_sailr
int _rl_overwrite_char(int count, int c) { int i; char mbkey[16]; int k; k = 1; if (count > 0 && (__ctype_get_mb_cur_max()) > 1 && rl_byte_oriented == 0) k = _rl_read_mbstring(c, mbkey, 16); if (k < 0) return 1; rl_begin_undo_group(); for (i = 0; i < count; i++) { if ((__ctype_get_mb_cur_max()) > 1 && rl_byte_oriented == 0) rl_insert_text(mbkey); else _rl_insert_char(1, c); if (rl_point < rl_end) rl_delete(1, c); } rl_end_undo_group(); return 0; }
int _rl_overwrite_char(unsigned long a0, unsigned long a1) { unsigned int v0; unsigned int v1; char v2; unsigned int v4; v1 = 1; if (a0 > 0) { v4 = __ctype_get_mb_cur_max(); if (v4 > 1 && !rl_byte_oriented) v1 = _rl_read_mbstring(a1, &v2, 0x10, &v2); } if (v1 < 0) { v4 = 1; } else { rl_begin_undo_group(); for (v0 = 0; v0 < a0; v0 += 1) { v4 = __ctype_get_mb_cur_max(); if (v4 > 1 && !rl_byte_oriented) rl_insert_text(&v2); if (v4 <= 1 || rl_byte_oriented) _rl_insert_char(0x1, a1); if (rl_point < rl_end) rl_delete(0x1, a1, rl_point, &v2); } rl_end_undo_group(); v4 = 0; } return v4; }
bash
angr_dream
char *expand_string_to_string(string, quoted) char *string; int quoted; { return (expand_string_to_string_internal(string, quoted, expand_string)); }
long long expand_string_to_string(char *a0, unsigned long a1) { return expand_string_to_string_internal(a0, a1, expand_string); }
bash
angr_phoenix
int unvis(char *cp, int c, int *astate, int flag) { unsigned char uc = (unsigned char)c; unsigned char st, ia, is, lc; ; ; st = ((*astate) & 0xff); if (flag & 0x0800) { switch (st) { case 5: case 6: case 9: *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 0: return 3; default: return -1; } } switch (st) { case 0: *cp = 0; if ((flag & 0x0400) == 0 && c == '\\') { *astate = (((uint32_t)(0) << 24) | (1)); return 3; } if ((flag & 0x0080) && c == '%') { *astate = (((uint32_t)(0) << 24) | (8)); return 3; } if ((flag & 0x0200) && c == '&') { *astate = (((uint32_t)(0) << 24) | (13)); return 3; } if ((flag & 0x0100) && c == '=') { *astate = (((uint32_t)(0) << 24) | (10)); return 3; } *cp = c; return 1; case 1: switch (c) { case '\\': *cp = c; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': *cp = (c - '0'); *astate = (((uint32_t)(0) << 24) | (5)); return 3; case 'M': *cp = (char)0200; *astate = (((uint32_t)(0) << 24) | (2)); return 3; case '^': *astate = (((uint32_t)(0) << 24) | (4)); return 3; case 'n': *cp = '\n'; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 'r': *cp = '\r'; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 'b': *cp = '\b'; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 'a': *cp = '\007'; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 'v': *cp = '\v'; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 't': *cp = '\t'; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 'f': *cp = '\f'; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 's': *cp = ' '; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 'E': *cp = '\033'; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 'x': *astate = (((uint32_t)(0) << 24) | (7)); return 3; case '\n': *astate = (((uint32_t)(0) << 24) | (0)); return 3; case '$': *astate = (((uint32_t)(0) << 24) | (0)); return 3; default: if (((*__ctype_b_loc())[(int)((c))] & (unsigned short int)_ISgraph)) { *cp = c; *astate = (((uint32_t)(0) << 24) | (0)); return 1; } } goto bad; case 2: if (c == '-') *astate = (((uint32_t)(0) << 24) | (3)); else if (c == '^') *astate = (((uint32_t)(0) << 24) | (4)); else goto bad; return 3; case 3: *astate = (((uint32_t)(0) << 24) | (0)); *cp |= c; return 1; case 4: if (c == '?') *cp |= 0177; else *cp |= c & 037; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 5: if ((((unsigned char)(uc)) >= '0' && ((unsigned char)(uc)) <= '7')) { *cp = (*cp << 3) + (c - '0'); *astate = (((uint32_t)(0) << 24) | (6)); return 3; } *astate = (((uint32_t)(0) << 24) | (0)); return 2; case 6: *astate = (((uint32_t)(0) << 24) | (0)); if ((((unsigned char)(uc)) >= '0' && ((unsigned char)(uc)) <= '7')) { *cp = (*cp << 3) + (c - '0'); return 1; } return 2; case 7: if (!((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISxdigit)) goto bad; case 8: if (((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISxdigit)) { *cp = (((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISdigit) ? (uc - '0') : ((tolower(uc) - 'a') + 10)); *astate = (((uint32_t)(0) << 24) | (9)); return 3; } *astate = (((uint32_t)(0) << 24) | (0)); return 2; case 9: *astate = 0; if (((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISxdigit)) { *cp = (((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISdigit) ? (uc - '0') : ((tolower(uc) - 'a') + 10)) | (*cp << 4); return 1; } return 2; case 10: if (uc == '\n' || uc == '\r') { *astate = (((uint32_t)(0) << 24) | (12)); return 3; } if (((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISxdigit) && (((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISdigit) || ((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISupper))) { *cp = (((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISdigit) ? (uc - '0') : ((uc - 'A') + 10)); *astate = (((uint32_t)(0) << 24) | (11)); return 3; } goto bad; case 11: if (((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISxdigit) && (((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISdigit) || ((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISupper))) { *astate = (((uint32_t)(0) << 24) | (0)); *cp = (((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISdigit) ? (uc - '0') : ((uc - 'A') + 10)) | (*cp << 4); return 1; } goto bad; case 12: switch (uc) { case '\r': case '\n': return 3; case '=': *astate = (((uint32_t)(0) << 24) | (10)); return 3; default: *cp = uc; *astate = (((uint32_t)(0) << 24) | (0)); return 1; } case 13: *cp = 0; if (uc == '#') { *astate = (((uint32_t)(0) << 24) | (14)); return 3; } *astate = (((uint32_t)(0) << 24) | (15)); case 15: ia = *cp; is = ((uint32_t)(*astate) >> 24); lc = is == 0 ? 0 : nv[ia].name[is - 1]; if (uc == ';') uc = '\0'; for (; ia < (sizeof(nv) / sizeof(nv[0])); ia++) { if (is != 0 && nv[ia].name[is - 1] != lc) goto bad; if (nv[ia].name[is] == uc) break; } if (ia == (sizeof(nv) / sizeof(nv[0]))) goto bad; if (uc != 0) { *cp = ia; *astate = (((uint32_t)(is + 1) << 24) | (15)); return 3; } *cp = nv[ia].value; *astate = (((uint32_t)(0) << 24) | (0)); return 1; case 14: if (uc == ';') return 1; if (!((*__ctype_b_loc())[(int)((uc))] & (unsigned short int)_ISdigit)) goto bad; *cp += (*cp * 10) + uc - '0'; return 3; default: bad: *astate = (((uint32_t)(0) << 24) | (0)); return -1; } }
int unvis(char *a0, unsigned long a1, unsigned int *a2, unsigned long a3) { char *v0; char v1; char v2; char v3; char v4; char v5; unsigned int v7; unsigned int v9; unsigned int v11; unsigned int v13; unsigned int v15; unsigned int v17; char v18; unsigned int v20; unsigned int v21; unsigned int v22; unsigned int v23; unsigned int v24; unsigned int v25; char v27; unsigned int v28; unsigned int v29; unsigned int v30; char v31; v0 = a0; v1 = a1; v3 = *(a2); if (!(a3 & 0x800)) { switch (v3) { case 0: *(a0) = 0; if (!(a3 & 0x400) && a1 == 92) { *(a2) = 1; v7 = 3; break; } if ((a3 & 128) && a1 == 37) { *(a2) = 8; v7 = 3; break; } if ((a3 & 0x200) && a1 == 38) { *(a2) = 13; v7 = 3; break; } if ((a3 & 0x100) && a1 == 61) { *(a2) = 10; v7 = 3; break; } *(a0) = a1; v7 = 1; break; case 1: switch (a1) { case 10: *(a2) = 0; v7 = 3; break; case 36: *(a2) = 0; v7 = 3; break; case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: *(a0) = a1 - 48; *(a2) = 5; v7 = 3; break; case 69: *(a0) = 27; *(a2) = 0; v7 = 1; break; case 77: *(a0) = 128; *(a2) = 2; v7 = 3; break; case 92: *(a0) = a1; *(a2) = 0; v7 = 1; break; case 94: *(a2) = 4; v7 = 3; break; case 97: *(a0) = 7; *(a2) = 0; v7 = 1; break; case 98: *(a0) = 8; *(a2) = 0; v7 = 1; break; case 102: *(a0) = 12; *(a2) = 0; v7 = 1; break; case 110: *(a0) = 10; *(a2) = 0; v7 = 1; break; case 114: *(a0) = 13; *(a2) = 0; v7 = 1; break; case 115: *(a0) = 32; *(a2) = 0; v7 = 1; break; case 116: *(a0) = 9; *(a2) = 0; v7 = 1; break; case 118: *(a0) = 11; *(a2) = 0; v7 = 1; break; case 120: *(a2) = 7; v7 = 3; break; default: if (*((*(__ctype_b_loc()) + a1 * 2)) < 0) { *(a0) = a1; *(a2) = 0; v7 = 1; break; } } goto LABEL_4009b3; case 2: if (a1 == 45) { *(a2) = 3; } else { if (!(a1 == 94)) goto LABEL_4009b3; *(a2) = 4; } v7 = 3; break; case 3: *(a2) = 0; *(a0) = a1 | *(a0); v7 = 1; break; case 4: if (a1 == 63) *(a0) = *(a0) | 127; else *(a0) = a1 & 31 | *(a0); *(a2) = 0; v7 = 1; break; case 5: if (v1 > 47 && v1 <= 55) { *(a0) = (*(a0) * 8) + a1 - 48; *(a2) = 6; v7 = 3; break; } *(a2) = 0; v7 = 2; break; case 6: *(a2) = 0; if (v1 > 47 && v1 <= 55) { *(a0) = (*(a0) * 8) + a1 - 48; v7 = 1; break; } v7 = 2; break; case 9: *(a2) = 0; v13 = *((*(__ctype_b_loc()) + v1 * 2)) & 0x1000; if (!v13) { v7 = 2; break; } else { *(&v13) = *((*(__ctype_b_loc()) + v1 * 2)); v22 = v13 & 0x800; if (v22) v23 = v1 - 48; else v23 = tolower(v1) - 87; *(&v23) = v23 | (*(a0) * 16); *(a0) = v23; v7 = 1; break; } case 10: if (v1 != 10 && v1 != 13) { v17 = *((*(__ctype_b_loc()) + v1 * 2)) & 0x1000; if (v17) { *(&v17) = *((*(__ctype_b_loc()) + v1 * 2)); v24 = v17 & 0x800; if (v24) { LABEL_400665: *(&v24) = *((*(__ctype_b_loc()) + v1 * 2)); v30 = v24 & 0x800; if (v30) v31 = v1 - 48; else v31 = v1 - 55; *(&a0) = v31; *(a2) = 11; v7 = 3; break; } else { *(&v24) = *((*(__ctype_b_loc()) + v1 * 2)); v24 = v24 & 0x100; if (!(!v24)) goto LABEL_400665; } } goto LABEL_4009b3; } *(a2) = 12; v7 = 3; break; case 11: v9 = *((*(__ctype_b_loc()) + v1 * 2)) & 0x1000; if (v9) { *(&v9) = *((*(__ctype_b_loc()) + v1 * 2)); v20 = v9 & 0x800; if (v20) { LABEL_40071f: *(a2) = 0; *(&v20) = *((*(__ctype_b_loc()) + v1 * 2)); v28 = v20 & 0x800; if (!v28) v29 = v1 - 55; else v29 = v1 - 48; *(&v29) = v29 | (*(a0) * 16); *(a0) = v29; v7 = 1; break; } else { *(&v20) = *((*(__ctype_b_loc()) + v1 * 2)); v20 = v20 & 0x100; if (!(!v20)) goto LABEL_40071f; } } goto LABEL_4009b3; case 12: if (v1 == 61) { *(a2) = 10; v7 = 3; break; } else { if (v1 > 61) { LABEL_4007b3: *(a0) = v1; *(a2) = 0; v7 = 1; break; } else { if (v1 != 10 && !(v1 == 13)) goto LABEL_4007b3; v7 = 3; break; } } case 14: if (v1 == 59) { v7 = 1; break; } v15 = *((*(__ctype_b_loc()) + v1 * 2)) & 0x800; if (v15) { *(a0) = v1 + ((*(a0) * 4) + *(a0)) * 2 + *(a0)-48; v7 = 3; break; } case 7: v11 = *((*(__ctype_b_loc()) + v1 * 2)) & 0x1000; if (!v11) goto LABEL_4009b3; case 8: *(&v11) = *((*(__ctype_b_loc()) + v1 * 2)); v21 = v11 & 0x1000; if (!v21) { *(a2) = 0; v7 = 2; break; } else { *(&v21) = *((*(__ctype_b_loc()) + v1 * 2)); v25 = v21 & 0x800; if (v25) { v27 = v1 - 48; } else { *(&v25) = tolower(v1) - 87; v27 = *(&v25); } *(&a0) = v27; *(a2) = 9; v7 = 3; break; } case 13: *(a0) = 0; if (v1 != 35) { *(a2) = 15; goto LABEL_4007fc; } else { *(a2) = 14; v7 = 3; break; } case 15: LABEL_4007fc: v2 = *(a0); v4 = *(a2) >> 24; if (!v4) v18 = 0; else v18 = *((4197504 + 8 * v2 + v4 - 1)); v5 = v18; if (v1 == 59) v1 = 0; while (true) { if (v2 > 99) { LABEL_4008ca: if (v2 == 100) break; if (v1) { *(a0) = v2; *(a2) = ((v4 + 1) * 0x1000000) | 15; v7 = 3; break; } else { *(a0) = (&g_400c87)[v2]; *(a2) = 0; v7 = 1; break; } } else { if (v4 && *((4197504 + 8 * v2 + v4 - 1)) != v5) break; if (*((4197504 + 8 * v2 + v4)) == v1) goto LABEL_4008ca; v2 += 1; } } default: LABEL_4009b3: *(a2) = 0; v7 = -1; break; } } else if (v3 == 9) { LABEL_400053: *(a2) = 0; v7 = 1; } else { if (v3 <= 9) { if (!v3) { v7 = 3; goto LABEL_4009c2; } if (v3 >= 0 && v3 - 5 <= 1) goto LABEL_400053; } v7 = -1; } LABEL_4009c2: return v7; }
libbsd-0.11.7
angr_phoenix
static void env_modprobe_options_append(const char *value) { const char *old = getenv("MODPROBE_OPTIONS"); char *env; if (old == ((void *)0)) { setenv("MODPROBE_OPTIONS", value, 1); return; } if (asprintf(&env, "%s %s", old, value) < 0) { log_printf(3, "could not append value to $MODPROBE_OPTIONS\n"); return; } if (setenv("MODPROBE_OPTIONS", env, 1) < 0) log_printf(3, "could not setenv(MODPROBE_OPTIONS, \"%s\")\n", env); free(env); }
void env_modprobe_options_append(char *a0) { char v0; unsigned long v1; char v2; unsigned int v4; unsigned long long v5; unsigned long long *v6; unsigned long long v7; v1 = getenv("MODPROBE_OPTIONS"); if (!v1) { setenv("MODPROBE_OPTIONS", a0, 0x1); } else { v4 = v1; if (asprintf(&v0, "%s %s", v1, a0) < 0) { log_printf(0x3, "could not append value to $MODPROBE_OPTIONS\n", v5); } else { if (setenv("MODPROBE_OPTIONS", *(&v0), 0x1) < 0) log_printf(0x3, "could not setenv(MODPROBE_OPTIONS, \"%s\")\n", *(&v0)); free(*(&v0)); } } v7 = *(&v2) ^ v6[5]; return; }
kmod
angr_phoenix
int Read_Runlevel_Log(int *runlevel) { FILE *log_file; int status; log_file = fopen("/var/run/runlevel", "r"); if (!log_file) return 0; status = fscanf(log_file, "%c", (char *)runlevel); fclose(log_file); if (status < 1) return 0; return 1; }
long long Read_Runlevel_Log(unsigned long a0) { unsigned int v0; void *v1; void *v3; v1 = fopen("/var/run/runlevel", "r"); if (!v1) { v3 = 0; return v3; } v0 = fscanf(v1, "%c", a0); fclose(v1); v3 = (v0 <= 0 ? 1 : 0); return v3; }
sysvinit
angr_sailr
int sshbuf_put_string(struct sshbuf *buf, const void *v, size_t len) { u_char *d; int r; if (len > 0x8000000 - 4) { ; return -9; } if ((r = sshbuf_reserve(buf, len + 4, &d)) < 0) return r; do { const u_int32_t __v = (len); ((u_char *)(d))[0] = (__v >> 24) & 0xff; ((u_char *)(d))[1] = (__v >> 16) & 0xff; ((u_char *)(d))[2] = (__v >> 8) & 0xff; ((u_char *)(d))[3] = __v & 0xff; } while (0); if (len != 0) memcpy(d + 4, v, len); return 0; }
int sshbuf_put_string(undefined8 param_1, void *param_2, ulong param_3) { int iVar1; long in_FS_OFFSET; undefined *local_18; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); if (param_3 < 0x7fffffd) { iVar1 = sshbuf_reserve(param_1, param_3 + 4, &local_18); if (-1 < iVar1) { *local_18 = (char)(param_3 >> 0x18); local_18[1] = (char)(param_3 >> 0x10); local_18[2] = (char)(param_3 >> 8); local_18[3] = (char)param_3; if (param_3 != 0) { memcpy(local_18 + 4, param_2, param_3); } iVar1 = 0; } } else { iVar1 = -9; } if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return iVar1; } __stack_chk_fail(); }
openssh-portable
ghidra
size_t ssh_digest_blocksize(struct ssh_digest_ctx *ctx) { return EVP_MD_get_block_size(EVP_MD_CTX_get0_md(ctx->mdctx)); }
long long ssh_digest_blocksize(struct_0 *a0) { return EVP_MD_get_block_size(EVP_MD_CTX_get0_md(a0->field_8)); }
openssh-portable
angr_dream
static KbdintAuthctxt *kbdint_alloc(const char *devs) { KbdintAuthctxt *kbdintctxt; struct sshbuf *b; int i, r; kbdintctxt = xcalloc(1, sizeof(KbdintAuthctxt)); if (strcmp(devs, "") == 0) { if ((b = sshbuf_new()) == ((void *)0)) sshfatal("auth2-chall.c", __func__, 115, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new failed"); for (i = 0; devices[i]; i++) { if ((r = sshbuf_putf(b, "%s%s", sshbuf_len(b) ? "," : "", devices[i]->name)) != 0) sshfatal("auth2-chall.c", __func__, 119, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "buffer error"); } if ((kbdintctxt->devices = sshbuf_dup_string(b)) == ((void *)0)) sshfatal("auth2-chall.c", __func__, 122, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_dup_string failed"); sshbuf_free(b); } else { kbdintctxt->devices = xstrdup(devs); } sshlog("auth2-chall.c", __func__, 127, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "kbdint_alloc: devices '%s'", kbdintctxt->devices); kbdintctxt->ctxt = ((void *)0); kbdintctxt->device = ((void *)0); kbdintctxt->nreq = 0; return kbdintctxt; }
long *kbdint_alloc(char *param_1) { int iVar1; undefined *puVar2; undefined8 uVar3; long lVar4; char **ppcVar5; char *pcStack88; undefined8 uStack80; undefined auStack72[8]; char *local_40; int local_30; int local_2c; long *local_28; long local_20; ppcVar5 = (char **)auStack72; puVar2 = auStack72; uStack80 = 0x100020; local_40 = param_1; local_28 = (long *)xcalloc(1, 0x20); uStack80 = 0x100037; iVar1 = strcmp(local_40, ""); if (iVar1 == 0) { uStack80 = 0x100044; local_20 = sshbuf_new(); if (local_20 == 0) { ppcVar5 = &pcStack88; pcStack88 = "sshbuf_new failed"; sshfatal("auth2-chall.c", "kbdint_alloc", 0x73, 1, 1, 0); } for (local_30 = 0; (&devices)[local_30] != 0; local_30 = __addvsi3(local_30, 1)) { uVar3 = *(undefined8 *)(&devices)[local_30]; *(undefined8 *)((long)ppcVar5 + -8) = 0x1000bc; lVar4 = sshbuf_len(local_20); if (lVar4 == 0) { puVar2 = &DAT_00100f60; } else { puVar2 = &DAT_00100f81; } *(undefined8 *)((long)ppcVar5 + -8) = 0x1000ec; local_2c = sshbuf_putf(local_20, &DAT_00100f83, puVar2, uVar3); if (local_2c != 0) { *(undefined8 *)((long)ppcVar5 + -8) = 0x1000ff; uVar3 = ssh_err(local_2c); *(char **)((long)ppcVar5 + -0x10) = "buffer error"; *(undefined8 *)((long)ppcVar5 + -0x18) = 0x100136; sshfatal("auth2-chall.c", "kbdint_alloc", 0x77, 1, 1, uVar3); ppcVar5 = (char **)((long)ppcVar5 + -0x10); } *(undefined8 *)((long)ppcVar5 + -8) = 0x100143; } *(undefined8 *)((long)ppcVar5 + -8) = 0x100173; lVar4 = sshbuf_dup_string(local_20); *local_28 = lVar4; puVar2 = (undefined *)ppcVar5; if (*local_28 == 0) { puVar2 = (undefined *)((long)ppcVar5 + -0x10); *(char **)((long)ppcVar5 + -0x10) = "sshbuf_dup_string failed"; *(undefined8 *)((long)ppcVar5 + -0x18) = 0x1001c0; sshfatal("auth2-chall.c", "kbdint_alloc", 0x7a, 1, 1, 0); } lVar4 = local_20; *(undefined8 *)(puVar2 + -8) = 0x1001cc; sshbuf_free(lVar4); } else { uStack80 = 0x1001da; lVar4 = xstrdup(local_40); *local_28 = lVar4; } *(long *)(puVar2 + -8) = *local_28; *(char **)(puVar2 + -0x10) = "kbdint_alloc: devices \'%s\'"; *(undefined8 *)(puVar2 + -0x18) = 0x10021f; sshlog("auth2-chall.c", "kbdint_alloc", 0x7f, 0, 5, 0); local_28[1] = 0; local_28[2] = 0; *(undefined4 *)(local_28 + 3) = 0; return local_28; }
openssh-portable
ghidra
get_stat_mtime(struct stat const *st) { return ((st)->st_mtim); }
void get_stat_mtime(void) { halt_baddata(); }
gzip-1.12
ghidra
static char *history_completion_generator(hint_text, state) const char *hint_text; int state; { static int local_index, len; static const char *text; if (state == 0) { if (dabbrev_expand_active) rl_completion_suppress_append = 1; local_index = 0; build_history_completion_array(); text = hint_text; len = strlen(text); } while (history_completion_array && history_completion_array[local_index]) { if (strncmp(text, history_completion_array[local_index++], len) == 0) return ((char *)strcpy( sh_xmalloc((1 + strlen(history_completion_array[local_index - 1])), "bashline.c", 3666), (history_completion_array[local_index - 1]))); } return ((char *)((void *)0)); }
char *history_completion_generator(char *param_1, int param_2) { int iVar1; size_t sVar2; long lVar3; char *__dest; char *pcVar4; if (param_2 == 0) { if (dabbrev_expand_active != 0) { rl_completion_suppress_append = 1; } local_index_11834 = 0; build_history_completion_array(); text_11836 = param_1; sVar2 = strlen(param_1); len_11835 = (int)sVar2; } while ((history_completion_array != 0 && (*(long *)(history_completion_array + (long)local_index_11834 * 8) != 0))) { lVar3 = (long)local_index_11834; local_index_11834 = local_index_11834 + 1; iVar1 = strncmp(text_11836, *(char **)(lVar3 * 8 + history_completion_array), (long)len_11835); if (iVar1 == 0) { pcVar4 = *(char **)(history_completion_array + (long)local_index_11834 * 8 + -8); sVar2 = strlen(*(char **)(history_completion_array + (long)local_index_11834 * 8 + -8)); __dest = (char *)sh_xmalloc(sVar2 + 1, "bashline.c", 0xe52); pcVar4 = strcpy(__dest, pcVar4); return pcVar4; } } return (char *)0x0; }
bash
ghidra
static int xstrcoll_df_version(V a, V b) { return dirfirst_check(a, b, xstrcoll_version); }
long long xstrcoll_df_version(void *a0, void *a1) { return dirfirst_check(a0, a1, xstrcoll_version); }
coreutils
angr_phoenix
void ssh_packet_set_mux(struct ssh *ssh) { ssh->state->mux = 1; ssh->state->rekeying = 0; kex_free(ssh->kex); ssh->kex = ((void *)0); }
long long ssh_packet_set_mux(struct_0 *a0) { a0->field_0->field_1e0 = 1; a0->field_0->field_1dc = 0; kex_free(a0->field_8); a0->field_8 = 0; return a0; }
openssh-portable
angr_phoenix
void fatal(char const *msgid) { print_message_queue(); ((!!sizeof(struct { _Static_assert(2, "verify_expr (" "2" ", " "(error (2, 0, \"%s\", gettext (msgid)), assume (false))" ")"); int _gl_dummy; })) ? ((error(2, 0, "%s", gettext(msgid)), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(2, 0, "%s", gettext(msgid)), ((0) ? (void)0 : __builtin_unreachable())))); }
void fatal(char *a0) { print_message_queue(); gettext(a0); error(0x2, 0x0, "%s"); }
diffutils
angr_dream
static _Bool do_arm_swaps(struct predicate *p) { if (p) { _Bool swapped; do { swapped = 0; if (consider_arm_swap(p) || do_arm_swaps(p->pred_left) || do_arm_swaps(p->pred_right)) { swapped = 1; } } while (swapped); return swapped; } else { return 0; } }
char do_arm_swaps(long param_1) { char cVar1; char local_9; if (param_1 == 0) { local_9 = '\0'; } else { do { local_9 = '\0'; cVar1 = consider_arm_swap(param_1); if (((cVar1 != '\0') || (cVar1 = do_arm_swaps(*(undefined8 *)(param_1 + 0x110)), cVar1 != '\0')) || (cVar1 = do_arm_swaps(*(undefined8 *)(param_1 + 0x118)), cVar1 != '\0')) { local_9 = '\x01'; } } while (local_9 != '\0'); } return local_9; }
findutils
ghidra
static void print_rx_sc(const char *prefix, __be64 sci, __u8 active, struct rtattr *rxsc_stats, struct rtattr *sa) { struct rtattr *sa_attr[MACSEC_SA_ATTR_MAX + 1]; struct rtattr *a; int rem; print_string(PRINT_FP, ((void *)0), "%s", prefix); print_0xhex(PRINT_ANY, "sci", "RXSC: %016llx,", ((1 == ntohl(1)) ? (sci) : ((uint64_t)ntohl((sci) & 0xFFFFFFFF) << 32) | ntohl((sci) >> 32))); print_bool(PRINT_JSON, "active", ((void *)0), active); print_string(PRINT_FP, ((void *)0), " state %s\n", active ? "on" : "off"); print_rxsc_stats(prefix, rxsc_stats); open_json_array(PRINT_JSON, "sa_list"); rem = ((int)((sa)->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))); for (a = ((void *)(((char *)(sa)) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))); ((rem) >= (int)sizeof(struct rtattr) && (a)->rta_len >= sizeof(struct rtattr) && (a)->rta_len <= (rem)); a = ((rem) -= ((((a)->rta_len) + 4U - 1) & ~(4U - 1)), (struct rtattr *)(((char *)(a)) + ((((a)->rta_len) + 4U - 1) & ~(4U - 1))))) { _Bool state; open_json_object(((void *)0)); (parse_rtattr_flags( (sa_attr), (MACSEC_SA_ATTR_MAX), ((void *)(((char *)(a)) + ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0)))), ((int)((a)->rta_len) - ((((sizeof(struct rtattr)) + 4U - 1) & ~(4U - 1)) + (0))), (1 << 15))); state = rta_getattr_u8(sa_attr[MACSEC_SA_ATTR_ACTIVE]); print_string(PRINT_FP, ((void *)0), "%s", prefix); print_string(PRINT_FP, ((void *)0), "%s", prefix); print_uint(PRINT_ANY, "an", "%u:", rta_getattr_u8(sa_attr[MACSEC_SA_ATTR_AN])); print_uint(PRINT_ANY, "pn", " PN %u,", rta_getattr_u32(sa_attr[MACSEC_SA_ATTR_PN])); print_bool(PRINT_JSON, "active", ((void *)0), state); print_string(PRINT_FP, ((void *)0), " state %s,", state ? "on" : "off"); print_key(sa_attr[MACSEC_SA_ATTR_KEYID]); print_rxsa_stats(prefix, sa_attr[MACSEC_SA_ATTR_STATS]); close_json_object(); } close_json_array(PRINT_JSON, ((void *)0)); }
void print_rx_sc(unsigned long long a0, unsigned long long a1, unsigned long long a2, unsigned long a3, unsigned short *a4, unsigned long long a5) { char v0; unsigned int v1; unsigned short *v2; char v3; char v4; char v5; char v6; char v7; char v8; char v9; unsigned long long v11; unsigned long long v13; unsigned long long v14; unsigned long long *v15; unsigned long long v16; print_string(0x1, 0x0, "%s", a0); if (ntohl(0x1) == 1) v11 = a1; else v11 = ntohl(a1 / 0x100000000) | ntohl(a1) * 0x100000000; print_0xhex(0x4, "sci", "RXSC: %016llx,", v11); print_bool(0x2, "active", 0x0, a2); if (a2) v13 = "on"; else v13 = "off"; print_string(0x1, 0x0, " state %s\n", v13); print_rxsc_stats(a0, a3, a3, a3, a4, a5); open_json_array(0x2, "sa_list"); v1 = *(a4)-4; v2 = a4 + 2; while (true) { if (v1 <= 3) break; if (*(v2) <= 3) break; if (v1 < *(v2)) break; open_json_object(0x0); parse_rtattr_flags(&v3, 0x9, v2 + 2, *(v2)-4, 0x8000); v0 = rta_getattr_u8(*(&v5)); print_string(0x1, 0x0, "%s", a0); print_string(0x1, 0x0, "%s", a0); print_uint(0x4, "an", "%u:", rta_getattr_u8(*(&v4))); print_uint(0x4, "pn", " PN %u,", rta_getattr_u32(*(&v6))); print_bool(0x2, "active", 0x0, v0); if (!v0) v14 = "off"; else v14 = "on"; print_string(0x1, 0x0, " state %s,", v14); print_key(*(&v7)); print_rxsa_stats(a0, *(&v8), *(&v8), a3, 0x8000, a5); close_json_object(a0, a1, a2, a3, 0x8000, a5); v1 -= *(v2) + 3 & 0xfffffffc; v2 = v2 + (*(v2) + 3 & 0xfffffffc); } close_json_array(0x2, 0x0); v16 = *(&v9) ^ v15[5]; return; }
iproute2-6.0.0
angr_phoenix
static int proposals_match(char *my[PROPOSAL_MAX], char *peer[PROPOSAL_MAX]) { static int check[] = {PROPOSAL_KEX_ALGS, PROPOSAL_SERVER_HOST_KEY_ALGS, -1}; int *idx; char *p; for (idx = &check[0]; *idx != -1; idx++) { if ((p = strchr(my[*idx], ',')) != ((void *)0)) *p = '\0'; if ((p = strchr(peer[*idx], ',')) != ((void *)0)) *p = '\0'; if (strcmp(my[*idx], peer[*idx]) != 0) { sshlog("kex.c", __func__, 894, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "proposal mismatch: my %s peer %s", my[*idx], peer[*idx]); return (0); } } sshlog("kex.c", __func__, 899, 0, SYSLOG_LEVEL_DEBUG2, ((void *)0), "proposals match"); return (1); }
undefined8 proposals_match(long param_1, long param_2) { int iVar1; char *pcVar2; undefined8 uVar3; undefined1 *local_18; local_18 = check_19414; while (true) { if (*(int *)local_18 == -1) { sshlog("kex.c", "proposals_match", 899, 0, 6, 0, "proposals match"); return 1; } pcVar2 = strchr(*(char **)(param_1 + (long)*(int *)local_18 * 8), 0x2c); if (pcVar2 != (char *)0x0) { *pcVar2 = '\0'; } pcVar2 = strchr(*(char **)(param_2 + (long)*(int *)local_18 * 8), 0x2c); if (pcVar2 != (char *)0x0) { *pcVar2 = '\0'; } uVar3 = 0x1026c2; iVar1 = strcmp(*(char **)(param_1 + (long)*(int *)local_18 * 8), *(char **)(param_2 + (long)*(int *)local_18 * 8)); if (iVar1 != 0) break; local_18 = (undefined1 *)((long)local_18 + 4); } sshlog("kex.c", "proposals_match", 0x37e, 0, 6, 0, "proposal mismatch: my %s peer %s", *(undefined8 *)(param_1 + (long)*(int *)local_18 * 8), *(undefined8 *)(param_2 + (long)*(int *)local_18 * 8), uVar3); return 0; }
openssh-portable
ghidra
int stdfd_devnull(int do_stdin, int do_stdout, int do_stderr) { int devnull, ret = 0; if ((devnull = open("/dev/null", 02)) == -1) { sshlog("misc.c", __func__, 2608, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "open %s: %s", "/dev/null", strerror((*__errno_location()))); return -1; } if ((do_stdin && dup2(devnull, 0) == -1) || (do_stdout && dup2(devnull, 1) == -1) || (do_stderr && dup2(devnull, 2) == -1)) { sshlog("misc.c", __func__, 2615, 1, SYSLOG_LEVEL_ERROR, ((void *)0), "dup2: %s", strerror((*__errno_location()))); ret = -1; } if (devnull > 2) close(devnull); return ret; }
long stdfd_devnull(int a1, int a2, int a3) { int *v3; char *v4; int *v6; char *v7; unsigned int v9; int fd; v9 = 0; fd = open("/dev/null", 2); if (fd == -1) { v3 = _errno_location(); v4 = strerror(*v3); sshlog("misc.c", "stdfd_devnull", 2608LL, 1LL, 2LL, 0LL, "open %s: %s", "/dev/null", v4); return 0xFFFFFFFFLL; } else { if (a1 && dup2(fd, 0) == -1 || a2 && dup2(fd, 1) == -1 || a3 && dup2(fd, 2) == -1) { v6 = _errno_location(); v7 = strerror(*v6); sshlog("misc.c", "stdfd_devnull", 2615LL, 1LL, 2LL, 0LL, "dup2: %s", v7); v9 = -1; } if (fd > 2) close(fd); return v9; } }
openssh-portable
ida
int rtnl_rtntype_a2n(int *id, char *arg) { char *end; unsigned long res; if (strcmp(arg, "local") == 0) res = RTN_LOCAL; else if (strcmp(arg, "nat") == 0) res = RTN_NAT; else if (matches(arg, "broadcast") == 0 || strcmp(arg, "brd") == 0) res = RTN_BROADCAST; else if (matches(arg, "anycast") == 0) res = RTN_ANYCAST; else if (matches(arg, "multicast") == 0) res = RTN_MULTICAST; else if (matches(arg, "prohibit") == 0) res = RTN_PROHIBIT; else if (matches(arg, "unreachable") == 0) res = RTN_UNREACHABLE; else if (matches(arg, "blackhole") == 0) res = RTN_BLACKHOLE; else if (matches(arg, "xresolve") == 0) res = RTN_XRESOLVE; else if (matches(arg, "unicast") == 0) res = RTN_UNICAST; else if (strcmp(arg, "throw") == 0) res = RTN_THROW; else { res = strtoul(arg, &end, 0); if (!end || end == arg || *end || res > 255) return -1; } *id = res; return 0; }
long long rtnl_rtntype_a2n(unsigned int *a0, char *a1) { char v0; unsigned long long v1; unsigned long long v3; unsigned long long v4; unsigned long long v5; unsigned long long v6; unsigned long long v7; v3 = strcmp(a1, "local"); if (!v3) { v1 = 2; } else { v4 = strcmp(a1, "nat"); if (!v4) { v1 = 10; } else { *(&v4) = matches(a1, "broadcast") ^ 1; if (!v4) { v5 = strcmp(a1, "brd"); if (v5) { *(&v5) = matches(a1, "anycast") ^ 1; if (v5) { v1 = 4; } else { *(&v5) = matches(a1, "multicast") ^ 1; *(&v5) = matches(a1, "prohibit") ^ 1; *(&v5) = matches(a1, "unreachable") ^ 1; *(&v5) = matches(a1, "blackhole") ^ 1; *(&v5) = matches(a1, "xresolve") ^ 1; *(&v5) = matches(a1, "unicast") ^ 1; v6 = strcmp(a1, "throw"); if (!v6) v1 = 9; else v1 = strtoul(a1, &v0, 0x0, &v0); } } } if (!v5 || v4) v1 = 3; } } if (false) { v1 = 5; v1 = 8; v1 = 7; v1 = 6; v1 = 11; v1 = 1; } if (!v5 && !v4 && v3 && v5 && a1 != *(&v0) && v6 && *(&v0) && v4 && !*(*(&v0)) && v1 > 255 || !v5 && !v4 && v3 && v5 && a1 != *(&v0) && v6 && *(&v0) && v4 && *(*(&v0)) || !v5 && !v4 && v3 && v5 && v6 && *(&v0) && v4 && a1 == *(&v0) || !v5 && !v4 && v3 && v5 && v6 && v4 && !*(&v0)) v7 = 4294967295; if (!v5 && !v4 && v3 && v5 && a1 != *(&v0) && v6 && *(&v0) && v4 && !*(*(&v0)) && v1 <= 255 || !v6 && !v5 && !v4 && v3 && v5 && v4 || !v4 && v3 && v5 && v5 && v4 || v3 && v4 && (!v5 || v4) || !v4 && v3 || !v3) { *(a0) = v1; v7 = 0; } return v7; }
iproute2-6.0.0
angr_dream
((sb->s_jnl_backup_type == 1) && memcmp(inode.i_block, sb->s_jnl_blocks, (((12 + 1) + 1) + 1)*4))) { if (fix_problem(ctx, 0x00002D, &pctx)) { memcpy(sb->s_jnl_blocks, inode.i_block, (((12 + 1) + 1) + 1) * 4); sb->s_jnl_blocks[15] = inode.i_size_high; sb->s_jnl_blocks[16] = inode.i_size; sb->s_jnl_backup_type = 1; ext2fs_mark_super_dirty(fs); fs->flags &= ~0x200; } }
int memcmp(void *__s1, void *__s2, size_t __n) { halt_baddata(); }
e2fsprogs-1.46.5
ghidra
int do_download(struct sftp_conn *conn, const char *remote_path, const char *local_path, Attrib *a, int preserve_flag, int resume_flag, int fsync_flag, int inplace_flag) { struct sshbuf *msg; u_char *handle; int local_fd = -1, write_error; int read_error, write_errno, lmodified = 0, reordered = 0, r; u_int64_t offset = 0, size, highwater; u_int mode, id, buflen, num_req, max_req, status = 0; off_t progress_counter; size_t handle_len; struct stat st; struct requests requests; struct request *req; u_char type; sshlog("sftp-client.c", __func__, 1604, 1, SYSLOG_LEVEL_DEBUG2, ((void *)0), "download remote \"%s\" to local \"%s\"", remote_path, local_path); do { (&requests)->tqh_first = ((void *)0); (&requests)->tqh_last = &(&requests)->tqh_first; } while (0); if (a == ((void *)0) && (a = do_stat(conn, remote_path, 0)) == ((void *)0)) return -1; if (a->flags & 0x00000004) mode = a->perm & 0777; else mode = 0666; if ((a->flags & 0x00000004) && (!((((a->perm)) & 0170000) == (0100000)))) { sshlog("sftp-client.c", __func__, 1620, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "download %s: not a regular file", remote_path); return (-1); } if (a->flags & 0x00000001) size = a->size; else size = 0; buflen = conn->download_buflen; if (send_open(conn, remote_path, "remote", 0x00000001, ((void *)0), &handle, &handle_len) != 0) return -1; local_fd = open(local_path, 01 | 0100 | ((resume_flag || inplace_flag) ? 0 : 01000), mode | 0200); if (local_fd == -1) { sshlog("sftp-client.c", __func__, 1639, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "open local \"%s\": %s", local_path, strerror((*__errno_location()))); goto fail; } offset = highwater = 0; if (resume_flag) { if (fstat(local_fd, &st) == -1) { sshlog("sftp-client.c", __func__, 1645, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "stat local \"%s\": %s", local_path, strerror((*__errno_location()))); goto fail; } if (st.st_size < 0) { sshlog("sftp-client.c", __func__, 1650, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "\"%s\" has negative size", local_path); goto fail; } if ((u_int64_t)st.st_size > size) { sshlog("sftp-client.c", __func__, 1654, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Unable to resume download of \"%s\": " "local file is larger than remote", local_path); fail: do_close(conn, handle, handle_len); free(handle); if (local_fd != -1) close(local_fd); return -1; } offset = highwater = st.st_size; } write_error = read_error = write_errno = num_req = 0; max_req = 1; progress_counter = offset; if (showprogress && size != 0) { start_progress_meter(progress_meter_path(remote_path), size, &progress_counter); } if ((msg = sshbuf_new()) == ((void *)0)) sshfatal("sftp-client.c", __func__, 1677, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshbuf_new failed"); while (num_req > 0 || max_req > 0) { u_char *data; size_t len; if (interrupted) { if (num_req == 0) break; max_req = 0; } while (num_req < max_req) { sshlog("sftp-client.c", __func__, 1695, 0, SYSLOG_LEVEL_DEBUG3, ((void *)0), "Request range %llu -> %llu (%d/%d)", (unsigned long long)offset, (unsigned long long)offset + buflen - 1, num_req, max_req) ; req = request_enqueue(&requests, conn->msg_id++, buflen, offset); offset += buflen; num_req++; send_read_request(conn, req->id, req->offset, req->len, handle, handle_len); } sshbuf_reset(msg); get_msg(conn, msg); if ((r = sshbuf_get_u8(msg, &type)) != 0 || (r = sshbuf_get_u32(msg, &id)) != 0) sshfatal("sftp-client.c", __func__, 1711, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse"); sshlog("sftp-client.c", __func__, 1712, 0, SYSLOG_LEVEL_DEBUG3, ((void *)0), "Received reply T:%u I:%u R:%d", type, id, max_req); if ((req = request_find(&requests, id)) == ((void *)0)) sshfatal("sftp-client.c", __func__, 1716, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "Unexpected reply %u", id); switch (type) { case 101: if ((r = sshbuf_get_u32(msg, &status)) != 0) sshfatal("sftp-client.c", __func__, 1721, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse status"); if (status != 1) read_error = 1; max_req = 0; do { if (((req)->tq.tqe_next) != ((void *)0)) (req)->tq.tqe_next->tq.tqe_prev = (req)->tq.tqe_prev; else (&requests)->tqh_last = (req)->tq.tqe_prev; *(req)->tq.tqe_prev = (req)->tq.tqe_next; ; ; } while (0); free(req); num_req--; break; case 103: if ((r = sshbuf_get_string(msg, &data, &len)) != 0) sshfatal("sftp-client.c", __func__, 1731, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse data"); sshlog("sftp-client.c", __func__, 1732, 0, SYSLOG_LEVEL_DEBUG3, ((void *)0), "Received data %llu -> %llu", (unsigned long long)req->offset, (unsigned long long)req->offset + len - 1) ; if (len > req->len) sshfatal("sftp-client.c", __func__, 1736, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "Received more data than asked for " "%zu > %zu", len, req->len); lmodified = 1; if ((lseek(local_fd, req->offset, 0) == -1 || atomicio((ssize_t (*)(int, void *, size_t))write, local_fd, data, len) != len) && !write_error) { write_errno = (*__errno_location()); write_error = 1; max_req = 0; } else if (!reordered && req->offset <= highwater) highwater = req->offset + len; else if (!reordered && req->offset > highwater) reordered = 1; progress_counter += len; free(data); if (len == req->len) { do { if (((req)->tq.tqe_next) != ((void *)0)) (req)->tq.tqe_next->tq.tqe_prev = (req)->tq.tqe_prev; else (&requests)->tqh_last = (req)->tq.tqe_prev; *(req)->tq.tqe_prev = (req)->tq.tqe_next; ; ; } while (0); free(req); num_req--; } else { sshlog("sftp-client.c", __func__, 1759, 0, SYSLOG_LEVEL_DEBUG3, ((void *)0), "Short data block, re-requesting " "%llu -> %llu (%2d)", (unsigned long long)req->offset + len, (unsigned long long)req->offset + req->len - 1, num_req) ; req->id = conn->msg_id++; req->len -= len; req->offset += len; send_read_request(conn, req->id, req->offset, req->len, handle, handle_len); if (len < buflen) buflen = (((512) > (len)) ? (512) : (len)); } if (max_req > 0) { if (size > 0 && offset > size) { sshlog("sftp-client.c", __func__, 1777, 0, SYSLOG_LEVEL_DEBUG3, ((void *)0), "Finish at %llu (%2d)", (unsigned long long)offset, num_req) ; max_req = 1; } else if (max_req < conn->num_requests) { ++max_req; } } break; default: sshfatal("sftp-client.c", __func__, 1787, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "Expected SSH2_FXP_DATA(%u) packet, got %u", 103, type); } } if (showprogress && size) stop_progress_meter(); if (((&requests)->tqh_first) != ((void *)0)) sshfatal("sftp-client.c", __func__, 1797, 0, SYSLOG_LEVEL_FATAL, ((void *)0), "Transfer complete, but requests still in queue"); if (inplace_flag || read_error || write_error || interrupted) { if (reordered && resume_flag) { sshlog("sftp-client.c", __func__, 1804, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "Unable to resume download of \"%s\": " "server reordered requests", local_path); } sshlog("sftp-client.c", __func__, 1807, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "truncating at %llu", (unsigned long long)highwater); if (ftruncate(local_fd, highwater) == -1) sshlog("sftp-client.c", __func__, 1809, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "local ftruncate \"%s\": %s", local_path, strerror((*__errno_location()))); } if (read_error) { sshlog("sftp-client.c", __func__, 1813, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "read remote \"%s\" : %s", remote_path, fx2txt(status)); status = -1; do_close(conn, handle, handle_len); } else if (write_error) { sshlog("sftp-client.c", __func__, 1817, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "write local \"%s\": %s", local_path, strerror(write_errno)); status = 4; do_close(conn, handle, handle_len); } else { if (do_close(conn, handle, handle_len) != 0 || interrupted) status = 4; else status = 0; if (preserve_flag && fchmod(local_fd, mode) == -1) sshlog("sftp-client.c", __func__, 1832, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "local chmod \"%s\": %s", local_path, strerror((*__errno_location()))); if (preserve_flag && (a->flags & 0x00000008)) { struct timeval tv[2]; tv[0].tv_sec = a->atime; tv[1].tv_sec = a->mtime; tv[0].tv_usec = tv[1].tv_usec = 0; if (utimes(local_path, tv) == -1) sshlog("sftp-client.c", __func__, 1841, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "local set times \"%s\": %s", local_path, strerror((*__errno_location()))); } if (resume_flag && !lmodified) sshlog("sftp-client.c", __func__, 1845, 0, SYSLOG_LEVEL_INFO, ((void *)0), "File \"%s\" was not modified", local_path); else if (fsync_flag) { sshlog("sftp-client.c", __func__, 1847, 0, SYSLOG_LEVEL_DEBUG1, ((void *)0), "syncing \"%s\"", local_path); if (fsync(local_fd) == -1) sshlog("sftp-client.c", __func__, 1849, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "local sync \"%s\": %s", local_path, strerror((*__errno_location()))); } } close(local_fd); sshbuf_free(msg); free(handle); return status == 0 ? 0 : -1; }
int do_download(unsigned int a0[7], char *a1, char *a2, unsigned long a3, unsigned long a4, unsigned long a5, unsigned int v46, unsigned int a6) { unsigned long long v0; int tmp_22; int tmp_42; unsigned long long v1; unsigned long v2; unsigned long v3; unsigned long v4; unsigned long v5; struct_0 *v6; char *v7; unsigned int v8[7]; char v9; char v10; unsigned int v11; unsigned int v12; unsigned int v13; unsigned int v14; unsigned int v15; unsigned int v16; unsigned int v17; unsigned int v18; unsigned int v19; unsigned int v20; unsigned int v21; unsigned int v22; char v23; unsigned long long v24; char v25; char v26; char v27; unsigned long long v28; void *v29; unsigned long long v30; unsigned long long v31; struct_2 *v32; void *v33; unsigned long long *v34; unsigned long v35; void *v36; unsigned long v37; void *v38; char v39; char v40; unsigned long long v41; unsigned long v42; unsigned long v43; unsigned long v44; char v45; unsigned int v47; unsigned int v48; *(&v8[0]) = a0; v7 = a1; v6 = a3; v22 = -1; v15 = 0; v16 = 0; v28 = 0; v11 = 0; v4 = v7; sshlog("sftp-client.c", "do_download", 0x644, 0x1, 0x6, 0x0, "download remote \"%s\" to local \"%s\""); v33 = 0; v34 = &v33; if (!v6) { v6 = do_stat(a0, v7, 0x0); if (!v6) v47 = -1; } if (v6 || v6) { if ((v6->field_0 & 4)) v18 = v6->field_18 & 511; else v18 = 438; if ((v6->field_0 & 4) && (v6->field_18 & 0xf000) != 0x8000) { v5 = v7; sshlog("sftp-client.c", "do_download", 0x654, 0x0, 0x2, 0x0, "download %s: not a regular file"); v47 = -1; } if (!(v6->field_0 & 4) || (v6->field_18 & 0xf000) == 0x8000) { if ((v6->field_0 & 1)) v29 = v6->field_8; else v29 = 0; v19 = a0[2]; v47 = send_open(a0, v7, "remote", 0x1, 0x0, &v23, &v25); if (v47) { v47 = -1; } else { *(&v47) = v18; *(&v47) = v18 | 128; if (!a5 && !a6) v48 = 577; if (a6 || a5) v48 = 65; v47 = open(a2, v48, v47); v22 = v47; if (v22 == -1) { strerror(*(__errno_location())); v4 = a2; sshlog("sftp-client.c", "do_download", 0x667, 0x0, 0x2, 0x0, "open local \"%s\": %s"); } else { v30 = 0; v28 = v30; if (a5) { v47 = fstat(v22, &v39); if (v47 == -1) { strerror(*(__errno_location())); v4 = a2; sshlog("sftp-client.c", "do_download", 0x66d, 0x0, 0x2, 0x0, "stat local \"%s\": %s"); } else if (*(&v40) < 0) { v5 = a2; sshlog("sftp-client.c", "do_download", 0x672, 0x0, 0x2, 0x0, "\"%s\" has negative size"); } else if (v29 < *(&v40)) { v5 = a2; sshlog("sftp-client.c", "do_download", 0x676, 0x0, 0x2, 0x0, "Unable to resume download of \"%s\": local file is " "larger than remote"); } else { v30 = *(&v40); v28 = v30; } } if ((!a5 || v47 != -1) && (!a5 || *(&v40) >= 0) && (!a5 || v29 >= *(&v40))) { v20 = 0; v14 = 0; v13 = v14; v12 = v13; v21 = 1; v24 = v28; if (showprogress && v29) { v47 = progress_meter_path(v7); start_progress_meter(v47, v29, &v24, v47); } v31 = sshbuf_new(); if (!v31) sshfatal("sftp-client.c", "do_download", 0x68d, 0x1, 0x1, 0x0, "sshbuf_new failed"); while (true) { if (!v20) { if (!v21) break; } if (interrupted) { if (!v20) break; if (v20) v21 = 0; } while (v20 < v21) { v3 = v20; v2 = v28 + v19 - 1; v1 = v28; v0 = "Request range %llu -> %llu (%d/%d)"; sshlog("sftp-client.c", "do_download", 0x69f, 0x0, 0x7, 0x0, *(&v45)); tmp_22 = a0[6]; a0[6] = a0[6] + 1; v32 = request_enqueue(&v33, tmp_22, v19, v28); v28 += v19; v20 += 1; send_read_request(a0, v32->field_0, v32->field_10, v32->field_8, *(&v23), *(&v25)); } sshbuf_reset(v31); get_msg(a0, v31); v17 = sshbuf_get_u8(v31, &v9, &v9); if (!v17) v17 = sshbuf_get_u32(v31, &v10, &v10); if (v17 || v17) sshfatal("sftp-client.c", "do_download", 0x6af, 0x1, 0x1, ssh_err(v17), *(&v45)); v44 = v21; v43 = *(&v10); v42 = v9; v41 = "Received reply T:%u I:%u R:%d"; sshlog("sftp-client.c", "do_download", 0x6b0, 0x0, 0x7, 0x0, *(&v45)); v32 = request_find(&v33, *(&v10)); if (!v32) { v44 = *(&v10); v43 = "Unexpected reply %u"; sshfatal("sftp-client.c", "do_download", 0x6b4, 0x0, 0x1, 0x0, *(&v45)); } *(&v47) = v9; if (v9 == 101) { v17 = sshbuf_get_u32(v31, &v11, &v11); if (v17) { v43 = "parse status"; sshfatal("sftp-client.c", "do_download", 0x6b9, 0x1, 0x1, ssh_err(v17), *(&v45)); } if (v11 != 1) v13 = 1; v21 = 0; if (v32->field_18) v32->field_18->field_20 = v32->field_20; else v34 = &v32->field_20->field_0; v32->field_20->field_0 = v32->field_18; free(v32); v20 -= 1; } else if (v47 == 103) { v17 = sshbuf_get_string(v31, &v26, &v27, &v26); if (v17) { v43 = "parse data"; sshfatal("sftp-client.c", "do_download", 0x6c3, 0x1, 0x1, ssh_err(v17), *(&v45)); } v43 = *(&v27) + v32->field_10 - 1; v42 = v32->field_10; v41 = "Received data %llu -> %llu"; sshlog("sftp-client.c", "do_download", 0x6c4, 0x0, 0x7, 0x0, *(&v45)); if (v32->field_8 < *(&v27)) { v43 = v32->field_8; v42 = *(&v27); v41 = "Received more data than asked for %zu > %zu"; sshfatal("sftp-client.c", "do_download", 0x6c8, 0x0, 0x1, 0x0, *(&v45)); } v15 = 1; v47 = lseek(v22, v32->field_10, 0x0); if (v47 != -1) v47 = atomicio(got.write, v22, *(&v26), *(&v27)); if ((v47 == -1 || v47 != *(&v27)) && !v12) { v47 = *(__errno_location()); v14 = v47; v12 = 1; v21 = 0; } if (v12 || v47 == *(&v27) && v47 != -1) { if (!v16 && v30 >= v32->field_10) v30 = *(&v27) + v32->field_10; if ((v30 < v32->field_10 || v16) && !v16 && v30 < v32->field_10) v16 = 1; } v24 = *(&v27) + v24; free(*(&v26)); if (v32->field_8 == *(&v27)) { if (v32->field_18) v32->field_18->field_20 = v32->field_20; else v34 = &v32->field_20->field_0; v32->field_20->field_0 = v32->field_18; free(v32); v20 -= 1; } else { v44 = v20; v43 = v32->field_8 + v32->field_10 - 1; v42 = v32->field_10 + *(&v27); v41 = "Short data block, re-requesting %llu -> %llu (%2d)"; sshlog("sftp-client.c", "do_download", 0x6df, 0x0, 0x7, 0x0, *(&v45)); tmp_42 = a0[6]; a0[6] = a0[6] + 1; v32->field_0 = tmp_42; v32->field_8 = v32->field_8 - *(&v27); v32->field_10 = v32->field_10 + *(&v27); send_read_request(a0, v32->field_0, v32->field_10, v32->field_8, *(&v23), *(&v25)); if (v19 > *(&v27)) { v47 = *(&v27); if (*(&v27) < 0x200) v47 = 0x200; v19 = v47; } } if (v21) { if (v29 && v28 > v29) { v43 = v20; v42 = v28; v41 = "Finish at %llu (%2d)"; sshlog("sftp-client.c", "do_download", 0x6f1, 0x0, 0x7, 0x0, *(&v45)); v21 = 1; } if ((v28 <= v29 || !v29) && v21 < a0[4]) v21 += 1; } } else { v43 = v9; v42 = 103; v41 = "Expected SSH2_FXP_DATA(%u) packet, got %u"; sshfatal("sftp-client.c", "do_download", 0x6fb, 0x0, 0x1, 0x0, *(&v45)); } } if (showprogress && v29) stop_progress_meter(); if (v33) { v43 = "Transfer complete, but requests still in queue"; sshfatal("sftp-client.c", "do_download", 0x705, 0x0, 0x1, 0x0, *(&v45)); } if (v12 || a6 || v13 || interrupted) { if (v16 && a5) { v44 = a2; v43 = "Unable to resume download of \"%s\": server reordered " "requests"; sshlog("sftp-client.c", "do_download", 0x70c, 0x0, 0x2, 0x0, *(&v45)); } v44 = v30; v43 = "truncating at %llu"; sshlog("sftp-client.c", "do_download", 0x70f, 0x0, 0x5, 0x0, *(&v45)); v47 = ftruncate(v22, v30); if (v47 == -1) { v43 = strerror(*(__errno_location())); v42 = a2; v41 = "local ftruncate \"%s\": %s"; sshlog("sftp-client.c", "do_download", 0x711, 0x0, 0x2, 0x0, *(&v45)); } } if (v13) { v43 = fx2txt(v11); v42 = v7; v41 = "read remote \"%s\" : %s"; sshlog("sftp-client.c", "do_download", 0x715, 0x0, 0x2, 0x0, *(&v45)); v11 = -1; do_close(a0, *(&v23), *(&v25)); } else if (v12) { v43 = strerror(v14); v42 = a2; v41 = "write local \"%s\": %s"; sshlog("sftp-client.c", "do_download", 0x719, 0x0, 0x2, 0x0, *(&v45)); v11 = 4; do_close(a0, *(&v23), *(&v25)); } else { v47 = do_close(a0, *(&v23), *(&v25)); if (!v47 && !interrupted) v11 = 0; if (v47 || interrupted) v11 = 4; if (a4) { v47 = fchmod(v22, v18); if (v47 == -1) { v43 = strerror(*(__errno_location())); v42 = a2; v41 = "local chmod \"%s\": %s"; sshlog("sftp-client.c", "do_download", 0x728, 0x0, 0x2, 0x0, *(&v45)); } } if (a4 && (v6->field_0 & 8)) { v35 = v6->field_1c; v37 = v6->field_20; v38 = 0; v36 = v38; v47 = utimes(a2, &v35); if (v47 == -1) { v43 = strerror(*(__errno_location())); v42 = a2; v41 = "local set times \"%s\": %s"; sshlog("sftp-client.c", "do_download", 0x731, 0x0, 0x2, 0x0, *(&v45)); } } if (a5 && !v15) { v44 = a2; v43 = "File \"%s\" was not modified"; sshlog("sftp-client.c", "do_download", 0x735, 0x0, 0x3, 0x0, *(&v45)); } if ((!a5 || v15) && v46) { v44 = a2; v43 = "syncing \"%s\""; sshlog("sftp-client.c", "do_download", 0x737, 0x0, 0x5, 0x0, *(&v45)); v47 = fsync(v22); if (v47 == -1) { v43 = strerror(*(__errno_location())); v42 = a2; v41 = "local sync \"%s\": %s"; sshlog("sftp-client.c", "do_download", 0x739, 0x0, 0x2, 0x0, *(&v45)); } } } close(v22); sshbuf_free(v31); free(*(&v23)); if (!v11) v47 = 0; else v47 = -1; } } if (v22 == -1 || v47 == -1 && a5 || *(&v40) < 0 && a5 || v29 < *(&v40) && a5) { do_close(a0, *(&v23), *(&v25)); free(*(&v23)); if (v22 != -1) close(v22); v47 = -1; } } } } return v47; }
openssh-portable
angr_dream
static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb) { __u32 table = r->rtm_table; if (tb[RTA_TABLE]) table = rta_getattr_u32(tb[RTA_TABLE]); return table; }
int rtm_get_table(struct_1 *a0, struct_0 *a1) { unsigned int v0; v0 = a0->field_4; if (a1->field_78) { v0 = rta_getattr_u32(a1->field_78); return v0; } return v0; }
iproute2-6.0.0
angr_sailr
void rl_cleanup_after_signal(void) {}
long long rl_cleanup_after_signal() { unsigned long v1; return v1; }
libedit
angr_sailr
int _rl_isearch_cleanup(_rl_search_cxt *cxt, int r) { if (r >= 0) _rl_isearch_fini(cxt); _rl_scxt_dispose(cxt, 0); _rl_iscxt = 0; (rl_readline_state &= ~(0x0000080)); return (r != 0); }
void _rl_isearch_cleanup(void *a0, unsigned long long a1, unsigned long long a2, unsigned long long a3, unsigned long long a4, unsigned long long a5) { unsigned long long v1; unsigned long v2; if (a1 >= 0) _rl_isearch_fini(a0, a1, a2, a3, a4, a5); _rl_scxt_dispose(a0, 0x0); _rl_iscxt = 0; v1 = rl_readline_state; *(&v1) = rl_readline_state & 127; rl_readline_state = v1; v2 = a1; return; }
bash
angr_dream
static int extmatch(xc, s, se, p, pe, flags) int xc; unsigned char *s, *se; unsigned char *p, *pe; int flags; { unsigned char *prest; unsigned char *psub; unsigned char *pnext; unsigned char *srest; int m1, m2, xflags; prest = glob_patscan(p + (*p == '('), pe, 0); if (prest == 0) return (strcompare(p - 1, pe, s, se)); switch (xc) { case '+': case '*': if (xc == '*' && (gmatch(s, se, prest, pe, ((void *)0), flags) == 0)) return 0; for (psub = p + 1;; psub = pnext) { pnext = glob_patscan(psub, pe, '|'); for (srest = s; srest <= se; srest++) { m1 = gmatch(s, srest, psub, pnext - 1, ((void *)0), flags) == 0; if (m1) { xflags = (srest > s) ? (flags & ~((1 << 2) | (1 << 7))) : flags; m2 = (gmatch(srest, se, prest, pe, ((void *)0), xflags) == 0) || (s != srest && gmatch(srest, se, p - 1, pe, ((void *)0), xflags) == 0); } if (m1 && m2) return (0); } if (pnext == prest) break; } return (1); case '?': case '@': if (xc == '?' && (gmatch(s, se, prest, pe, ((void *)0), flags) == 0)) return 0; for (psub = p + 1;; psub = pnext) { pnext = glob_patscan(psub, pe, '|'); srest = (prest == pe) ? se : s; for (; srest <= se; srest++) { xflags = (srest > s) ? (flags & ~((1 << 2) | (1 << 7))) : flags; if (gmatch(s, srest, psub, pnext - 1, ((void *)0), flags) == 0 && gmatch(srest, se, prest, pe, ((void *)0), xflags) == 0) return (0); } if (pnext == prest) break; } return (1); case '!': for (srest = s; srest <= se; srest++) { m1 = 0; for (psub = p + 1;; psub = pnext) { pnext = glob_patscan(psub, pe, '|'); if (m1 = (gmatch(s, srest, psub, pnext - 1, ((void *)0), flags) == 0)) break; if (pnext == prest) break; } if (m1 == 0 && (flags & (1 << 2)) && *s == '.') return (1); if (m1 == 0 && (flags & (1 << 7)) && ((s[0] == '.' && (s[1] == 0 || (s[1] == '.' && s[2] == 0))) || ((flags & (1 << 0)) && s[-1] == '/' && (s[0] == '.' && ((((s[1]) == '/') || (s[1]) == 0) || (s[1] == '.' && (((s[2]) == '/') || (s[2]) == 0))))))) return (1); xflags = (srest > s) ? (flags & ~((1 << 2) | (1 << 7))) : flags; if (m1 == 0 && gmatch(srest, se, prest, pe, ((void *)0), xflags) == 0) return (0); } return (1); } return (1); }
_BOOL8 extmatch(int a1, char *a2, char *a3, _BYTE *a4, char *a5, unsigned int a6) { unsigned char *k; _BOOL4 v8; unsigned int v9; _BOOL4 v10; unsigned char *i; char *v12; unsigned int v13; unsigned char *ii; _BOOL4 v15; unsigned int v16; _BOOL4 v21; unsigned int v22; unsigned int v23; _BOOL4 v24; _BOOL4 v25; char *v26; char *v27; char *v28; unsigned char *m; unsigned char *j; unsigned char *n; unsigned char *v32; unsigned char *v33; unsigned char *v34; unsigned char *v35; v32 = glob_patscan(&a4[*a4 == 40], (unsigned char *)a5, 0); if (!v32) return strcompare(a4 - 1, a5, a2, a3); if (a1 > 64) return 1LL; if (a1 >= 63) { if (a1 != 63 || gmatch((unsigned char *)a2, (unsigned char *)a3, (char *)v32, a5, 0LL, a6)) { v27 = a4 + 1; for (i = glob_patscan(a4 + 1, (unsigned char *)a5, 124);; i = glob_patscan(v34, (unsigned char *)a5, 124)) { v34 = i; v12 = v32 == (unsigned char *)a5 ? a3 : a2; for (j = (unsigned char *)v12; j <= (unsigned char *)a3; ++j) { v13 = a6; if (j > (unsigned char *)a2) LOBYTE(v13) = a6 & 0x7B; v23 = v13; if (!gmatch((unsigned char *)a2, j, v27, (char *)v34 - 1, 0LL, a6) && !gmatch(j, (unsigned char *)a3, (char *)v32, a5, 0LL, v23)) { return 0LL; } } if (v34 == v32) break; v27 = (char *)v34; } return 1LL; } else { return 0LL; } } else { if (a1 != 33) { if (a1 >= 33 && (unsigned int)(a1 - 42) <= 1) { if (a1 == 42 && !gmatch((unsigned char *)a2, (unsigned char *)a3, (char *)v32, a5, 0LL, a6)) return 0LL; v26 = a4 + 1; for (k = glob_patscan(a4 + 1, (unsigned char *)a5, 124);; k = glob_patscan(v33, (unsigned char *)a5, 124)) { v33 = k; for (m = (unsigned char *)a2; m <= (unsigned char *)a3; ++m) { v8 = gmatch((unsigned char *)a2, m, v26, (char *)v33 - 1, 0LL, a6); v24 = !v8; if (!v8) { v9 = a6; if (m > (unsigned char *)a2) LOBYTE(v9) = a6 & 0x7B; v22 = v9; v10 = !gmatch(m, (unsigned char *)a3, (char *)v32, a5, 0LL, v9) || a2 != (char *)m && !gmatch(m, (unsigned char *)a3, a4 - 1, a5, 0LL, v22); v21 = v10; } if (v24 && v21) return 0LL; } if (v33 == v32) break; v26 = (char *)v33; } return 1LL; } return 1LL; } for (n = (unsigned char *)a2; n <= (unsigned char *)a3; ++n) { v28 = a4 + 1; for (ii = glob_patscan(a4 + 1, (unsigned char *)a5, 124);; ii = glob_patscan(v35, (unsigned char *)a5, 124)) { v35 = ii; v15 = gmatch((unsigned char *)a2, n, v28, (char *)ii - 1, 0LL, a6); v25 = !v15; if (!v15 || v35 == v32) break; v28 = (char *)v35; } if (v15 && (a6 & 4) != 0 && *a2 == 46) return 1LL; if (v15 && (a6 & 0x80) != 0 && (*a2 == 46 && (!a2[1] || a2[1] == 46 && !a2[2]) || (a6 & 1) != 0 && *(a2 - 1) == 47 && *a2 == 46 && (a2[1] == 47 || !a2[1] || a2[1] == 46 && (a2[2] == 47 || !a2[2])))) { return 1LL; } v16 = a6; if (n > (unsigned char *)a2) LOBYTE(v16) = a6 & 0x7B; if (!v25 && !gmatch(n, (unsigned char *)a3, (char *)v32, a5, 0LL, v16)) return 0LL; } return 1LL; } }
bash
ida
int note_err(const char *, ...) __attribute__((__format__(printf, 1, 2))); void verifydir(char *); struct passwd *pwd; uid_t userid; int errs, remin, remout, remin2, remout2; int Tflag, pflag, iamremote, iamrecursive, targetshouldbedirectory; char cmd[64]; enum scp_mode_e { MODE_SCP, MODE_SFTP };
void note_err(unsigned long long a0, unsigned long a1, unsigned long a2) { unsigned int v0; unsigned int v1; unsigned long v2; unsigned long v3; unsigned long v4; char v5; unsigned long v6; unsigned long v7; unsigned long v8; unsigned long v9; unsigned long v10; int v11; int v12; int v13; int v14; int v15; int v16; int v17; int 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; void *v33; unsigned long long v34; unsigned long long v35; unsigned long long v36; v6 = a1; v7 = a2; v8 = v20; v9 = v21; v10 = v22; if (v23) { v11 = v24; v12 = v25; v13 = v26; v14 = v27; v15 = v28; v16 = v29; v17 = v30; v18 = v31; } v4 = v32[5]; if (a0) { targetshouldbedirectory = __addvsi3(0x10ec8348e5894855, 0x1); if (emsg.8360) { v34 = 4294967295; } else { v0 = 8; v1 = 48; v2 = &v19; v3 = &v5; vasnmprintf(&emsg.8360, 0x7fffffff, 0x0, a0, &v0); v36 = 4294967295; } } else if (!emsg.8360) { v33 = 0; } else { run_err(); free(emsg.8360); emsg.8360 = 0; v35 = 4294967295; } if (!(v4 ^ v32[5])) return; __stack_chk_fail(); }
openssh-portable
angr_sailr
static inline void emit_mandatory_arg_note(void) { fputs_unlocked(gettext("\nMandatory arguments to long options are mandatory " "for short options too.\n"), stdout) ; }
void emit_mandatory_arg_note() { unsigned long long v1; v1 = fputs_unlocked(gettext("\nMandatory arguments to long options are " "mandatory for short options too.\n"), stdout); return; }
coreutils
angr_sailr
static int do_rmmod(int argc, char *argv[]) { struct kmod_ctx *ctx; const char *null_config = ((void *)0); int flags = 0; int i, err, r = 0; for (;;) { int c, idx = 0; c = getopt_long(argc, argv, cmdopts_s, cmdopts, &idx); if (c == -1) break; switch (c) { case 'f': flags |= KMOD_REMOVE_FORCE; break; case 's': use_syslog = 1; break; case 'v': verbose++; break; case 'h': help(); return 0; case 'V': puts("kmod" " version " "30"); puts("-ZSTD -XZ -ZLIB -LIBCRYPTO -EXPERIMENTAL"); return 0; case '?': return 1; default: log_printf(3, "unexpected getopt_long() value '%c'.\n", c); return 1; } } log_open(use_syslog); if (optind >= argc) { log_printf(3, "missing module name.\n"); r = 1; goto done; } ctx = kmod_new(((void *)0), &null_config); if (!ctx) { log_printf(3, "kmod_new() failed!\n"); r = 1; goto done; } log_setup_kmod_log(ctx, verbose); for (i = optind; i < argc; i++) { struct kmod_module *mod; const char *arg = argv[i]; struct stat st; if (stat(arg, &st) == 0) err = kmod_module_new_from_path(ctx, arg, &mod); else err = kmod_module_new_from_name(ctx, arg, &mod); if (err < 0) { log_printf(3, "could not use module %s: %s\n", arg, strerror(-err)); break; } if (!(flags & KMOD_REMOVE_FORCE) && check_module_inuse(mod) < 0) { r++; goto next; } err = kmod_module_remove_module(mod, flags); if (err < 0) { log_printf(3, "could not remove module %s: %s\n", arg, strerror(-err)); r++; } next: kmod_module_unref(mod); } kmod_unref(ctx); done: log_close(); return r == 0 ? 0 : 1; }
long long do_rmmod(unsigned long a0, unsigned long long *a1) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; void *v5; unsigned int v6; unsigned long long v7; char *v8; char v9; unsigned long long v11; unsigned long long v12; v5 = 0; v0 = 0; v3 = 0; while (true) { v6 = 0; v4 = getopt_long(a0, a1, "fsvVwh", &cmdopts, &v6); if (v4 == -1) { log_open(use_syslog); if (a0 <= optind) { log_printf(0x3, "missing module name.\n", "fsvVwh"); v3 = 1; } else { v7 = kmod_new(0x0, &v5); if (!v7) { log_printf(0x3, "kmod_new() failed!\n", "fsvVwh"); v3 = 1; } else { log_setup_kmod_log(v7, verbose, verbose); v1 = optind; while (true) { if (v1 >= a0) break; v8 = a1[v1]; if (!stat(v8, &v9)) v2 = kmod_module_new_from_path(v7, v8, &v6, v8); else v2 = kmod_module_new_from_name(v7, v8, &v6, v8); if (v2 >= 0) { if ((v0 & 0x200) || check_module_inuse(*(&v6), a1, v12) >= 0) { v2 = kmod_module_remove_module(*(&v6), v0, v0); if (v2 < 0) { strerror(-(v2)); log_printf(0x3, "could not remove module %s: %s\n", v8); v3 += 1; } } else { v3 += 1; } kmod_module_unref(*(&v6)); v1 += 1; } else { strerror(-(v2)); log_printf(0x3, "could not use module %s: %s\n", v8); break; } } kmod_unref(v7); } } log_close(); v11 = v3; break; } else if (v4 != 63) { if (v4 < 63) goto LABEL_400771; if (!(v4 <= 118)) goto LABEL_400771; if (v4 < 86) goto LABEL_400771; switch (v4) { case 86: puts("kmod version 30"); puts("-ZSTD -XZ -ZLIB -LIBCRYPTO -EXPERIMENTAL"); v11 = 0; break; case 102: v0 |= 0x200; goto LABEL_400799; case 104: help(); v11 = 0; break; case 115: use_syslog = 1; goto LABEL_400799; case 118: verbose = verbose + 1; goto LABEL_400799; default: LABEL_400771: log_printf(0x3, "unexpected getopt_long() value '%c'.\n", v4); v11 = 1; break; } LABEL_400799: } else { v11 = 1; break; } } return v11; }
kmod
angr_sailr
static inline _Bool is_addrtype_inet_not_unspec(const inet_prefix *p) { return (p->flags & ADDRTYPE_INET_UNSPEC) == ADDRTYPE_INET; }
int is_addrtype_inet_not_unspec(unsigned short *a0) { unsigned int v1; v1 = *(a0) & 6; *(&v1) = (*(a0) & 6) == 2; return v1; }
iproute2-6.0.0
angr_sailr
int testcmd(int argc, char **argv) { const struct t_op *op; enum token n; int res = 1; if (*argv[0] == '[') { if (*argv[--argc] != ']') sh_error("missing ]"); argv[argc] = ((void *)0); } t_wp_op = ((void *)0); recheck: argv++; argc--; if (argc < 1) return res; switch (argc) { case 3: op = getop(argv[1]); if (op && op->op_type == BINOP) { n = OPERAND; goto eval; } case 4: if (!strcmp(argv[0], "(") && !strcmp(argv[argc - 1], ")")) { argv[--argc] = ((void *)0); argv++; argc--; } else if (!strcmp(argv[0], "!")) { res = 0; goto recheck; } } n = t_lex(argv); eval: t_wp = argv; res ^= oexpr(n); argv = t_wp; if (argv[0] != ((void *)0) && argv[1] != ((void *)0)) syntax(argv[0], "unexpected operator"); return res; }
uint testcmd(int param_1, char **param_2) { int iVar1; char **ppcVar2; int iVar3; uint uVar4; long lVar5; char **local_28; int local_1c; undefined4 local_18; uint local_14; local_14 = 1; local_1c = param_1; if (**param_2 == '[') { local_1c = param_1 + -1; if (*param_2[local_1c] != ']') { sh_error("missing ]"); } param_2[local_1c] = (char *)0x0; } t_wp_op = 0; local_28 = param_2; do { ppcVar2 = local_28 + 1; iVar1 = local_1c + -1; if (iVar1 < 1) { return local_14; } if (iVar1 != 3) { if (iVar1 == 4) goto LAB_0010015b; LAB_001001ef: local_28 = ppcVar2; local_18 = t_lex(local_28); LAB_001001fe: t_wp = local_28; uVar4 = oexpr(local_18); local_14 = local_14 ^ uVar4; if (*t_wp == (char *)0x0) { return local_14; } if (t_wp[1] == (char *)0x0) { return local_14; } syntax(*t_wp, "unexpected operator"); return local_14; } lVar5 = getop(local_28[2]); if ((lVar5 != 0) && (*(short *)(lVar5 + 10) == 1)) { local_18 = 0x27; local_28 = ppcVar2; goto LAB_001001fe; } LAB_0010015b: iVar3 = strcmp(*ppcVar2, "("); if ((iVar3 == 0) && (iVar3 = strcmp(ppcVar2[(long)iVar1 + -1], ")"), iVar3 == 0)) { ppcVar2[local_1c + -2] = (char *)0x0; ppcVar2 = local_28 + 2; goto LAB_001001ef; } iVar3 = strcmp(*ppcVar2, "!"); if (iVar3 != 0) goto LAB_001001ef; local_14 = 0; local_28 = ppcVar2; local_1c = iVar1; } while (true); }
dash-0.5.11+git20210903+057cd650a4ed
ghidra
static void open_group_files(void) { if (gr_lock() == 0) { fprintf(stderr, gettext("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname()); fail_exit(10); } gr_locked = 1; if (gr_open(0100 | 02) == 0) { fprintf(stderr, gettext("%s: cannot open %s\n"), Prog, gr_dbname()); fail_exit(10); } if (is_shadow_grp) { if (sgr_lock() == 0) { fprintf(stderr, gettext("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname()); fail_exit(10); } sgr_locked = 1; if (sgr_open(0100 | 02) == 0) { fprintf(stderr, gettext("%s: cannot open %s\n"), Prog, sgr_dbname()); fail_exit(10); } } }
void open_group_files() { unsigned long long v1; unsigned long long v2; unsigned long long v3; unsigned long long v5; unsigned long long v6; if (!gr_lock()) { v1 = gr_dbname(); fprintf(*(&stderr), gettext("%s: cannot lock %s; try again later.\n")); fail_exit(0xa); } gr_locked = 1; if (!gr_open(0x42)) { v3 = gr_dbname(); fprintf(*(&stderr), gettext("%s: cannot open %s\n")); fail_exit(0xa); } v2 = is_shadow_grp; if (!is_shadow_grp) { return; } else if (!sgr_lock()) { v5 = sgr_dbname(); fprintf(*(&stderr), gettext("%s: cannot lock %s; try again later.\n")); fail_exit(0xa); } else { sgr_locked = 1; if (!sgr_open(0x42)) { v6 = sgr_dbname(); fprintf(*(&stderr), gettext("%s: cannot open %s\n")); fail_exit(0xa); } return; } }
shadow
angr_sailr
int mm_answer_keyverify(struct ssh *ssh, int sock, struct sshbuf *m) { struct sshkey *key; const u_char *signature, *data, *blob; char *sigalg = ((void *)0), *fp = ((void *)0); size_t signaturelen, datalen, bloblen; int r, ret, req_presence = 0, req_verify = 0, valid_data = 0; int encoded_ret; struct sshkey_sig_details *sig_details = ((void *)0); if ((r = sshbuf_get_string_direct(m, &blob, &bloblen)) != 0 || (r = sshbuf_get_string_direct(m, &signature, &signaturelen)) != 0 || (r = sshbuf_get_string_direct(m, &data, &datalen)) != 0 || (r = sshbuf_get_cstring(m, &sigalg, ((void *)0))) != 0) sshfatal("monitor.c", __func__, 1407, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse"); if (hostbased_cuser == ((void *)0) || hostbased_chost == ((void *)0) || !monitor_allowed_key(blob, bloblen)) sshfatal("monitor.c", __func__, 1411, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "bad key, not previously allowed"); if (*sigalg == '\0') { free(sigalg); sigalg = ((void *)0); } if ((r = sshkey_from_blob(blob, bloblen, &key)) != 0) sshfatal("monitor.c", __func__, 1421, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "parse key"); switch (key_blobtype) { case MM_USERKEY: valid_data = monitor_valid_userblob(ssh, data, datalen); auth_method = "publickey"; break; case MM_HOSTKEY: valid_data = monitor_valid_hostbasedblob(data, datalen, hostbased_cuser, hostbased_chost); auth_method = "hostbased"; break; default: valid_data = 0; break; } if (!valid_data) sshfatal("monitor.c", __func__, 1438, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "bad %s signature data blob", key_blobtype == MM_USERKEY ? "userkey" : (key_blobtype == MM_HOSTKEY ? "hostkey" : "unknown")) ; if ((fp = sshkey_fingerprint(key, options.fingerprint_hash, SSH_FP_DEFAULT)) == ((void *)0)) sshfatal("monitor.c", __func__, 1444, 1, SYSLOG_LEVEL_FATAL, ((void *)0), "sshkey_fingerprint failed"); ret = sshkey_verify(key, signature, signaturelen, data, datalen, sigalg, ssh->compat, &sig_details); sshlog("monitor.c", __func__, 1448, 1, SYSLOG_LEVEL_DEBUG3, ((void *)0), "%s %s signature using %s %s%s%s", auth_method, sshkey_type(key), sigalg == ((void *)0) ? "default" : sigalg, (ret == 0) ? "verified" : "unverified", (ret != 0) ? ": " : "", (ret != 0) ? ssh_err(ret) : "") ; if (ret == 0 && key_blobtype == MM_USERKEY && sig_details != ((void *)0)) { req_presence = (options.pubkey_auth_options & (1)) || !key_opts->no_require_user_presence; if (req_presence && (sig_details->sk_flags & 0x01) == 0) { sshlog("monitor.c", __func__, 1459, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "public key %s %s signature for %s%s from %.128s " "port %d rejected: user presence " "(authenticator touch) requirement not met ", sshkey_type(key), fp, authctxt->valid ? "" : "invalid user ", authctxt->user, ssh_remote_ipaddr(ssh), ssh_remote_port(ssh)) ; ret = -21; } req_verify = (options.pubkey_auth_options & (1 << 1)) || key_opts->require_verify; if (req_verify && (sig_details->sk_flags & 0x04) == 0) { sshlog("monitor.c", __func__, 1472, 0, SYSLOG_LEVEL_ERROR, ((void *)0), "public key %s %s signature for %s%s from %.128s " "port %d rejected: user verification requirement " "not met ", sshkey_type(key), fp, authctxt->valid ? "" : "invalid user ", authctxt->user, ssh_remote_ipaddr(ssh), ssh_remote_port(ssh)) ; ret = -21; } } auth2_record_key(authctxt, ret == 0, key); if (key_blobtype == MM_USERKEY) auth_activate_options(ssh, key_opts); monitor_reset_key_state(); sshbuf_reset(m); encoded_ret = (ret != 0); if ((r = sshbuf_put_u32(m, encoded_ret)) != 0 || (r = sshbuf_put_u8(m, sig_details != ((void *)0))) != 0) sshfatal("monitor.c", __func__, 1493, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "assemble"); if (sig_details != ((void *)0)) { if ((r = sshbuf_put_u32(m, sig_details->sk_counter)) != 0 || (r = sshbuf_put_u8(m, sig_details->sk_flags)) != 0) sshfatal("monitor.c", __func__, 1497, 1, SYSLOG_LEVEL_FATAL, ssh_err(r), "assemble sk"); } sshkey_sig_details_free(sig_details); mm_request_send(sock, MONITOR_ANS_KEYVERIFY, m); free(sigalg); free(fp); sshkey_free(key); return ret == 0; }
_BOOL8 mm_answer_keyverify(long a1, unsigned int a2, long a3) { long v3; long v4; const char *v5; const char *v6; const char *v7; const char *v8; const char *v9; const char *v10; _BOOL4 v11; long v12; const char *v13; const char *v14; const char *v15; const char *v16; _BOOL4 v17; long v18; const char *v19; const char *v20; const char *v21; const char *v22; long v23; long v24; unsigned int string_direct; unsigned int v28; unsigned int v29; unsigned int v30; unsigned int v31; _BOOL4 valid; long v33; long v34; long v35; long v36; void *ptr; long v38; long v39; long v40; unsigned int *v41; void *v42; unsigned long v43; v43 = __readfsqword(0x28u); ptr = 0LL; v42 = 0LL; v41 = 0LL; string_direct = sshbuf_get_string_direct(a3, &v36, &v40); if (string_direct || (string_direct = sshbuf_get_string_direct(a3, &v34, &v38)) != 0 || (string_direct = sshbuf_get_string_direct(a3, &v35, &v39)) != 0 || (string_direct = sshbuf_get_cstring(a3, &ptr, 0LL)) != 0) { v3 = ssh_err(string_direct); sshfatal("monitor.c", "mm_answer_keyverify", 1407LL, 1LL, 1LL, v3, "parse"); } if (!hostbased_cuser || !hostbased_chost || !monitor_allowed_key(v36, v40)) sshfatal("monitor.c", "mm_answer_keyverify", 1411LL, 1LL, 1LL, 0LL, "bad key, not previously allowed"); if (!*(_BYTE *)ptr) { free(ptr); ptr = 0LL; } v28 = sshkey_from_blob(v36, v40, &v33); if (v28) { v4 = ssh_err(v28); sshfatal("monitor.c", "mm_answer_keyverify", 1421LL, 1LL, 1LL, v4, "parse key"); } if (key_blobtype == 1) { valid = monitor_valid_hostbasedblob(v35, v39, (const char *)hostbased_cuser, (const char *)hostbased_chost); auth_method = "hostbased"; } else if (key_blobtype == 2) { valid = monitor_valid_userblob(a1, v35, v39); auth_method = "publickey"; } else { valid = 0; } if (!valid) { if (key_blobtype == 2) { v5 = "userkey"; } else if (key_blobtype == 1) { v5 = "hostkey"; } else { v5 = "unknown"; } sshfatal("monitor.c", "mm_answer_keyverify", 1438LL, 1LL, 1LL, 0LL, "bad %s signature data blob", v5); } v42 = (void *)sshkey_fingerprint(v33, options[1962], 0LL); if (!v42) sshfatal("monitor.c", "mm_answer_keyverify", 1444LL, 1LL, 1LL, 0LL, "sshkey_fingerprint failed"); v31 = sshkey_verify(v33, v34, v38, v35, v39, ptr, *(unsigned int *)(a1 + 2108), &v41); if (v31) v6 = (const char *)ssh_err(v31); else v6 = (const char *)&unk_63A3; if (v31) v7 = ": "; else v7 = (const char *)&unk_63A3; if (v31) v8 = "unverified"; else v8 = "verified"; if (ptr) v9 = (const char *)ptr; else v9 = "default"; v10 = (const char *)sshkey_type(v33); sshlog("monitor.c", "mm_answer_keyverify", 1448LL, 1LL, 7LL, 0LL, "%s %s signature using %s %s%s%s", auth_method, v10, v9, v8, v7, v6); if (!v31 && key_blobtype == 2 && v41) { v11 = (options[328] & 1) != 0 || !*(_DWORD *)(key_opts + 128); if (v11 && (v41[1] & 1) == 0) { v12 = (unsigned int)ssh_remote_port(a1); v13 = (const char *)ssh_remote_ipaddr(a1); v14 = (const char *)*((_QWORD *)authctxt + 4); if (*((_DWORD *)authctxt + 3)) v15 = (const char *)&unk_63A3; else v15 = "invalid user "; v16 = (const char *)sshkey_type(v33); sshlog( "monitor.c", "mm_answer_keyverify", 1459LL, 0LL, 2LL, 0LL, "public key %s %s signature for %s%s from %.128s port %d rejected: " "user presence (authenticator touch) requirement not met ", v16, (const char *)v42, v15, v14, v13, v12); v31 = -21; } v17 = (options[328] & 2) != 0 || *(_DWORD *)(key_opts + 132); if (v17 && (v41[1] & 4) == 0) { v18 = (unsigned int)ssh_remote_port(a1); v19 = (const char *)ssh_remote_ipaddr(a1); v20 = (const char *)*((_QWORD *)authctxt + 4); if (*((_DWORD *)authctxt + 3)) v21 = (const char *)&unk_63A3; else v21 = "invalid user "; v22 = (const char *)sshkey_type(v33); sshlog("monitor.c", "mm_answer_keyverify", 1472LL, 0LL, 2LL, 0LL, "public key %s %s signature for %s%s from %.128s port %d " "rejected: user verification requirement not met ", v22, (const char *)v42, v21, v20, v19, v18); v31 = -21; } } auth2_record_key(authctxt, v31 == 0, v33); if (key_blobtype == 2) auth_activate_options(a1, key_opts); monitor_reset_key_state(); sshbuf_reset(a3); v29 = sshbuf_put_u32(a3, v31 != 0); if (v29 || (v29 = sshbuf_put_u8(a3, v41 != 0LL)) != 0) { v23 = ssh_err(v29); sshfatal("monitor.c", "mm_answer_keyverify", 1493LL, 1LL, 1LL, v23, "assemble"); } if (v41) { v30 = sshbuf_put_u32(a3, *v41); if (v30 || (v30 = sshbuf_put_u8(a3, *((unsigned char *)v41 + 4))) != 0) { v24 = ssh_err(v30); sshfatal("monitor.c", "mm_answer_keyverify", 1497LL, 1LL, 1LL, v24, "assemble sk"); } } sshkey_sig_details_free(v41); mm_request_send(a2, 25LL, a3); free(ptr); free(v42); sshkey_free(v33); return v31 == 0; }
openssh-portable
ida
void _rl_set_insert_mode(int im, int force) { rl_insert_mode = im; }
void _rl_set_insert_mode(undefined4 param_1) { rl_insert_mode = param_1; return; }
bash
ghidra
static inline void emit_ancillary_info(char const *program) { struct infomap { char const *program; char const *node; } const infomap[] = { {"[", "test invocation"}, {"coreutils", "Multi-call invocation"}, {"sha224sum", "sha2 utilities"}, {"sha256sum", "sha2 utilities"}, {"sha384sum", "sha2 utilities"}, {"sha512sum", "sha2 utilities"}, {((void *)0), ((void *)0)}}; char const *node = program; struct infomap const *map_prog = infomap; while (map_prog->program && !(strcmp(program, map_prog->program) == 0)) map_prog++; if (map_prog->node) node = map_prog->node; printf (gettext ("\n%s online help: <%s>\n"), "GNU coreutils", "https: char const *lc_messages = setlocale ( 5 , ((void *)0) ); if (lc_messages && strncmp (lc_messages, "" "en_" "", sizeof ("en_") - 1)) { fputs_unlocked (gettext ("Report any translation bugs to " "<https: stdout ) ; } char const *url_program = (strcmp (program, "[") == 0) ? "test" : program; printf (gettext ("Full documentation <%s%s>\n"), "https: printf (gettext ("or available locally via: info '(coreutils) %s%s'\n"), node, node == program ? " invocation" : ""); }
void emit_ancillary_info(char *param_1) { FILE *__stream; int iVar1; char *pcVar2; char *pcVar3; long in_FS_OFFSET; char *local_b8; char **local_b0; char *local_98; char *local_90; char *local_88; char *local_80; char *local_78; char *local_70; char *local_68; char *local_60; char *local_58; char *local_50; char *local_48; char *local_40; undefined8 local_38; undefined8 local_30; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); local_98 = "["; local_90 = "test invocation"; local_88 = "coreutils"; local_80 = "Multi-call invocation"; local_78 = "sha224sum"; local_70 = "sha2 utilities"; local_68 = "sha256sum"; local_60 = "sha2 utilities"; local_58 = "sha384sum"; local_50 = "sha2 utilities"; local_48 = "sha512sum"; local_40 = "sha2 utilities"; local_38 = 0; local_30 = 0; local_b0 = &local_98; while ((*local_b0 != (char *)0x0 && (iVar1 = strcmp(param_1, *local_b0), iVar1 != 0))) { local_b0 = local_b0 + 2; } local_b8 = param_1; if (local_b0[1] != (char *)0x0) { local_b8 = local_b0[1]; } pcVar2 = (char *)gettext("\n%s online help: <%s>\n"); printf(pcVar2,"GNU coreutils","https: pcVar2 = setlocale(5,(char *)0x0); if ((pcVar2 != (char *)0x0) && (iVar1 = strncmp(pcVar2,"en_",3), __stream = stdout, iVar1 != 0)) { pcVar2 = (char *)gettext("Report any translation bugs to <https: ); fputs_unlocked(pcVar2, __stream); } iVar1 = strcmp(param_1,"["); pcVar2 = param_1; if (iVar1 == 0) { pcVar2 = "test"; } pcVar3 = (char *)gettext("Full documentation <%s%s>\n"); printf(pcVar3,"https: if (local_b8 == param_1) { pcVar2 = " invocation"; } else { pcVar2 = ""; } pcVar3 = (char *)gettext("or available locally via: info \'(coreutils) %s%s\'\n"); printf(pcVar3,local_b8,pcVar2); if (local_20 == *(long *)(in_FS_OFFSET + 0x28)) { return; } __stack_chk_fail(); }
coreutils
ghidra
static void run_status_loggers(struct invoke_list *hook_list) { struct invoke_hook *hook; for (hook = hook_list->head; hook; hook = hook->next) { int fd; fd = run_logger(hook, gettext("status logger")); statusfd_add(fd); } }
void run_status_loggers(unsigned long long *a0, unsigned long a1, unsigned long a2, unsigned long long a3, unsigned long long a4, unsigned long long a5) { unsigned int v0; unsigned long long *v1; unsigned long long v3; unsigned long long v4; unsigned long long v5; v3 = *(a0); for (v1 = *(a0); v1; v1 = *(v1)) { v4 = gettext("status logger"); v0 = run_logger(v1, v4, v4, a3, a4, a5); statusfd_add(v0); v5 = *(v1); } return; }
dpkg
angr_sailr
void xheader_write_global(struct xheader *xhdr) { if (keyword_global_override_list) { struct keyword_list *kp; xheader_init(xhdr); for (kp = keyword_global_override_list; kp; kp = kp->next) code_string(kp->value, kp->pattern, xhdr); } if (xhdr->stk) { char *name; xheader_finish(xhdr); name = xheader_ghdr_name(); xheader_write('g', name, start_time.tv_sec, xhdr); free(name); } }
long long xheader_write_global(unsigned long long *a0) { unsigned long long v0[3]; void *v1; unsigned long long v3; if (keyword_global_override_list) { xheader_init(a0); for (v0[0] = keyword_global_override_list; v0; v0[0] = v0[0]) { code_string(v0[2], v0[1], a0); } } v3 = *(a0); if (*(a0)) { xheader_finish(a0); v1 = xheader_ghdr_name(); xheader_write(0x67, v1, start_time, a0); v3 = free(v1); return v3; } return v3; }
tar
angr_sailr
int main(int argc, char **argv) { mode_t newmode; char const *specified_mode = ((void *)0); int exit_status = 0; int optc; char const *scontext = ((void *)0); struct selabel_handle *set_security_context = ((void *)0); ; set_program_name(argv[0]); setlocale(6, ""); bindtextdomain("coreutils", "/usr/local/share/locale"); textdomain("coreutils"); atexit(close_stdout); while ((optc = getopt_long(argc, argv, "m:Z", longopts, ((void *)0))) != -1) { switch (optc) { case 'm': specified_mode = optarg; break; case 'Z': if (is_smack_enabled()) { scontext = optarg; } else if (is_selinux_enabled() > 0) { if (optarg) scontext = optarg; else { set_security_context = selabel_open(0, ((void *)0), 0); if (!set_security_context) error(0, (*__errno_location()), gettext("warning: ignoring --context")); } } else if (optarg) { error(0, 0, gettext("warning: ignoring --context; " "it requires an SELinux/SMACK-enabled kernel")); } break; case GETOPT_HELP_CHAR: usage(0); break; ; case GETOPT_VERSION_CHAR: version_etc(stdout, "mkfifo", "GNU coreutils", Version, ("David MacKenzie"), (char *)((void *)0)); exit(0); break; ; default: usage(1); } } if (optind == argc) { error(0, 0, gettext("missing operand")); usage(1); } if (scontext) { int ret = 0; if (is_smack_enabled()) ret = smack_set_label_for_self(scontext); else ret = setfscreatecon(scontext); if (ret < 0) ((!!sizeof(struct { _Static_assert(1, "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), gettext " "(\"failed to set default file creation context to " "%s\"), quote (scontext)), assume (false))" ")"); int _gl_dummy; })) ? ((error( 1, (*__errno_location()), gettext("failed to set default file creation context to %s"), quote(scontext)), ((0) ? (void)0 : __builtin_unreachable()))) : ((error( 1, (*__errno_location()), gettext("failed to set default file creation context to %s"), quote(scontext)), ((0) ? (void)0 : __builtin_unreachable())))) ; } newmode = (0400 | 0200 | (0400 >> 3) | (0200 >> 3) | ((0400 >> 3) >> 3) | ((0200 >> 3) >> 3)); if (specified_mode) { mode_t umask_value; struct mode_change *change = mode_compile(specified_mode); if (!change) ((!!sizeof(struct { _Static_assert( 1, "verify_expr (" "1" ", " "(error (1, 0, gettext (\"invalid mode\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, 0, gettext("invalid mode")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, 0, gettext("invalid mode")), ((0) ? (void)0 : __builtin_unreachable())))); umask_value = umask(0); umask(umask_value); newmode = mode_adjust(newmode, 0, umask_value, change, ((void *)0)); free(change); if (newmode & ~((0400 | 0200 | 0100) | ((0400 | 0200 | 0100) >> 3) | (((0400 | 0200 | 0100) >> 3) >> 3))) ((!!sizeof(struct { _Static_assert(1, "verify_expr (" "1" ", " "(error (1, 0, gettext (\"mode must specify only " "file permission bits\")), assume (false))" ")"); int _gl_dummy; })) ? ((error(1, 0, gettext("mode must specify only file permission bits")), ((0) ? (void)0 : __builtin_unreachable()))) : ((error(1, 0, gettext("mode must specify only file permission bits")), ((0) ? (void)0 : __builtin_unreachable())))); } for (; optind < argc; ++optind) { if (set_security_context) defaultcon(set_security_context, argv[optind], 0010000); if (mkfifo(argv[optind], newmode) != 0) { error(0, (*__errno_location()), gettext("cannot create fifo %s"), quotearg_style(shell_escape_always_quoting_style, argv[optind])); exit_status = 1; } else if (specified_mode && lchmod(argv[optind], newmode) != 0) { error(0, (*__errno_location()), gettext("cannot set permissions of %s"), quotearg_style(shell_escape_always_quoting_style, argv[optind])); exit_status = 1; } } return exit_status; }
int main(unsigned long a0, unsigned long long *a1) { unsigned int v0; unsigned int v1; unsigned int v2; unsigned int v3; unsigned int v4; void *v5; void *v6; void *v7; void *v8; unsigned long long v13; unsigned long long v16; unsigned long long v17; v5 = 0; v1 = 0; v6 = 0; v7 = 0; set_program_name(*(a1)); setlocale(0x6, &g_400a7b); bindtextdomain("coreutils", "/usr/local/share/locale"); textdomain("coreutils"); atexit(got.close_stdout); while (true) { v3 = getopt_long(a0, a1, "m:Z", &longopts, NULL); if (v3 != -1) { if (v3 != 109) { if (v3 <= 109) { if (v3 != 90) { if (v3 <= 90) { if (v3 == -131) { version_etc(stdout, "mkfifo", "GNU coreutils", Version, "David MacKenzie", 0x0); exit(0x0); } if (v3 == -130) usage(0x0); } } else { if (is_smack_enabled()) { v6 = *(&optarg); continue; } else if (is_selinux_enabled() <= 0) { if (!*(&optarg)) continue; error(0x0, 0x0, gettext("warning: ignoring --context; it requires an " "SELinux/SMACK-enabled kernel")); continue; } else if (*(&optarg)) { v6 = *(&optarg); continue; } else { v7 = selabel_open(0x0, 0x0, 0x0); if (v7) continue; error(0x0, *(__errno_location()), gettext("warning: ignoring --context")); continue; } } } if (v3 > 109 || v3 != 90 && v3 > 90 || v3 != 90 && v3 != -131 && v3 != -130) usage(0x1); } else { v5 = *(&optarg); } } else { if (a0 == optind) { error(0x0, 0x0, gettext("missing operand")); usage(0x1); } if (v6) { v2 = 0; if (is_smack_enabled()) v2 = smack_set_label_for_self(v6); else v2 = setfscreatecon(v6); if (v2 < 0) { v13 = quote(v6); error(0x1, *(__errno_location()), gettext("failed to set default file creation context to %s")); } } if (!v6 || v2 >= 0) { v0 = 438; if (v5) { v8 = mode_compile(v5); if (!v8) error(0x1, 0x0, gettext("invalid mode")); v4 = umask(0x0); umask(v4); v0 = mode_adjust(v0, 0x0, v4, v8, 0x0); free(v8); if ((v0 & -0x200)) error(0x1, 0x0, gettext("mode must specify only file permission bits")); } if (!v5 || !(v0 & -0x200) && v8) { for (; a0 > optind; optind = optind + 1) { if (v7) defaultcon(v7, a1[optind], 0x1000, a1[optind]); if (mkfifo(a1[optind], v0)) { v16 = quotearg_style(0x4, a1[optind], optind * 8); error(0x0, *(__errno_location()), gettext("cannot create fifo %s")); v1 = 1; } else if (v5 && lchmod(a1[optind], v0, v0)) { v17 = quotearg_style(0x4, a1[optind], optind * 8); error(0x0, *(__errno_location()), gettext("cannot set permissions of %s")); v1 = 1; } } } } } } return v1; }
coreutils
angr_dream
static char *dumpdir_first(struct dumpdir *dump, int all, struct dumpdir_iter **pitr) { struct dumpdir_iter *itr = xmalloc(sizeof(*itr)); itr->dump = dump; itr->all = all; itr->next = 0; *pitr = itr; return dumpdir_next(itr); }
char *dumpdir_first(long a1, int a2, _QWORD *a3) { _DWORD *v5; v5 = xmalloc(24LL); *(_QWORD *)v5 = a1; v5[2] = a2; *((_QWORD *)v5 + 2) = 0LL; *a3 = v5; return dumpdir_next(v5); }
tar
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_sailr
static void xbotch(mem, e, s, file, line) void *mem; int e; const char *s; const char *file; int line; { fprintf(stderr, gettext("\r\nmalloc: %s:%d: assertion botched\r\n"), file ? file : gettext("unknown"), line); (void)fflush(stderr); programming_error(s, file, line); }
void xbotch(unsigned long a0, unsigned long a1, unsigned long long a2, unsigned long long a3, unsigned long a4) { unsigned int v0; unsigned long v1; unsigned long long v3; unsigned long long v4; v1 = a0; v0 = a1; if (!a3) v3 = gettext("unknown"); fprintf(stderr, gettext("\r\nmalloc: %s:%d: assertion botched\r\n")); fflush(stderr); v4 = programming_error(a2, a3, a4, a3); return; }
bash
angr_dream
int unzip(in, out) int in, out; { ulg orig_crc = 0; ulg orig_len = 0; int n; uch buf[16]; int err = 0; ifd = in; ofd = out; updcrc(((void *)0), 0); if (pkzip && !ext_header) { orig_crc = ((ulg)(((ush)(uch)((inbuf + 14)[0]) | ((ush)(uch)((inbuf + 14)[1]) << 8))) | ((ulg)(((ush)(uch)(((inbuf + 14) + 2)[0]) | ((ush)(uch)(((inbuf + 14) + 2)[1]) << 8))) << 16)); orig_len = ((ulg)(((ush)(uch)((inbuf + 22)[0]) | ((ush)(uch)((inbuf + 22)[1]) << 8))) | ((ulg)(((ush)(uch)(((inbuf + 22) + 2)[0]) | ((ush)(uch)(((inbuf + 22) + 2)[1]) << 8))) << 16)); } if (method == 8) { int res = inflate(); if (res == 3) { xalloc_die(); } else if (res != 0) { gzip_error("invalid compressed data--format violated"); } } else if (pkzip && method == 0) { register ulg n = ((ulg)(((ush)(uch)((inbuf + 22)[0]) | ((ush)(uch)((inbuf + 22)[1]) << 8))) | ((ulg)(((ush)(uch)(((inbuf + 22) + 2)[0]) | ((ush)(uch)(((inbuf + 22) + 2)[1]) << 8))) << 16)); if (n != ((ulg)(((ush)(uch)((inbuf + 18)[0]) | ((ush)(uch)((inbuf + 18)[1]) << 8))) | ((ulg)(((ush)(uch)(((inbuf + 18) + 2)[0]) | ((ush)(uch)(((inbuf + 18) + 2)[1]) << 8))) << 16)) - (decrypt ? 12 : 0)) { fprintf(stderr, "len %lu, siz %lu\n", n, ((ulg)(((ush)(uch)((inbuf + 18)[0]) | ((ush)(uch)((inbuf + 18)[1]) << 8))) | ((ulg)(((ush)(uch)(((inbuf + 18) + 2)[0]) | ((ush)(uch)(((inbuf + 18) + 2)[1]) << 8))) << 16))); gzip_error("invalid compressed data--length mismatch"); } while (n--) { uch c = (uch)(inptr < insize ? inbuf[inptr++] : fill_inbuf(0)); { window[outcnt++] = (uch)(c); if (outcnt == 0x8000) flush_window(); }; } flush_window(); } else { gzip_error("internal error, invalid method"); } if (!pkzip) { for (n = 0; n < 8; n++) { buf[n] = (uch)(inptr < insize ? inbuf[inptr++] : fill_inbuf(0)); } orig_crc = ((ulg)(((ush)(uch)((buf)[0]) | ((ush)(uch)((buf)[1]) << 8))) | ((ulg)(((ush)(uch)(((buf) + 2)[0]) | ((ush)(uch)(((buf) + 2)[1]) << 8))) << 16)); orig_len = ((ulg)(((ush)(uch)((buf + 4)[0]) | ((ush)(uch)((buf + 4)[1]) << 8))) | ((ulg)(((ush)(uch)(((buf + 4) + 2)[0]) | ((ush)(uch)(((buf + 4) + 2)[1]) << 8))) << 16)); } else if (ext_header) { for (n = 0; n < 16; n++) { buf[n] = (uch)(inptr < insize ? inbuf[inptr++] : fill_inbuf(0)); } orig_crc = ((ulg)(((ush)(uch)((buf + 4)[0]) | ((ush)(uch)((buf + 4)[1]) << 8))) | ((ulg)(((ush)(uch)(((buf + 4) + 2)[0]) | ((ush)(uch)(((buf + 4) + 2)[1]) << 8))) << 16)); orig_len = ((ulg)(((ush)(uch)((buf + 12)[0]) | ((ush)(uch)((buf + 12)[1]) << 8))) | ((ulg)(((ush)(uch)(((buf + 12) + 2)[0]) | ((ush)(uch)(((buf + 12) + 2)[1]) << 8))) << 16)); } if (orig_crc != updcrc(outbuf, 0)) { fprintf(stderr, "\n%s: %s: invalid compressed data--crc error\n", program_name, ifname); err = 1; } if (orig_len != (ulg)(bytes_out & 0xffffffff)) { fprintf(stderr, "\n%s: %s: invalid compressed data--length error\n", program_name, ifname); err = 1; } if (pkzip && inptr + 4 < insize && ((ulg)(((ush)(uch)((inbuf + inptr)[0]) | ((ush)(uch)((inbuf + inptr)[1]) << 8))) | ((ulg)(((ush)(uch)(((inbuf + inptr) + 2)[0]) | ((ush)(uch)(((inbuf + inptr) + 2)[1]) << 8))) << 16)) == 0x04034b50L) { if (to_stdout) { { if (!quiet) fprintf(stderr, "%s: %s has more than one entry--rest ignored\n", program_name, ifname); if (exit_code == 0) exit_code = 2; } ; } else { fprintf(stderr, "%s: %s has more than one entry -- unchanged\n", program_name, ifname); err = 1; } } ext_header = pkzip = 0; unzip_crc = orig_crc; if (err == 0) return 0; exit_code = 1; if (!test) abort_gzip(); return err; }
long long unzip(unsigned long a0, unsigned long a1) { char v0; int tmp_5; unsigned int v1; unsigned int v2; unsigned int v3; unsigned long long v4; unsigned long v5; char v6; char v7; char v8; char v9; char v10; char v11; char v12; char v13; char v14; char v15; char v16; char v17; unsigned long long v19; unsigned long long v20; unsigned long long v21; void *v23; v4 = 0; v5 = 0; v2 = 0; ifd = a0; ofd = a1; updcrc(0x0, 0x0); if (pkzip && !ext_header) { v4 = g_500016 | (g_500017 * 0x100) | (insize | (g_500019 * 0x100)) * 0x10000; v5 = g_50001e | (g_50001f * 0x100) | (program_name | (g_500021 * 0x100)) * 0x10000; } if (method == 8) { v3 = inflate(); if (v3 == 3) { xalloc_die(); } else if (v3) { gzip_error("invalid compressed data--format violated"); } } if (method != 8 || v3 != 3 && v3) { if (pkzip && !method) { v19 = g_50001e | (g_50001f * 0x100) | (program_name | (g_500021 * 0x100)) * 0x10000; if (decrypt) v20 = 12; else v20 = 0; if ((g_50001e | (g_50001f << 8) | (program_name | (g_500021 << 8)) << 16) != ((g_50001c | (g_50001d << 8)) << 16 | g_50001a | (g_50001b << 8)) - v20) { fprintf(stderr, "len %lu, siz %lu\n", (g_50001e | (g_50001f * 0x100) | (program_name | (g_500021 * 0x100)) * 0x10000), ((g_50001c | (g_50001d * 0x100)) * 0x10000 | g_50001a | (g_50001b * 0x100))); gzip_error("invalid compressed data--length mismatch"); } while (true) { v21 = v19; v19 -= 1; if (v21) { if (inptr < insize) { inptr = inptr + 1; *(&v20) = *(inptr + &inbuf); } else { v20 = fill_inbuf(0x0); } v0 = v20; outcnt = outcnt + 1; *(outcnt + &window) = v0; if (outcnt != 0x8000) continue; flush_window(); } else { flush_window(); break; } } } if (!pkzip || method) gzip_error("internal error, invalid method"); } if (v3 != 3 || method != 8) { if (!pkzip) { for (v1 = 0; v1 <= 7; v1 += 1) { if (inptr < insize) { tmp_5 = inptr; inptr = inptr + 1; *(&v21) = *(tmp_5 + &inbuf); } else { v21 = fill_inbuf(0x0); } (&v6)[v1] = v21; } v4 = v6 | (v7 * 0x100) | (v8 | (v9 * 0x100)) * 0x10000; v5 = v10 | (v11 * 0x100) | (v12 | (v13 * 0x100)) * 0x10000; } else if (ext_header) { for (v1 = 0; v1 <= 15; v1 += 1) { if (inptr < insize) { tmp_5 = inptr; inptr = inptr + 1; *(&v21) = *(tmp_5 + &inbuf); } else { v21 = fill_inbuf(0x0); } (&v6)[v1] = v21; } v4 = v10 | (v11 * 0x100) | (v12 | (v13 * 0x100)) * 0x10000; v5 = v14 | (v15 * 0x100) | (v16 | (v17 * 0x100)) * 0x10000; } if (v4 != updcrc(0x500098, 0x0)) { fprintf(stderr, "\n%s: %s: invalid compressed data--crc error\n", program_name, &ifname); v2 = 1; } if (v5 != bytes_out) { fprintf(stderr, "\n%s: %s: invalid compressed data--length error\n", program_name, &ifname); v2 = 1; } if (pkzip && inptr + 4 < insize && (*(&inbuf + inptr) | (*(1 + &inbuf + inptr) << 8) | (*(2 + &inbuf + inptr) | (*(3 + &inbuf + inptr) << 8)) << 16) == 67324752) { if (to_stdout) { if (!quiet) fprintf(stderr, "%s: %s has more than one entry--rest ignored\n", program_name, &ifname); if (!exit_code) exit_code = 2; } else { fprintf(stderr, "%s: %s has more than one entry -- unchanged\n", program_name, &ifname); v2 = 1; } } pkzip = 0; ext_header = pkzip; unzip_crc = v4; if (!v2) { v23 = 0; } else { exit_code = 1; if (!test) abort_gzip(); v23 = v2; } return v23; } }
gzip-1.12
angr_dream
Channel *channel_by_id(struct ssh *ssh, int id) { Channel *c; if (id < 0 || (u_int)id >= ssh->chanctxt->channels_alloc) { sshlog("channels.c", __func__, 245, 1, SYSLOG_LEVEL_INFO, ((void *)0), "%d: bad id", id); return ((void *)0); } c = ssh->chanctxt->channels[id]; if (c == ((void *)0)) { sshlog("channels.c", __func__, 250, 1, SYSLOG_LEVEL_INFO, ((void *)0), "%d: bad id: channel free", id); return ((void *)0); } return c; }
int channel_by_id(struct_0 *a0, unsigned long a1) { unsigned long v0; unsigned long v1; unsigned int v3; if (a1 >= 0 && a0->field_868->field_8 > a1) { v1 = *((a0->field_868->field_0 + a1 * 8)); if (v1) { v3 = v1; return v3; } v0 = a1; sshlog("channels.c", "channel_by_id", 0xfa, 0x1, 0x3, 0x0, "%d: bad id: channel free"); v3 = 0; return v3; } v0 = a1; sshlog("channels.c", "channel_by_id", 0xf5, 0x1, 0x3, 0x0, "%d: bad id"); v3 = 0; return v3; }
openssh-portable
angr_sailr
static void cmd_parser(int argc, char **argv) { process_options(argc, argv); gnutls_global_set_log_function(tls_log_func); if (systemkey_tool_options.present.debug) { gnutls_global_set_log_level(systemkey_tool_options.value.debug); printf("Setting log level to %d\n", (int)systemkey_tool_options.value.debug); } if (systemkey_tool_options.present.outder) { outcert_format = GNUTLS_X509_FMT_DER; outkey_format = GNUTLS_X509_FMT_DER; } else { outcert_format = GNUTLS_X509_FMT_PEM; outkey_format = GNUTLS_X509_FMT_PEM; } if (systemkey_tool_options.present.outfile) { outfile = safe_open_rw(systemkey_tool_options.arg.outfile, 0); if (outfile == ((void *)0)) { fprintf(stderr, "%s", systemkey_tool_options.arg.outfile); app_exit(1); } outfile_name = systemkey_tool_options.arg.outfile; } else outfile = stdout; if (systemkey_tool_options.present.delete) { systemkey_delete(systemkey_tool_options.arg.delete, outfile); } else if (systemkey_tool_options.present.list) { systemkey_list(outfile); } else { usage(stdout, (1)); } fclose(outfile); gnutls_global_deinit(); }
void cmd_parser(unsigned long long a0, unsigned long a1, unsigned long long a2, unsigned long long a3, unsigned long long a4, unsigned long long a5) { unsigned long long v1; process_options(a0, a1, a1); gnutls_global_set_log_function(tls_log_func); if (systemkey_tool_options) { gnutls_global_set_log_level(usage); a1 = usage; printf("Setting log level to %d\n", usage); } if (g_500034) { outcert_format = 0; outkey_format = 0; } else { outcert_format = 1; outkey_format = 1; } if (g_500031) { outfile = safe_open_rw(printf, 0x0); if (!outfile) { fprintf(stderr, "%s", printf); app_exit(0x1); } outfile_name = printf; } else { outfile = stdout; } if (!g_500031 || outfile) { if (g_500033) { systemkey_delete(safe_open_rw, outfile); } else if (g_500032) { systemkey_list(outfile); } else { usage(stdout, 0x1); } fclose(outfile); v1 = gnutls_global_deinit(a0, a1, a2, a3, a4, a5); return; } }
gnutls
angr_dream
char *expand_and_quote_assoc_word(w, type) char *w; int type; { char *nword, *key, *value, *s, *t; int ind, wlen, i; if (w[0] != '[') return (sh_single_quote(w)); ind = skipsubscript(w, 0, 0); if (w[ind] != ']') return (sh_single_quote(w)); w[ind] = '\0'; t = expand_subscript_string(w + 1, 0); s = (t && strchr(t, '\001')) ? quote_escapes(t) : t; key = sh_single_quote(s ? s : ""); if (s != t) sh_xfree((s), "arrayfunc.c", 1018); w[ind] = ']'; sh_xfree((t), "arrayfunc.c", 1020); wlen = (((key) && (key)[0]) ? ((key)[1] ? ((key)[2] ? strlen(key) : 2) : 1) : 0); nword = sh_xmalloc((wlen + 5), "arrayfunc.c", 1023); nword[0] = '['; memcpy(nword + 1, key, wlen); i = wlen + 1; nword[i++] = w[ind++]; if (w[ind] == '+') nword[i++] = w[ind++]; nword[i++] = w[ind++]; t = expand_subscript_string(w + ind, 0); s = (t && strchr(t, '\001')) ? quote_escapes(t) : t; value = sh_single_quote(s ? s : ""); if (s != t) sh_xfree((s), "arrayfunc.c", 1037); sh_xfree((t), "arrayfunc.c", 1038); nword = sh_xrealloc((nword), (wlen + 5 + (((value) && (value)[0]) ? ((value)[1] ? ((value)[2] ? strlen(value) : 2) : 1) : 0)), "arrayfunc.c", 1039); strcpy(nword + i, value); sh_xfree((key), "arrayfunc.c", 1042); sh_xfree((value), "arrayfunc.c", 1043); return nword; }
long expand_and_quote_assoc_word(_BYTE *a1) { char *v2; int v3; int v4; int v5; int v6; char *v7; size_t v8; int v9; int v10; int v11; int v12; int v13; char *s; char *sa; char *v16; char *v17; char *v18; _BYTE *v19; long v20; char *src; if (*a1 != 91) return sh_single_quote(a1); v9 = skipsubscript(a1, 0LL, 0LL); if (a1[v9] != 93) return sh_single_quote(a1); a1[v9] = 0; s = (char *)expand_subscript_string(a1 + 1, 0LL); if (s && strchr(s, 1)) v2 = (char *)quote_escapes(s); else v2 = s; v16 = v2; if (!v2) v2 = (char *)&unk_3AB5; v18 = (char *)sh_single_quote(v2); if (v16 != s) sh_xfree(v16, "arrayfunc.c", 1018LL); a1[v9] = 93; sh_xfree(s, "arrayfunc.c", 1020LL); if (v18 && *v18) { if (v18[1]) { if (v18[2]) v3 = strlen(v18); else v3 = 2; } else { v3 = 1; } } else { v3 = 0; } v13 = v3; v19 = (_BYTE *)sh_xmalloc(v3 + 5, "arrayfunc.c", 1023LL); *v19 = 91; memcpy(v19 + 1, v18, v13); v4 = v9; v10 = v9 + 1; v11 = v13 + 2; v19[v13 + 1] = a1[v4]; if (a1[v10] == 43) { v5 = v10++; v11 = v13 + 3; v19[v13 + 2] = a1[v5]; } v6 = v11; v12 = v11 + 1; v19[v6] = a1[v10]; sa = (char *)expand_subscript_string(&a1[v10 + 1], 0LL); if (sa && strchr(sa, 1)) v7 = (char *)quote_escapes(sa); else v7 = sa; v17 = v7; if (!v7) v7 = (char *)&unk_3AB5; src = (char *)sh_single_quote(v7); if (v17 != sa) sh_xfree(v17, "arrayfunc.c", 1037LL); sh_xfree(sa, "arrayfunc.c", 1038LL); if (src && *src) { if (src[1]) { if (src[2]) v8 = strlen(src); else v8 = 2LL; } else { v8 = 1LL; } } else { v8 = 0LL; } v20 = sh_xrealloc(v19, v8 + v13 + 5, "arrayfunc.c", 1039LL); strcpy((char *)(v20 + v12), src); sh_xfree(v18, "arrayfunc.c", 1042LL); sh_xfree(src, "arrayfunc.c", 1043LL); return v20; }
bash
ida