| 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 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) { |
| 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 |
| 36 | ERR_clear_error(); |
| 37 | return 0; |
| 38 | } |
| 39 |