[vlc-commits] keystore: store/find a decoded path

Thomas Guillem git at videolan.org
Mon Jan 11 19:02:15 CET 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jan 11 18:12:13 2016 +0100| [b1152f5c7c51318333e2b718d2f26b061fcf3258] | committer: Thomas Guillem

keystore: store/find a decoded path

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

 src/misc/keystore.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/misc/keystore.c b/src/misc/keystore.c
index 8e0b765..934b55a 100644
--- a/src/misc/keystore.c
+++ b/src/misc/keystore.c
@@ -131,6 +131,9 @@ find_closest_path(vlc_keystore_entry *p_entries, unsigned i_count,
 {
     vlc_keystore_entry *p_match_entry = NULL;
     size_t i_last_pathlen = 0;
+    char *psz_decoded_path = vlc_uri_decode_duplicate(psz_path);
+    if (psz_decoded_path == NULL)
+        return NULL;
 
     /* Try to find the entry that has the closest path to psz_url */
     for (unsigned int i = 0; i < i_count; ++i)
@@ -139,13 +142,14 @@ find_closest_path(vlc_keystore_entry *p_entries, unsigned i_count,
         const char *psz_entry_path = p_entry->ppsz_values[KEY_PATH];
         size_t i_entry_pathlen = strlen(psz_entry_path);
 
-        if (strncasecmp(psz_path, psz_entry_path, i_entry_pathlen) == 0
+        if (strncasecmp(psz_decoded_path, psz_entry_path, i_entry_pathlen) == 0
          && i_entry_pathlen > i_last_pathlen)
         {
             i_last_pathlen = i_entry_pathlen;
             p_match_entry = p_entry;
         }
     }
+    free(psz_decoded_path);
     return p_match_entry;
 }
 
@@ -430,7 +434,8 @@ vlc_credential_store(vlc_credential *p_credential)
     const vlc_url_t *p_url = p_credential->p_url;
 
     char *psz_path = NULL;
-    if (protocol_store_path(p_url) && (psz_path = strdup(p_url->psz_path)))
+    if (protocol_store_path(p_url)
+     && (psz_path =  vlc_uri_decode_duplicate(p_url->psz_path)) != NULL)
     {
         char *p_slash;
         if (protocol_is_smb(p_url))
@@ -473,7 +478,10 @@ vlc_credential_store(vlc_credential *p_credential)
     if (asprintf(&psz_label, "LibVLC password for %s://%s%s",
                  p_url->psz_protocol, p_url->psz_host,
                  psz_path ? psz_path : "") == -1)
+    {
+        free(psz_path);
         return false;
+    }
 
     bool b_ret = vlc_keystore_store(p_credential->p_keystore, ppsz_values,
                                     (const uint8_t *)p_credential->psz_password,



More information about the vlc-commits mailing list