Bug 205157

Summary: [patch] pw(8) does not accept 8-bit characters in a GECOS field
Product: Base System Reporter: orios814
Component: binAssignee: Baptiste Daroussin <bapt>
Status: Closed FIXED    
Severity: Affects Many People CC: des, ngie, orios814
Priority: --- Keywords: patch
Version: 10.2-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
A patch to make pw(8) accept 8-bit characters in a GECOS field. none

Description orios814 2015-12-09 13:22:51 UTC
Created attachment 164014 [details]
A patch to make pw(8) accept 8-bit characters in a GECOS field.

The command pw(8) does not accept 8-bit characters in a GECOS field, though 'pw_user.c' claims at line 1238 that 8-bit characters are intended to be allowed in a GECOS field.

[How-To-Repeat] Try the following command on your shell.
# pw useradd foobar -c '<some 8-bit characters>'

[Reason] The function 'pw_checkname' in '/usr/src/usr.sbin/pw/pw_user.c' checks if the input string does not have characters of 0x00--0x1F at line 1233 by the following condition:
  *ch < ' '
However, the type of 'ch' was changed from 'u_char' to 'char' (Jul. 3, 2015), which made the above condition match also characters 0x80--0xFF. So the condition must be the following:
  (*ch >= 0 && *ch < ' ')

The attached patch for '/usr/src/usr.sbin/pw/pw_user.c' will fix this problem.

Thank you for reading!
Comment 1 Enji Cooper freebsd_committer freebsd_triage 2015-12-09 21:52:45 UTC
Should be fixed with this MFC: https://svnweb.freebsd.org/changeset/base/292026 .
It should probably have an EN though.
Comment 2 Baptiste Daroussin freebsd_committer freebsd_triage 2015-12-09 22:01:03 UTC
I am working on an EN with a couple of other fixes, some are not trivial to bring in 10.2 (not that for this particular PR it straight forward for the EN)