OpenCoverage

bss_file.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bio/bss_file.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10#ifndef HEADER_BSS_FILE_C-
11# define HEADER_BSS_FILE_C-
12-
13# if defined(__linux) || defined(__sun) || defined(__hpux)-
14/*-
15 * Following definition aliases fopen to fopen64 on above mentioned-
16 * platforms. This makes it possible to open and sequentially access files-
17 * larger than 2GB from 32-bit application. It does not allow to traverse-
18 * them beyond 2GB with fseek/ftell, but on the other hand *no* 32-bit-
19 * platform permits that, not with fseek/ftell. Not to mention that breaking-
20 * 2GB limit for seeking would require surgery to *our* API. But sequential-
21 * access suffices for practical cases when you can run into large files,-
22 * such as fingerprinting, so we can let API alone. For reference, the list-
23 * of 32-bit platforms which allow for sequential access of large files-
24 * without extra "magic" comprise *BSD, Darwin, IRIX...-
25 */-
26# ifndef _FILE_OFFSET_BITS-
27# define _FILE_OFFSET_BITS 64-
28# endif-
29# endif-
30-
31# include <stdio.h>-
32# include <errno.h>-
33# include "bio_lcl.h"-
34# include <openssl/err.h>-
35-
36# if !defined(OPENSSL_NO_STDIO)-
37-
38static int file_write(BIO *h, const char *buf, int num);-
39static int file_read(BIO *h, char *buf, int size);-
40static int file_puts(BIO *h, const char *str);-
41static int file_gets(BIO *h, char *str, int size);-
42static long file_ctrl(BIO *h, int cmd, long arg1, void *arg2);-
43static int file_new(BIO *h);-
44static int file_free(BIO *data);-
45static const BIO_METHOD methods_filep = {-
46 BIO_TYPE_FILE,-
47 "FILE pointer",-
48 /* TODO: Convert to new style write function */-
49 bwrite_conv,-
50 file_write,-
51 /* TODO: Convert to new style read function */-
52 bread_conv,-
53 file_read,-
54 file_puts,-
55 file_gets,-
56 file_ctrl,-
57 file_new,-
58 file_free,-
59 NULL, /* file_callback_ctrl */-
60};-
61-
62BIO *BIO_new_file(const char *filename, const char *mode)-
63{-
64 BIO *ret;-
65 FILE *file = openssl_fopen(filename, mode);-
66 int fp_flags = BIO_CLOSE;-
67-
68 if (strchr(mode, 'b') == NULL)
(__extension__...== ((void *)0)Description
TRUEevaluated 4705 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5098 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
__builtin_constant_p ( 'b' )Description
TRUEevaluated 9803 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
!__builtin_constant_p ( mode )Description
TRUEevaluated 9803 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
( 'b' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 9803 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-9803
69 fp_flags |= BIO_FP_TEXT;
executed 4705 times by 1 test: fp_flags |= 0x10;
Executed by:
  • libcrypto.so.1.1
4705
70-
71 if (file == NULL) {
file == ((void *)0)Description
TRUEevaluated 2540 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7263 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2540-7263
72 SYSerr(SYS_F_FOPEN, get_last_sys_error());-
73 ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");-
74 if (errno == ENOENT
(*__errno_location ()) == 2Description
TRUEevaluated 2539 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-2539
75# ifdef ENXIO-
76 || errno == ENXIO
(*__errno_location ()) == 6Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
77# endif-
78 )-
79 BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);
executed 2539 times by 1 test: ERR_put_error(32,(109),(128),__FILE__,79);
Executed by:
  • libcrypto.so.1.1
2539
80 else-
81 BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB);
executed 1 time by 1 test: ERR_put_error(32,(109),(2),__FILE__,81);
Executed by:
  • libcrypto.so.1.1
1
82 return NULL;
executed 2540 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
2540
83 }-
84 if ((ret = BIO_new(BIO_s_file())) == NULL) {
(ret = BIO_new...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 7263 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7263
85 fclose(file);-
86 return NULL;
never executed: return ((void *)0) ;
0
87 }-
88-
89 BIO_clear_flags(ret, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage-
90 * UPLINK */-
91 BIO_set_fp(ret, file, fp_flags);-
92 return ret;
executed 7263 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
7263
93}-
94-
95BIO *BIO_new_fp(FILE *stream, int close_flag)-
96{-
97 BIO *ret;-
98-
99 if ((ret = BIO_new(BIO_s_file())) == NULL)
(ret = BIO_new...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10202 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
0-10202
100 return NULL;
never executed: return ((void *)0) ;
0
101-
102 /* redundant flag, left for documentation purposes */-
103 BIO_set_flags(ret, BIO_FLAGS_UPLINK);-
104 BIO_set_fp(ret, stream, close_flag);-
105 return ret;
executed 10202 times by 12 tests: return ret;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
10202
106}-
107-
108const BIO_METHOD *BIO_s_file(void)-
109{-
110 return &methods_filep;
executed 22400 times by 12 tests: return &methods_filep;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
22400
111}-
112-
113static int file_new(BIO *bi)-
114{-
115 bi->init = 0;-
116 bi->num = 0;-
117 bi->ptr = NULL;-
118 bi->flags = BIO_FLAGS_UPLINK; /* default to UPLINK */-
119 return 1;
executed 22400 times by 12 tests: return 1;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
22400
120}-
121-
122static int file_free(BIO *a)-
123{-
124 if (a == NULL)
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 44800 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
0-44800
125 return 0;
never executed: return 0;
0
126 if (a->shutdown) {
a->shutdownDescription
TRUEevaluated 34660 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
FALSEevaluated 10140 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
10140-34660
127 if ((a->init) && (a->ptr != NULL)) {
(a->init)Description
TRUEevaluated 12260 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 22400 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
(a->ptr != ((void *)0) )Description
TRUEevaluated 12260 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-22400
128 if (a->flags & BIO_FLAGS_UPLINK)
a->flags & 0Description
TRUEnever evaluated
FALSEevaluated 12260 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-12260
129 UP_fclose(a->ptr);
never executed: fclose(a->ptr);
0
130 else-
131 fclose(a->ptr);
executed 12260 times by 1 test: fclose(a->ptr);
Executed by:
  • libcrypto.so.1.1
12260
132 a->ptr = NULL;-
133 a->flags = BIO_FLAGS_UPLINK;-
134 }
executed 12260 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
12260
135 a->init = 0;-
136 }
executed 34660 times by 12 tests: end of block
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
34660
137 return 1;
executed 44800 times by 12 tests: return 1;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
44800
138}-
139-
140static int file_read(BIO *b, char *out, int outl)-
141{-
142 int ret = 0;-
143-
144 if (b->init && (out != NULL)) {
b->initDescription
TRUEevaluated 7006 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(out != ((void *)0) )Description
TRUEevaluated 7006 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-7006
145 if (b->flags & BIO_FLAGS_UPLINK)
b->flags & 0Description
TRUEnever evaluated
FALSEevaluated 7006 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7006
146 ret = UP_fread(out, 1, (int)outl, b->ptr);
never executed: ret = fread(out, 1, (int)outl, b->ptr);
0
147 else-
148 ret = fread(out, 1, (int)outl, (FILE *)b->ptr);
executed 7006 times by 1 test: ret = fread(out, 1, (int)outl, (FILE *)b->ptr);
Executed by:
  • libcrypto.so.1.1
7006
149 if (ret == 0
ret == 0 && (b...FILE *)b->ptr)Description
TRUEnever evaluated
FALSEevaluated 7006 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
ret == 0Description
TRUEevaluated 767 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6239 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7006
150 && (b->flags & BIO_FLAGS_UPLINK) ? UP_ferror((FILE *)b->ptr) :
ret == 0 && (b...FILE *)b->ptr)Description
TRUEnever evaluated
FALSEevaluated 7006 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(b->flags & 0)Description
TRUEnever evaluated
FALSEevaluated 767 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7006
151 ferror((FILE *)b->ptr)) {
ret == 0 && (b...FILE *)b->ptr)Description
TRUEnever evaluated
FALSEevaluated 7006 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7006
152 SYSerr(SYS_F_FREAD, get_last_sys_error());-
153 BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB);-
154 ret = -1;-
155 }
never executed: end of block
0
156 }
executed 7006 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
7006
157 return ret;
executed 7006 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
7006
158}-
159-
160static int file_write(BIO *b, const char *in, int inl)-
161{-
162 int ret = 0;-
163-
164 if (b->init && (in != NULL)) {
b->initDescription
TRUEevaluated 413449 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
FALSEnever evaluated
(in != ((void *)0) )Description
TRUEevaluated 413449 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
FALSEnever evaluated
0-413449
165 if (b->flags & BIO_FLAGS_UPLINK)
b->flags & 0Description
TRUEnever evaluated
FALSEevaluated 413449 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
0-413449
166 ret = UP_fwrite(in, (int)inl, 1, b->ptr);
never executed: ret = fwrite(in, (int)inl, 1, b->ptr);
0
167 else-
168 ret = fwrite(in, (int)inl, 1, (FILE *)b->ptr);
executed 413449 times by 12 tests: ret = fwrite(in, (int)inl, 1, (FILE *)b->ptr);
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
413449
169 if (ret)
retDescription
TRUEevaluated 413449 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
FALSEnever evaluated
0-413449
170 ret = inl;
executed 413449 times by 12 tests: ret = inl;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
413449
171 /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */-
172 /*-
173 * according to Tim Hudson <tjh@openssl.org>, the commented out-
174 * version above can cause 'inl' write calls under some stupid stdio-
175 * implementations (VMS)-
176 */-
177 }
executed 413449 times by 12 tests: end of block
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
413449
178 return ret;
executed 413449 times by 12 tests: return ret;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
413449
179}-
180-
181static long file_ctrl(BIO *b, int cmd, long num, void *ptr)-
182{-
183 long ret = 1;-
184 FILE *fp = (FILE *)b->ptr;-
185 FILE **fpp;-
186 char p[4];-
187 int st;-
188-
189 switch (cmd) {-
190 case BIO_C_FILE_SEEK:
never executed: case 128:
0
191 case BIO_CTRL_RESET:
executed 5 times by 1 test: case 1:
Executed by:
  • libcrypto.so.1.1
5
192 if (b->flags & BIO_FLAGS_UPLINK)
b->flags & 0Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
193 ret = (long)UP_fseek(b->ptr, num, 0);
never executed: ret = (long)fseek(b->ptr, num, 0);
0
194 else-
195 ret = (long)fseek(fp, num, 0);
executed 5 times by 1 test: ret = (long)fseek(fp, num, 0);
Executed by:
  • libcrypto.so.1.1
5
196 break;
executed 5 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
5
197 case BIO_CTRL_EOF:
executed 11122 times by 1 test: case 2:
Executed by:
  • libcrypto.so.1.1
11122
198 if (b->flags & BIO_FLAGS_UPLINK)
b->flags & 0Description
TRUEnever evaluated
FALSEevaluated 11122 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11122
199 ret = (long)UP_feof(fp);
never executed: ret = (long)feof(fp);
0
200 else-
201 ret = (long)feof(fp);
executed 11122 times by 1 test: ret = (long)feof(fp);
Executed by:
  • libcrypto.so.1.1
11122
202 break;
executed 11122 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
11122
203 case BIO_C_FILE_TELL:
never executed: case 133:
0
204 case BIO_CTRL_INFO:
never executed: case 3:
0
205 if (b->flags & BIO_FLAGS_UPLINK)
b->flags & 0Description
TRUEnever evaluated
FALSEnever evaluated
0
206 ret = UP_ftell(b->ptr);
never executed: ret = ftell(b->ptr);
0
207 else-
208 ret = ftell(fp);
never executed: ret = ftell(fp);
0
209 break;
never executed: break;
0
210 case BIO_C_SET_FILE_PTR:
executed 17465 times by 12 tests: case 106:
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
17465
211 file_free(b);-
212 b->shutdown = (int)num & BIO_CLOSE;-
213 b->ptr = ptr;-
214 b->init = 1;-
215# if BIO_FLAGS_UPLINK!=0-
216# if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)-
217# define _IOB_ENTRIES 20-
218# endif-
219 /* Safety net to catch purely internal BIO_set_fp calls */-
220# if defined(_MSC_VER) && _MSC_VER>=1900-
221 if (ptr == stdin || ptr == stdout || ptr == stderr)-
222 BIO_clear_flags(b, BIO_FLAGS_UPLINK);-
223# elif defined(_IOB_ENTRIES)-
224 if ((size_t)ptr >= (size_t)stdin &&-
225 (size_t)ptr < (size_t)(stdin + _IOB_ENTRIES))-
226 BIO_clear_flags(b, BIO_FLAGS_UPLINK);-
227# endif-
228# endif-
229# ifdef UP_fsetmod-
230 if (b->flags & BIO_FLAGS_UPLINK)-
231 UP_fsetmod(b->ptr, (char)((num & BIO_FP_TEXT) ? 't' : 'b'));-
232 else-
233# endif-
234 {-
235# if defined(OPENSSL_SYS_WINDOWS)-
236 int fd = _fileno((FILE *)ptr);-
237 if (num & BIO_FP_TEXT)-
238 _setmode(fd, _O_TEXT);-
239 else-
240 _setmode(fd, _O_BINARY);-
241# elif defined(OPENSSL_SYS_MSDOS)-
242 int fd = fileno((FILE *)ptr);-
243 /* Set correct text/binary mode */-
244 if (num & BIO_FP_TEXT)-
245 _setmode(fd, _O_TEXT);-
246 /* Dangerous to set stdin/stdout to raw (unless redirected) */-
247 else {-
248 if (fd == STDIN_FILENO || fd == STDOUT_FILENO) {-
249 if (isatty(fd) <= 0)-
250 _setmode(fd, _O_BINARY);-
251 } else-
252 _setmode(fd, _O_BINARY);-
253 }-
254# elif defined(OPENSSL_SYS_WIN32_CYGWIN)-
255 int fd = fileno((FILE *)ptr);-
256 if (num & BIO_FP_TEXT)-
257 setmode(fd, O_TEXT);-
258 else-
259 setmode(fd, O_BINARY);-
260# endif-
261 }-
262 break;
executed 17465 times by 12 tests: break;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
17465
263 case BIO_C_SET_FILENAME:
executed 4935 times by 1 test: case 108:
Executed by:
  • libcrypto.so.1.1
4935
264 file_free(b);-
265 b->shutdown = (int)num & BIO_CLOSE;-
266 if (num & BIO_FP_APPEND) {
num & 0x08Description
TRUEnever evaluated
FALSEevaluated 4935 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4935
267 if (num & BIO_FP_READ)
num & 0x02Description
TRUEnever evaluated
FALSEnever evaluated
0
268 OPENSSL_strlcpy(p, "a+", sizeof(p));
never executed: OPENSSL_strlcpy(p, "a+", sizeof(p));
0
269 else-
270 OPENSSL_strlcpy(p, "a", sizeof(p));
never executed: OPENSSL_strlcpy(p, "a", sizeof(p));
0
271 } else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
(num & 0x02)Description
TRUEevaluated 4935 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(num & 0x04)Description
TRUEnever evaluated
FALSEevaluated 4935 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4935
272 OPENSSL_strlcpy(p, "r+", sizeof(p));
never executed: OPENSSL_strlcpy(p, "r+", sizeof(p));
0
273 else if (num & BIO_FP_WRITE)
num & 0x04Description
TRUEnever evaluated
FALSEevaluated 4935 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4935
274 OPENSSL_strlcpy(p, "w", sizeof(p));
never executed: OPENSSL_strlcpy(p, "w", sizeof(p));
0
275 else if (num & BIO_FP_READ)
num & 0x02Description
TRUEevaluated 4935 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-4935
276 OPENSSL_strlcpy(p, "r", sizeof(p));
executed 4935 times by 1 test: OPENSSL_strlcpy(p, "r", sizeof(p));
Executed by:
  • libcrypto.so.1.1
4935
277 else {-
278 BIOerr(BIO_F_FILE_CTRL, BIO_R_BAD_FOPEN_MODE);-
279 ret = 0;-
280 break;
never executed: break;
0
281 }-
282# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32_CYGWIN)-
283 if (!(num & BIO_FP_TEXT))-
284 OPENSSL_strlcat(p, "b", sizeof(p));-
285 else-
286 OPENSSL_strlcat(p, "t", sizeof(p));-
287# endif-
288 fp = openssl_fopen(ptr, p);-
289 if (fp == NULL) {
fp == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4935 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4935
290 SYSerr(SYS_F_FOPEN, get_last_sys_error());-
291 ERR_add_error_data(5, "fopen('", ptr, "','", p, "')");-
292 BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);-
293 ret = 0;-
294 break;
never executed: break;
0
295 }-
296 b->ptr = fp;-
297 b->init = 1;-
298 BIO_clear_flags(b, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage-
299 * UPLINK */-
300 break;
executed 4935 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
4935
301 case BIO_C_GET_FILE_PTR:
executed 2 times by 1 test: case 107:
Executed by:
  • libcrypto.so.1.1
2
302 /* the ptr parameter is actually a FILE ** in this case. */-
303 if (ptr != NULL) {
ptr != ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2
304 fpp = (FILE **)ptr;-
305 *fpp = (FILE *)b->ptr;-
306 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
307 break;
executed 2 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
2
308 case BIO_CTRL_GET_CLOSE:
never executed: case 8:
0
309 ret = (long)b->shutdown;-
310 break;
never executed: break;
0
311 case BIO_CTRL_SET_CLOSE:
never executed: case 9:
0
312 b->shutdown = (int)num;-
313 break;
never executed: break;
0
314 case BIO_CTRL_FLUSH:
executed 32247 times by 12 tests: case 11:
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
32247
315 st = b->flags & BIO_FLAGS_UPLINK
b->flags & 0Description
TRUEnever evaluated
FALSEevaluated 32247 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
0-32247
316 ? UP_fflush(b->ptr) : fflush((FILE *)b->ptr);-
317 if (st == EOF) {
st == (-1)Description
TRUEnever evaluated
FALSEevaluated 32247 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
0-32247
318 SYSerr(SYS_F_FFLUSH, get_last_sys_error());-
319 ERR_add_error_data(1, "fflush()");-
320 BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);-
321 ret = 0;-
322 }
never executed: end of block
0
323 break;
executed 32247 times by 12 tests: break;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
32247
324 case BIO_CTRL_DUP:
never executed: case 12:
0
325 ret = 1;-
326 break;
never executed: break;
0
327-
328 case BIO_CTRL_WPENDING:
never executed: case 13:
0
329 case BIO_CTRL_PENDING:
never executed: case 10:
0
330 case BIO_CTRL_PUSH:
executed 2774 times by 12 tests: case 6:
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
2774
331 case BIO_CTRL_POP:
executed 240 times by 1 test: case 7:
Executed by:
  • libcrypto.so.1.1
240
332 default:
never executed: default:
0
333 ret = 0;-
334 break;
executed 3014 times by 12 tests: break;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
3014
335 }-
336 return ret;
executed 68790 times by 12 tests: return ret;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
68790
337}-
338-
339static int file_gets(BIO *bp, char *buf, int size)-
340{-
341 int ret = 0;-
342-
343 buf[0] = '\0';-
344 if (bp->flags & BIO_FLAGS_UPLINK) {
bp->flags & 0Description
TRUEnever evaluated
FALSEevaluated 376779 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-376779
345 if (!UP_fgets(buf, size, bp->ptr))
!fgets(buf, size, bp->ptr)Description
TRUEnever evaluated
FALSEnever evaluated
0
346 goto err;
never executed: goto err;
0
347 } else {
never executed: end of block
0
348 if (!fgets(buf, size, (FILE *)bp->ptr))
!fgets(buf, si...ILE *)bp->ptr)Description
TRUEevaluated 6349 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 370430 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
6349-370430
349 goto err;
executed 6349 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
6349
350 }
executed 370430 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
370430
351 if (buf[0] != '\0')
buf[0] != '\0'Description
TRUEevaluated 370430 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-370430
352 ret = strlen(buf);
executed 370430 times by 1 test: ret = strlen(buf);
Executed by:
  • libcrypto.so.1.1
