Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-13238

BlobHandler generates non-padded md5

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.0, 6.6.5, 7.0, 7.6, 7.7
    • Fix Version/s: 8.3
    • Component/s: blobstore
    • Labels:
      None

      Description

      Introduced in SOLR-6787

      The blob handler currently uses the following logic for generating/storing the md5 for uploads:

      MessageDigest m = MessageDigest.getInstance("MD5");
      m.update(payload.array(), payload.position(), payload.limit());
      String md5 = new BigInteger(1, m.digest()).toString(16);
      

      Unfortunately, this method does not provide padding for any md5 with less than 0x10 for its most significant byte. This means that on many occasions it could end up with a md5 hash of 31 characters instead of 32.

      I have opened a PR with the following recommended change:

      String md5 = new String(Hex.encodeHex(m.digest()));
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                janhoy Jan H√łydahl
                Reporter:
                jtwalraven Jeff Walraven
              • Votes:
                3 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h