X-Git-Url: https://git.sven.stormbind.net/?p=sven%2Ffuse-exfat.git;a=blobdiff_plain;f=libexfat%2Fnode.c;h=bc342b780d59292b905ba43a755350bbaf45d82d;hp=cce1de7c0c93eeed5b96887e3f848bf5e369be4a;hb=c970b8dc781ddfc1fc6f7d3890babd2a8fbe028b;hpb=c1c45856c432c68749276ecbeff56c88f85bcd3e diff --git a/libexfat/node.c b/libexfat/node.c index cce1de7..bc342b7 100644 --- a/libexfat/node.c +++ b/libexfat/node.c @@ -905,6 +905,23 @@ int exfat_rename(struct exfat* ef, const char* old_path, const char* new_path) exfat_put_node(ef, node); return rc; } + + /* check that target is not a subdirectory of the source */ + if (node->flags & EXFAT_ATTRIB_DIR) + { + struct exfat_node* p; + + for (p = dir; p; p = p->parent) + if (node == p) + { + if (existing != NULL) + exfat_put_node(ef, existing); + exfat_put_node(ef, dir); + exfat_put_node(ef, node); + return -EINVAL; + } + } + if (existing != NULL) { /* remove target if it's not the same node as source */