Skip to content

Potential fix for code scanning alert no. 1935: Unbounded write#26

Open
HaplessIdiot wants to merge 438 commits into
masterfrom
alert-autofix-1935
Open

Potential fix for code scanning alert no. 1935: Unbounded write#26
HaplessIdiot wants to merge 438 commits into
masterfrom
alert-autofix-1935

Conversation

@HaplessIdiot

Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/supersonic-xserver/ssX/security/code-scanning/1935

In general, to fix unbounded write issues like this, every copy into a heap or stack buffer must be limited by the known size of that buffer, and the destination must always be null-terminated. For string copies, this means replacing strcpy with strncpy or, more robustly, snprintf/strlcpy-style calls that take the buffer size as an argument. The size used must be the same or smaller than what was used when allocating or defining the buffer.

For this specific instance in programs/xdm/auth.c in MakeServerAuthFile, we already allocate d->authFile with malloc(len) where len was computed as strlen(d->clientAuthFile) + 1 when d->clientAuthFile is used. The simplest safe fix is to copy at most len - 1 bytes and explicitly null-terminate. We can do this with strncpy(d->authFile, d->clientAuthFile, len - 1); d->authFile[len - 1] = '\0';. This preserves behavior (the entire string is copied, because len - 1 equals strlen(d->clientAuthFile) here) but makes the sink safe even if the allocation logic is modified later or if len is computed differently. No new headers are needed because <string.h> is already indirectly available in this codebase; if it were not, we would add it.

Concretely:

  • In programs/xdm/auth.c, within MakeServerAuthFile, replace the strcpy (d->authFile, d->clientAuthFile); line with a bounded copy using strncpy and forced null-termination, using the existing len variable.
  • No other files/snippets need modification to address this particular strcpy sink; the taint-analysis chain through the other files is only to justify untrusted input, not to be changed for this fix.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

jmcneill and others added 30 commits February 9, 2020 11:40
…aki.

I've finally contacted with Yamasaki-san and he kindly answered
"no objection to change them to 2 clause license" in private mail.
Diffs to be committed have also been confirmed by him.
We appreciate all his contribution to early NetBSD/x68k.
https://mail-index.netbsd.org/source-changes/2020/07/18/msg119473.html
> Use AllocDevicePair() to initialize input devices in InitInput().

Untested, but I'll re-visit on migrating to HAVE_XORG_SERVER_VER=120.
As per upstream commits for Xnest:
 https://cgit.freedesktop.org/xorg/xserver/commit/?id=67c303fff303f94b62f03a76de97116c6ebcfda9

Note GLXEXT is defined as 1 in xorg-server/include/xorg-server.h
(i.e. /usr/X11R7/include/xorg/xorg-server.h) so no proper way to
disable it on building MD servers per ${MACHINE} basis.
https://mail-index.netbsd.org/source-changes/2020/07/18/msg119488.html
> Fix 1bpp Xservers on "whitePixel=0, blackPixel=1" VRAMs.
>
> - Don't override pScreen->blackPixel and pScreen->whitePixel
>   (set in MD server Init functions per -filpPixels option)
>   on 1bpp servers in merged fbSetupScreen() (merged one
>   from cfbSetupScrenn and mfbSetupScreen() in old xsrc/xfree)
> - Pull mfbCreateColormap() function from old xsrc/xfree tree
>   and use it on 1bpp servers

Confirmed on luna68k 1bpp Xorg 1.20 server using xf86-video-wsfb
with "-flipPixels" option.
This is based on 1.10 version imported into xorg-server.old and
all upstream API changes between xorg-server 1.10 and 1.20 are
applied almost mechanically.
 https://github.com/tsutsui/xorg-server-Xsun/commits/xorg-server-1.20

Xsun and XsunMono servers are also confirmed working with bwtwo on
3/60 and tme, and cgtwo on tme. XKB stuff is still to be resolved.
Fixes build error on sparc64.  No binary change on sun3.
Now CapsLock and NumLock LEDs work correctly.
XXX: No ScrollLock LED
…ball.

From aac28e1 Mon Sep 17 00:00:00 2001
From: Matthieu Herrb <matthieu@herrb.eu>
Date: Sat, 25 Jul 2020 19:33:50 +0200
Subject: [PATCH] fix for ZDI-11426

Avoid leaking un-initalized memory to clients by zeroing the
whole pixmap on initial allocation.

This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
…tings.

Now all modifier keys (CTRL, SHIFT, and NumLock) work as expected.

It seems XkbApplyMappingChange() doesn't update some XKB modifier
settings even if new modmap data is specified.
HaplessIdiot and others added 28 commits March 14, 2026 11:35
Potential fix for code scanning alert no. 62: Non-constant format string
…pr-1780

Revert "glamor/glamor_egl.c: Check if at least one (format, modifier) pair is supported"
…pr-1780

Revert "glamor/glamor_egl.c: Check if at least one (format, modifier) pair is supported"
Make IgnoreABI configurable through config files
Unify intel video driver and evdev input inside source tree
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@HaplessIdiot HaplessIdiot marked this pull request as ready for review March 14, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants