From 8c71b3ecb355d4967171236033ef14c270cb0d81 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 19 Dec 2018 17:37:02 +0100 Subject: [PATCH] pk_parse*keyfile: explicitly validate path=NULL Don't rely on the check in pk_load_file, that's fragile. --- library/pkparse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/pkparse.c b/library/pkparse.c index 127f9b840..ae210bca6 100644 --- a/library/pkparse.c +++ b/library/pkparse.c @@ -135,6 +135,7 @@ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx, unsigned char *buf; PK_VALIDATE_RET( ctx != NULL ); + PK_VALIDATE_RET( path != NULL ); if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) return( ret ); @@ -161,6 +162,7 @@ int mbedtls_pk_parse_public_keyfile( mbedtls_pk_context *ctx, const char *path ) unsigned char *buf; PK_VALIDATE_RET( ctx != NULL ); + PK_VALIDATE_RET( path != NULL ); if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) return( ret );