mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-01-04 09:50:13 +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> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2061>
This commit is contained in:
parent
b096785df4
commit
8d25a89143
1 changed files with 1 additions and 1 deletions
2
os/log.c
2
os/log.c
|
|
@ -801,7 +801,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