/* Make sure the name is printable */
for (i = 0; i < size && buf[i] != '\0'; i++) {
- if (!isgraph(buf[i]))
+ if (!isgraph((unsigned char)buf[i]))
return 0;
}
static Record *
get_record(IPAddr *ip)
{
- uint32_t last_hit, oldest_hit = 0;
+ uint32_t last_hit = 0, oldest_hit = 0;
Record *record, *oldest_record;
unsigned int first, i, j;
/* Make sure the name is at least printable and has no spaces */
for (i = 0; name[i] != '\0'; i++) {
- if (!isgraph(name[i]))
+ if (!isgraph((unsigned char)name[i]))
return NSR_InvalidName;
}
inst->server_name[length] = '\0';
/* Make sure the name is printable and has no spaces */
- for (i = 0; i < length && isgraph(inst->server_name[i]); i++)
+ for (i = 0; i < length && isgraph((unsigned char)inst->server_name[i]); i++)
;
if (i != length) {
DEBUG_LOG("Invalid server name");
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) {
if (!(flags & SCK_FLAG_MSG_DESCRIPTOR) || cmsg->cmsg_len != CMSG_LEN(sizeof (int))) {
- unsigned int i;
+ int i, fd;
DEBUG_LOG("Unexpected SCM_RIGHTS");
- for (i = 0; CMSG_LEN((i + 1) * sizeof (int)) <= cmsg->cmsg_len; i++)
- close(((int *)CMSG_DATA(cmsg))[i]);
+ for (i = 0; CMSG_LEN((i + 1) * sizeof (int)) <= cmsg->cmsg_len; i++) {
+ memcpy(&fd, (char *)CMSG_DATA(cmsg) + i * sizeof (int), sizeof (fd));
+ close(fd);
+ }
r = 0;
} else {
- message->descriptor = *(int *)CMSG_DATA(cmsg);
+ memcpy(&message->descriptor, CMSG_DATA(cmsg), sizeof (message->descriptor));
}
}
}