Index: sources/update/UiProtocol.cpp =================================================================== diff -u -ra789f05e3d97087703029792b6fd81bce77157f0 -r7adf8457ae210e8a598c2e5272175acc8c354e1a --- sources/update/UiProtocol.cpp (.../UiProtocol.cpp) (revision a789f05e3d97087703029792b6fd81bce77157f0) +++ sources/update/UiProtocol.cpp (.../UiProtocol.cpp) (revision 7adf8457ae210e8a598c2e5272175acc8c354e1a) @@ -353,6 +353,8 @@ // While data to stream... const std::size_t image_size = _pProvider->totalSize; + + std::size_t zero_reads = 0; while (_transfered < image_size) { // Compute the size in bytes of the transfer, upto MAX_TRANSFER_SIZE. const uint32 sz = (uint32)(_transfered + MAX_TRANSFER_SIZE) < (uint32)image_size ? @@ -374,8 +376,18 @@ return false; } if (!ok) { + zero_reads++; + if (zero_reads > 10) { + // Ten failed reads, we are likely reading a bad file, pop out of the loop. + // It was signed but it's invalid, this is seen if a bug in the build tool + // exists or the file was hacked. Returning false provides a good UI experience. + return false; + } + // Retry read. continue; + } else { + zero_reads = 0; } // Create the security token and send it.