fix initgroups_dyn

This commit is contained in:
Motiejus Jakštys 2022-07-14 19:58:05 +03:00
parent f63c7f317c
commit 63a6756a6b

View File

@ -11,6 +11,7 @@ const Allocator = mem.Allocator;
const DB = @import("DB.zig");
const File = @import("File.zig");
const ErrCtx = @import("ErrCtx.zig");
const compress = @import("compress.zig");
const CGroup = @import("Group.zig").CGroup;
const PackedGroup = @import("PackedGroup.zig");
const CUser = @import("User.zig").CUser;
@ -476,8 +477,13 @@ fn initgroups_dyn(
return c.NSS_STATUS_NOTFOUND;
};
var gids = db.userGids(user.additional_gids_offset);
if (size.* < gids.remaining()) {
// TODO: use db.userGids()
const offset = user.additional_gids_offset;
var vit = compress.varintSliceIteratorMust(db.additional_gids[offset..]);
const remaining = vit.remaining;
var gids = compress.deltaDecompressionIterator(&vit);
if (size.* < remaining) {
const oldsize = @intCast(usize, size.*);
const newsize = if (limit <= 0)
oldsize + gids.remaining()