LCOV - code coverage report
Current view: top level - src/connectivity/security - memory.cpp (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 7 7 100.0 %
Date: 2024-05-11 09:31:29 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2024 Savoir-faire Linux Inc.
       3             :  *
       4             :  *  Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
       5             :  *
       6             :  *  This program is free software; you can redistribute it and/or modify
       7             :  *  it under the terms of the GNU General Public License as published by
       8             :  *  the Free Software Foundation; either version 3 of the License, or
       9             :  *  (at your option) any later version.
      10             :  *
      11             :  *  This program is distributed in the hope that it will be useful,
      12             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  *  GNU General Public License for more details.
      15             :  *
      16             :  *  You should have received a copy of the GNU General Public License
      17             :  *  along with this program; if not, write to the Free Software
      18             :  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
      19             :  */
      20             : 
      21             : #include "memory.h"
      22             : 
      23             : #ifdef _WIN32
      24             : #include <windows.h>
      25             : #include <wincrypt.h>
      26             : #endif
      27             : 
      28             : #include <algorithm>
      29             : 
      30             : namespace jami {
      31             : namespace secure {
      32             : 
      33             : void
      34       13603 : memzero(void* ptr, std::size_t length)
      35             : {
      36             : #ifdef _WIN32
      37             :     SecureZeroMemory(ptr, length);
      38             : #else
      39       13603 :     volatile auto* p = static_cast<unsigned char*>(ptr);
      40       13603 :     std::fill_n(p, length, 0);
      41             : #endif
      42       13603 : }
      43             : 
      44             : } // namespace secure
      45             : } // namespace jami
      46             : 
      47             : extern "C" void
      48       13603 : ring_secure_memzero(void* ptr, size_t length)
      49             : {
      50       13603 :     jami::secure::memzero(ptr, length);
      51       13603 : }

Generated by: LCOV version 1.14