From 0e5365127abece6c1f18f6bbab3cbede8f80727e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 22 Feb 2022 15:22:30 +0200 Subject: [PATCH] increase gecos length --- README.md | 2 +- src/user.zig | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f6bb396..13b34d4 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Tight packing places some constraints on the underlying data: - Maximum database size: 4GB. - Permitted length of username and groupname: 1-32 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. Checking out and building diff --git a/src/user.zig b/src/user.zig index de90a64..d55687c 100644 --- a/src/user.zig +++ b/src/user.zig @@ -14,8 +14,8 @@ pub const PackedUser = packed struct { home_len: u6, name_is_a_suffix: bool, name_len: u5, - gecos_len: u8, - padding: u5, + gecos_len: u10, + padding: u3, // blobSize returns the length of the blob storing string values. 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 name_len = try downCast(u5, user.name.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{ .uid = user.uid, @@ -259,7 +259,7 @@ test "construct PackedUser blob" { .uid = 0, .gid = 4294967295, .name = "n" ** 32, - .gecos = "g" ** 255, + .gecos = "g" ** 1023, .home = "h" ** 64, .shell = "s" ** 64, } };