Skip to content

Commit 6b56d2d

Browse files
Alan-JowettCopilot
andcommitted
Fix C6101: zero context_ptr on error paths in get_network_context
The _Out_writes_ SAL annotation on context_ptr requires the buffer to be initialized on all paths. Zero the output buffer upfront to satisfy the code analyzer on early-return error paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 091f978 commit 6b56d2d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

netebpfext/net_ebpf_ext_sock_addr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ _ebpf_sock_addr_get_network_context(
353353
if (context_size == 0 || context_ptr == NULL) {
354354
return -1;
355355
}
356+
357+
// Zero the output buffer upfront to satisfy the _Out_writes_ annotation on all paths.
358+
memset(context_ptr, 0, context_size);
359+
356360
net_ebpf_sock_addr_t* sock_addr_ctx = CONTAINING_RECORD(ctx, net_ebpf_sock_addr_t, base);
357361

358362
// This helper is only supported at CONNECT_AUTHORIZATION and RECV_ACCEPT layers.

0 commit comments

Comments
 (0)