MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / OLE_read_block

Function OLE_read_block

src/file_doc.c:101–121  ·  view source on GitHub ↗

@ @ requires \valid(IN); @ requires (9 == uSectorShift) || (12 == uSectorShift); @ requires \valid( buf + (0 .. (1< \initialized(buf + (0 .. (1<<uSectorShift)-1)); @ assigns *IN, errno; @ assigns *((char *)buf + (0

Source from the content-addressed store, hash-verified

99 @ assigns Frama_C_entropy_source;
100 @*/
101static int OLE_read_block(FILE *IN, char *buf, const unsigned int uSectorShift, const unsigned int block, const uint64_t offset)
102{
103 const size_t size=1<<uSectorShift;
104 /*@ assert size == 1<<uSectorShift; */
105 if(block==0xFFFFFFFF || block==0xFFFFFFFE)
106 return -1;
107 if(my_fseek(IN, offset + ((uint64_t)(1+block)<<uSectorShift), SEEK_SET) < 0)
108 {
109 return -1;
110 }
111 if(fread(buf, size, 1, IN)!=1)
112 {
113 return -1;
114 }
115#if defined(__FRAMAC__)
116 Frama_C_make_unknown(buf, size);
117#endif
118 /*@ assert \initialized(buf + (0 .. size-1)); */
119 /*@ assert \initialized(buf + (0 .. (1<<uSectorShift)-1)); */
120 return 0;
121}
122
123/*@
124 @ requires \valid(IN);

Callers 5

OLE_load_FATFunction · 0.85
file_check_doc_auxFunction · 0.85
OLE_read_streamFunction · 0.85
OLE_load_MiniFATFunction · 0.85
file_rename_docFunction · 0.85

Calls 1

my_fseekFunction · 0.85

Tested by

no test coverage detected