+ if (namelen < MAXHOSTNAMELEN + 1) {
+ char local_buf[MAXHOSTNAMELEN + 1];
+ size_t local_len = sizeof(local_buf);
+ if (sysctl(mib, 2, local_buf, &local_len, NULL, 0) == -1) {
+ if (errno == ENOMEM)
+ errno = ENAMETOOLONG;
+ return (-1);
+ }
+ strncpy(name, local_buf, namelen);
+ name[namelen - 1] = 0;
+ } else {