[vlc-commits] remoteosd: properly check for gcrypt_cipher_open errors

Zan Li git at videolan.org
Sun Apr 15 19:49:16 CEST 2018


vlc | branch: master | Zan Li <lizan at ruc.edu.cn> | Sat Apr 14 20:30:29 2018 +0800| [1e606c0ffe9a64c29cdf31c34acef4446678ecc8] | committer: Jean-Baptiste Kempf

remoteosd: properly check for gcrypt_cipher_open errors

The implementation of vnc_encrypt_bytes called by vnc_connect needs to add a
return value check on function gcry_cipher_open.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1e606c0ffe9a64c29cdf31c34acef4446678ecc8
---

 modules/spu/remoteosd.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/modules/spu/remoteosd.c b/modules/spu/remoteosd.c
index a0396bbb82..fa0fc7fb05 100644
--- a/modules/spu/remoteosd.c
+++ b/modules/spu/remoteosd.c
@@ -183,7 +183,7 @@ static inline bool raw_line(  filter_sys_t* p_sys,
                               uint16_t i_x, uint16_t i_y,
                               uint16_t i_w );
 
-static void vnc_encrypt_bytes( unsigned char *bytes, char *passwd );
+static int vnc_encrypt_bytes( unsigned char *bytes, char *passwd );
 
 
 /*****************************************************************************
@@ -392,7 +392,9 @@ static int vnc_connect( filter_t *p_filter )
             goto error;
         }
 
-        vnc_encrypt_bytes( challenge, p_sys->psz_passwd );
+        int err = vnc_encrypt_bytes( challenge, p_sys->psz_passwd );
+	if (err != VLC_SUCCESS)
+	    return false;
 
         if( !write_exact(p_filter, fd, challenge, CHALLENGESIZE ) )
         {
@@ -1312,7 +1314,7 @@ static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
     return VLC_SUCCESS;
 }
 
-static void vnc_encrypt_bytes( unsigned char *bytes, char *passwd )
+static int vnc_encrypt_bytes( unsigned char *bytes, char *passwd )
 {
     unsigned char key[8];
 
@@ -1320,7 +1322,9 @@ static void vnc_encrypt_bytes( unsigned char *bytes, char *passwd )
         key[i] = i < strlen( passwd ) ? passwd[i] : '\0';
 
     gcry_cipher_hd_t ctx;
-    gcry_cipher_open( &ctx, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_ECB,0);
+    int err = gcry_cipher_open( &ctx, GCRY_CIPHER_DES, GCRY_CIPHER_MODE_ECB,0);
+    if (err)
+	return VLC_EGENERIC;
 
     /* reverse bits of the key */
     for( unsigned i = 0 ; i < 8 ; i++ )
@@ -1337,5 +1341,6 @@ static void vnc_encrypt_bytes( unsigned char *bytes, char *passwd )
     gcry_cipher_setkey( ctx, key, 8 );
     gcry_cipher_encrypt( ctx, bytes, CHALLENGESIZE, bytes, CHALLENGESIZE );
     gcry_cipher_close( ctx );
+    return VLC_SUCCESS;
 }
 



More information about the vlc-commits mailing list