Skip to content

fix(display): reject trailing X11 display input - #1797

Open
unbridled-41 wants to merge 1 commit into
OpenAtom-Linyaps:masterfrom
unbridled-41:fix/x11-display-trailing-input
Open

fix(display): reject trailing X11 display input#1797
unbridled-41 wants to merge 1 commit into
OpenAtom-Linyaps:masterfrom
unbridled-41:fix/x11-display-trailing-input

Conversation

@unbridled-41

Copy link
Copy Markdown

Summary

Reject malformed X11 DISPLAY values containing trailing characters or extra numeric segments.

Root cause

std::stoi() was used without checking how many characters it consumed. Inputs such as localhost:0junk and localhost:0.1junk were therefore accepted because their numeric prefixes parsed successfully and the remaining characters were ignored.

Changes

  • Check the consumed length for display and screen numbers.
  • Reject unexpected text after the display number.
  • Reject trailing characters and extra dot-separated segments after the screen number.
  • Add regression tests for host and absolute Unix-socket forms.

Reproduction

Call getXOrgDisplay("localhost:0junk"). Before this change it returns a parsed display number of 0; after this change it returns an error.

Test plan

  • Release build with the complete fix set
  • Full CTest suite: 528 passed, 2 unrelated environment-dependent X11 tests skipped, 0 failed
  • Added four focused malformed-input cases
  • git diff --check

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: unbridled-41

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Hi @unbridled-41. Thanks for your PR.

I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Require display and screen numbers to consume their complete input. This prevents malformed DISPLAY values with trailing characters or extra segments from being silently accepted. Add coverage for hostname and Unix-socket forms.

Signed-off-by: 做着百万梦的鱼 <yangzihao_41@outlook.com>
@unbridled-41
unbridled-41 force-pushed the fix/x11-display-trailing-input branch from 80dac00 to e125710 Compare August 10, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants