/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 | 6.42k | { |
37 | 6.42k | return &null_method; |
38 | 6.42k | } |
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 | 17.2M | { |
47 | 17.2M | return inl; |
48 | 17.2M | } |
49 | | |
50 | | static long null_ctrl(BIO *b, int cmd, long num, void *ptr) |
51 | 5.34k | { |
52 | 5.34k | long ret = 1; |
53 | | |
54 | 5.34k | 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 | 5.34k | default: |
69 | 5.34k | ret = 0; |
70 | 5.34k | break; |
71 | 5.34k | } |
72 | 5.34k | return ret; |
73 | 5.34k | } |
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 | 5.01M | { |
82 | 5.01M | if (str == NULL) |
83 | 0 | return 0; |
84 | 5.01M | return strlen(str); |
85 | 5.01M | } |