[vlc-commits] Add config_IsSafe() internal helper

Rémi Denis-Courmont git at videolan.org
Sat Jul 16 11:53:44 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jul 13 22:25:12 2011 +0300| [719507f3517de525ec811ce74b83d3a35404ac5e] | committer: Rémi Denis-Courmont

Add config_IsSafe() internal helper

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

 src/config/core.c    |    6 ++++++
 src/libvlc.h         |    1 +
 src/misc/variables.c |   14 +++++---------
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/config/core.c b/src/config/core.c
index 236e944..4bc2519 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -89,6 +89,12 @@ int config_GetType( vlc_object_t *p_this, const char *psz_name )
     return i_type;
 }
 
+bool config_IsSafe( const char *name )
+{
+    module_config_t *p_config = config_FindConfig( NULL, name );
+    return p_config != NULL && p_config->b_safe;
+}
+
 #undef config_GetInt
 /*****************************************************************************
  * config_GetInt: get the value of an int variable
diff --git a/src/libvlc.h b/src/libvlc.h
index a9d64f5..b5f8da8 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -235,6 +235,7 @@ extern const size_t libvlc_config_count;
  * Variables stuff
  */
 void var_OptionParse (vlc_object_t *, const char *, bool trusted);
+bool config_IsSafe (const char *);
 
 
 /*
diff --git a/src/misc/variables.c b/src/misc/variables.c
index f2f8c27..801782e 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -1034,16 +1034,12 @@ void var_OptionParse( vlc_object_t *p_obj, const char *psz_option,
         ( !psz_value || !*psz_value ) ) goto cleanup; /* Invalid value */
 
     /* check if option is unsafe */
-    if( !trusted )
+    if( !trusted && !config_IsSafe( psz_name ) )
     {
-        module_config_t *p_config = config_FindConfig( p_obj, psz_name );
-        if( !p_config || !p_config->b_safe )
-        {
-            msg_Err( p_obj, "unsafe option \"%s\" has been ignored for "
-                            "security reasons", psz_name );
-            free( psz_name );
-            return;
-        }
+        msg_Err( p_obj, "unsafe option \"%s\" has been ignored for "
+                        "security reasons", psz_name );
+        free( psz_name );
+        return;
     }
 
     /* Create the variable in the input object.



More information about the vlc-commits mailing list