X-Git-Url: http://git.sven.stormbind.net/?p=sven%2Fexfat-utils.git;a=blobdiff_plain;f=libexfat%2Fnode.c;h=bc342b780d59292b905ba43a755350bbaf45d82d;hp=cce1de7c0c93eeed5b96887e3f848bf5e369be4a;hb=refs%2Ftags%2Fupstream%2F1.0.1;hpb=4efb596cee7f7cc961990f8dffc3b210e579e49c 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 */