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