- Timestamp:
- Nov 14, 2010 11:15:04 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67742
- Location:
- trunk/src/VBox/Runtime/common/zip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/zip/tar.h
r34049 r34060 105 105 106 106 /** 107 * The GNU header. 108 */ 109 typedef struct RTZIPTARHDRGNU 110 { 111 char name[100]; 112 char mode[8]; 113 char uid[8]; 114 char gid[8]; 115 char size[12]; 116 char mtime[12]; 117 char chksum[8]; 118 char typeflag; 119 char linkname[100]; 120 char magic[8]; 121 char uname[32]; 122 char gname[32]; 123 char devmajor[8]; 124 char devminor[8]; 125 char atime[12]; 126 char ctime[12]; 127 char offset[12]; 128 char longnames[4]; 129 char unused[1]; 130 struct 131 { 132 char offset[12]; 133 char numbytes[12]; 134 } sparse[4]; 135 char isextended; 136 char realsize[12]; 137 char unused2[17]; 138 } RTZIPTARHDRGNU; 139 AssertCompileSize(RTZIPTARHDRGNU, 512); 140 AssertCompileMemberOffset(RTZIPTARHDRGNU, name, 0); 141 AssertCompileMemberOffset(RTZIPTARHDRGNU, mode, 100); 142 AssertCompileMemberOffset(RTZIPTARHDRGNU, uid, 108); 143 AssertCompileMemberOffset(RTZIPTARHDRGNU, gid, 116); 144 AssertCompileMemberOffset(RTZIPTARHDRGNU, size, 124); 145 AssertCompileMemberOffset(RTZIPTARHDRGNU, mtime, 136); 146 AssertCompileMemberOffset(RTZIPTARHDRGNU, chksum, 148); 147 AssertCompileMemberOffset(RTZIPTARHDRGNU, typeflag, 156); 148 AssertCompileMemberOffset(RTZIPTARHDRGNU, linkname, 157); 149 AssertCompileMemberOffset(RTZIPTARHDRGNU, magic, 257); 150 AssertCompileMemberOffset(RTZIPTARHDRGNU, uname, 265); 151 AssertCompileMemberOffset(RTZIPTARHDRGNU, gname, 297); 152 AssertCompileMemberOffset(RTZIPTARHDRGNU, devmajor, 329); 153 AssertCompileMemberOffset(RTZIPTARHDRGNU, devminor, 337); 154 AssertCompileMemberOffset(RTZIPTARHDRGNU, atime, 345); 155 AssertCompileMemberOffset(RTZIPTARHDRGNU, ctime, 357); 156 AssertCompileMemberOffset(RTZIPTARHDRGNU, offset, 369); 157 AssertCompileMemberOffset(RTZIPTARHDRGNU, longnames, 381); 158 AssertCompileMemberOffset(RTZIPTARHDRGNU, unused, 385); 159 AssertCompileMemberOffset(RTZIPTARHDRGNU, sparse, 386); 160 AssertCompileMemberOffset(RTZIPTARHDRGNU, isextended,482); 161 AssertCompileMemberOffset(RTZIPTARHDRGNU, realsize, 483); 162 AssertCompileMemberOffset(RTZIPTARHDRGNU, unused2, 495); 163 164 165 /** 107 166 * Tar header union. 108 167 */ … … 110 169 { 111 170 /** Byte view. */ 112 char ab[512];171 char ab[512]; 113 172 /** The standard header. */ 114 RTZIPTARHDRPOSIX Posix; 173 RTZIPTARHDRPOSIX Posix; 174 /** The GNU header. */ 175 RTZIPTARHDRGNU Gnu; 115 176 } RTZIPTARHDR; 116 177 AssertCompileSize(RTZIPTARHDR, 512); … … 120 181 typedef RTZIPTARHDR const *PCRTZIPTARHDR; 121 182 183 184 /** 185 * Tar header type. 186 */ 187 typedef enum RTZIPTARTYPE 188 { 189 /** Invalid type value. */ 190 RTZIPTARTYPE_INVALID = 0, 191 /** Posix header. */ 192 RTZIPTARTYPE_POSIX, 193 /** The old GNU header, has layout conflicting with posix. */ 194 RTZIPTARTYPE_GNU, 195 /** Ancient tar header which does not use anything beyond the magic. */ 196 RTZIPTARTYPE_ANCIENT, 197 /** End of the valid type values (this is not valid). */ 198 RTZIPTARTYPE_END, 199 /** The usual type blow up. */ 200 RTZIPTARTYPE_32BIT_HACK = 0x7fffffff 201 } RTZIPTARTYPE; 202 typedef RTZIPTARTYPE *PRTZIPTARTYPE; 203 204 122 205 #endif 123 206 -
trunk/src/VBox/Runtime/common/zip/tarvfs.cpp
r34055 r34060 306 306 * @returns VINF_SUCCESS if valid, appropriate VERR_TAR_XXX if not. 307 307 * @param pTar The TAR header. 308 */ 309 static int rtZipTarHdrValidate(PCRTZIPTARHDR pTar) 308 * @param penmType Where to return the type of header on success. 309 */ 310 static int rtZipTarHdrValidate(PCRTZIPTARHDR pTar, PRTZIPTARTYPE penmType) 310 311 { 311 312 /* … … 325 326 return VERR_TAR_BAD_CHKSUM_FIELD; 326 327 if ( i32ChkSum != i64HdrChkSum 327 && i32ChkSumSignedAlt != i64HdrChkSum) /** @todo checkthis */328 && i32ChkSumSignedAlt != i64HdrChkSum) /** @todo test this */ 328 329 return VERR_TAR_CHKSUM_MISMATCH; 329 330 330 331 /* 332 * Detect the tar type. 333 */ 334 RTZIPTARTYPE enmType; 335 if ( pTar->Posix.magic[0] == 'u' 336 && pTar->Posix.magic[1] == 's' 337 && pTar->Posix.magic[2] == 't' 338 && pTar->Posix.magic[3] == 'a' 339 && pTar->Posix.magic[4] == 'r') 340 { 341 if ( pTar->Posix.magic[5] == '\0' 342 && pTar->Posix.version[0] == '0' 343 && pTar->Posix.version[1] == '0') 344 enmType = RTZIPTARTYPE_POSIX; 345 else if ( pTar->Posix.magic[5] == ' ' 346 && pTar->Posix.version[0] == ' ' 347 && pTar->Posix.version[1] == '\0') 348 enmType = RTZIPTARTYPE_GNU; 349 else 350 return VERR_TAR_NOT_USTAR_V00; 351 } 352 else 353 enmType = RTZIPTARTYPE_ANCIENT; 354 *penmType = enmType; 355 356 /* 331 357 * Perform some basic checks. 332 358 */ 333 if (!rtZipTarHdrIsUstar(pTar)) 334 { 335 RTAssertMsg2("%.6s%c%c\n", pTar->Posix.magic, pTar->Posix.version[0], pTar->Posix.version[1]); 336 RTAssertMsg2("%.8Rhxs\n", pTar->Posix.magic); 337 return VERR_TAR_NOT_USTAR_V00; 338 } 339 359 /** @todo more/less? */ 340 360 switch (pTar->Posix.typeflag) 341 361 { … … 352 372 return VERR_TAR_EMPTY_NAME; 353 373 374 /** @todo People claim some (older and newer buggy) tar stores dirs as regular files with a trailing slash. */ 354 375 const char *pchEnd = RTStrEnd(&pTar->Posix.name[0], sizeof(pTar->Posix.name)); 355 376 pchEnd = pchEnd ? pchEnd - 1 : &pTar->Posix.name[sizeof(pTar->Posix.name) - 1]; … … 379 400 return VERR_TAR_UNSUPPORTED_GNU_HDR_TYPE; 380 401 } 402 381 403 382 404 return VINF_SUCCESS; … … 982 1004 * We pick up the start of the zero headers here in the failure path. 983 1005 */ 984 rc = rtZipTarHdrValidate(&Hdr); 1006 RTZIPTARTYPE enmTarType; 1007 rc = rtZipTarHdrValidate(&Hdr, &enmTarType); 985 1008 if (RT_FAILURE_NP(rc)) 986 1009 {
Note:
See TracChangeset
for help on using the changeset viewer.