mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-13 01:08:41 -09:00
Throw an error when running out of DevId numbers
I find it hard to imagine that this will happen on a real filesystem, but it can be triggered by a malicious export file. Better protect against that than invoke undefined behavior.
This commit is contained in:
parent
252f7fc253
commit
18f322c532
1 changed files with 1 additions and 0 deletions
|
|
@ -346,6 +346,7 @@ pub const devices = struct {
|
|||
defer lock.unlock();
|
||||
const d = lookup.getOrPut(dev) catch unreachable;
|
||||
if (!d.found_existing) {
|
||||
if (list.items.len >= std.math.maxInt(DevId)) ui.die("Maximum number of device identifiers exceeded.\n", .{});
|
||||
d.value_ptr.* = @as(DevId, @intCast(list.items.len));
|
||||
list.append(dev) catch unreachable;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue