1
Fork 0

increase gecos length

This commit is contained in:
Motiejus Jakštys 2022-02-22 15:22:30 +02:00 committed by Motiejus Jakštys
parent e06cac38b2
commit 0e5365127a
2 changed files with 5 additions and 5 deletions

View File

@ -68,7 +68,7 @@ Tight packing places some constraints on the underlying data:
- Maximum database size: 4GB. - Maximum database size: 4GB.
- Permitted length of username and groupname: 1-32 bytes. - Permitted length of username and groupname: 1-32 bytes.
- Permitted length of shell and home: 1-64 bytes. - Permitted length of shell and home: 1-64 bytes.
- Permitted comment ("gecos") length: 0-255 bytes. - Permitted comment ("gecos") length: 0-1023 bytes.
- User name, groupname and gecos must be utf8-encoded. - User name, groupname and gecos must be utf8-encoded.
Checking out and building Checking out and building

View File

@ -14,8 +14,8 @@ pub const PackedUser = packed struct {
home_len: u6, home_len: u6,
name_is_a_suffix: bool, name_is_a_suffix: bool,
name_len: u5, name_len: u5,
gecos_len: u8, gecos_len: u10,
padding: u5, padding: u3,
// blobSize returns the length of the blob storing string values. // blobSize returns the length of the blob storing string values.
pub fn blobLength(self: *const PackedUser) usize { pub fn blobLength(self: *const PackedUser) usize {
@ -88,7 +88,7 @@ pub const UserWriter = struct {
const home_len = try downCast(u6, user.home.len - 1); const home_len = try downCast(u6, user.home.len - 1);
const name_len = try downCast(u5, user.name.len - 1); const name_len = try downCast(u5, user.name.len - 1);
const shell_len = try downCast(u6, user.shell.len - 1); const shell_len = try downCast(u6, user.shell.len - 1);
const gecos_len = try downCast(u8, user.gecos.len); const gecos_len = try downCast(u10, user.gecos.len);
var puser = PackedUser{ var puser = PackedUser{
.uid = user.uid, .uid = user.uid,
@ -259,7 +259,7 @@ test "construct PackedUser blob" {
.uid = 0, .uid = 0,
.gid = 4294967295, .gid = 4294967295,
.name = "n" ** 32, .name = "n" ** 32,
.gecos = "g" ** 255, .gecos = "g" ** 1023,
.home = "h" ** 64, .home = "h" ** 64,
.shell = "s" ** 64, .shell = "s" ** 64,
} }; } };