[Toybox] [PATCH] bufgetgrgid: fix for very large groups.

Rob Landley rob at landley.net
Mon Jul 2 20:14:44 PDT 2018


On 07/02/2018 01:13 PM, enh wrote:
>> These twio functions irritate me because it's the same code with trivially
>> different data types. It's even using the same structure offsets and putting the
>> same stuff on the stack, just using a different static list pointer and calling
>> a different function pointer. Grumble grumble duplication...
> 
> templates, dude. templates.

I could have a macro generate the two functions so there's only one copy of the
_source_, but that just has the compiler duplicate the code for me.

>> So the only way for the struct passwd size to blow up is for the string members
>> to be arbitrarily long, which is possible but I've never seen it. (And in theory
>> they'd cap at PATH_MAX anyway? A 4k allocation would almost certainly cover it...)
>>
>> Sigh, but I might as well keep the two functions matching in case I do work out
>> a way to collapse them together later.
> 
> you didn't change enough in the groups code. i'm surprised it doesn't
> SEGV for you too.

Huh. I was going to say "all my users/groups fit in 512 bytes." but looking at
the temp/list switch... no idea why it didn't segfault for me?

(Sigh, rushing to check things in at the end of a weekend rather than try to
reverse engineer my own work a week later. Needed another review pass...)

I need to get the test suite properly fleshed out and fixed so "VERBOSE=fail
make tests" is useful. (I just ran it and all the chmod tests are failing and I
think it's the chmod test file that's failing? Throw that on the todo heap...)

And THEN I need to add tests so it's testing everything, including "enough
groups to cause the expand logic to trigger", which gets us back to setting up
the qemu test environment, which is on top of mkroot, which means implementing
the two remaining busybox commands that's using so I can do a pure toybox
version and merge it into the toybox source as scripts/mkroot.sh...

> fix for the crashes attached.

Applied, except I want to keep the two the same so I applied the *=2 in both places.

> i've also restored the doubling behavior
> for groups on the assumption that there's a bimodal distribution out
> there: folks on single-user machines only need a tiny buffer, while
> folks on large corporate networks need ridiculously large buffers.

I didn't know you needed megabytes for this. Yeah, doubling makes sense with
that design assumption.

Rob



More information about the Toybox mailing list