Skip to content

Revert "strchriscntrl: reject C1 control bytes (0x80-0x9F)"#1602

Merged
hallyn merged 2 commits intoshadow-maint:masterfrom
alejandro-colomar:c1
Apr 1, 2026
Merged

Revert "strchriscntrl: reject C1 control bytes (0x80-0x9F)"#1602
hallyn merged 2 commits intoshadow-maint:masterfrom
alejandro-colomar:c1

Conversation

@alejandro-colomar
Copy link
Copy Markdown
Collaborator

@alejandro-colomar alejandro-colomar commented Mar 25, 2026

C1 control bytes are more complicated than that. They're represented as two bytes in UTF-8.

Commit 19d725d, has issues, rejecting otherwise valid UTF-8 multi-byte characters.

We could in theory do correct parsing of UTF, possibly parsing the multi-byte sequences, or translating to wchar_t. However, that would complicate the source code well beyond what I'd be comfortable with.

Instead, let's revert this, and claim no intention to support UTF-8. If an admin uses a UTF-8 locale while reading /etc/passwd, that's their own fault.

Reverts: 19d725d (2026-03-13; "strchriscntrl: reject C1 control bytes (0x80-0x9F)")
Fixes: 19d725d (2026-03-13; "strchriscntrl: reject C1 control bytes (0x80-0x9F)")
Closes: #1598
Reported-by: @grawity
Cc: @KhaelK138
Cc: @stoeckmann


Revisions:

v2
  • Add CAVEATS to passwd(5), documenting that the C locale should be used when reading /etc/passwd.
$ git rd 
1:  a2a94f2d = 1:  a2a94f2d Revert "strchriscntrl: reject C1 control bytes (0x80-0x9F)"
-:  -------- > 2:  61263b74 man/passwd.5.xml: CAVEATS: Add section

C1 control bytes are more complicated than that.  They're represented as
two bytes in UTF-8.

Commit 19d725d, has issues, rejecting otherwise valid UTF-8 multi-byte
characters.

We could in theory do correct parsing of UTF, possibly parsing the
multi-byte sequences, or translating to wchar_t.  However, that would
complicate the source code well beyond what I'd be comfortable with.

Instead, let's revert this, and claim no intention to support UTF-8.
If an admin uses a UTF-8 locale while reading /etc/passwd, that's their
own fault.

Reverts: 19d725d (2026-03-13; "strchriscntrl: reject C1 control bytes (0x80-0x9F)")
Fixes: 19d725d (2026-03-13; "strchriscntrl: reject C1 control bytes (0x80-0x9F)")
Closes: <shadow-maint#1598>
Reported-by: Mantas Mikulėnas <grawity@gmail.com>
Cc: KhaelK-Praetorian <khael.kugler@praetorian.com>
Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
@ikerexxe
Copy link
Copy Markdown
Collaborator

Is there any place where claim no intention to support UTF-8 is stated?

@alejandro-colomar
Copy link
Copy Markdown
Collaborator Author

alejandro-colomar commented Mar 30, 2026

Is there any place where claim no intention to support UTF-8 is stated?

I guess we could use release notes. And/or maybe we should add something to passwd(5) in a CAVEATS section.

@ikerexxe
Copy link
Copy Markdown
Collaborator

I prefer the second option, as people are more likely to read it.

Do you want to use this PR to update it, or shall we leave it for later?

@alejandro-colomar
Copy link
Copy Markdown
Collaborator Author

I prefer the second option, as people are more likely to read it.

Do you want to use this PR to update it, or shall we leave it for later?

I'll update this PR.

Document that when reading passwd(5), the C locale should be used.

Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Mantas Mikulėnas <grawity@gmail.com>
Cc: KhaelK-Praetorian <khael.kugler@praetorian.com>
Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
@alejandro-colomar
Copy link
Copy Markdown
Collaborator Author

I prefer the second option, as people are more likely to read it.
Do you want to use this PR to update it, or shall we leave it for later?

I'll update this PR.

Done.

Copy link
Copy Markdown
Collaborator

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for taking care of this patch.

I won’t merge it just yet, in case any native English speakers would like to review the updated documentation

Copy link
Copy Markdown
Member

@hallyn hallyn left a comment

Choose a reason for hiding this comment

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

Not entirely comfortable with it. I see I have UTF8 as my locale on my laptop. But I agree that we're inviting trouble if we try to do the parsing.

@hallyn hallyn merged commit 4a5ca89 into shadow-maint:master Apr 1, 2026
16 checks passed
@alejandro-colomar alejandro-colomar deleted the c1 branch April 5, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

recent strchriscntrl change

3 participants