Skip to content

b2 cannot deal with Windows archive files that exceed 2 GB #607

Description

@pkl97

The Windows archive scanner of b2 (inherited from Perforce Jam) is not able to handle Windows .lib files that exceed 2 GB in size.

We found this issue years ago in Perforce Jam and looking at the code of b2 it has the exact same issue.

This simple patch (changing 2 lines) fixes the problem:

diff --git a/src/engine/filent.cpp b/src/engine/filent.cpp
index 59a0f0d3b..4bab14b37 100644
--- a/src/engine/filent.cpp
+++ b/src/engine/filent.cpp
@@ -404,7 +404,7 @@ int file_collect_archive_content_( file_archive_info_t * const archive )
     struct ar_hdr ar_hdr;
     char * string_table = 0;
     char buf[ MAXJPATH ];
-    long offset;
+    __int64 offset;
     const char * path = object_str( archive->file->name );
     int const fd = open( path , O_RDONLY | O_BINARY, 0 );

@@ -503,7 +503,7 @@ int file_collect_archive_content_( file_archive_info_t * const archive )
         }

         offset += SARHDR + lar_size;
-        lseek( fd, offset, 0 );
+        _lseeki64( fd, offset, 0 );
     }

     close( fd );

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions