Adam Langley | d09175f | 2016-05-20 10:51:48 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2016, Google Inc. |
| 2 | * |
| 3 | * Permission to use, copy, modify, and/or distribute this software for any |
| 4 | * purpose with or without fee is hereby granted, provided that the above |
| 5 | * copyright notice and this permission notice appear in all copies. |
| 6 | * |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 14 | |
David Benjamin | 4c0e6c6 | 2016-10-13 19:03:17 -0400 | [diff] [blame] | 15 | #include <openssl/bio.h> |
| 16 | #include <openssl/err.h> |
Adam Langley | d09175f | 2016-05-20 10:51:48 -0700 | [diff] [blame] | 17 | #include <openssl/mem.h> |
| 18 | #include <openssl/pem.h> |
| 19 | |
| 20 | |
David Benjamin | 0939f80 | 2016-10-12 10:35:18 -0400 | [diff] [blame] | 21 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) { |
Adam Langley | d09175f | 2016-05-20 10:51:48 -0700 | [diff] [blame] | 22 | char *name, *header; |
| 23 | uint8_t *pem_data; |
| 24 | long pem_len; |
| 25 | |
| 26 | BIO *bio = BIO_new_mem_buf(buf, len); |
| 27 | |
| 28 | if (PEM_read_bio(bio, &name, &header, &pem_data, &pem_len) == 1) { |
| 29 | OPENSSL_free(name); |
| 30 | OPENSSL_free(header); |
| 31 | OPENSSL_free(pem_data); |
| 32 | } |
| 33 | |
| 34 | BIO_free(bio); |
| 35 | |
David Benjamin | 4c0e6c6 | 2016-10-13 19:03:17 -0400 | [diff] [blame] | 36 | ERR_clear_error(); |
Adam Langley | d09175f | 2016-05-20 10:51:48 -0700 | [diff] [blame] | 37 | return 0; |
| 38 | } |