Changeset 34928 in vbox for trunk/src/VBox
- Timestamp:
- Dec 9, 2010 10:54:17 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/zip/tarvfs.cpp
r34507 r34928 180 180 static int rtZipTarHdrFieldToNum(const char *pszField, size_t cchField, bool fOctalOnly, int64_t *pi64) 181 181 { 182 size_t const cchFieldOrg = cchField; 182 unsigned char const *puchField = (unsigned char const *)pszField; 183 size_t const cchFieldOrg = cchField; 183 184 if ( fOctalOnly 184 || !(* (unsigned char *)pszField & 0x80))185 || !(*puchField & 0x80)) 185 186 { 186 187 /* 187 188 * Skip leading spaces. Include zeros to save a few slower loops below. 188 189 */ 189 char ch;190 while (cchField > 0 && ((ch = *p szField) == ' '|| ch == '0'))191 cchField--, p szField++;190 unsigned char ch; 191 while (cchField > 0 && ((ch = *puchField) == ' '|| ch == '0')) 192 cchField--, puchField++; 192 193 193 194 /* … … 197 198 while (cchField > 0) 198 199 { 199 unsigned char uDigit = *p szField - '0';200 unsigned char uDigit = *puchField - '0'; 200 201 if (uDigit >= 8) 201 202 break; … … 203 204 i64 |= uDigit; 204 205 205 p szField++;206 puchField++; 206 207 cchField--; 207 208 } … … 213 214 while (cchField > 0) 214 215 { 215 ch = *p szField++;216 ch = *puchField++; 216 217 if (ch != 0 && ch != ' ') 217 218 return cchField < cchFieldOrg … … 223 224 else 224 225 { 225 /** @todo implement base-256 encoded fields. */ 226 return VERR_TAR_BASE_256_NOT_SUPPORTED; 226 /* 227 * The first byte has the bit 7 set to indicate base-256, while bit 6 228 * is the signed bit. Bits 5:0 are the most significant value bits. 229 */ 230 int64_t i64 = !(0x40 & *puchField) ? 0 : -1; 231 i64 = (i64 << 6) | (*puchField & 0x3f); 232 cchField--; 233 puchField++; 234 235 /* 236 * The remaining bytes are used in full. 237 */ 238 while (cchField-- > 0) 239 { 240 if (RT_UNLIKELY(i64 > INT64_MAX / 256)) 241 return VERR_TAR_NUM_VALUE_TOO_LARGE; 242 if (RT_UNLIKELY(i64 < INT64_MIN / 256)) 243 return VERR_TAR_NUM_VALUE_TOO_LARGE; 244 i64 = (i64 << 8) | *puchField++; 245 } 246 *pi64 = i64; 227 247 } 228 248
Note:
See TracChangeset
for help on using the changeset viewer.