summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2011-06-07 13:17:17 -0700
committerChristopher Tate <ctate@google.com>2011-06-07 13:17:17 -0700
commit3f6c77b7caa02193205cb6ce180e0eb5a7579aa6 (patch)
treef811ac1b87ff6368b62db25eca407badb37f0a81 /services/java
parent65abc4531f1222ffa04350a3afc6d61fcc77b2a3 (diff)
downloadframeworks_base-3f6c77b7caa02193205cb6ce180e0eb5a7579aa6.zip
frameworks_base-3f6c77b7caa02193205cb6ce180e0eb5a7579aa6.tar.gz
frameworks_base-3f6c77b7caa02193205cb6ce180e0eb5a7579aa6.tar.bz2
Fix embedded spaces in tar stream EVEN HARDER
Change-Id: I97ac586ff3541a05d73e1e53f680517c15e6c662
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/BackupManagerService.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index b568af1..c28732e 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -2859,6 +2859,7 @@ class BackupManagerService extends IBackupManager.Stub {
final int end = offset + maxChars;
for (int i = offset; i < end; i++) {
final byte b = data[i];
+ // Numeric fields in tar can terminate with either NUL or SPC
if (b == 0 || b == ' ') break;
if (b < '0' || b > ('0' + radix - 1)) {
throw new IOException("Invalid number in header");
@@ -2871,8 +2872,8 @@ class BackupManagerService extends IBackupManager.Stub {
String extractString(byte[] data, int offset, int maxChars) throws IOException {
final int end = offset + maxChars;
int eos = offset;
- // tar string fields can end with either NUL or SPC
- while (eos < end && data[eos] != 0 && data[eos] != ' ') eos++;
+ // tar string fields terminate early with a NUL
+ while (eos < end && data[eos] != 0) eos++;
return new String(data, offset, eos-offset, "US-ASCII");
}