mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-02-03 12:30:28 +01:00
os: avoid potential out-of-bounds access at logVHdrMessageVerb
The LogVHdrMessageVerb function may access an array out of bounds in a
specific edge case. Specifically, the line:
newline = (buf[len - 1] == '\n');
can result in accessing buf[-1] if len == 0, which is undefined behavior.
Commit adds check to avoid access out of bounds at pointed line.
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1841
Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
(cherry picked from commit 8d25a89143)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2077>
This commit is contained in:
parent
b53d9fa417
commit
c49bf5f7fd
1 changed files with 1 additions and 1 deletions
2
os/log.c
2
os/log.c
|
|
@ -834,7 +834,7 @@ LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
|
|||
if (size - len == 1)
|
||||
buf[len - 1] = '\n';
|
||||
|
||||
newline = (buf[len - 1] == '\n');
|
||||
newline = (len > 0 && buf[len - 1] == '\n');
|
||||
LogSWrite(verb, buf, len, newline);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue