OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.webapk.lib.client; | 5 package org.chromium.webapk.lib.client; |
6 | 6 |
7 import static java.nio.ByteOrder.LITTLE_ENDIAN; | 7 import static java.nio.ByteOrder.LITTLE_ENDIAN; |
8 | 8 |
9 import android.support.annotation.IntDef; | 9 import android.support.annotation.IntDef; |
10 import android.util.Log; | 10 import android.util.Log; |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 } | 372 } |
373 if (!hasBlockAtStart) { | 373 if (!hasBlockAtStart) { |
374 return ERROR_BAD_BLANK_SPACE; | 374 return ERROR_BAD_BLANK_SPACE; |
375 } | 375 } |
376 if (positionOfLastByteOfLastBlock != mCentralDirOffset) { | 376 if (positionOfLastByteOfLastBlock != mCentralDirOffset) { |
377 seek(mCentralDirOffset - V2_SIGNING_MAGIC.length()); | 377 seek(mCentralDirOffset - V2_SIGNING_MAGIC.length()); |
378 String magic = readString(V2_SIGNING_MAGIC.length()); | 378 String magic = readString(V2_SIGNING_MAGIC.length()); |
379 if (V2_SIGNING_MAGIC.equals(magic)) { | 379 if (V2_SIGNING_MAGIC.equals(magic)) { |
380 // Only if we have a v2 signature do we allow medium sized gap b etween the last | 380 // Only if we have a v2 signature do we allow medium sized gap b etween the last |
381 // block and the start of the central directory. | 381 // block and the start of the central directory. |
382 if (positionOfLastByteOfLastBlock + MAX_V2_SIGNING_BLOCK_SIZE > mCentralDirOffset) { | 382 if (mCentralDirOffset - positionOfLastByteOfLastBlock > MAX_V2_S IGNING_BLOCK_SIZE) { |
383 return ERROR_BAD_V2_BLOCK; | 383 return ERROR_BAD_V2_BLOCK; |
Xi Han
2017/05/24 18:28:52
Can you make this error more meaningful?
ScottK
2017/05/25 00:26:25
Done.
| |
384 } | 384 } |
385 } else { | 385 } else { |
386 return ERROR_BAD_BLANK_SPACE; | 386 return ERROR_BAD_BLANK_SPACE; |
387 } | 387 } |
388 } | 388 } |
389 return ERROR_OK; | 389 return ERROR_OK; |
390 } | 390 } |
391 | 391 |
392 /** | 392 /** |
393 * We search buffer for EOCD_SIG and return the location where we found it. If the file has no | 393 * We search buffer for EOCD_SIG and return the location where we found it. If the file has no |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 return null; | 461 return null; |
462 } | 462 } |
463 byte[] data = new byte[len / 2]; | 463 byte[] data = new byte[len / 2]; |
464 for (int i = 0; i < len; i += 2) { | 464 for (int i = 0; i < len; i += 2) { |
465 data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) | 465 data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) |
466 + Character.digit(s.charAt(i + 1), 16)); | 466 + Character.digit(s.charAt(i + 1), 16)); |
467 } | 467 } |
468 return data; | 468 return data; |
469 } | 469 } |
470 } | 470 } |
OLD | NEW |