@@ -376,6 +376,7 @@ pub fn enumerate_account_rights(sid: &Sid) -> anyhow::Result<Vec<U16CString>> {
376376
377377 if open_policy_status. is_err ( ) {
378378 // Convert NTSTATUS to a Win32 error code and return as an error
379+ // SAFETY: LsaNtStatusToWinError is always safe to call with any NTSTATUS value.
379380 let error_code = unsafe { Identity :: LsaNtStatusToWinError ( open_policy_status) } ;
380381 let error_code = WIN32_ERROR ( error_code) ;
381382
@@ -387,12 +388,14 @@ pub fn enumerate_account_rights(sid: &Sid) -> anyhow::Result<Vec<U16CString>> {
387388 let mut rights = ScopeGuard :: new ( ptr:: null_mut :: < Identity :: LSA_UNICODE_STRING > ( ) , |ptr| {
388389 if !ptr. is_null ( ) {
389390 // FIXME: maybe we should log the error here.
391+ // SAFETY: ptr is a valid pointer returned by LsaEnumerateAccountRights.
390392 let _ = unsafe { Identity :: LsaFreeMemory ( Some ( ptr as * const std:: ffi:: c_void ) ) } ;
391393 }
392394 } ) ;
393395
394396 let mut rights_count: u32 = 0 ;
395397
398+ // SAFETY: We pass valid pointers and policy_handle was obtained from LsaOpenPolicy.
396399 let enum_status = unsafe {
397400 Identity :: LsaEnumerateAccountRights (
398401 * policy_handle. as_ref ( ) ,
@@ -407,6 +410,7 @@ pub fn enumerate_account_rights(sid: &Sid) -> anyhow::Result<Vec<U16CString>> {
407410 Vec :: new ( )
408411 } else if enum_status. is_err ( ) {
409412 // Convert NTSTATUS to a Win32 error code and return as an error
413+ // SAFETY: LsaNtStatusToWinError is always safe to call with any NTSTATUS value.
410414 let error_code = unsafe { Identity :: LsaNtStatusToWinError ( enum_status) } ;
411415 let error_code = WIN32_ERROR ( error_code) ;
412416
0 commit comments