diff options
author | ulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-11-26 00:28:05 +0000 |
---|---|---|
committer | ulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-11-26 00:28:05 +0000 |
commit | 88f37769f2612da8e5a32733e8283268e8a1b64b (patch) | |
tree | fed9066a30943ae8c49681ac1c5b3deb68ce9aaf /libmenu | |
parent | 8b8b9ada52e3c3fb0e1901e61286c939dadcb12b (diff) | |
download | mpv-88f37769f2612da8e5a32733e8283268e8a1b64b.tar.bz2 mpv-88f37769f2612da8e5a32733e8283268e8a1b64b.tar.xz |
Fix code to make sure the browse starting path within the menu-chroot path.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25162 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmenu')
-rw-r--r-- | libmenu/menu_filesel.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/libmenu/menu_filesel.c b/libmenu/menu_filesel.c index d6e8715ff0..fe582c2217 100644 --- a/libmenu/menu_filesel.c +++ b/libmenu/menu_filesel.c @@ -393,7 +393,7 @@ static void clos(menu_t* menu) { static int open_fs(menu_t* menu, char* args) { char *path = mpriv->path, *freepath = NULL; int r = 0; - char wd[PATH_MAX+1]; + char wd[PATH_MAX+1], b[PATH_MAX+1]; args = NULL; // Warning kill menu->draw = menu_list_draw; @@ -425,22 +425,32 @@ static int open_fs(menu_t* menu, char* args) { } getcwd(wd,PATH_MAX); - if(!path || path[0] == '\0') { - int l = strlen(wd) + 2; - char b[l]; - sprintf(b,"%s/",wd); - r = open_dir(menu,b); - } else if(path[0] != '/') { - int al = strlen(path); - int l = strlen(wd) + al + 3; - char b[l]; - if(b[al-1] != '/') - sprintf(b,"%s/%s/",wd,path); + if (!path || path[0] == '\0') + path = wd; + if (path[0] != '/') { + if(path[strlen(path)-1] != '/') + snprintf(b,sizeof(b),"%s/%s/",wd,path); else - sprintf(b,"%s/%s",wd,path); - r = open_dir(menu,b); - } else - r = open_dir(menu,path); + snprintf(b,sizeof(b),"%s/%s",wd,path); + path = b; + } else if (path[strlen(path)-1]!='/') { + sprintf(b,"%s/",path); + path = b; + } + if (menu_chroot && menu_chroot[0] == '/') { + int l = strlen(menu_chroot); + if (l > 0 && menu_chroot[l-1] == '/') + --l; + if (strncmp(menu_chroot, path, l) || (path[l] != '\0' && path[l] != '/')) { + if (menu_chroot[l] == '/') + path = menu_chroot; + else { + sprintf(b,"%s/",menu_chroot); + path = b; + } + } + } + r = open_dir(menu,path); if (freepath) free(freepath); |