| 83 | } |
| 84 | |
| 85 | static int ListFile_GetFileDataId(PLISTFILE_CACHE pCache, PDWORD PtrFileDataId) |
| 86 | { |
| 87 | char * szLineBegin = ListFile_SkipSpaces(pCache); |
| 88 | char * szLineEnd; |
| 89 | DWORD dwNewInt32 = 0; |
| 90 | DWORD dwInt32 = 0; |
| 91 | |
| 92 | // Set the limit for loading the number |
| 93 | szLineEnd = CASCLIB_MIN((szLineBegin + 20), pCache->pEnd); |
| 94 | |
| 95 | // Extract decimal digits from the string |
| 96 | while(szLineBegin < szLineEnd && '0' <= szLineBegin[0] && szLineBegin[0] <= '9') |
| 97 | { |
| 98 | // Check integer overflow |
| 99 | dwNewInt32 = (dwInt32 * 10) + (szLineBegin[0] - '0'); |
| 100 | if(dwNewInt32 < dwInt32) |
| 101 | return ERROR_BAD_FORMAT; |
| 102 | |
| 103 | dwInt32 = dwNewInt32; |
| 104 | szLineBegin++; |
| 105 | } |
| 106 | |
| 107 | // There must still be some space |
| 108 | if(szLineBegin < szLineEnd) |
| 109 | { |
| 110 | // There must be a semicolon after the decimal integer |
| 111 | // The decimal integer must be smaller than 10 MB (files) |
| 112 | if(szLineBegin[0] != ';' || dwInt32 >= 0xA00000) |
| 113 | return ERROR_BAD_FORMAT; |
| 114 | |
| 115 | pCache->pPos = szLineBegin + 1; |
| 116 | PtrFileDataId[0] = dwInt32; |
| 117 | return ERROR_SUCCESS; |
| 118 | } |
| 119 | |
| 120 | return ERROR_NO_MORE_FILES; |
| 121 | } |
| 122 | |
| 123 | //----------------------------------------------------------------------------- |
| 124 | // Functions for parsing an external listfile |
no test coverage detected