Skip to content

Commit

Permalink
daemon: Fix DrMemory hit in |bitmap_intersect()|
Browse files Browse the repository at this point in the history
Fix DrMemory hit in |bitmap_intersect()|, which happened
because arr mask data were accessed beyond the maximum
index specified by |bitmap4.count|.

Example:
---- snip ----
Error #1: UNINITIALIZED READ: reading 4 byte(s)
0 bitmap_intersect                   [ms-nfs41-client\daemon\util.h:123]
1 nfs41_superblock_supported_attrs   [ms-nfs41-client\daemon\nfs41.h:491]
2 nfs41_open                         [ms-nfs41-client\daemon\nfs41_ops.c:535]
3 do_open                            [ms-nfs41-client\daemon\open.c:311]
4 open_or_delegate                   [ms-nfs41-client\daemon\open.c:352]
5 handle_open                        [ms-nfs41-client\daemon\open.c:972]
6 upcall_handle                      [ms-nfs41-client\daemon\upcall.c:220]
7 nfsd_worker_thread_main            [ms-nfs41-client\daemon\nfs41_daemon.c:201]
8 nfsd_thread_main                   [ms-nfs41-client\daemon\nfs41_daemon.c:239]
9 KERNEL32.dll!BaseThreadInitThunk  +0x13     (0x00007ffbfeca7374 <KERNEL32.dll+0x17374>)
---- snip ----

Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
  • Loading branch information
gisburn authored and kofemann committed Nov 7, 2024
1 parent 32c4e46 commit 1a8f1a7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions daemon/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ static __inline void bitmap_unset(
static __inline void bitmap_intersect(
IN bitmap4 *dst,
IN const bitmap4 *src)
{
uint32_t i, count = 0;
for (i = 0; i < 3; i++) {
dst->arr[i] &= src->arr[i];
if (dst->arr[i])
count = i+1;
}
{
uint32_t i, count = 0;
for (i = 0; i < 3; i++) {
dst->arr[i] = ((i < dst->count)?dst->arr[i]:0) & ((i < src->count)?src->arr[i]:0);
if (dst->arr[i])
count = i+1;
}
dst->count = min(dst->count, count);
}

Expand Down

0 comments on commit 1a8f1a7

Please sign in to comment.