From: Apple Date: Sat, 18 Dec 2010 02:07:37 +0000 (+0000) Subject: Libinfo-330.9.tar.gz X-Git-Tag: mac-os-x-1067^0 X-Git-Url: https://git.saurik.com/apple/libinfo.git/commitdiff_plain/1c0d47b08c4a5bba026ba15f4f426d3ce0424dfa?hp=f19b8b3a0c164ced08dbb5645b2f1f322c1a5128 Libinfo-330.9.tar.gz --- diff --git a/lookup.subproj/mdns_module.c b/lookup.subproj/mdns_module.c index 5a216a8..ef3e88e 100644 --- a/lookup.subproj/mdns_module.c +++ b/lookup.subproj/mdns_module.c @@ -175,6 +175,7 @@ typedef struct { uint32_t ifnum; } mdns_reply_t; +static uint32_t _mdns_generation = 0; DNSServiceRef _mdns_sdref; DNSServiceRef _mdns_old_sdref; @@ -1240,6 +1241,8 @@ _mdns_parse_domain_name(const uint8_t *data, uint32_t datalen) uint32_t domainlen = 0; char *domain = NULL; + if ((data == NULL) || (datalen == 0)) return NULL; + // i: index into input data // j: index into output string while (datalen-- > 0) { @@ -1419,6 +1422,7 @@ typedef struct { size_t ansmaxlen; // DNS packet buffer maximum length int type; // type of query: A, AAAA, PTR, SRV... uint16_t last_type; // last type received + uint32_t sd_gen; DNSServiceRef sd; DNSServiceFlags flags; DNSServiceErrorType error; @@ -1451,6 +1455,7 @@ _mdns_query_start(mdns_query_context_t *ctx, mdns_reply_t *reply, uint8_t *answe ctx->type = type; ctx->sd = _mdns_sdref; + ctx->sd_gen = _mdns_generation; ctx->kq = kq; if (reply) { ctx->reply = reply; @@ -1527,10 +1532,13 @@ _mdns_query_clear(mdns_query_context_t *ctx) int complete = _mdns_query_is_complete(ctx); if (ctx == NULL) return complete; - if (ctx->sd != NULL) { + /* only dealloc this DNSServiceRef if the "main" _mdns_sdref has not been deallocated */ + if (ctx->sd != NULL && ctx->sd_gen == _mdns_generation) { DNSServiceRefDeallocate(ctx->sd); - ctx->sd = NULL; } + + ctx->sd = NULL; + ctx->sd_gen = 0; ctx->flags = 0; ctx->kq = -1; @@ -1821,6 +1829,10 @@ _mdns_query_mDNSResponder(const char *name, int class, int type, const char *int timeout = delta; _mdns_now(&start); + for (i = 0; i < 2; ++i) { + memset(&ctx[i], 0 , sizeof(mdns_query_context_t)); + } + // set up the kqueue kq = kqueue(); EV_SET(&ev, 1, EVFILT_USER, EV_ADD | EV_CLEAR, 0, 0, 0); @@ -1839,6 +1851,7 @@ _mdns_query_mDNSResponder(const char *name, int class, int type, const char *int if (_mdns_sdref == NULL) { if (_mdns_old_sdref != NULL) { + _mdns_generation++; DNSServiceRefDeallocate(_mdns_old_sdref); _mdns_old_sdref = NULL; } @@ -1870,6 +1883,7 @@ _mdns_query_mDNSResponder(const char *name, int class, int type, const char *int err == kDNSServiceErr_ServiceNotRunning || err == kDNSServiceErr_BadReference) { if (_mdns_sdref) { + _mdns_generation++; DNSServiceRefDeallocate(_mdns_sdref); _mdns_sdref = NULL; } @@ -1911,6 +1925,7 @@ _mdns_query_mDNSResponder(const char *name, int class, int type, const char *int if (_mdns_debug) printf(";; DNSServiceProcessResult status %d\n", err); err = 0; // re-initialize the shared connection + _mdns_generation++; DNSServiceRefDeallocate(_mdns_sdref); _mdns_sdref = NULL; initialize = 1; diff --git a/rpc.subproj/auth_unix.c b/rpc.subproj/auth_unix.c index 9bfe580..e8ae5fd 100644 --- a/rpc.subproj/auth_unix.c +++ b/rpc.subproj/auth_unix.c @@ -106,7 +106,11 @@ static struct auth_ops auth_unix_ops = { struct audata { struct opaque_auth au_origcred; /* original credentials */ struct opaque_auth au_shcred; /* short hand cred */ +#ifdef __LP64__ + uint32_t au_shfaults; /* short hand cache faults */ +#else u_long au_shfaults; /* short hand cache faults */ +#endif char au_marshed[MAX_AUTH_BYTES]; u_int au_mpos; /* xdr pos at end of marshed */ }; diff --git a/rpc.subproj/clnt_simple.c b/rpc.subproj/clnt_simple.c index 0ba26d0..e5d2da1 100644 --- a/rpc.subproj/clnt_simple.c +++ b/rpc.subproj/clnt_simple.c @@ -120,9 +120,13 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) bcopy(hp->h_addr, (char *)&server_addr.sin_addr, hp->h_length); server_addr.sin_family = AF_INET; server_addr.sin_port = 0; - if ((crp->client = clntudp_create(&server_addr, (u_long)prognum, - (u_long)versnum, timeout, &crp->socket)) == NULL) +#ifdef __LP64__ + if ((crp->client = clntudp_create(&server_addr, (uint32_t)prognum, (uint32_t)versnum, timeout, &crp->socket)) == NULL) return ((int) rpc_createerr.cf_stat); +#else + if ((crp->client = clntudp_create(&server_addr, (u_long)prognum, (u_long)versnum, timeout, &crp->socket)) == NULL) + return ((int) rpc_createerr.cf_stat); +#endif crp->valid = 1; crp->oldprognum = prognum; crp->oldversnum = versnum; diff --git a/rpc.subproj/clnt_tcp.c b/rpc.subproj/clnt_tcp.c index 106d4be..20934f6 100644 --- a/rpc.subproj/clnt_tcp.c +++ b/rpc.subproj/clnt_tcp.c @@ -267,19 +267,19 @@ fooy: CLIENT * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) #ifdef __LP64__ -struct sockaddr_in *raddr; -uint32_t prog; -uint32_t vers; -int *sockp; -uint32_t sendsz; -uint32_t recvsz; + struct sockaddr_in *raddr; + uint32_t prog; + uint32_t vers; + int *sockp; + uint32_t sendsz; + uint32_t recvsz; #else -struct sockaddr_in *raddr; -u_long prog; -u_long vers; -register int *sockp; -u_int sendsz; -u_int recvsz; + struct sockaddr_in *raddr; + u_long prog; + u_long vers; + register int *sockp; + u_int sendsz; + u_int recvsz; #endif { return clnttcp_create_timeout(raddr, (uint32_t)prog, (uint32_t)vers, sockp, (uint32_t)sendsz, (uint32_t)recvsz, NULL, NULL); @@ -288,7 +288,11 @@ u_int recvsz; static enum clnt_stat clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) register CLIENT *h; +#ifdef __LP64__ + uint32_t proc; +#else u_long proc; +#endif xdrproc_t xdr_args; caddr_t args_ptr; xdrproc_t xdr_results; @@ -298,8 +302,13 @@ clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) register struct ct_data *ct = (struct ct_data *) h->cl_private; register XDR *xdrs = &(ct->ct_xdrs); struct rpc_msg reply_msg; +#ifdef __LP64__ + uint32_t x_id; + uint32_t *msg_x_id = (uint32_t *)(ct->ct_mcall); /* yuk */ +#else u_long x_id; u_long *msg_x_id = (u_long *)(ct->ct_mcall); /* yuk */ +#endif register bool_t shipnow; int refreshes = 2; diff --git a/rpc.subproj/clnt_udp.c b/rpc.subproj/clnt_udp.c index db3c242..ea76ba1 100644 --- a/rpc.subproj/clnt_udp.c +++ b/rpc.subproj/clnt_udp.c @@ -262,21 +262,21 @@ fooy: CLIENT * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) #ifdef __LP64__ -struct sockaddr_in *raddr; -uint32_t program; -uint32_t version; -struct timeval wait; -int *sockp; -uint32_t sendsz; -uint32_t recvsz; + struct sockaddr_in *raddr; + uint32_t program; + uint32_t version; + struct timeval wait; + int *sockp; + uint32_t sendsz; + uint32_t recvsz; #else -struct sockaddr_in *raddr; -u_long program; -u_long version; -struct timeval wait; -register int *sockp; -u_int sendsz; -u_int recvsz; + struct sockaddr_in *raddr; + u_long program; + u_long version; + struct timeval wait; + register int *sockp; + u_int sendsz; + u_int recvsz; #endif { return clntudp_bufcreate_timeout(raddr, (uint32_t)program, (uint32_t)version, sockp, (uint32_t)sendsz, (uint32_t)recvsz, &wait, NULL); @@ -305,7 +305,11 @@ clntudp_create(raddr, program, version, wait, sockp) static enum clnt_stat clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) register CLIENT *cl; /* client handle */ +#ifdef __LP64__ + uint32_t proc; /* procedure number */ +#else u_long proc; /* procedure number */ +#endif xdrproc_t xargs; /* xdr routine for args */ caddr_t argsp; /* pointer to args */ xdrproc_t xresults; /* xdr routine for results */ @@ -427,12 +431,15 @@ send_again: cu->cu_error.re_errno = errno; return (cu->cu_error.re_status = RPC_CANTRECV); } - if (inlen < sizeof(u_long)) - continue; - /* see if reply transaction id matches sent id */ #ifdef __LP64__ + if (inlen < sizeof(uint32_t)) + continue; + /* see if reply transaction id matches sent id */ if (*((uint32_t *)(cu->cu_inbuf)) != *((uint32_t *)(cu->cu_outbuf))) continue; #else + if (inlen < sizeof(u_long)) + continue; + /* see if reply transaction id matches sent id */ if (*((u_long *)(cu->cu_inbuf)) != *((u_long *)(cu->cu_outbuf))) continue; #endif /* we now assume we have the proper reply */ diff --git a/rpc.subproj/pmap_getport.c b/rpc.subproj/pmap_getport.c index 44a87ef..318df95 100644 --- a/rpc.subproj/pmap_getport.c +++ b/rpc.subproj/pmap_getport.c @@ -127,15 +127,15 @@ pmap_getport_timeout(struct sockaddr_in *address, uint32_t program, uint32_t ver u_short pmap_getport(address, program, version, protocol) #ifdef __LP64__ -struct sockaddr_in *address; -uint32_t program; -uint32_t version; -uint32_t protocol; + struct sockaddr_in *address; + uint32_t program; + uint32_t version; + uint32_t protocol; #else -struct sockaddr_in *address; -u_long program; -u_long version; -u_int protocol; + struct sockaddr_in *address; + u_long program; + u_long version; + u_int protocol; #endif { return pmap_getport_timeout(address, (uint32_t)program, (uint32_t)version, (uint32_t)protocol, NULL, NULL); diff --git a/rpc.subproj/pmap_rmt.c b/rpc.subproj/pmap_rmt.c index c9813ba..16819b6 100644 --- a/rpc.subproj/pmap_rmt.c +++ b/rpc.subproj/pmap_rmt.c @@ -156,7 +156,11 @@ xdr_rmtcall_args(xdrs, cap) if (! (*(cap->xdr_args))(xdrs, cap->args_ptr)) return (FALSE); position = XDR_GETPOS(xdrs); +#ifdef __LP64__ + cap->arglen = (uint32_t)position - (uint32_t)argposition; +#else cap->arglen = (u_long)position - (u_long)argposition; +#endif XDR_SETPOS(xdrs, lenposition); if (! xdr_u_long(xdrs, &(cap->arglen))) return (FALSE); @@ -178,14 +182,17 @@ xdr_rmtcallres(xdrs, crp) caddr_t port_ptr; port_ptr = (caddr_t)crp->port_ptr; - if (xdr_reference(xdrs, &port_ptr, sizeof (u_long), (xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { #ifdef __LP64__ + if (xdr_reference(xdrs, &port_ptr, sizeof (uint32_t), (xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { crp->port_ptr = (unsigned int *)port_ptr; + return ((*(crp->xdr_results))(xdrs, crp->results_ptr)); + } #else + if (xdr_reference(xdrs, &port_ptr, sizeof (u_long), (xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { crp->port_ptr = (unsigned long *)port_ptr; -#endif return ((*(crp->xdr_results))(xdrs, crp->results_ptr)); } +#endif return (FALSE); } @@ -406,8 +413,13 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) stat = RPC_CANTRECV; goto done_broad; } +#ifdef __LP64__ + if (inlen < sizeof(uint32_t)) + goto recv_again; +#else if (inlen < sizeof(u_long)) goto recv_again; +#endif /* * see if reply transaction id matches sent id. * If so, decode the results. diff --git a/rpc.subproj/svc.c b/rpc.subproj/svc.c index b17fe4e..9fc4c01 100644 --- a/rpc.subproj/svc.c +++ b/rpc.subproj/svc.c @@ -89,8 +89,13 @@ static SVCXPRT **xports; */ static struct svc_callout { struct svc_callout *sc_next; +#ifdef __LP64__ + uint32_t sc_prog; + uint32_t sc_vers; +#else u_long sc_prog; u_long sc_vers; +#endif void (*sc_dispatch)(); } *svc_head; @@ -224,8 +229,13 @@ svc_unregister(prog, vers) */ static struct svc_callout * svc_find(prog, vers, prev) +#ifdef __LP64__ + uint32_t prog; + uint32_t vers; +#else u_long prog; u_long vers; +#endif struct svc_callout **prev; { register struct svc_callout *s, *p; @@ -417,21 +427,37 @@ svc_getreqset(readfds) enum xprt_stat stat; struct rpc_msg msg; int prog_found; +#ifdef __LP64__ + uint32_t low_vers; + uint32_t high_vers; +#else u_long low_vers; u_long high_vers; +#endif struct svc_req r; register SVCXPRT *xprt; +#ifdef __LP64__ + register uint32_t mask; +#else register u_long mask; +#endif register int bit; +#ifdef __LP64__ + register uint32_t *maskp; +#else register u_long *maskp; +#endif register int sock; char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE]; msg.rm_call.cb_cred.oa_base = cred_area; msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]); r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]); - +#ifdef __LP64__ + maskp = (uint32_t *)readfds->fds_bits; +#else maskp = (u_long *)readfds->fds_bits; +#endif for (sock = 0; sock <= svc_maxfd; sock += NFDBITS) { for (mask = *maskp++; (bit = ffs(mask)); mask ^= (1 << (bit - 1))) { if ((sock + bit) > (svc_maxfd + 1)) diff --git a/rpc.subproj/svc_simple.c b/rpc.subproj/svc_simple.c index 3796844..c0952fd 100644 --- a/rpc.subproj/svc_simple.c +++ b/rpc.subproj/svc_simple.c @@ -84,6 +84,9 @@ struct proglst *pl; int registerrpc(prognum, versnum, procnum, progname, inproc, outproc) + int prognum; + int versnum; + int procnum; char *(*progname)(); xdrproc_t inproc, outproc; { @@ -103,13 +106,23 @@ registerrpc(prognum, versnum, procnum, progname, inproc, outproc) return (-1); } } - (void) pmap_unset((u_long)prognum, (u_long)versnum); - if (!svc_register(transp, (u_long)prognum, (u_long)versnum, +#ifdef __LP64__ + (void) pmap_unset((uint32_t)prognum, (uint32_t)versnum); + if (!svc_register(transp, (uint32_t)prognum, (uint32_t)versnum, universal, IPPROTO_UDP)) { (void) fprintf(stderr, "couldn't register prog %d vers %d\n", prognum, versnum); return (-1); } +#else + (void) pmap_unset((u_long)prognum, (u_long)versnum); + if (!svc_register(transp, (u_long)prognum, (u_long)versnum, + universal, IPPROTO_UDP)) { + (void) fprintf(stderr, "couldn't register prog %d vers %d\n", + prognum, versnum); + return (-1); + } +#endif pl = (struct proglst *)malloc(sizeof(struct proglst)); if (pl == NULL) { (void) fprintf(stderr, "registerrpc: out of memory\n"); diff --git a/rpc.subproj/svc_tcp.c b/rpc.subproj/svc_tcp.c index 23c6f65..a69c923 100644 --- a/rpc.subproj/svc_tcp.c +++ b/rpc.subproj/svc_tcp.c @@ -123,7 +123,11 @@ struct tcp_rendezvous { /* kept in xprt->xp_p1 */ struct tcp_conn { /* kept in xprt->xp_p1 */ enum xprt_stat strm_stat; +#ifdef __LP64__ + uint32_t x_id; +#else u_long x_id; +#endif XDR xdrs; char verf_body[MAX_AUTH_BYTES]; }; diff --git a/rpc.subproj/svc_udp.c b/rpc.subproj/svc_udp.c index 3cbd9f4..b74daf5 100644 --- a/rpc.subproj/svc_udp.c +++ b/rpc.subproj/svc_udp.c @@ -66,6 +66,7 @@ static char *rcsid = "$Id: svc_udp.c,v 1.5 2004/10/13 00:24:07 jkh Exp $"; #include #include +#include #include #include #include @@ -100,7 +101,11 @@ extern int errno; */ struct svcudp_data { u_int su_iosz; /* byte size of send.recv buffer */ +#ifdef __LP64__ + uint32_t su_xid; /* transaction id */ +#else u_long su_xid; /* transaction id */ +#endif XDR su_xdrs; /* XDR handle */ char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */ char * su_cache; /* cached data, NULL if no cache */ @@ -205,15 +210,24 @@ svcudp_recv(xprt, msg) register XDR *xdrs = &(su->su_xdrs); register int rlen; char *reply; +#ifdef __LP64__ + uint32_t replylen; +#else u_long replylen; +#endif again: xprt->xp_addrlen = sizeof(struct sockaddr_in); rlen = recvfrom(xprt->xp_sock, rpc_buffer(xprt), (int) su->su_iosz, 0, (struct sockaddr *)&(xprt->xp_raddr), (unsigned int *)&(xprt->xp_addrlen)); if (rlen == -1 && errno == EINTR) goto again; +#ifdef __LP64__ + if (rlen < 4*sizeof(uint32_t)) + return (FALSE); +#else if (rlen < 4*sizeof(u_long)) return (FALSE); +#endif xdrs->x_op = XDR_DECODE; XDR_SETPOS(xdrs, 0); if (! xdr_callmsg(xdrs, msg)) @@ -249,7 +263,11 @@ svcudp_reply(xprt, msg) == slen) { stat = TRUE; if (su->su_cache && slen >= 0) { +#ifdef __LP64__ + cache_set(xprt, (uint32_t) slen); +#else cache_set(xprt, (u_long) slen); +#endif } } } @@ -320,16 +338,27 @@ struct cache_node { /* * Index into cache is xid, proc, vers, prog and address */ +#ifdef __LP64__ + uint32_t cache_xid; + uint32_t cache_proc; + uint32_t cache_vers; + uint32_t cache_prog; +#else u_long cache_xid; u_long cache_proc; u_long cache_vers; u_long cache_prog; +#endif struct sockaddr_in cache_addr; /* * The cached reply and length */ char * cache_reply; +#ifdef __LP64__ + uint32_t cache_replylen; +#else u_long cache_replylen; +#endif /* * Next node on the list, if there is a collision */ @@ -342,13 +371,24 @@ struct cache_node { * The entire cache */ struct udp_cache { +#ifdef __LP64__ + uint32_t uc_size; /* size of cache */ +#else u_long uc_size; /* size of cache */ +#endif cache_ptr *uc_entries; /* hash table of entries in cache */ cache_ptr *uc_fifo; /* fifo list of entries in cache */ +#ifdef __LP64__ + uint32_t uc_nextvictim; /* points to next victim in fifo list */ + uint32_t uc_prog; /* saved program number */ + uint32_t uc_vers; /* saved version number */ + uint32_t uc_proc; /* saved procedure number */ +#else u_long uc_nextvictim; /* points to next victim in fifo list */ u_long uc_prog; /* saved program number */ u_long uc_vers; /* saved version number */ u_long uc_proc; /* saved procedure number */ +#endif struct sockaddr_in uc_addr; /* saved caller's address */ }; @@ -367,7 +407,11 @@ struct udp_cache { int svcudp_enablecache(transp, size) SVCXPRT *transp; +#ifdef __LP64__ + uint32_t size; +#else u_long size; +#endif { struct svcudp_data *su = su_data(transp); struct udp_cache *uc; @@ -406,7 +450,11 @@ svcudp_enablecache(transp, size) static void cache_set(xprt, replylen) SVCXPRT *xprt; - u_long replylen; +#ifdef __LP64__ + uint32_t replylen; +#else + u_long replylen; +#endif { register cache_ptr victim; register cache_ptr *vicp; @@ -473,7 +521,11 @@ cache_get(xprt, msg, replyp, replylenp) SVCXPRT *xprt; struct rpc_msg *msg; char **replyp; +#ifdef __LP64__ + uint32_t *replylenp; +#else u_long *replylenp; +#endif { u_int loc; register cache_ptr ent;