MailJD nbsp;·nbsp; Test Dashboard nbsp;·nbsp; Coverage
LCOV - code coverage report
Current view: top level - util - SecureUtil.h (source / functions) Coverage Total Hit
Test: MailJD Coverage (Unit + E2E) Lines: 100.0 % 6 6
Test Date: 2026-06-21 21:10:19 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 100.0 % 2 2

             Branch data     Line data    Source code
       1                 :             : #pragma once
       2                 :             : 
       3                 :             : #include <QByteArray>
       4                 :             : 
       5                 :             : // SEC-22: Secure memory handling utilities.
       6                 :             : // Defense-in-depth: zeroing is best-effort because Qt may have internal copies.
       7                 :             : namespace SecureUtil {
       8                 :             : 
       9                 :             : // Overwrite QByteArray buffer with zeros, then clear it.
      10                 :             : // Uses explicit_bzero (or volatile write) to prevent optimizer removal.
      11                 :          17 : inline void zeroMemory(QByteArray &data) {
      12         [ +  + ]:          17 :   if (!data.isEmpty()) {
      13                 :             :     // Force detach so we own the buffer before zeroing
      14                 :          16 :     data.detach();
      15                 :             : #if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) || defined(Q_OS_UNIX)
      16                 :          16 :     explicit_bzero(data.data(), static_cast<size_t>(data.size()));
      17                 :             : #else
      18                 :             :     // Volatile write loop — prevents optimizer from removing the memset
      19                 :             :     volatile char *p = data.data();
      20                 :             :     for (int i = 0; i < data.size(); ++i)
      21                 :             :       p[i] = 0;
      22                 :             : #endif
      23                 :          16 :     data.clear();
      24                 :             :   }
      25                 :          17 : }
      26                 :             : 
      27                 :             : } // namespace SecureUtil
        

Generated by: LCOV version 2.0-1