if (--ift >= ifa) {
ift->ifa_next = NULL;
*pif = ifa;
- } else {
- *pif = NULL;
- free(ifa);
- }
-
- for (ift = ifa; ift != NULL; ift = ift->ifa_next)
- {
- if (ift->ifa_addr->sa_family == AF_INET6)
+
+ for (ift = ifa; ift != NULL; ift = ift->ifa_next)
{
- sin6 = (struct sockaddr_in6 *)ift->ifa_addr;
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) || IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))
+ if (ift->ifa_addr->sa_family == AF_INET6)
{
- esid = ntohs(sin6->sin6_addr.__u6_addr.__u6_addr16[1]);
- sin6->sin6_addr.__u6_addr.__u6_addr16[1] = 0;
- if (sin6->sin6_scope_id == 0) sin6->sin6_scope_id = esid;
+ sin6 = (struct sockaddr_in6 *)ift->ifa_addr;
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) || IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))
+ {
+ esid = ntohs(sin6->sin6_addr.__u6_addr.__u6_addr16[1]);
+ sin6->sin6_addr.__u6_addr.__u6_addr16[1] = 0;
+ if (sin6->sin6_scope_id == 0) sin6->sin6_scope_id = esid;
+ }
}
}
}
+ else {
+ *pif = NULL;
+ free(ifa);
+ }
return (0);
}
{
struct ifaddrs *ifaddrs, *ifa;
unsigned int ni;
- int nbytes;
+ size_t nbytes;
struct if_nameindex *ifni, *ifni2;
char *cp;
_ds_list(si_mod_t *si, int cat, const char *procname, const void *extra, od_extract_t extract)
{
__block si_list_t *list;
- uint64_t va, vb;
+ uint64_t va = 0, vb = 0;
xpc_object_t reply, result;
if (procname == NULL) return NULL;
_ds_item(si_mod_t *si, int cat, const char *procname, const void *extra, od_extract_t extract, xpc_object_t payload)
{
xpc_object_t result;
- uint64_t va, vb;
+ uint64_t va = 0, vb = 0;
si_item_t *item = NULL;
if (procname == NULL) return NULL;
.Fa ai_flags
set to
.Dv AI_DEFAULT.
+.Pp
+Note that NAT64 address synthesis is always disabled for IPv4 addresses
+in the following ranges:
+0.0.0.0/8,
+127.0.0.0/8,
+169.254.0.0/16,
+192.0.0.0/29,
+192.88.99.0/24,
+224.0.0.0/4, and
+255.255.255.255/32.
+Additionally, NAT64 address synthesis is disabled when the network uses
+the well-known prefix (64:ff9b::/96)
+for IPv4 addresses in the following ranges:
+10.0.0.0/8,
+100.64.0.0/10,
+172.16.0.0/12, and
+192.168.0.0/16.
+.Pp
+Historically, passing a host's own hostname to
+.Fn getaddrinfo
+has been a popular
+technique for determining that host's IP address(es), but this is fragile,
+and doesn't work reliably in all cases. The appropriate way for software to
+discover the IP address(es) of the host it is running on is to use
+.Xr getifaddrs 3 .
+.Pp
+The
+.Fn getaddrinfo
+implementations on all versions of OS X and iOS are now, and always have been,
+thread-safe. Previous versions of this man page incorrectly reported that
+.Fn getaddrinfo
+was not thread-safe.
.Sh RETURN VALUES
.Fn getaddrinfo
returns zero on success or one of the error codes listed in
/* GLOBAL */
-#if __ARM_ARCH_7K__ && __BIGGEST_ALIGNMENT__ > 4
+#if __ARM_ARCH_7K__ || __ARM64_ARCH_8_32__
static const uint32_t align_32[] = { 0, 1, 2, 0, 4, 0, 0, 0, 8 };
#else
static const uint32_t align_32[] = { 0, 1, 2, 0, 4, 0, 0, 0, 4 };
groups[0] = basegid;
*ngroups = 1;
- item = si_grouplist(si_search(), name, max);
+ item = si_grouplist(si_search(), name, max+1);
LI_set_thread_item(CATEGORY_GROUPLIST, item);
if (item == NULL) return 0;
if (h->host.h_addr_list == NULL)
{
h->addr_count = 0;
+ free(buf);
return -1;
}
if (rdlen < sizeof(mdns_rr_srv_t))
{
malformed = 1;
+ free(srv);
break;
}
if (srv->srv.target == NULL)
{
malformed = 1;
+ free(srv);
break;
}
extern char *_fsi_get_line(FILE *fp);
static void si_module_config_parse_line(search_si_private_t *pp, char *line);
-static void si_module_config_modules_for_category(search_si_private_t *pp, int cat, int ntokens, const char * const *tokens);
+static int si_module_config_modules_for_category(search_si_private_t *pp, int cat, int ntokens, const char * const *tokens);
static si_mod_t *
search_get_module(search_si_private_t *pp, int cat, int *n)
si_mod_t *
si_module_static_search(void)
{
+ static bool result = false;
+
static const struct si_mod_vtable_s search_vtable =
{
.sim_close = &search_close,
};
int count = sizeof(modules) / sizeof(char *);
- si_module_config_modules_for_category(pp, CATEGORY_DEFAULT, count, modules);
+ if (si_module_config_modules_for_category(pp, CATEGORY_DEFAULT, count, modules) != 0)
+ {
+ free(si.name);
+ si.name = NULL;
+ free(pp);
+ si.private = NULL;
+ result = true;
+ return;
+ }
+
pp->cache = pp->search_list[CATEGORY_DEFAULT].module[0];
char *check = getenv("SYSINFO_CONF_ENABLE");
}
});
- return &si;
+ return (!result) ? &si : NULL;
}
static void
free(tokens);
}
-static void
+static int
si_module_config_modules_for_category(search_si_private_t *pp, int cat, int ntokens, const char * const *tokens)
{
int count = ntokens - 1;
pp->search_list[cat].count = count;
if (count == 0)
{
- return;
+ return -1;
}
pp->search_list[cat].module = (si_mod_t **)calloc(pp->search_list[cat].count, sizeof(si_mod_t *));
{
free(pp->search_list[cat].module);
free(pp->search_list[cat].module_flags);
- return;
+ return -1;
}
int i, j;
}
}
}
+ return 0;
}
else
{
l->count = 0;
+ free(l);
l = NULL;
}
}
{
/* ENXIO */
if (err != NULL) *err = SI_STATUS_EAI_FAIL;
+ free(serv);
return NULL;
}
}
if ((flags & AI_NUMERICSERV) != 0)
{
+ if (servptr == NULL)
+ {
+ if (err) *err = SI_STATUS_H_ERRNO_NO_RECOVERY;
+ return NULL;
+ }
port = *(uint16_t*)servptr;
}
else
}
static si_list_t *
-_gai_nat64_synthesis(si_mod_t *si, const char *node, const char *serv, int numericserv,
+_gai_nat64_synthesis(si_mod_t *si, const char *node, const void *servptr, int numericserv,
uint32_t family, uint32_t socktype, uint32_t proto, uint32_t flags, const char *interface)
{
if (NULL == node)
return NULL;
}
+ /* validate that IPv4 address is eligible for NAT64 synthesis */
+#if defined(NW_NAT64_API_VERSION) && NW_NAT64_API_VERSION >= 2
+ if (!nw_nat64_can_v4_address_be_synthesized(&a4)) {
+ return NULL;
+ }
+#endif // NW_NAT64_API_VERSION
+
/* validate that there is at least an IPv6 address configured */
uint32_t num_inet6 = 0;
if ((si_inet_config(NULL, &num_inet6) < 0) || (0 == num_inet6))
uint16_t port = 0;
if (0 == numericserv)
{
- if (_gai_serv_to_port(serv, proto, &port) != 0)
+ if (_gai_serv_to_port((const char *)servptr, proto, &port) != 0)
{
return NULL;
}
flags |= AI_NUMERICSERV;
}
}
+ else if (NULL != servptr)
+ {
+ port = *((const uint16_t *)servptr);
+ }
/* query NAT64 prefixes */
nw_nat64_prefix_t *prefixes = NULL;
}
/* NAT64 IPv6 address synthesis support */
- si_list_t *nat64_list = _gai_nat64_synthesis(si, node, serv, numericserv, family, socktype, proto, flags, interface);
+ si_list_t *nat64_list = _gai_nat64_synthesis(si, node, servptr, numericserv, family, socktype, proto, flags, interface);
if (NULL != nat64_list)
{
return nat64_list;
.Bl -tag -width Er
.It Bq Er EIO
Communication with
-.Xr openditectoryd 8
+.Xr opendirectoryd 8
failed.
.It Bq Er ENOENT
.Fa user
or Active Directory server, it will have a 128 bit or larger sid.
.Pp
These routines communicate with
-.Xr openditectoryd 8 .
+.Xr opendirectoryd 8 .
.Pp
.Fn mbr_uid_to_uuid
takes a uid and looks up the associated user account.
Note that
.Fn mbr_uuid_to_id
always returns an id even if the uuid is not found.
-This returned id is not persistant,
+This returned id is not persistent,
but can be used to map back to the uuid during runtime.
To determine if the uuid exists, the returned id can be used in a call to
.Xr getpwuid 3
.Bl -tag -width Er
.It Bq Er EIO
Communication with
-.Xr openditectoryd 8
+.Xr opendirectoryd 8
failed.
.It Bq Er ENOENT
The mapping can not be performed.
.It Bq Er EAUTH
Communication with
-.Xr openditectoryd 8
+.Xr opendirectoryd 8
failed due to an authentication error.
.It Bq Er EINVAL
Invalid arguments were provided.
.Xr getpwuid 3 ,
.Xr getgrgid 3 ,
.Xr mbr_check_membership 3 ,
-.Xr openditectoryd 8
+.Xr opendirectoryd 8
the type of ID (ID_TYPE_UID or ID_TYPE_GID). Synthesized
UUID values will be directly translated to corresponding ID.
A UID will always be returned even if the UUID is not found.
- The returned ID is not persistant, but can be used to map back
+ The returned ID is not persistent, but can be used to map back
to the UUID during runtime.
@param uu is the UUID to be resolved
@param uid_or_gid is the UID or GID found for the UUID
char *gl_name;
char *gl_domain;
struct grouplist *gl_nxt;
-} *grouplist, *grlist;
+} *grouplist;
struct list { /* list of names to check for loops */
static char *match();
static char *domain;
-static char *oldgrp;
char *NETGROUP = "netgroup";
-
-void _old_endnetgrent(void);
-void _old_setnetgrent(char *);
-
-void _old_setnetgrent(grp)
- char *grp;
-{
-
- if (oldgrp == NULL)
- oldgrp = (char *)calloc(1,256);
- if (oldgrp == NULL) return;
- if (strcmp(oldgrp, grp) == 0)
- grlist = grouplist;
- else {
- if (grouplist != NULL)
- _old_endnetgrent();
- doit(grp, (struct list *) NULL);
- grlist = grouplist;
- (void) strcpy(oldgrp, grp);
- }
-}
-
-void _old_endnetgrent()
-{
- register struct grouplist *gl;
-
- for (gl = grouplist; gl != NULL; gl = gl->gl_nxt) {
- if (gl->gl_name)
- free(gl->gl_name);
- if (gl->gl_domain)
- free(gl->gl_domain);
- if (gl->gl_machine)
- free(gl->gl_machine);
- free((char *) gl);
- }
- grouplist = NULL;
- grlist = NULL;
- if (oldgrp) {
- free(oldgrp);
- oldgrp = 0;
- }
-}
-
-int _old_getnetgrent(machinep, namep, domainp)
- char **machinep, **namep, **domainp;
-{
-
- if (grlist == 0)
- return (0);
- *machinep = grlist->gl_machine;
- *namep = grlist->gl_name;
- *domainp = grlist->gl_domain;
- grlist = grlist->gl_nxt;
- return (1);
-}
-
/*
* recursive function to find the members of netgroup "group". "list" is
* the path followed through the netgroups so far, to check for cycles.
grouplist = gpls;
} else {
q = strpbrk(p, " \t\n#");
- if (q && *q == '#')
+ if (q == NULL || *q == '#')
break;
*q = 0;
doit(p,list);
return;
syntax_error:
+ free(gpls);
(void) fprintf(stderr,"syntax error in /etc/netgroup\n");
(void) fprintf(stderr,"--- %s\n",val);
return;
}
xdr_free((xdrproc_t)xdr_ypresp_all, (char *)&out);
- if (key == NULL || val == NULL)
+ if (key == NULL || val == NULL) {
+ free(key);
+ free(val);
return FALSE;
+ }
r = (*ypresp_allfn)(status, key,
out.ypresp_all_u.val.key.keydat_len, val,
au = (struct audata *)mem_alloc(sizeof(*au));
#ifndef KERNEL
if (au == NULL) {
+ mem_free(auth, sizeof(*auth));
(void)fprintf(stderr, "authunix_create: out of memory\n");
return (NULL);
}
au->au_origcred.oa_base = mem_alloc((u_int) len);
#else
if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) {
+ mem_free(auth, sizeof(*auth));
+ mem_free(au, sizeof(*au));
(void)fprintf(stderr, "authunix_create: out of memory\n");
return (NULL);
}
}
shipnow =
- (xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0
- && timeout.tv_usec == 0) ? FALSE : TRUE;
+ (xdr_results == (xdrproc_t)NULLPROC || (timeout.tv_sec == 0
+ && timeout.tv_usec == 0)) ? FALSE : TRUE;
call_again:
xdrs->x_op = XDR_ENCODE;
register struct pmaplist **next = NULL;
while (TRUE) {
- more_elements = (bool_t)(*rp != NULL);
+ more_elements = (bool_t)(!(rp == NULL || *rp == NULL));
if (! xdr_bool(xdrs, &more_elements))
return (FALSE);
if (! more_elements)
* before we free the current object ...
*/
if (freeing)
- next = &((*rp)->pml_next);
+ next = &((*rp)->pml_next);
if (! xdr_reference(xdrs, (caddr_t *)rp, (u_int)sizeof(struct pmaplist), (xdrproc_t)xdr_pmap))
return (FALSE);
rp = (freeing) ? next : &((*rp)->pml_next);
r->recvsize = recvsize;
xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT));
if (xprt == NULL) {
+ mem_free(r, sizeof(*r));
(void) fprintf(stderr, "svctcp_create: out of memory\n");
return (NULL);
}
}
su = (struct svcudp_data *)mem_alloc(sizeof(*su));
if (su == NULL) {
+ mem_free(xprt, sizeof(SVCXPRT));
(void)fprintf(stderr, "svcudp_create: out of memory\n");
return (NULL);
}
su->su_iosz = ((MAX(sendsz, recvsz) + 3) / 4) * 4;
if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL) {
+ mem_free(xprt, sizeof(SVCXPRT));
+ mem_free(su, sizeof(*su));
(void)fprintf(stderr, "svcudp_create: out of memory\n");
return (NULL);
}
uc->uc_nextvictim = 0;
uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS);
if (uc->uc_entries == NULL) {
+ mem_free(uc, sizeof(*uc));
CACHE_PERROR("enablecache: could not allocate cache data");
return(0);
}
BZERO(uc->uc_entries, cache_ptr, size * SPARSENESS);
uc->uc_fifo = ALLOC(cache_ptr, size);
if (uc->uc_fifo == NULL) {
+ mem_free(uc->uc_entries, sizeof(struct udp_cache)*size * SPARSENESS);
+ mem_free(uc, sizeof(struct udp_cache));
CACHE_PERROR("enablecache: could not allocate cache fifo");
return(0);
}
}
newbuf = mem_alloc(su->su_iosz);
if (newbuf == NULL) {
+ mem_free(victim, sizeof(*victim));
CACHE_PERROR("cache_set: could not allocate new rpc_buffer");
return;
}
LINK_WITH_STANDARD_LIBRARIES = NO
+SIM_SUFFIX[sdk=*simulator*] = _sim
+
LIBCOMPILER_RT_LDFLAGS = -lcompiler_rt
LIBMALLOC_LDFLAGS = -lsystem_malloc
-LIBPLATFORM_LDFLAGS = -lsystem_platform
-LIBPLATFORM_LDFLAGS[sdk=iphonesimulator*] = -lsystem_sim_platform
-LIBPTHREAD_LDFLAGS = -lsystem_pthread
-LIBPTHREAD_LDFLAGS[sdk=iphonesimulator*] = -lsystem_sim_pthread
-LIBSYSCALL_LDFLAGS = -lsystem_kernel
-LIBSYSCALL_LDFLAGS[sdk=iphonesimulator*] = -lsystem_sim_kernel
+LIBPLATFORM_LDFLAGS = -lsystem$(SIM_SUFFIX)_platform
+LIBPTHREAD_LDFLAGS = -lsystem$(SIM_SUFFIX)_pthread
+LIBSYSCALL_LDFLAGS = -lsystem$(SIM_SUFFIX)_kernel
LIBM_LDFLAGS = -lsystem_m
-LIBM_LDFLAGS[sdk=iphonesimulator*] = -lsystem_sim_m
LIBDYLD_LDFLAGS = -ldyld
LIBC_LDFLAGS = -lsystem_c
LIBDISPATCH_LDFLAGS = -ldispatch
LIBDNSD_LDFLAGS = -lsystem_dnssd
LIBNOTIFY_LDFLAGS = -lsystem_notify
LIBXPC_LDFLAGS = -lxpc
-LIBNETWORK_LDFLAGS = -Wl,-upward-lsystem_network
+LIBNETWORK_LDFLAGS = -lsystem_network
OTHER_LDFLAGS = -all_load -umbrella System -L/usr/lib/system $(LIBCOMPILER_RT_LDFLAGS) $(LIBDYLD_LDFLAGS) $(LIBSYSCALL_LDFLAGS) $(LIBMALLOC_LDFLAGS) $(LIBPLATFORM_LDFLAGS) $(LIBPTHREAD_LDFLAGS) $(LIBC_LDFLAGS) $(LIBDISPATCH_LDFLAGS) $(LIBLAUNCH_LDFLAGS) $(LIBASL_LDFLAGS) $(LIBBLOCKS_LDFLAGS) $(LIBDNSD_LDFLAGS) $(LIBNOTIFY_LDFLAGS) $(LIBXPC_LDFLAGS) $(LIBNETWORK_LDFLAGS)