anchor.diff:  do_get_format(#header_v7{}=V7, Bin)
     when is_binary(Bin), byte_size(Bin) =:= ?BLOCK_SIZE ->
       Checksum = parse_octal(V7#header_v7.checksum),
  -    Chk1 = compute_checksum(Bin),
  -    Chk2 = compute_signed_checksum(Bin),
  -    if Checksum =/= Chk1 andalso Checksum =/= Chk2 ->
  +    IsBadChecksum = case compute_checksum(Bin) of
  +                        Checksum -> false;
  +                        _ -> compute_signed_checksum(Bin) =/= Checksum
  +                    end,
  +    case IsBadChecksum of
  +        true ->
               ?FORMAT_UNKNOWN;
  -       true ->
  +        false ->
               %% guess magic
               Ustar = to_ustar(V7, Bin),
               Star = to_star(V7, Bin),
  
positive.code:             parse_octal(Bin)
      end.
  
  parse_octal(Bin) when is_binary(Bin) ->
      %% skip leading/trailing zero bytes and spaces
      do_parse_octal(Bin, <<>>).
  do_parse_octal(<<>>, <<>>) ->
      0;
  do_parse_octal(<<>>, Acc) ->
      case io_lib:fread("~8u", binary:bin_to_list(Acc)) of
          {error, _} -> throw({error, invalid_tar_checksum});
          {ok, [Octal], []} -> Octal;
          {ok, _, _} -> throw({error, invalid_tar_checksum})
      end;
  do_parse_octal(<<$\s,Rest/binary>>, Acc) ->
      do_parse_octal(Rest, Acc);
  do_parse_octal(<<0, Rest/binary>>, Acc) ->
      do_parse_octal(Rest, Acc);
  do_parse_octal(<<C, Rest/binary>>, Acc) ->
      do_parse_octal(Rest, <<Acc/binary, C>>).
  
  parse_string(Bin) when is_binary(Bin) ->
      do_parse_string(Bin, <<>>).
  do_parse_string(<<>>, Acc) ->
      case unicode:characters_to_list(Acc) of
          Str when is_list(Str) ->
              Str;
          {incomplete, _Str, _Rest} ->
              binary:bin_to_list(Acc);
          {error, _Str, _Rest} ->
              throw({error, {bad_header, invalid_string}})
      end;
  do_parse_string(<<0, _/binary>>, Acc) ->
      do_parse_string(<<>>, Acc);
  do_parse_string(<<C, Rest/binary>>, Acc) ->
      do_parse_string(Rest, <<Acc/binary, C>>).
  
  convert_header(Bin, #reader{pos=Pos}=Reader)
    when byte_size(Bin) =:= ?BLOCK_SIZE, (Pos rem ?BLOCK_SIZE) =:= 0 ->
  
negative.code: 
  %% Returns the checksum of a binary.
  checksum(Bin) -> checksum(Bin, 0).
  
  checksum(<<A/unsigned,B/unsigned,C/unsigned,D/unsigned,Rest/binary>>, Sum) ->
      checksum(Rest, Sum+A+B+C+D);
  checksum(<<A/unsigned,Rest/binary>>, Sum) ->
      checksum(Rest, Sum+A);
  checksum(<<>>, Sum) -> Sum.
  