Skip to content

Commit 2e834a5

Browse files
committed
mapi_lib: silence cov-scan warning untrusted-alloc-size (1)
These are semi false positives; if the client indicates that an array has 65535 values, we need to allocate as much… CIDs 1593810 1593812 1593817 1593836 1593838 1593840 1593846 1593849 1593856 1593867
1 parent 508f937 commit 2e834a5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/mapi/ext_buffer2.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: AGPL-3.0-or-later
2-
// SPDX-FileCopyrightText: 2023–2024 grommunio GmbH
2+
// SPDX-FileCopyrightText: 2023–2025 grommunio GmbH
33
// This file is part of Gromox.
4+
#include <algorithm>
45
#include <limits>
56
#include <string>
67
#include <vector>
@@ -43,6 +44,7 @@ using namespace gromox;
4344
{ \
4445
C count; \
4546
TRY(g_ ## c(&count)); \
47+
count = std::min(count, std::numeric_limits<C>::max()); \
4648
return g_ ## t ## _an(r, count); \
4749
}
4850

@@ -69,6 +71,7 @@ pack_result EXT_PULL::g_propid_a(std::vector<uint16_t> *a)
6971
{
7072
uint16_t count;
7173
TRY(g_uint16(&count));
74+
count = std::min(count, std::numeric_limits<uint16_t>::max());
7275
return g_uint16_an(a, count);
7376
}
7477

@@ -119,6 +122,7 @@ pack_result EXT_PULL::g_fb_a(std::vector<freebusy_event> *r) try
119122
r->clear();
120123
return pack_result::success;
121124
}
125+
count = std::min(count, std::numeric_limits<uint32_t>::max());
122126
r->resize(count);
123127
for (size_t i = 0; i < count; ++i)
124128
TRY(g_fb(&(*r)[i]));

0 commit comments

Comments
 (0)