LCOV - code coverage report
Current view: top level - src/port - explicit_bzero.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 6 6 100.0 %
Date: 2019-11-13 21:06:57 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * explicit_bzero.c
       4             :  *
       5             :  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
       6             :  * Portions Copyright (c) 1994, Regents of the University of California
       7             :  *
       8             :  *
       9             :  * IDENTIFICATION
      10             :  *    src/port/explicit_bzero.c
      11             :  *
      12             :  *-------------------------------------------------------------------------
      13             :  */
      14             : 
      15             : #include "c.h"
      16             : 
      17             : #if defined(HAVE_MEMSET_S)
      18             : 
      19             : void
      20             : explicit_bzero(void *buf, size_t len)
      21             : {
      22             :     (void) memset_s(buf, len, 0, len);
      23             : }
      24             : 
      25             : #elif defined(WIN32)
      26             : 
      27             : void
      28             : explicit_bzero(void *buf, size_t len)
      29             : {
      30             :     (void) SecureZeroMemory(buf, len);
      31             : }
      32             : 
      33             : #else
      34             : 
      35             : /*
      36             :  * Indirect call through a volatile pointer to hopefully avoid dead-store
      37             :  * optimisation eliminating the call.  (Idea taken from OpenSSH.)  We can't
      38             :  * assume bzero() is present either, so for simplicity we define our own.
      39             :  */
      40             : 
      41             : static void
      42         138 : bzero2(void *buf, size_t len)
      43             : {
      44         138 :     memset(buf, 0, len);
      45         138 : }
      46             : 
      47             : static void (* volatile bzero_p)(void *, size_t) = bzero2;
      48             : 
      49             : void
      50         138 : explicit_bzero(void *buf, size_t len)
      51             : {
      52         138 :     bzero_p(buf, len);
      53         138 : }
      54             : 
      55             : #endif

Generated by: LCOV version 1.13