Coverage Report

Created: 2025-07-23 06:43

/src/libtasn1/lib/gstr.h
Line
Count
Source
1
/*
2
 * Copyright (C) 2002-2025 Free Software Foundation, Inc.
3
 *
4
 * This file is part of LIBTASN1.
5
 *
6
 * The LIBTASN1 library is free software; you can redistribute it
7
 * and/or modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful, but
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, see
18
 * <https://www.gnu.org/licenses/>.
19
 */
20
21
#ifndef GSTR_H
22
# define GSTR_H
23
24
unsigned int _asn1_str_cpy (char *dest, size_t dest_tot_size,
25
          const char *src);
26
void _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src);
27
28
1.77k
# define Estrcpy(x,y) _asn1_str_cpy(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
29
1.77k
# define Estrcat(x,y) _asn1_str_cat(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
30
31
inline static void
32
safe_memset (void *data, int c, size_t size)
33
649k
{
34
649k
  volatile unsigned volatile_zero = 0;
35
649k
  volatile char *vdata = (volatile char *) data;
36
37
  /* This is based on a nice trick for safe memset,
38
   * sent by David Jacobson in the openssl-dev mailing list.
39
   */
40
41
649k
  if (size > 0)
42
649k
    do
43
649k
      {
44
649k
  memset (data, c, size);
45
649k
      }
46
649k
    while (vdata[volatile_zero] != c);
47
649k
}
Unexecuted instantiation: coding.c:safe_memset
Unexecuted instantiation: decoding.c:safe_memset
Unexecuted instantiation: element.c:safe_memset
Unexecuted instantiation: gstr.c:safe_memset
parser_aux.c:safe_memset
Line
Count
Source
33
649k
{
34
649k
  volatile unsigned volatile_zero = 0;
35
649k
  volatile char *vdata = (volatile char *) data;
36
37
  /* This is based on a nice trick for safe memset,
38
   * sent by David Jacobson in the openssl-dev mailing list.
39
   */
40
41
649k
  if (size > 0)
42
649k
    do
43
649k
      {
44
649k
  memset (data, c, size);
45
649k
      }
46
649k
    while (vdata[volatile_zero] != c);
47
649k
}
Unexecuted instantiation: structure.c:safe_memset
48
49
#endif /* GSTR_H */