svn commit: r329236 - head/contrib/netbsd-tests/kernel
Alan Somers
asomers at FreeBSD.org
Tue Feb 13 19:17:34 UTC 2018
Author: asomers
Date: Tue Feb 13 19:17:33 2018
New Revision: 329236
URL: https://svnweb.freebsd.org/changeset/base/329236
Log:
Fix Coverity CIDs in the sys/kern/sysv_test tests
CID 979810: strcpy => strlcpy
CID 1193367: don't leak a file descriptor
CID 1299856: Check the return value of read(2)
Reported by: Coverity
Coverity CID: 978910 1193367 1299856
MFC after: 3 weeks
X-MFC-With: 328896
Sponsored by: Spectra Logic Corp
Modified:
head/contrib/netbsd-tests/kernel/t_sysv.c
Modified: head/contrib/netbsd-tests/kernel/t_sysv.c
==============================================================================
--- head/contrib/netbsd-tests/kernel/t_sysv.c Tue Feb 13 17:58:02 2018 (r329235)
+++ head/contrib/netbsd-tests/kernel/t_sysv.c Tue Feb 13 19:17:33 2018 (r329236)
@@ -129,7 +129,8 @@ read_int(const char *path)
return -1;
else {
int value;
- read(input, &value, sizeof(value));
+ ATF_REQUIRE_EQ(read(input, &value, sizeof(value)), sizeof(value));
+ close(input);
return value;
}
}
@@ -284,7 +285,7 @@ ATF_TC_BODY(msg, tc)
* Send the first message to the receiver and wait for the ACK.
*/
m.mtype = MTYPE_1;
- strcpy(m.mtext, m1_str);
+ strlcpy(m.mtext, m1_str, sizeof(m.mtext));
ATF_REQUIRE_MSG(msgsnd(sender_msqid, &m, MESSAGE_TEXT_LEN,
0) != -1, "sender: msgsnd 1: %d", errno);
@@ -298,7 +299,7 @@ ATF_TC_BODY(msg, tc)
* Send the second message to the receiver and wait for the ACK.
*/
m.mtype = MTYPE_2;
- strcpy(m.mtext, m2_str);
+ strlcpy(m.mtext, m2_str, sizeof(m.mtext));
ATF_REQUIRE_MSG(msgsnd(sender_msqid, &m, MESSAGE_TEXT_LEN, 0) != -1,
"sender: msgsnd 2: %d", errno);
More information about the svn-src-all
mailing list