OpenCoverage

buf_str.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/buffer/buf_str.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: buf_str.c,v 1.11 2017/04/09 14:33:21 jsing Exp $ */-
2/*-
3 * Copyright (c) 2014 Bob Beck-
4 *-
5 * Permission to use, copy, modify, and distribute this software for any-
6 * purpose with or without fee is hereby granted, provided that the above-
7 * copyright notice and this permission notice appear in all copies.-
8 *-
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES-
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF-
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR-
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES-
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN-
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF-
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.-
16 */-
17-
18#include <stdlib.h>-
19#include <stdio.h>-
20#include <string.h>-
21-
22#include <openssl/buffer.h>-
23#include <openssl/err.h>-
24-
25/*-
26 * XXX these functions accept a NULL arg and return NULL-
27 * when the standard ones do not. we should at an appropriate-
28 * time change these to find the bad callers-
29 */-
30-
31char *-
32BUF_strdup(const char *str)-
33{-
34 char *ret = NULL;-
35-
36 if (str != NULL) {
str != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
37 if ((ret = strdup(str)) == NULL)
never executed: __retval = (char *) memcpy (__retval, str , __len);
(ret = (__exte...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
__retval != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( str )Description
TRUEnever evaluated
FALSEnever evaluated
((size_t)(cons...)( str ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
38 BUFerror(ERR_R_MALLOC_FAILURE);
never executed: ERR_put_error(7,(0xfff),((1|64)),__FILE__,38);
0
39 }
never executed: end of block
0
40 return ret;
never executed: return ret;
0
41}-
42-
43char *-
44BUF_strndup(const char *str, size_t siz)-
45{-
46 char *ret = NULL;-
47-
48 if (str != NULL) {
str != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
49 if ((ret = strndup(str, siz)) == NULL)
never executed: __len = __n + 1;
never executed: end of block
(ret = (__exte...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
__n < __lenDescription
TRUEnever evaluated
FALSEnever evaluated
__retval != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( str )Description
TRUEnever evaluated
FALSEnever evaluated
((size_t)(cons...)( str ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
50 BUFerror(ERR_R_MALLOC_FAILURE);
never executed: ERR_put_error(7,(0xfff),((1|64)),__FILE__,50);
0
51 }
never executed: end of block
0
52 return ret;
never executed: return ret;
0
53}-
54-
55void *-
56BUF_memdup(const void *data, size_t siz)-
57{-
58 void *ret = NULL;-
59-
60 if (data != NULL) {
data != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
61 if ((ret = malloc(siz)) == NULL)
(ret = malloc(...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
62 BUFerror(ERR_R_MALLOC_FAILURE);
never executed: ERR_put_error(7,(0xfff),((1|64)),__FILE__,62);
0
63 else-
64 (void) memcpy(ret, data, siz);
never executed: (void) memcpy(ret, data, siz);
0
65 }-
66 return ret;
never executed: return ret;
0
67}-
68-
69size_t-
70BUF_strlcpy(char *dst, const char *src, size_t size)-
71{-
72 return strlcpy(dst, src, size);
never executed: return strlcpy(dst, src, size);
0
73}-
74-
75size_t-
76BUF_strlcat(char *dst, const char *src, size_t size)-
77{-
78 return strlcat(dst, src, size);
never executed: return strlcat(dst, src, size);
0
79}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2