commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <>
Subject [jira] [Commented] (COMPRESS-411) TarUtils.formatLongOctalOrBinaryBytes never uses result of formatLongBinary
Date Sat, 17 Jun 2017 19:45:02 GMT


Stefan Bodewig commented on COMPRESS-411:

We deliberately store negative numbers in binary fields, yes.

You are certainly correct the code looks weird, {{formatBigIntegerBinary}} should probably
be executed inside an {{else}} branch.

It's been a long time since I've last looked at the way binary numbers are stored, but looking
at the code we don't use the most significant bit to signal negative numbers but the first
byte - which is 0xff for negative numbers and only the remaining 7 bytes are used. But we
can use all 56 bits of these 7 bytes (assuming length is 8). 

As we are calculating the twos-complement in {{formatLongBinary}} I think we should be safe,
if we did it correctly :-) Fix will be available soon.


        long val = Math.abs(value);

is going to result in a negative value for {{Long.MIN_VALUE}}.

> TarUtils.formatLongOctalOrBinaryBytes never uses result of formatLongBinary
> ---------------------------------------------------------------------------
>                 Key: COMPRESS-411
>                 URL:
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Archivers
>    Affects Versions: 1.14
>            Reporter: Simon Spero
>            Priority: Minor
> if the length < 9, formatLongBinary is executed, then overwritten by the results of
> If the results are not ignored, a unit test would fail.
> Also, do the binary hacks  need to support negative numbers? 

This message was sent by Atlassian JIRA

View raw message