Skip to content

Commit 3157f91

Browse files
committed
Fix reading/seeking stream blobs over 4GB in size
1 parent 1672adf commit 3157f91

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/jrd/blb.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -977,18 +977,20 @@ SLONG blb::BLB_lseek(USHORT mode, SLONG offset)
977977
if (!(blb_flags & BLB_stream))
978978
ERR_post(Arg::Gds(isc_bad_segstr_type));
979979

980+
SINT64 position = offset;
981+
980982
if (mode == 1)
981-
offset += blb_seek;
983+
position += blb_seek;
982984
else if (mode == 2)
983-
offset = blb_length + offset;
985+
position += blb_length;
984986

985-
if (offset < 0)
986-
offset = 0;
987+
if (position < 0)
988+
position = 0;
987989

988-
if (offset > (SLONG) blb_length)
989-
offset = blb_length;
990+
if (position > blb_length)
991+
position = blb_length;
990992

991-
blb_seek = offset;
993+
blb_seek = (FB_UINT64) position;
992994
blb_flags |= BLB_seek;
993995
blb_flags &= ~BLB_eof;
994996

src/jrd/blb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class blb : public pool_alloc<type_blb>
154154
ULONG blb_temp_id; // ID of newly created blob in transaction
155155
ULONG blb_sequence; // Blob page sequence
156156
ULONG blb_lead_page; // First page number
157-
ULONG blb_seek; // Seek location
157+
FB_UINT64 blb_seek; // Seek location
158158
ULONG blb_max_sequence; // Number of data pages
159159
ULONG blb_count; // Number of segments
160160

0 commit comments

Comments
 (0)