diff --git a/src/sections.zig b/src/sections.zig index b6b5c54..f503807 100644 --- a/src/sections.zig +++ b/src/sections.zig @@ -166,9 +166,8 @@ pub fn shellSections( corpus: *const Corpus, ) error{ OutOfMemory, Overflow }!ShellSections { var popcon = shellImport.ShellWriter.init(allocator); - for (corpus.usersMulti.items(.shell)) |shell| { + for (corpus.usersMulti.items(.shell)) |shell| try popcon.put(shell); - } return popcon.toOwnedSections(shellImport.max_shells); } @@ -189,8 +188,6 @@ pub const UserGids = struct { } }; -const userGidsPaddingBits = 3; - pub fn userGids( allocator: Allocator, corpus: *const Corpus, @@ -202,7 +199,6 @@ pub fn userGids( // zero'th entry is empty, so groupless users can refer to it. try compress.appendUvarint(&blob, 0); - try pad.arrayList(&blob, userGidsPaddingBits); var scratch = try allocator.alloc(u32, 256); defer allocator.free(scratch); @@ -222,7 +218,6 @@ pub fn userGids( try compress.appendUvarint(&blob, usergroups.len); for (scratch) |gid| try compress.appendUvarint(&blob, gid); - try pad.arrayList(&blob, userGidsPaddingBits); } return UserGids{ @@ -257,14 +252,12 @@ pub fn usersSection( errdefer blob.deinit(); for (corpus.users) |user, i| { const userOffset = try math.cast(u32, blob.items.len); - const gidOffset = gids.idx2offset[i]; std.debug.assert(userOffset & 7 == 0); - std.debug.assert(gidOffset & 7 == 0); idx2offset[i] = userOffset; try userImport.PackedUserHash.packTo( &blob, user, - @truncate(u29, @shrExact(gidOffset, 3)), + gids.idx2offset[i], shells.indices, ); } diff --git a/src/user.zig b/src/user.zig index bf75710..91ec653 100644 --- a/src/user.zig +++ b/src/user.zig @@ -212,7 +212,7 @@ fn packedUser(comptime ShellIndexType: type) type { pub fn packTo( arr: *ArrayList(u8), user: User, - additional_gids_offset: usize, + additional_gids_offset: u64, idxFn: ShellIndexType, ) error{ InvalidRecord, OutOfMemory }!void { // function arguments are consts. We need to mutate the underlying