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
This commit is contained in:
parent
0a061d0de0
commit
bda3956278
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user