From: Sven Hoexter Date: Tue, 5 Feb 2013 20:11:50 +0000 (+0100) Subject: Imported Upstream version 1.0.1 X-Git-Tag: upstream/1.0.1 X-Git-Url: https://git.sven.stormbind.net/?a=commitdiff_plain;h=2e575b1e5483257e1f38b52d14c5ab17755aa815;p=sven%2Fexfat-utils.git Imported Upstream version 1.0.1 --- diff --git a/ChangeLog b/ChangeLog index e24b2d6..adbf727 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1.0.1 (2013-02-02) + +* Fixed unexpected removal of a directory if it is moved into itself. +* Fixed "Operation not permitted" error on reading an empty file. + 1.0.0 (2013-01-19) * Fixed crash when renaming a file within a single directory and a new name diff --git a/libexfat/io.c b/libexfat/io.c index 1a555b9..4413aaa 100644 --- a/libexfat/io.c +++ b/libexfat/io.c @@ -341,7 +341,7 @@ ssize_t exfat_generic_pread(const struct exfat* ef, struct exfat_node* node, } if (!ef->ro && !ef->noatime) exfat_update_atime(node); - return size - remainder; + return MIN(size, node->size - offset) - remainder; } ssize_t exfat_generic_pwrite(struct exfat* ef, struct exfat_node* node, 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 */ diff --git a/libexfat/version.h b/libexfat/version.h index b795e91..debd185 100644 --- a/libexfat/version.h +++ b/libexfat/version.h @@ -23,6 +23,6 @@ #define EXFAT_VERSION_MAJOR 1 #define EXFAT_VERSION_MINOR 0 -#define EXFAT_VERSION_PATCH 0 +#define EXFAT_VERSION_PATCH 1 #endif /* ifndef VERSION_H_INCLUDED */