Skip to content

Hash calculation seems buggy (but consistent) #96

Open
@csachs

Description

@csachs

I was trying to recreate imagej-updater's hashing in Python, and while I had success with many files, I stumbled upon some very peculiar behaving files. Six hours of debugging later, I found two non-obvious bugs in imagej-updater's code.
While this seems to be two bugs, it doesn't really affect the updater, since the hashes are calculated consistently wrong ;) … or at least contrary to what taking a brief look at the code might suggest.

First: Contrary to what keepOnlyMainClass parameter (the default) suggests, the FilterManifest filter will never show the main class:

if (line.toUpperCase().startsWith("Main-Class:")) builder.append(line).append('\n');

After the .toUpperCase() call, it can never .startsWith() the mixed case text fragment ... hence just an empty manifest is passed.

Second: A missing super(). turns this simple supposedly-iterative (I presume) function into a rather unpredictable recursive affair ... contrary to what SkipHashedLines suggests, some lines starting with a # will hence remain in the resulting stream.

while ((ch = read()) != '\n' && ch != -1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions