VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/libzip/zip_set_archive_flag.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/libzip/zip_set_archive_flag.c')
-rw-r--r--src/Common/libzip/zip_set_archive_flag.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Common/libzip/zip_set_archive_flag.c b/src/Common/libzip/zip_set_archive_flag.c
index 610409d5..834ef5ba 100644
--- a/src/Common/libzip/zip_set_archive_flag.c
+++ b/src/Common/libzip/zip_set_archive_flag.c
@@ -39,15 +39,26 @@ ZIP_EXTERN int
zip_set_archive_flag(zip_t *za, zip_flags_t flag, int value) {
unsigned int new_flags;
- if (value)
+ if (flag == ZIP_AFL_IS_TORRENTZIP) {
+ zip_error_set(&za->error, ZIP_ER_INVAL, 0);
+ return -1;
+ }
+
+ /* TODO: when setting ZIP_AFL_WANT_TORRENTZIP, we should error out if any changes have been made that are not allowed for torrentzip. */
+
+ if (value) {
new_flags = za->ch_flags | flag;
- else
+ }
+ else {
new_flags = za->ch_flags & ~flag;
+ }
- if (new_flags == za->ch_flags)
+ if (new_flags == za->ch_flags) {
return 0;
+ }
- if (ZIP_IS_RDONLY(za)) {
+ /* Allow removing ZIP_AFL_RDONLY if manually set, not if archive was opened read-only. */
+ if (za->flags & ZIP_AFL_RDONLY) {
zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
return -1;
}