Pier Angelo Vendrame pushed to branch tor-browser-115.16.0esr-13.5-1 at The Tor Project / Applications / Tor Browser

Commits:

3 changed files:

Changes:

  • toolkit/mozapps/update/UpdateService.sys.mjs
    ... ... @@ -2127,8 +2127,6 @@ function UpdatePatch(patch) {
    2127 2127
             }
    
    2128 2128
             break;
    
    2129 2129
           case "finalURL":
    
    2130
    -      case "hashFunction":
    
    2131
    -      case "hashValue":
    
    2132 2130
           case "state":
    
    2133 2131
           case "type":
    
    2134 2132
           case "URL":
    
    ... ... @@ -2148,8 +2146,6 @@ UpdatePatch.prototype = {
    2148 2146
       // over writing nsIUpdatePatch attributes.
    
    2149 2147
       _attrNames: [
    
    2150 2148
         "errorCode",
    
    2151
    -    "hashFunction",
    
    2152
    -    "hashValue",
    
    2153 2149
         "finalURL",
    
    2154 2150
         "selected",
    
    2155 2151
         "size",
    
    ... ... @@ -2163,8 +2159,6 @@ UpdatePatch.prototype = {
    2163 2159
        */
    
    2164 2160
       serialize: function UpdatePatch_serialize(updates) {
    
    2165 2161
         var patch = updates.createElementNS(URI_UPDATE_NS, "patch");
    
    2166
    -    patch.setAttribute("hashFunction", this.hashFunction);
    
    2167
    -    patch.setAttribute("hashValue", this.hashValue);
    
    2168 2162
         patch.setAttribute("size", this.size);
    
    2169 2163
         patch.setAttribute("type", this.type);
    
    2170 2164
         patch.setAttribute("URL", this.URL);
    
    ... ... @@ -3737,18 +3731,20 @@ UpdateService.prototype = {
    3737 3731
     
    
    3738 3732
           switch (aUpdate.type) {
    
    3739 3733
             case "major":
    
    3740
    -          if (!majorUpdate) {
    
    3734
    +          if (!majorUpdate || majorUpdate.unsupported) {
    
    3741 3735
                 majorUpdate = aUpdate;
    
    3742 3736
               } else if (
    
    3737
    +            !aUpdate.unsupported &&
    
    3743 3738
                 vc.compare(majorUpdate.appVersion, aUpdate.appVersion) <= 0
    
    3744 3739
               ) {
    
    3745 3740
                 majorUpdate = aUpdate;
    
    3746 3741
               }
    
    3747 3742
               break;
    
    3748 3743
             case "minor":
    
    3749
    -          if (!minorUpdate) {
    
    3744
    +          if (!minorUpdate || minorUpdate.unsupported) {
    
    3750 3745
                 minorUpdate = aUpdate;
    
    3751 3746
               } else if (
    
    3747
    +            !aUpdate.unsupported &&
    
    3752 3748
                 vc.compare(minorUpdate.appVersion, aUpdate.appVersion) <= 0
    
    3753 3749
               ) {
    
    3754 3750
                 minorUpdate = aUpdate;
    
    ... ... @@ -5792,56 +5788,7 @@ Downloader.prototype = {
    5792 5788
         }
    
    5793 5789
     
    
    5794 5790
         LOG("Downloader:_verifyDownload downloaded size == expected size.");
    
    5795
    -    let fileStream = Cc[
    
    5796
    -      "@mozilla.org/network/file-input-stream;1"
    
    5797
    -    ].createInstance(Ci.nsIFileInputStream);
    
    5798
    -    fileStream.init(
    
    5799
    -      destination,
    
    5800
    -      FileUtils.MODE_RDONLY,
    
    5801
    -      FileUtils.PERMS_FILE,
    
    5802
    -      0
    
    5803
    -    );
    
    5804
    -
    
    5805
    -    let digest;
    
    5806
    -    try {
    
    5807
    -      let hash = Cc["@mozilla.org/security/hash;1"].createInstance(
    
    5808
    -        Ci.nsICryptoHash
    
    5809
    -      );
    
    5810
    -      var hashFunction =
    
    5811
    -        Ci.nsICryptoHash[this._patch.hashFunction.toUpperCase()];
    
    5812
    -      if (hashFunction == undefined) {
    
    5813
    -        throw Components.Exception("", Cr.NS_ERROR_UNEXPECTED);
    
    5814
    -      }
    
    5815
    -      hash.init(hashFunction);
    
    5816
    -      hash.updateFromStream(fileStream, -1);
    
    5817
    -      // NOTE: For now, we assume that the format of _patch.hashValue is hex
    
    5818
    -      // encoded binary (such as what is typically output by programs like
    
    5819
    -      // sha1sum).  In the future, this may change to base64 depending on how
    
    5820
    -      // we choose to compute these hashes.
    
    5821
    -      hash = hash.finish(false);
    
    5822
    -      digest = Array.from(hash, (c, i) =>
    
    5823
    -        hash.charCodeAt(i).toString(16).padStart(2, "0")
    
    5824
    -      ).join("");
    
    5825
    -    } catch (e) {
    
    5826
    -      LOG(
    
    5827
    -        "Downloader:_verifyDownload - failed to compute hash of the downloaded update archive"
    
    5828
    -      );
    
    5829
    -      digest = "";
    
    5830
    -    }
    
    5831
    -
    
    5832
    -    fileStream.close();
    
    5833
    -
    
    5834
    -    if (digest == this._patch.hashValue.toLowerCase()) {
    
    5835
    -      LOG("Downloader:_verifyDownload hashes match.");
    
    5836
    -      return true;
    
    5837
    -    }
    
    5838
    -
    
    5839
    -    LOG("Downloader:_verifyDownload hashes do not match. ");
    
    5840
    -    AUSTLMY.pingDownloadCode(
    
    5841
    -      this.isCompleteUpdate,
    
    5842
    -      AUSTLMY.DWNLD_ERR_VERIFY_NO_HASH_MATCH
    
    5843
    -    );
    
    5844
    -    return false;
    
    5791
    +    return true;
    
    5845 5792
       },
    
    5846 5793
     
    
    5847 5794
       /**
    
    ... ... @@ -6477,9 +6424,6 @@ Downloader.prototype = {
    6477 6424
               " is higher than patch size: " +
    
    6478 6425
               this._patch.size
    
    6479 6426
           );
    
    6480
    -      // It's important that we use a different code than
    
    6481
    -      // NS_ERROR_CORRUPTED_CONTENT so that tests can verify the difference
    
    6482
    -      // between a hash error and a wrong download error.
    
    6483 6427
           AUSTLMY.pingDownloadCode(
    
    6484 6428
             this.isCompleteUpdate,
    
    6485 6429
             AUSTLMY.DWNLD_ERR_PATCH_SIZE_LARGER
    
    ... ... @@ -6498,9 +6442,6 @@ Downloader.prototype = {
    6498 6442
               " is not equal to expected patch size: " +
    
    6499 6443
               this._patch.size
    
    6500 6444
           );
    
    6501
    -      // It's important that we use a different code than
    
    6502
    -      // NS_ERROR_CORRUPTED_CONTENT so that tests can verify the difference
    
    6503
    -      // between a hash error and a wrong download error.
    
    6504 6445
           AUSTLMY.pingDownloadCode(
    
    6505 6446
             this.isCompleteUpdate,
    
    6506 6447
             AUSTLMY.DWNLD_ERR_PATCH_SIZE_NOT_EQUAL
    

  • toolkit/mozapps/update/UpdateTelemetry.sys.mjs
    ... ... @@ -190,7 +190,6 @@ export var AUSTLMY = {
    190 190
       DWNLD_ERR_VERIFY_NO_REQUEST: 13,
    
    191 191
       DWNLD_ERR_VERIFY_PATCH_SIZE_NOT_EQUAL: 14,
    
    192 192
       DWNLD_ERR_WRITE_FAILURE: 15,
    
    193
    -  DWNLD_ERR_VERIFY_NO_HASH_MATCH: 16,
    
    194 193
       // Temporary failure code to see if there are failures without an update phase
    
    195 194
       DWNLD_UNKNOWN_PHASE_ERR_WRITE_FAILURE: 40,
    
    196 195
     
    

  • toolkit/mozapps/update/nsIUpdateService.idl
    ... ... @@ -39,17 +39,6 @@ interface nsIUpdatePatch : nsISupports
    39 39
        */
    
    40 40
       attribute AString finalURL;
    
    41 41
     
    
    42
    -  /**
    
    43
    -   * The hash function to use when determining this file's integrity
    
    44
    -   */
    
    45
    -  attribute AString hashFunction;
    
    46
    -
    
    47
    -  /**
    
    48
    -   * The value of the hash function named above that should be computed if
    
    49
    -   * this file is not corrupt.
    
    50
    -   */
    
    51
    -  attribute AString hashValue;
    
    52
    -
    
    53 42
       /**
    
    54 43
        * The size of this file, in bytes.
    
    55 44
        */