Bug fix: Paths with symbolic links preceding ".." were not interpreted properly
This commit is contained in:
@ -42,8 +42,8 @@
|
||||
/* @param eff_path returns resulting effective path.
|
||||
Must provide at least SfileadrL bytes of storage.
|
||||
@param flag bit0= do not produce problem events (unless faulty path format)
|
||||
bit1= work purely literally, do not use libisofs
|
||||
bit2= (with bit1) this is an address in the disk world
|
||||
bit1= do not use libisofs (work literally or in disk world)
|
||||
bit2= (implies bit1) this is an address in the disk world
|
||||
bit3= return root directory as "/" and not as ""
|
||||
bit4= (with bit2) determine type of disk file eff_path
|
||||
and return 0 if not existing
|
||||
@ -59,10 +59,13 @@ int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd,
|
||||
IsoImage *volume;
|
||||
IsoDir *dir= NULL;
|
||||
IsoNode *node= NULL;
|
||||
char *path= NULL, *apt, *npt, *cpt;
|
||||
char *path= NULL, *apt, *npt, *cpt, *link_target= NULL;
|
||||
|
||||
Xorriso_alloc_meM(path, char, SfileadrL);
|
||||
Xorriso_alloc_meM(link_target, char, SfileadrL);
|
||||
|
||||
if(flag & 4)
|
||||
flag|= 2;
|
||||
if((flag&64) || !(flag&2)) {
|
||||
ret= Xorriso_get_volume(xorriso, &volume, 0);
|
||||
if(ret<=0)
|
||||
@ -129,13 +132,31 @@ bonked_root:;
|
||||
{ret= -1; goto ex;}
|
||||
}
|
||||
dir= iso_node_get_parent(node);
|
||||
|
||||
/* >>> Get absolute path of dir as eff_path, to avoid link problems */;
|
||||
|
||||
}
|
||||
if(flag & 4) {
|
||||
/* Linux-ish local filesystem semantics:
|
||||
If the parent is a symbolic link, do not ascend to its parent,
|
||||
but to the parent of the link target.
|
||||
>>> ??? Are there systems which do it differently ?
|
||||
*/
|
||||
if(Sfile_type(eff_path, 0) == 3) {
|
||||
ret= Xorriso_resolve_link(xorriso, eff_path, link_target, 2);
|
||||
if(ret <= 0)
|
||||
{ret= -1; goto ex;}
|
||||
strcpy(eff_path, link_target);
|
||||
}
|
||||
}
|
||||
|
||||
/* truncate eff_path */;
|
||||
cpt= strrchr(eff_path, '/');
|
||||
if(cpt==NULL) /* ??? if not flag&2 then this is a bug */
|
||||
goto bonked_root;
|
||||
*cpt= 0;
|
||||
is_dir= 1;
|
||||
|
||||
continue;
|
||||
}
|
||||
is_dir= 0;
|
||||
@ -171,6 +192,7 @@ much_too_long:;
|
||||
ret= 1+!!is_dir;
|
||||
ex:;
|
||||
Xorriso_free_meM(path);
|
||||
Xorriso_free_meM(link_target);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user