370430
353 err:
code before this statement executed 370430 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
370430
354 return ret;
executed 376779 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
376779
355}-
356-
357static int file_puts(BIO *bp, const char *str)-
358{-
359 int n, ret;-
360-
361 n = strlen(str);-
362 ret = file_write(bp, str, n);-
363 return ret;
executed 37333 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
37333
364}-
365-
366#else-
367-
368static int file_write(BIO *b, const char *in, int inl)-
369{-
370 return -1;-
371}-
372static int file_read(BIO *b, char *out, int outl)-
373{-
374 return -1;-
375}-
376static int file_puts(BIO *bp, const char *str)-
377{-
378 return -1;-
379}-
380static int file_gets(BIO *bp, char *buf, int size)-
381{-
382 return 0;-
383}-
384static long file_ctrl(BIO *b, int cmd, long num, void *ptr)-
385{-
386 return 0;-
387}-
388static int file_new(BIO *bi)-
389{-
390 return 0;-
391}-
392static int file_free(BIO *a)-
393{-
394 return 0;-
395}-
396-
397static const BIO_METHOD methods_filep = {-
398 BIO_TYPE_FILE,-
399 "FILE pointer",-
400 /* TODO: Convert to new style write function */-
401 bwrite_conv,-
402 file_write,-
403 /* TODO: Convert to new style read function */-
404 bread_conv,-
405 file_read,-
406 file_puts,-
407 file_gets,-
408 file_ctrl,-
409 file_new,-
410 file_free,-
411 NULL, /* file_callback_ctrl */-
412};-
413-
414const BIO_METHOD *BIO_s_file(void)-
415{-
416 return &methods_filep;-
417}-
418-
419BIO *BIO_new_file(const char *filename, const char *mode)-
420{-
421 return NULL;-
422}-
423-
424# endif /* OPENSSL_NO_STDIO */-
425-
426#endif /* HEADER_BSS_FILE_C */-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2