1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-23 23:32:26 +00:00

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
This commit is contained in:
ulion 2007-11-26 00:28:05 +00:00
parent 8b8b9ada52
commit 88f37769f2

View File

@ -393,7 +393,7 @@ static void clos(menu_t* menu) {
static int open_fs(menu_t* menu, char* args) { static int open_fs(menu_t* menu, char* args) {
char *path = mpriv->path, *freepath = NULL; char *path = mpriv->path, *freepath = NULL;
int r = 0; int r = 0;
char wd[PATH_MAX+1]; char wd[PATH_MAX+1], b[PATH_MAX+1];
args = NULL; // Warning kill args = NULL; // Warning kill
menu->draw = menu_list_draw; menu->draw = menu_list_draw;
@ -425,22 +425,32 @@ static int open_fs(menu_t* menu, char* args) {
} }
getcwd(wd,PATH_MAX); getcwd(wd,PATH_MAX);
if(!path || path[0] == '\0') { if (!path || path[0] == '\0')
int l = strlen(wd) + 2; path = wd;
char b[l]; if (path[0] != '/') {
sprintf(b,"%s/",wd); if(path[strlen(path)-1] != '/')
r = open_dir(menu,b); snprintf(b,sizeof(b),"%s/%s/",wd,path);
} 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);
else else
sprintf(b,"%s/%s",wd,path); snprintf(b,sizeof(b),"%s/%s",wd,path);
r = open_dir(menu,b); path = b;
} else } else if (path[strlen(path)-1]!='/') {
r = open_dir(menu,path); 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) if (freepath)
free(freepath); free(freepath);