mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-23 11:18:54 +00:00
Fix several Coverity CIDs in devd
CID 1362055, 1362054: File descriptor leaks during shutdown CID 1362013: Potential null-termination fail with long network device names CID 1362097: Uncaught exception during memory pressure CID 1362017, 1362016: Unchecked errors, possibly resulting in weird behavior if two devd instances start at the same time. CID 1362015: Unchecked error that will probably never fail Reported by: Coverity CID: 1362055 1362054 1362013 1362097 1362017 1362016 1362015 MFC after: 4 weeks Sponsored by: Spectra Logic Corp
This commit is contained in:
parent
c9bf814804
commit
daa0d9dd7e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=312395
@ -372,7 +372,7 @@ media::do_match(config &c)
|
||||
s = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (s >= 0) {
|
||||
memset(&ifmr, 0, sizeof(ifmr));
|
||||
strncpy(ifmr.ifm_name, value.c_str(), sizeof(ifmr.ifm_name));
|
||||
strlcpy(ifmr.ifm_name, value.c_str(), sizeof(ifmr.ifm_name));
|
||||
|
||||
if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) >= 0 &&
|
||||
ifmr.ifm_status & IFM_AVALID) {
|
||||
@ -871,8 +871,10 @@ create_socket(const char *name, int socktype)
|
||||
if (::bind(fd, (struct sockaddr *) & sun, slen) < 0)
|
||||
err(1, "bind");
|
||||
listen(fd, 4);
|
||||
chown(name, 0, 0); /* XXX - root.wheel */
|
||||
chmod(name, 0666);
|
||||
if (chown(name, 0, 0)) /* XXX - root.wheel */
|
||||
err(1, "chown");
|
||||
if (chmod(name, 0666))
|
||||
err(1, "chmod");
|
||||
return (fd);
|
||||
}
|
||||
|
||||
@ -1058,7 +1060,13 @@ event_loop(void)
|
||||
buffer[rv] = '\0';
|
||||
while (buffer[--rv] == '\n')
|
||||
buffer[rv] = '\0';
|
||||
process_event(buffer);
|
||||
try {
|
||||
process_event(buffer);
|
||||
}
|
||||
catch (std::length_error e) {
|
||||
devdlog(LOG_ERR, "Dropping event %s "
|
||||
"due to low memory", buffer);
|
||||
}
|
||||
} else if (rv < 0) {
|
||||
if (errno != EINTR)
|
||||
break;
|
||||
@ -1076,6 +1084,8 @@ event_loop(void)
|
||||
if (FD_ISSET(seqpacket_fd, &fds))
|
||||
new_client(seqpacket_fd, SOCK_SEQPACKET);
|
||||
}
|
||||
close(seqpacket_fd);
|
||||
close(stream_fd);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
@ -1218,7 +1228,8 @@ check_devd_enabled()
|
||||
if (val == 0) {
|
||||
warnx("Setting " SYSCTL " to 1000");
|
||||
val = 1000;
|
||||
sysctlbyname(SYSCTL, NULL, NULL, &val, sizeof(val));
|
||||
if (sysctlbyname(SYSCTL, NULL, NULL, &val, sizeof(val)))
|
||||
err(1, "sysctlbyname");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user