Coverage Report

Created: 2025-12-07 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/boringssl/crypto/pem/pem_oth.cc
Line
Count
Source
1
// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <openssl/pem.h>
16
17
#include <stdio.h>
18
19
#include <openssl/err.h>
20
#include <openssl/evp.h>
21
#include <openssl/mem.h>
22
#include <openssl/obj.h>
23
#include <openssl/rand.h>
24
#include <openssl/x509.h>
25
26
// Handle 'other' PEMs: not private keys
27
28
void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
29
0
                        pem_password_cb *cb, void *u) {
30
0
  const unsigned char *p = nullptr;
31
0
  unsigned char *data = nullptr;
32
0
  long len;
33
0
  char *ret = nullptr;
34
35
0
  if (!PEM_bytes_read_bio(&data, &len, nullptr, name, bp, cb, u)) {
36
0
    return nullptr;
37
0
  }
38
0
  p = data;
39
0
  ret = reinterpret_cast<char *>(d2i(x, &p, len));
40
0
  if (ret == nullptr) {
41
0
    OPENSSL_PUT_ERROR(PEM, ERR_R_ASN1_LIB);
42
0
  }
43
0
  OPENSSL_free(data);
44
0
  return ret;
45
0
}