File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,7 +145,11 @@ private bool LoadGroupIndexFile(string hash) {
145145
146146 var maxFooterSize = FixedFooter . SIZE + FixedFooter . MAX_CHECKSUM_SIZE ; // (we only care about the end checksum, not start)
147147 var maxFooterBuffer = new byte [ maxFooterSize ] ;
148- RandomAccess . Read ( ArchiveGroupFileHandle , maxFooterBuffer , length - maxFooterSize ) ;
148+ var readHeaderSize = RandomAccess . Read ( ArchiveGroupFileHandle , maxFooterBuffer , length - maxFooterSize ) ;
149+ if ( readHeaderSize != maxFooterSize )
150+ {
151+ throw new IOException ( $ "short footer read: { readHeaderSize } bytes (expected { maxFooterSize } )") ;
152+ }
149153
150154 using ( var maxFooterReader = new BinaryReader ( new MemoryStream ( maxFooterBuffer ) ) ) {
151155 ArchiveGroupFooter = ReadFooter ( maxFooterReader ) ;
@@ -158,7 +162,13 @@ private bool LoadGroupIndexFile(string hash) {
158162
159163 var lastEKeyArrayOffset = pageCount * pageSize ;
160164 ArchiveGroupPageLastEKeys = new FullEKey [ pageCount ] ;
161- RandomAccess . Read ( ArchiveGroupFileHandle , ArchiveGroupPageLastEKeys . AsSpan ( ) . AsBytes ( ) , lastEKeyArrayOffset ) ;
165+
166+ var ekeysBuffer = ArchiveGroupPageLastEKeys . AsSpan ( ) . AsBytes ( ) ;
167+ var readEKeysSize = RandomAccess . Read ( ArchiveGroupFileHandle , ekeysBuffer , lastEKeyArrayOffset ) ;
168+ if ( readEKeysSize != ekeysBuffer . Length )
169+ {
170+ throw new IOException ( $ "short ekeys read: { readEKeysSize } bytes (expected { ekeysBuffer . Length } )") ;
171+ }
162172
163173 return true ;
164174 }
You can’t perform that action at this time.
0 commit comments