/src/openssl/crypto/bio/bss_null.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.  | 
3  |  |  *  | 
4  |  |  * Licensed under the Apache License 2.0 (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  |  | #include <stdio.h>  | 
11  |  | #include <errno.h>  | 
12  |  | #include "bio_local.h"  | 
13  |  | #include "internal/cryptlib.h"  | 
14  |  |  | 
15  |  | static int null_write(BIO *h, const char *buf, int num);  | 
16  |  | static int null_read(BIO *h, char *buf, int size);  | 
17  |  | static int null_puts(BIO *h, const char *str);  | 
18  |  | static int null_gets(BIO *h, char *str, int size);  | 
19  |  | static long null_ctrl(BIO *h, int cmd, long arg1, void *arg2);  | 
20  |  | static const BIO_METHOD null_method = { | 
21  |  |     BIO_TYPE_NULL,  | 
22  |  |     "NULL",  | 
23  |  |     bwrite_conv,  | 
24  |  |     null_write,  | 
25  |  |     bread_conv,  | 
26  |  |     null_read,  | 
27  |  |     null_puts,  | 
28  |  |     null_gets,  | 
29  |  |     null_ctrl,  | 
30  |  |     NULL,  | 
31  |  |     NULL,  | 
32  |  |     NULL,                     /* null_callback_ctrl */  | 
33  |  | };  | 
34  |  |  | 
35  |  | const BIO_METHOD *BIO_s_null(void)  | 
36  | 0  | { | 
37  | 0  |     return &null_method;  | 
38  | 0  | }  | 
39  |  |  | 
40  |  | static int null_read(BIO *b, char *out, int outl)  | 
41  | 0  | { | 
42  | 0  |     return 0;  | 
43  | 0  | }  | 
44  |  |  | 
45  |  | static int null_write(BIO *b, const char *in, int inl)  | 
46  | 0  | { | 
47  | 0  |     return inl;  | 
48  | 0  | }  | 
49  |  |  | 
50  |  | static long null_ctrl(BIO *b, int cmd, long num, void *ptr)  | 
51  | 0  | { | 
52  | 0  |     long ret = 1;  | 
53  |  | 
  | 
54  | 0  |     switch (cmd) { | 
55  | 0  |     case BIO_CTRL_RESET:  | 
56  | 0  |     case BIO_CTRL_EOF:  | 
57  | 0  |     case BIO_CTRL_SET:  | 
58  | 0  |     case BIO_CTRL_SET_CLOSE:  | 
59  | 0  |     case BIO_CTRL_FLUSH:  | 
60  | 0  |     case BIO_CTRL_DUP:  | 
61  | 0  |         ret = 1;  | 
62  | 0  |         break;  | 
63  | 0  |     case BIO_CTRL_GET_CLOSE:  | 
64  | 0  |     case BIO_CTRL_INFO:  | 
65  | 0  |     case BIO_CTRL_GET:  | 
66  | 0  |     case BIO_CTRL_PENDING:  | 
67  | 0  |     case BIO_CTRL_WPENDING:  | 
68  | 0  |     default:  | 
69  | 0  |         ret = 0;  | 
70  | 0  |         break;  | 
71  | 0  |     }  | 
72  | 0  |     return ret;  | 
73  | 0  | }  | 
74  |  |  | 
75  |  | static int null_gets(BIO *bp, char *buf, int size)  | 
76  | 0  | { | 
77  | 0  |     return 0;  | 
78  | 0  | }  | 
79  |  |  | 
80  |  | static int null_puts(BIO *bp, const char *str)  | 
81  | 0  | { | 
82  | 0  |     if (str == NULL)  | 
83  | 0  |         return 0;  | 
84  | 0  |     return strlen(str);  | 
85  | 0  | }  |