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

Function OLE_parse_uni_software_entry

src/file_doc.c:1022–1070  ·  view source on GitHub ↗

@ @ requires 8 <= size <= 1024*1024; @ requires offset <= size; @ requires \valid_read(buffer+ (0 .. size-1)); @ requires \initialized(buffer+ (0 .. size-1)); @ requires \valid(ext); @ requires *ext == \null || valid_read_string(*ext); @ ensures *ext == \null || valid_read_string(*ext); @ assigns *ext; @*/

Source from the content-addressed store, hash-verified

1020 @ assigns *ext;
1021 @*/
1022static void OLE_parse_uni_software_entry(const char *buffer, const unsigned int size, const unsigned int offset, const char **ext)
1023{
1024 if(offset >= size - 8)
1025 {
1026 /*@ assert *ext == \null || valid_read_string(*ext); */
1027 return ;
1028 }
1029 /*@ assert offset < size - 8; */
1030 {
1031 const unsigned int offset_soft=offset + 8;
1032 /*@ assert offset_soft < size; */
1033 const unsigned int count=get32u(buffer, offset + 4);
1034 unsigned int count2;
1035 if(count == 0 || count > size/2)
1036 {
1037 /*@ assert *ext == \null || valid_read_string(*ext); */
1038 return ;
1039 }
1040 /*@ assert 0 < count <= size/2; */
1041 count2=2*count;
1042 /*@ assert 0 < count2 <= size; */
1043 if(count2 > size - offset_soft)
1044 {
1045 /*@ assert *ext == \null || valid_read_string(*ext); */
1046 return ;
1047 }
1048 /*@ assert count2 <= size - offset_soft; */
1049 /*@ assert offset_soft + count2 <= size; */
1050 /*@ assert \valid_read(buffer + (0 .. size - 1)) && \initialized(buffer + (0 .. size - 1)); */
1051 /*@ assert \valid_read(buffer + (0 .. offset_soft + count2 - 1)); */
1052#ifdef DEBUG_OLE
1053 {
1054 unsigned int j;
1055 log_info("Software ");
1056 for(j=0; j < count2; j+=2)
1057 {
1058 /*@ assert 0 <= j < count2; */
1059 /*@ assert offset_soft + count2 <= size; */
1060 const unsigned int tmp=offset_soft + j;
1061 /*@ assert tmp < size; */
1062 log_info("%c", buffer[tmp]);
1063 }
1064 log_info("\n");
1065 }
1066#endif
1067 *ext=software_uni2ext(&buffer[offset_soft], count);
1068 }
1069 /*@ assert *ext == \null || valid_read_string(*ext); */
1070}
1071
1072/*@
1073 @ requires 8 <= size <= 1024*1024;

Callers 1

Calls 2

get32uFunction · 0.85
software_uni2extFunction · 0.85

Tested by

no test coverage detected