From 2dc15c8e7dc863b1d5394fcec91867817b85f4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 5 Feb 2015 11:34:49 +0000 Subject: [PATCH] Fix unchecked error on windows --- ChangeLog | 5 +++-- library/x509parse.c | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a6a4bc3b8..b13d757a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,9 +20,10 @@ Bugfix * Fix memory leaks in PKCS#5 and PKCS#12. * Stack buffer overflow if ctr_drbg_update() is called with too large add_len (found by Jean-Philippe Aumasson) (not triggerable remotely). - * Fix bug in MPI/bugnum on s390/s390x (reported by Dan Horák) (introduced + * Fix bug in MPI/bignum on s390/s390x (reported by Dan Horák) (introduced in 1.2.12). - + * Fix unchecked return code in x509_crt_parse_path() on Windows (found by + Peter Vaskovic). Changes * Blind RSA private operations even when POLARSSL_RSA_NO_CRT is defined. diff --git a/library/x509parse.c b/library/x509parse.c index fff6dd69c..ea59bec67 100644 --- a/library/x509parse.c +++ b/library/x509parse.c @@ -1949,6 +1949,8 @@ int x509parse_crtpath( x509_cert *chain, const char *path ) filename[len++] = '*'; w_ret = MultiByteToWideChar( CP_ACP, 0, filename, len, szDir, MAX_PATH - 3 ); + if( w_ret == 0 ) + return( POLARSSL_ERR_X509_INVALID_INPUT ); hFind = FindFirstFileW( szDir, &file_data ); if (hFind == INVALID_HANDLE_VALUE) @@ -1966,6 +1968,8 @@ int x509parse_crtpath( x509_cert *chain, const char *path ) lstrlenW(file_data.cFileName), p, len - 1, NULL, NULL ); + if( w_ret == 0 ) + return( POLARSSL_ERR_X509_FILE_IO_ERROR ); w_ret = x509parse_crtfile( chain, filename ); if( w_ret < 0 )