brendan-duncan / archive

Dart library to encode and decode various archive and compression formats, such as Zip, Tar, GZip, ZLib, and BZip2.
MIT License
399 stars 139 forks source link

Failed to decompress the secret zip file #253

Open wadychou opened 1 year ago

wadychou commented 1 year ago

Flutter stable, 3.7.5 archive: ^3.3.6

my code:

import 'package:archive/archive_io.dart';

...
 Archive archive = ZipDecoder().decodeBytes(
      byteData.buffer.asUint8List(),
      verify: true,
      password: '123456'
  );
...

error:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: Cannot modify an unmodifiable list

0 _UnmodifiableUint8ArrayView.[]= (dart:typed_data-patch/typed_data_patch.dart:5391:5)

1 ZipFile._decodeZipCrypto (package:archive/src/zip/zip_file.dart:194:12)

2 ZipFile.content (package:archive/src/zip/zip_file.dart:131:27)

3 ZipDecoder.decodeBuffer (package:archive/src/zip_decoder.dart:35:41)

4 ZipDecoder.decodeBytes (package:archive/src/zip_decoder.dart:16:12)

@brendan-duncan @brendan-duncan-g

richshaw2015 commented 1 year ago

if you use ByteData data = await rootBundle.load(dbAsset); to load a zip file, you may counter this problem

Change

var bytes = data.buffer.asUint8List();

to:

var bytes = data.buffer.asUint8List().sublist(0);
fz3hra commented 1 year ago

@wadychou were you able to fix the issue please?