changeset 308:5f882de409eb

Added test for file access
author Sebastien Decugis <sdecugis@nict.go.jp>
date Mon, 17 May 2010 15:23:48 +0900
parents b49f187df50d
children b1a7d6d5dec4
files freeDiameter/fdd.y
diffstat 1 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/freeDiameter/fdd.y	Mon May 17 15:00:52 2010 +0900
+++ b/freeDiameter/fdd.y	Mon May 17 15:23:48 2010 +0900
@@ -495,6 +495,23 @@
 
 tls_cred:		TLS_CRED '=' QSTRING ',' QSTRING ';'
 			{
+				FILE * fd;
+				fd = fopen($3, "r");
+				if (fd == NULL) {
+					int ret = errno;
+					TRACE_DEBUG(INFO, "Unable to open certificate file %s for reading: %s\n", $3, strerror(ret));
+					yyerror (&yylloc, conf, "Error on file name"); 
+					YYERROR;
+				}
+				fclose(fd);
+				fd = fopen($5, "r");
+				if (fd == NULL) {
+					int ret = errno;
+					TRACE_DEBUG(INFO, "Unable to open private key file %s for reading: %s\n", $5, strerror(ret));
+					yyerror (&yylloc, conf, "Error on file name"); 
+					YYERROR;
+				}
+				fclose(fd);
 				conf->cnf_sec_data.cert_file = $3;
 				conf->cnf_sec_data.key_file = $5;
 				
@@ -509,6 +526,15 @@
 
 tls_ca:			TLS_CA '=' QSTRING ';'
 			{
+				FILE * fd;
+				fd = fopen($3, "r");
+				if (fd == NULL) {
+					int ret = errno;
+					TRACE_DEBUG(INFO, "Unable to open CA file %s for reading: %s\n", $3, strerror(ret));
+					yyerror (&yylloc, conf, "Error on file name"); 
+					YYERROR;
+				}
+				fclose(fd);
 				conf->cnf_sec_data.ca_file = $3;
 				CHECK_GNUTLS_DO( conf->cnf_sec_data.ca_file_nr += gnutls_certificate_set_x509_trust_file( 
 							conf->cnf_sec_data.credentials,
@@ -520,6 +546,15 @@
 			
 tls_crl:		TLS_CRL '=' QSTRING ';'
 			{
+				FILE * fd;
+				fd = fopen($3, "r");
+				if (fd == NULL) {
+					int ret = errno;
+					TRACE_DEBUG(INFO, "Unable to open CRL file %s for reading: %s\n", $3, strerror(ret));
+					yyerror (&yylloc, conf, "Error on file name"); 
+					YYERROR;
+				}
+				fclose(fd);
 				conf->cnf_sec_data.crl_file = $3;
 				CHECK_GNUTLS_DO( gnutls_certificate_set_x509_crl_file( 
 							conf->cnf_sec_data.credentials,
"Welcome to our mercurial repository"