1
Fork 0

user gids are unpadded

main
Motiejus Jakštys 2022-03-09 06:06:37 +02:00 committed by Motiejus Jakštys
parent 8fbd605b8d
commit ba56ff8d3b
2 changed files with 3 additions and 10 deletions

View File

@ -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,
);
}

View File

@ -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