/* Try to start up libdw on DEBUGFILE. */ static Dwfl_Error load_dw (Dwfl_Module *mod, struct dwfl_file *debugfile) { if (mod->e_type == ET_REL && !debugfile->relocated) { const Dwfl_Callbacks *const cb = mod->dwfl->callbacks; /* The debugging sections have to be relocated. */ if (cb->section_address == NULL) return DWFL_E_NOREL; Dwfl_Error error = __libdwfl_module_getebl (mod); if (error != DWFL_E_NOERROR) return error; find_symtab (mod); Dwfl_Error result = mod->symerr; if (result == DWFL_E_NOERROR) result = __libdwfl_relocate (mod, debugfile->elf, true); if (result != DWFL_E_NOERROR) return result; /* Don't keep the file descriptors around. */ if (mod->main.fd != -1 && elf_cntl (mod->main.elf, ELF_C_FDREAD) == 0) { close (mod->main.fd); mod->main.fd = -1; } if (debugfile->fd != -1 && elf_cntl (debugfile->elf, ELF_C_FDREAD) == 0) { close (debugfile->fd); debugfile->fd = -1; } } mod->dw = INTUSE(dwarf_begin_elf) (debugfile->elf, DWARF_C_READ, NULL); if (mod->dw == NULL) { int err = INTUSE(dwarf_errno) (); return err == DWARF_E_NO_DWARF ? DWFL_E_NO_DWARF : DWFL_E (LIBDW, err); } /* Until we have iterated through all CU's, we might do lazy lookups. */ mod->lazycu = 1; return DWFL_E_NOERROR; }
bool_t xdr_keystatus (XDR * xdrs, keystatus * objp) { if (!INTUSE(xdr_enum) (xdrs, (enum_t *) objp)) return FALSE; return TRUE; }
bool_t xdr_netnamestr (XDR * xdrs, netnamestr * objp) { if (!INTUSE(xdr_string) (xdrs, objp, MAXNETNAMELEN)) return FALSE; return TRUE; }
int key_get_conv (char *pkey, des_block *deskey) { cryptkeyres res; if (!key_call ((u_long) KEY_GET_CONV, (xdrproc_t) INTUSE(xdr_keybuf), pkey, (xdrproc_t) INTUSE(xdr_cryptkeyres), (char *) &res)) return -1; if (res.status != KEY_SUCCESS) { debug ("get_conv status is nonzero"); return -1; } *deskey = res.cryptkeyres_u.deskey; return 0; }
bool_t xdr_keybuf (XDR * xdrs, keybuf objp) { if (!INTUSE(xdr_opaque) (xdrs, objp, HEXKEYBYTES)) return FALSE; return TRUE; }
int key_setnet (struct key_netstarg *arg) { keystatus status; if (!key_call ((u_long) KEY_NET_PUT, (xdrproc_t) INTUSE(xdr_key_netstarg), (char *) arg,(xdrproc_t) INTUSE(xdr_keystatus), (char *) &status)) return -1; if (status != KEY_SUCCESS) { debug ("key_setnet status is nonzero"); return -1; } return 1; }
internal_function unsigned char * __libdw_formptr (Dwarf_Attribute *attr, int sec_index, int err_nodata, unsigned char **endpp, Dwarf_Off *offsetp) { if (attr == NULL) return NULL; const Elf_Data *d = attr->cu->dbg->sectiondata[sec_index]; if (unlikely (d == NULL)) { __libdw_seterrno (err_nodata); return NULL; } Dwarf_Word offset; if (attr->form == DW_FORM_sec_offset) { if (__libdw_read_offset (attr->cu->dbg, attr->cu->dbg, cu_sec_idx (attr->cu), attr->valp, attr->cu->offset_size, &offset, sec_index, 0)) return NULL; } else if (attr->cu->version > 3) goto invalid; else switch (attr->form) { case DW_FORM_data4: case DW_FORM_data8: if (__libdw_read_offset (attr->cu->dbg, attr->cu->dbg, cu_sec_idx (attr->cu), attr->valp, attr->form == DW_FORM_data4 ? 4 : 8, &offset, sec_index, 0)) return NULL; break; default: if (INTUSE(dwarf_formudata) (attr, &offset)) return NULL; }; unsigned char *readp = d->d_buf + offset; unsigned char *endp = d->d_buf + d->d_size; if (unlikely (readp >= endp)) { invalid: __libdw_seterrno (DWARF_E_INVALID_DWARF); return NULL; } if (endpp != NULL) *endpp = endp; if (offsetp != NULL) *offsetp = offset; return readp; }
Dwarf * dwarf_begin (int fd, Dwarf_Cmd cmd) { Elf *elf; Elf_Cmd elfcmd; Dwarf *result = NULL; switch (cmd) { case DWARF_C_READ: elfcmd = ELF_C_READ_MMAP; break; case DWARF_C_WRITE: elfcmd = ELF_C_WRITE; break; case DWARF_C_RDWR: elfcmd = ELF_C_RDWR; break; default: /* No valid mode. */ __libdw_seterrno (DWARF_E_INVALID_CMD); return NULL; } /* We have to call `elf_version' here since the user might have not done it or initialized libelf with a different version. This would break libdwarf since we are using the ELF data structures in a certain way. */ elf_version (EV_CURRENT); /* Get an ELF descriptor. */ elf = elf_begin (fd, elfcmd, NULL); if (elf == NULL) { /* Test why the `elf_begin" call failed. */ struct stat64 st; if (fstat64 (fd, &st) == 0 && ! S_ISREG (st.st_mode)) __libdw_seterrno (DWARF_E_NO_REGFILE); else if (errno == EBADF) __libdw_seterrno (DWARF_E_INVALID_FILE); else __libdw_seterrno (DWARF_E_IO_ERROR); } else { /* Do the real work now that we have an ELF descriptor. */ result = INTUSE(dwarf_begin_elf) (elf, cmd, NULL); /* If this failed, free the resources. */ if (result == NULL) elf_end (elf); else result->free_elf = true; } return result; }
/* * Create a client handle for memory based rpc. */ CLIENT * clntraw_create (u_long prog, u_long vers) { struct clntraw_private_s *clp = clntraw_private; struct rpc_msg call_msg; XDR *xdrs; CLIENT *client; if (clp == 0) { clp = (struct clntraw_private_s *) calloc (1, sizeof (*clp)); if (clp == 0) return (0); clntraw_private = clp; } xdrs = &clp->xdr_stream; client = &clp->client_object; /* * pre-serialize the static part of the call msg and stash it away */ call_msg.rm_direction = CALL; call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; call_msg.rm_call.cb_prog = prog; call_msg.rm_call.cb_vers = vers; INTUSE(xdrmem_create) (xdrs, clp->mashl_callmsg.msg, MCALL_MSG_SIZE, XDR_ENCODE); if (!INTUSE(xdr_callhdr) (xdrs, &call_msg)) { perror (_ ("clnt_raw.c: fatal header serialization error")); } clp->mcnt = XDR_GETPOS (xdrs); XDR_DESTROY (xdrs); /* * Set xdrmem for client/server shared buffer */ INTUSE(xdrmem_create) (xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE); /* * create client handle */ client->cl_ops = (struct clnt_ops *) &client_ops; client->cl_auth = INTUSE(authnone_create) (); return client; }
/* * XDR the MSG_DENIED part of a reply message union */ bool_t xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr) { /* personalized union, rather than calling xdr_union */ if (!INTUSE(xdr_enum) (xdrs, (enum_t *) & (rr->rj_stat))) return FALSE; switch (rr->rj_stat) { case RPC_MISMATCH: if (!INTUSE(xdr_u_long) (xdrs, &(rr->rj_vers.low))) return FALSE; return INTUSE(xdr_u_long) (xdrs, &(rr->rj_vers.high)); case AUTH_ERROR: return INTUSE(xdr_enum) (xdrs, (enum_t *) & (rr->rj_why)); } return FALSE; }
void svc_getreq (int rdfds) { fd_set readfds; FD_ZERO (&readfds); readfds.fds_bits[0] = rdfds; INTUSE(svc_getreqset) (&readfds); }
/* key_secretkey_is_set() returns 1 if the keyserver has a secret key * stored for the caller's effective uid; it returns 0 otherwise * * N.B.: The KEY_NET_GET key call is undocumented. Applications shouldn't * be using it, because it allows them to get the user's secret key. */ int key_secretkey_is_set (void) { struct key_netstres kres; memset (&kres, 0, sizeof (kres)); if (key_call ((u_long) KEY_NET_GET, (xdrproc_t) INTUSE(xdr_void), (char *) NULL, (xdrproc_t) INTUSE(xdr_key_netstres), (char *) &kres) && (kres.status == KEY_SUCCESS) && (kres.key_netstres_u.knet.st_priv_key[0] != 0)) { /* avoid leaving secret key in memory */ memset (kres.key_netstres_u.knet.st_priv_key, 0, HEXKEYBYTES); return 1; } return 0; }
static int module_callback (Dwfl_Module *mod, void **userdata, const char *name, Dwarf_Addr start, void *arg) { const struct module_callback_info *info = arg; Dwarf_Addr bias = 0; Dwarf *dw = INTUSE(dwfl_module_getdwarf) (mod, &bias); return (*info->callback) (mod, userdata, name, start, dw, bias, info->arg); }
int _IO_obstack_vprintf (struct obstack *obstack, const char *format, va_list args) { struct obstack_FILE { struct _IO_obstack_file ofile; } new_f; int result; int size; int room; #ifdef _IO_MTSAFE_IO new_f.ofile.file.file._lock = NULL; #endif _IO_no_init (&new_f.ofile.file.file, _IO_USER_LOCK, -1, NULL, NULL); _IO_JUMPS (&new_f.ofile.file) = &_IO_obstack_jumps; room = obstack_room (obstack); size = obstack_object_size (obstack) + room; if (size == 0) { /* We have to handle the allocation a bit different since the `_IO_str_init_static' function would handle a size of zero different from what we expect. */ /* Get more memory. */ obstack_make_room (obstack, 64); /* Recompute how much room we have. */ room = obstack_room (obstack); size = room; assert (size != 0); } _IO_str_init_static_internal ((struct _IO_strfile_ *) &new_f.ofile, obstack_base (obstack), size, obstack_next_free (obstack)); /* Now allocate the rest of the current chunk. */ assert (size == (new_f.ofile.file.file._IO_write_end - new_f.ofile.file.file._IO_write_base)); assert (new_f.ofile.file.file._IO_write_ptr == (new_f.ofile.file.file._IO_write_base + obstack_object_size (obstack))); obstack_blank_fast (obstack, room); new_f.ofile.obstack = obstack; result = INTUSE(_IO_vfprintf) (&new_f.ofile.file.file, format, args); /* Shrink the buffer to the space we really currently need. */ obstack_blank_fast (obstack, (new_f.ofile.file.file._IO_write_ptr - new_f.ofile.file.file._IO_write_end)); return result; }
int attribute_compat_text_section __nldbl_vfprintf (FILE *s, const char *fmt, va_list ap) { int done; set_no_long_double (); done = INTUSE(_IO_vfprintf) (s, fmt, ap); clear_no_long_double (); return done; }
int attribute_compat_text_section __nldbl__IO_vsprintf (char *string, const char *fmt, va_list ap) { int done; __no_long_double = 1; done = INTUSE(_IO_vsprintf) (string, fmt, ap); __no_long_double = 0; return done; }
int attribute_compat_text_section __nldbl___vfscanf (FILE *s, const char *fmt, va_list ap) { int res; set_no_long_double (); res = INTUSE(_IO_vfscanf) (s, fmt, ap, NULL); clear_no_long_double (); return res; }
int _compat_vaddr_at_end_dwfl_module_build_id (Dwfl_Module *mod, const unsigned char **bits, GElf_Addr *vaddr) { int result = INTUSE(dwfl_module_build_id) (mod, bits, vaddr); if (result > 0) *vaddr += (result + 3) & -4; return result; }
static void authnone_create_once (void) { struct authnone_private_s *ap; XDR xdr_stream; XDR *xdrs; ap = &authnone_private; ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; ap->no_client.ah_ops = &ops; xdrs = &xdr_stream; INTUSE(xdrmem_create) (xdrs, ap->marshalled_client, (u_int) MAX_MARSHAL_SIZE, XDR_ENCODE); (void) INTUSE(xdr_opaque_auth) (xdrs, &ap->no_client.ah_cred); (void) INTUSE(xdr_opaque_auth) (xdrs, &ap->no_client.ah_verf); ap->mcnt = XDR_GETPOS (xdrs); XDR_DESTROY (xdrs); }
int registerrpc (u_long prognum, u_long versnum, u_long procnum, char *(*progname) (char *), xdrproc_t inproc, xdrproc_t outproc) { struct proglst_ *pl; char *buf; if (procnum == NULLPROC) { if (__asprintf (&buf, _("can't reassign procedure number %ld\n"), NULLPROC) < 0) buf = NULL; goto err_out; } if (transp == 0) { transp = INTUSE(svcudp_create) (RPC_ANYSOCK); if (transp == NULL) { buf = strdup (_("couldn't create an rpc server\n")); goto err_out; } } (void) pmap_unset ((u_long) prognum, (u_long) versnum); if (!svc_register (transp, (u_long) prognum, (u_long) versnum, universal, IPPROTO_UDP)) { if (__asprintf (&buf, _("couldn't register prog %ld vers %ld\n"), prognum, versnum) < 0) buf = NULL; goto err_out; } pl = (struct proglst_ *) malloc (sizeof (struct proglst_)); if (pl == NULL) { buf = strdup (_("registerrpc: out of memory\n")); goto err_out; } pl->p_progname = progname; pl->p_prognum = prognum; pl->p_procnum = procnum; pl->p_inproc = inproc; pl->p_outproc = outproc; pl->p_nxt = proglst; proglst = pl; return 0; err_out: if (buf == NULL) return -1; (void) __fxprintf (NULL, "%s", buf); free (buf); return -1; }
int key_decryptsession (char *remotename, des_block *deskey) { cryptkeyarg arg; cryptkeyres res; arg.remotename = remotename; arg.deskey = *deskey; if (!key_call ((u_long) KEY_DECRYPT, (xdrproc_t) INTUSE(xdr_cryptkeyarg), (char *) &arg, (xdrproc_t) INTUSE(xdr_cryptkeyres), (char *) &res)) return -1; if (res.status != KEY_SUCCESS) { debug ("decrypt status is nonzero"); return -1; } *deskey = res.cryptkeyres_u.deskey; return 0; }
/* VARARGS2 */ int __isoc99_vscanf (const char *format, _IO_va_list args) { int done; _IO_acquire_lock_clear_flags2 (stdin); stdin->_flags2 |= _IO_FLAGS2_SCANF_STD; done = INTUSE(_IO_vfscanf) (stdin, format, args, NULL); _IO_release_lock (stdin); return done; }
ptrdiff_t dwfl_getdwarf (Dwfl *dwfl, int (*callback) (Dwfl_Module *, void **, const char *, Dwarf_Addr, Dwarf *, Dwarf_Addr, void *), void *arg, ptrdiff_t offset) { struct module_callback_info info = { callback, arg }; return INTUSE(dwfl_getmodules) (dwfl, &module_callback, &info, offset); }
/* VARARGS1 */ int __scanf (const char *format, ...) { va_list arg; int done; va_start (arg, format); done = INTUSE(_IO_vfscanf) (stdin, format, arg, NULL); va_end (arg); return done; }
void svc_run (void) { int i; struct pollfd *my_pollfd = NULL; int last_max_pollfd = 0; for (;;) { int max_pollfd = svc_max_pollfd; if (max_pollfd == 0 && svc_pollfd == NULL) break; if (last_max_pollfd != max_pollfd) { struct pollfd *new_pollfd = realloc (my_pollfd, sizeof (struct pollfd) * max_pollfd); if (new_pollfd == NULL) { perror (_("svc_run: - out of memory")); break; } my_pollfd = new_pollfd; last_max_pollfd = max_pollfd; } for (i = 0; i < max_pollfd; ++i) { my_pollfd[i].fd = svc_pollfd[i].fd; my_pollfd[i].events = svc_pollfd[i].events; my_pollfd[i].revents = 0; } switch (i = __poll (my_pollfd, max_pollfd, -1)) { case -1: if (errno == EINTR) continue; perror (_("svc_run: - poll failed")); break; case 0: continue; default: INTUSE(svc_getreq_poll) (my_pollfd, i); continue; } break; } free (my_pollfd); }
/* * XDR the MSG_ACCEPTED part of a reply message union */ bool_t xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar) { /* personalized union, rather than calling xdr_union */ if (!INTUSE(xdr_opaque_auth) (xdrs, &(ar->ar_verf))) return FALSE; if (!INTUSE(xdr_enum) (xdrs, (enum_t *) & (ar->ar_stat))) return FALSE; switch (ar->ar_stat) { case SUCCESS: return ((*(ar->ar_results.proc)) (xdrs, ar->ar_results.where)); case PROG_MISMATCH: if (!INTUSE(xdr_u_long) (xdrs, &(ar->ar_vers.low))) return FALSE; return (INTUSE(xdr_u_long) (xdrs, &(ar->ar_vers.high))); default: return TRUE; } return TRUE; /* TRUE => open ended set of problems */ }
void __register_frame (void *begin) { struct object *ob; /* If .eh_frame is empty, don't register at all. */ if (*(uword *) begin == 0) return; ob = (struct object *) malloc (sizeof (struct object)); INTUSE(__register_frame_info_bases) (begin, ob, 0, 0); }
static enum xprt_stat svctcp_stat (SVCXPRT *xprt) { struct tcp_conn *cd = (struct tcp_conn *) (xprt->xp_p1); if (cd->strm_stat == XPRT_DIED) return XPRT_DIED; if (!INTUSE(xdrrec_eof) (&(cd->xdrs))) return XPRT_MOREREQS; return XPRT_IDLE; }
int internal_function __libdw_attr_intval (Dwarf_Die *die, int *linep, int attval) { Dwarf_Attribute attr_mem; Dwarf_Word line; int res = INTUSE(dwarf_formudata) (INTUSE(dwarf_attr_integrate) (die, attval, &attr_mem), &line); if (res == 0) { if (line > INT_MAX) { __libdw_seterrno (DWARF_E_INVALID_DWARF); res = -1; } else *linep = line; } return res; }
int ntp_gettime (struct ntptimeval *ntv) { struct timex tntx; int result; tntx.modes = 0; result = INTUSE(__adjtimex) (&tntx); ntv->time = tntx.time; ntv->maxerror = tntx.maxerror; ntv->esterror = tntx.esterror; return result; }