Skip to content

wolfsshd: config file parser fixes - #1347

Open
ejohnstown wants to merge 4 commits into
wolfSSL:masterfrom
ejohnstown:sshd-parser
Open

ejohnstown wants to merge 4 commits into
wolfSSL:masterfrom
ejohnstown:sshd-parser

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

Four fixes to how wolfsshd parses its config file.

  • Numeric options reject trailing text and values over 0x7FFFFFFF
  • Include expands a leading '*' and skips dotfiles, as glob(3) does
  • Match User and Match Group accept comma separated name lists
  • Lines up to 1023 bytes load whole; a longer directive fails the load

This overlaps the long-line change in #1344; whichever merges second
will be rebased onto the other.

Issue: F-10549, F-10550, F-14632, F-11661, F-14395

GetConfigInt() now requires the whole value to be decimal digits,
apart from one time-unit suffix for LoginGraceTime, so "Port 22abc"
and "LoginGraceTime 2junk" fail to load instead of reading 22 and 2.

- accept the s, m, h, d and w time suffixes in either case, as
  OpenSSH does
- reject values above 0x7FFFFFFF, before and after the multiplier
- add Port, Protocol and LoginGraceTime cases to the parser test

Issue: F-10549
HandleInclude() now checks the first character of the pattern for a
'*', so a pattern with no directory part, such as "Include *.conf",
is expanded rather than opened as a literal file. The '*' may match
an empty sequence, but the fixed prefix and postfix may not overlap.

- skip names with a leading '.' unless the pattern starts with '.',
  as glob(3) does
- add tests for foo*, *foo, f*o, a*a and the overlapping ab*ba
- add a leading-wildcard pattern that matches nothing

Issue: F-10550, F-14632
Match User and Match Group now take a comma separated list of exact
names and apply when any entry equals the user or one of the user's
groups.

- reject '*', '?', '!' and empty entries in a Match name list
- add parser cases and a Match list lookup test

Issue: F-11661
Copilot AI balanced review requested due to automatic review settings October 28, 2026 22:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

ConfigLoad() reads lines of up to 1023 bytes and drains the rest of a
longer one, so its tail is never parsed as a line of its own.

- skip an over-long comment whole and fail the load on an over-long
  directive, also one pushed out by leading whitespace
- ignore whitespace past the end of the buffer
- move the limit to WOLFSSHD_MAX_LINE_SIZE in configuration.h, raised
  from 160 to 1024
- add a long-line load test

Issue: F-14395
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