Skip to content

Commit ea7b6c3

Browse files
committed
[xray] Fix oob memory access in FDR BufferQueue iterator.
Before this change, the FDR BufferQueue iterator could access memory out of due to checks of the form `!Buffers[Offset].Used && Offset != Max`, which can potentially access `Buffers[Max]`, which is past the end of the `Buffers`. Fix this by testing `Offset != Max` first.
1 parent e2a72fa commit ea7b6c3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler-rt/lib/xray/xray_buffer_queue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class BufferQueue {
8787
DCHECK_NE(Offset, Max);
8888
do {
8989
++Offset;
90-
} while (!Buffers[Offset].Used && Offset != Max);
90+
} while (Offset != Max && !Buffers[Offset].Used);
9191
return *this;
9292
}
9393

@@ -107,7 +107,7 @@ class BufferQueue {
107107
Max(M) {
108108
// We want to advance to the first Offset where the 'Used' property is
109109
// true, or to the end of the list/queue.
110-
while (!Buffers[Offset].Used && Offset != Max) {
110+
while (Offset != Max && !Buffers[Offset].Used) {
111111
++Offset;
112112
}
113113
}

0 commit comments

Comments
 (0)