mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-06-07 02:58:22 +02:00
xkb: fix potential buff overflow in XkbVModIndexText for XkbCFile format
len calculation and strncpy limit were off by one when prefixing
"vmod_" to the virtual modifier name. This could write the final
NULL one byte past the allocated buffer from tbGetBuffer().
Use proper allocation len for prefix to avoid writing out-of-bounds.
Found by Linux Verification Center (linuxtesting.org) with SVACE
Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
(cherry picked from commit 5dfb435c1d)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2224>
This commit is contained in:
parent
c251243f28
commit
cc2bd590f3
1 changed files with 2 additions and 2 deletions
|
|
@ -139,11 +139,11 @@ XkbVModIndexText(XkbDescPtr xkb, unsigned ndx, unsigned format)
|
|||
|
||||
len = strlen(tmp) + 1;
|
||||
if (format == XkbCFile)
|
||||
len += 4;
|
||||
len += 5;
|
||||
rtrn = tbGetBuffer(len);
|
||||
if (format == XkbCFile) {
|
||||
strcpy(rtrn, "vmod_");
|
||||
strncpy(&rtrn[5], tmp, len - 4);
|
||||
strncpy(&rtrn[5], tmp, len - 5);
|
||||
}
|
||||
else
|
||||
strncpy(rtrn, tmp, len);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue