diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-04-18 13:31:58 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-04-18 13:31:58 +0000 |
commit | a6de8f97e88bfa45f973909faf1b3c8caf8f8909 (patch) | |
tree | 6e2b052dbcbe367d5d862bdbb05a8f2e6e110654 /lib/gnutls_srp.c | |
parent | 05de2ecb11d8956aa7def54bf324e8667ab5379c (diff) | |
download | gnutls-a6de8f97e88bfa45f973909faf1b3c8caf8f8909.tar.gz |
Some minor fixes in SRP support. Changed extension generation. Now less
allocation with malloc are done.
Diffstat (limited to 'lib/gnutls_srp.c')
-rw-r--r-- | lib/gnutls_srp.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/gnutls_srp.c b/lib/gnutls_srp.c index 0aa59b958f..41e42dfe53 100644 --- a/lib/gnutls_srp.c +++ b/lib/gnutls_srp.c @@ -403,6 +403,17 @@ int gnutls_srp_allocate_server_sc( GNUTLS_SRP_SERVER_CREDENTIALS *sc) { return 0; } +inline +static int file_exists( const char* file) { +FILE* fd; + + fd = fopen( file, "r"); + if (fd==NULL) return -1; + + fclose(fd); + return 0; +} + /** * gnutls_srp_set_server_cred_file - Used to set the password files, in a GNUTLS_SRP_SERVER_CREDENTIALS structure * @res: is an &GNUTLS_SRP_SERVER_CREDENTIALS structure. @@ -417,6 +428,17 @@ int i; gnutls_assert(); return GNUTLS_E_INVALID_PARAMETERS; } + + /* Check if the files can be opened */ + if (file_exists( password_file)!=0) { + gnutls_assert(); + return GNUTLS_E_FILE_ERROR; + } + + if (file_exists( password_conf_file)!=0) { + gnutls_assert(); + return GNUTLS_E_FILE_ERROR; + } res->password_file = gnutls_realloc( res->password_file, sizeof(char*)*(res->password_files+1)); |