Skip to content

Commit 0358f7a

Browse files
metan-ucwpevik
authored andcommitted
syscalls/msgstress01: Fix off by one in array access
The size returned from recvmsg() is the size of the payload but the payload is defined as: struct { char len; char pbytes[99]; } data; So the lenght of the pbytes is actually one byte shorter than the size and we access one byte after the array in the comparsion. Better fix for this would be removal of the len from the data payload but since we are close to the release lets do the minimal fix now and do the cleanup after the release. Link: https://lore.kernel.org/ltp/[email protected]/ Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Cyril Hrubis <[email protected]>
1 parent dac76a8 commit 0358f7a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

testcases/kernel/syscalls/ipc/msgstress/msgstress01.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static void reader(const int id, const int pos)
160160
return;
161161
}
162162

163-
for (int i = 0; i < size; i++) {
163+
for (int i = 0; i < msg_recv.data.len; i++) {
164164
if (msg_recv.data.pbytes[i] != buff->msg.data.pbytes[i]) {
165165
tst_res(TFAIL, "Received wrong data at index %d: %x != %x", i,
166166
msg_recv.data.pbytes[i],

0 commit comments

Comments
 (0)