Coverage Report

Created: 2025-08-28 06:59

/src/boringssl/fuzz/read_pem.cc
Line
Count
Source
1
// Copyright 2016 The BoringSSL Authors
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/bio.h>
16
#include <openssl/err.h>
17
#include <openssl/mem.h>
18
#include <openssl/pem.h>
19
20
21
1.13k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
22
1.13k
  char *name, *header;
23
1.13k
  uint8_t *pem_data;
24
1.13k
  long pem_len;
25
26
1.13k
  BIO *bio = BIO_new_mem_buf(buf, len);
27
28
1.13k
  if (PEM_read_bio(bio, &name, &header, &pem_data, &pem_len) == 1) {
29
47
    OPENSSL_free(name);
30
47
    OPENSSL_free(header);
31
47
    OPENSSL_free(pem_data);
32
47
  }
33
34
1.13k
  BIO_free(bio);
35
36
1.13k
  ERR_clear_error();
37
1.13k
  return 0;
38
1.13k
}