January 03, 2022
On Monday, 3 January 2022 at 00:52:38 UTC, Brian Callahan wrote:
> Perhaps D should provide a similar function

int[] array;

array.length = 5;

January 03, 2022

On Monday, 3 January 2022 at 00:57:55 UTC, rikki cattermole wrote:

>

That sounds similar to my idea of callocSlice but applied to realloc as well.

Which absolutely is the solution here I think. Using malloc directly should be a red flag.

mhmm.. i think we need a helper function, which is malloc(size, count) much like calloc, the test/protections are done in the helper. If a slice is returned then bounds checking is incorporated when we cast it to something else. So i agree with that idea, though using malloc/calloc slice vs malloc/calloc...

It does make me wonder if my ScaledInt will be incorporated so cent/ucent can be used natively (division being the only real complicated and slow part of the code). Reminds me, i gotta get back to the optional crypto instruction set to make it faster.

January 03, 2022

On Monday, 3 January 2022 at 01:29:11 UTC, Adam Ruppe wrote:

>

On Monday, 3 January 2022 at 00:52:38 UTC, Brian Callahan wrote:

>

Perhaps D should provide a similar function

int[] array;

array.length = 5;

I don't think that helps...

long cnt=60, itemsize=100;

array.length = cnt*itemsize; //cannot pass argument `cnt * itemsize` of type `long` to parameter `uint newlength`

Even if you do your math there and it overflows, it's the same problem as using malloc.

January 03, 2022

On Monday, 3 January 2022 at 01:34:38 UTC, Era Scarecrow wrote:

>

Even if you do your math there and it overflows, it's the same problem as using malloc.

Except maybe the item size (in this case) is already known.

January 03, 2022
On Monday, 3 January 2022 at 00:52:38 UTC, Brian Callahan wrote:
> Perhaps D should provide a similar function

What is wrong with Mallocator, mentioned else-thread?
January 03, 2022
On Friday, 31 December 2021 at 13:52:26 UTC, Paul Backus wrote:
> On Friday, 31 December 2021 at 00:13:56 UTC, Walter Bright wrote:
>> While D offers buffer overflow detection, it does not protect against buffer overflows resulting from an array size calculation overflow:
>>
>>     T* p = cast(T*)malloc(len * T.sizeof);
>>
>> What if `len*T.sizeof` overflows? malloc() will succeed, but the result will be too small for the data.
>
> For projects using Phobos, an easy way to avoid this is to use [`Mallocator`][1] and [`makeArray`][2] from the `std.experimental.allocator` package.
>
>     T[] array = Mallocator.instance.makeArray!T(len);
>
> `makeArray` will perform an overflow check internally and return `null` if the check fails.
>
> [1]: https://dlang.org/library/std/experimental/allocator/mallocator/mallocator.html
> [2]: https://dlang.org/library/std/experimental/allocator/make_array.html

In the vulnerability described in the article, the 'len' parameter is the result of a sum overflowing in a previous for loop, so the problem actually is _outside_ of the allocator.

Anyway, apart from the vulnerability, the described exploit details are fascinating and terrific at the same time ..."My other compression format is turing-complete!"


January 03, 2022

On Monday, 3 January 2022 at 01:29:14 UTC, Era Scarecrow wrote:

>

mhmm.. i think we need a helper function, which is malloc(size, count) much like calloc, the test/protections are done in the helper.

This is exactly what reallocarray does.

January 03, 2022
On Monday, 3 January 2022 at 12:58:33 UTC, Paolo Invernizzi wrote:
>
> In the vulnerability described in the article, the 'len' parameter is the result of a sum overflowing in a previous for loop, so the problem actually is _outside_ of the allocator.
>

That is not entirely correct, and could mislead one into implementing a less than optimal solution to the problem.

The overflow and the allocater 'together', provide the attack surface.

January 04, 2022
On Monday, 3 January 2022 at 21:00:38 UTC, forkit wrote:
> On Monday, 3 January 2022 at 12:58:33 UTC, Paolo Invernizzi wrote:
>>
>> In the vulnerability described in the article, the 'len' parameter is the result of a sum overflowing in a previous for loop, so the problem actually is _outside_ of the allocator.
>>
>
> That is not entirely correct, and could mislead one into implementing a less than optimal solution to the problem.
>
> The overflow and the allocater 'together', provide the attack surface.

I agree that the _surface_ is the couple, but the vulnerability to patch is how the needed amount is calculated, and that can be an arbitrary complex piece of code. A super-duper-safe allocator does not help here, if we are talking about a system language and write to memory via pointers arithmetic.

1 2 3 4
Next ›   Last »