Skip to content

completion: Validate cursor position - #6761

Merged
swick merged 1 commit into
flatpak:mainfrom
razzeee:completion-papercuts
Sep 21, 2026
Merged

swick merged 1 commit into
flatpak:mainfrom
razzeee:completion-papercuts

Conversation

@razzeee

@razzeee razzeee commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Parse the cursor as a long before narrowing it to the completion structure's integer field. This lets malformed, negative, and overflowing positions fail before they can index outside the command-line buffer, while preserving the existing behavior of clamping positive positions beyond the line length.

Comment thread tests/test-completion.sh
EOF

ok "complete list --columns=arch,"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a useless whitespace change here and the commit message is not wrapper. You can easily avoid this entirely class of issues by configuring your agent and then actually checking the diff.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's my formatter in vscode, I usually have a trim whitespace plugin active and this file has a lot of lines, that have spaces at the end.

So I had to revert every automatic change manually and probably missed the line change here

Comment thread app/flatpak-complete.c Outdated

/* Ensure we're not going oob if we got weird arguments. */
_point = MIN (_point, strlen (arg_line));
point = MIN ((gsize) point, strlen (arg_line));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@razzeee
razzeee force-pushed the completion-papercuts branch from 10dd536 to b657441 Compare August 27, 2026 20:23
Parse the cursor as a long before narrowing it to the completion
structure's integer field. This lets malformed, negative, and overflowing
positions fail before they can index outside the command-line buffer, while
preserving the existing behavior of clamping positive positions beyond the
line length.
@razzeee
razzeee force-pushed the completion-papercuts branch from b657441 to 0649885 Compare August 27, 2026 20:24
@swick
swick added this pull request to the merge queue Sep 21, 2026
Merged via the queue into flatpak:main with commit db7830e Sep 21, 2026
11 checks passed
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