File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -915,6 +915,19 @@ class PackageBackend {
915915 _logger.info ('Examining tarball content ($guid ).' );
916916 final sw = Stopwatch ()..start ();
917917 final file = File (filename);
918+ final fileLength = await file.length ();
919+ if (fileLength != info.length) {
920+ _logger.warning (
921+ 'Saved file length mismatch ($fileLength != ${info .length }).' );
922+ throw InvalidInputException (
923+ 'Failed to save uploaded file: length mismatch.' );
924+ }
925+ final md5Hash = (await file.openRead ().transform (md5).single).bytes;
926+ if (! md5Hash.byteToByteEquals (info.md5Hash)) {
927+ _logger.warning ('Saved file md5 mismatch.' );
928+ throw InvalidInputException (
929+ 'Failed to save uploaded file: md5 mismatch.' );
930+ }
918931 final sha256Hash = (await file.openRead ().transform (sha256).single).bytes;
919932 final archive = await summarizePackageArchive (
920933 filename,
You can’t perform that action at this time.
0 commit comments