/*****************************************************************************
* Preamble
*****************************************************************************/
-#define _GNU_SOURCE
+
+#include <vlc/vlc.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
-#include <vlc/vlc.h>
#include <sys/types.h>
#include <errno.h>
#include "vlc_tls.h"
-#include "charset.h"
+#include <vlc_charset.h>
#include <gcrypt.h>
#include <gnutls/gnutls.h>
return 0;
}
-static int
-gnutls_VerifyHostname( vlc_object_t *p_this, gnutls_session session,
- const char *psz_hostname )
-{
- const gnutls_datum *p_data;
- gnutls_x509_crt cert;
- unsigned status;
- int val;
-
- /* certificate (host)name verification */
- p_data = gnutls_certificate_get_peers( session, &status );
- if( p_data == NULL )
- {
- msg_Err( p_this, "TLS peer certificate not available" );
- return -1;
- }
-
- val = gnutls_x509_crt_init( &cert );
- if( val )
- {
- msg_Err( p_this, "x509 fatal error: %s", gnutls_strerror( val ) );
- return -1;
- }
-
- val = gnutls_x509_crt_import( cert, p_data, GNUTLS_X509_FMT_DER );
- if( val )
- {
- msg_Err( p_this, "x509 certificate import error: %s",
- gnutls_strerror( val ) );
- gnutls_x509_crt_deinit( cert );
- return -1;
- }
-
- if( gnutls_x509_crt_check_hostname( cert, psz_hostname ) == 0 )
- {
- msg_Err( p_this, "x509 certificate does not match \"%s\"",
- psz_hostname );
- gnutls_x509_crt_deinit( cert );
- return -1;
- }
-
- gnutls_x509_crt_deinit( cert );
- msg_Dbg( p_this, "x509 hostname matches %s", psz_hostname );
- return 0;
-}
-
typedef struct
{
vlc_bool_t b_priv )
{
DIR* dir;
- const char *psz_dirent;
if( *psz_dirname == '\0' )
psz_dirname = ".";
}
#endif
- while( ( psz_dirent = utf8_readdir( dir ) ) != NULL )
+ for (;;)
{
- char *psz_filename;
- int check;
+ char *ent = utf8_readdir (dir);
+ if (ent == NULL)
+ break;
- if( ( strcmp( ".", psz_dirent ) == 0 )
- || ( strcmp( "..", psz_dirent ) == 0 ) )
+ if ((strcmp (ent, ".") == 0) || (strcmp (ent, "..") == 0))
continue;
- check = asprintf( &psz_filename, "%s/%s", psz_dirname,
- psz_dirent );
- LocaleFree( psz_dirent );
- if( check == -1 )
- continue;
+ char path[strlen (psz_dirname) + strlen (ent) + 2];
+ sprintf (path, "%s"DIR_SEP"%s", psz_dirname, ent);
+ free (ent);
- gnutls_Addx509File( p_this, cred, psz_filename, b_priv );
- free( psz_filename );
+ gnutls_Addx509File( p_this, cred, path, b_priv );
}
closedir( dir );