Merge "Corrupt the PersistentDataBlock payload explicitly in factory reset" am: af5c516b49 am: 26bad177d3 am: fd89f0cf17
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1710289 Change-Id: I3b4e70f5dce90cb213a8c95a47f42e30d7d4eefc
This commit is contained in:
@@ -39,11 +39,9 @@ import com.android.internal.annotations.GuardedBy;
|
|||||||
import libcore.io.IoUtils;
|
import libcore.io.IoUtils;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@@ -377,11 +375,16 @@ public class PersistentDataBlockService extends SystemService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
FileChannel channel = getBlockOutputChannel();
|
FileChannel channel = getBlockOutputChannel();
|
||||||
ByteBuffer buf = ByteBuffer.allocate(DIGEST_SIZE_BYTES + HEADER_SIZE);
|
int header_size = DIGEST_SIZE_BYTES + HEADER_SIZE;
|
||||||
|
ByteBuffer buf = ByteBuffer.allocate(header_size);
|
||||||
buf.put(new byte[DIGEST_SIZE_BYTES]);
|
buf.put(new byte[DIGEST_SIZE_BYTES]);
|
||||||
buf.putInt(PARTITION_TYPE_MARKER);
|
buf.putInt(PARTITION_TYPE_MARKER);
|
||||||
buf.putInt(0);
|
buf.putInt(0);
|
||||||
channel.write(buf);
|
channel.write(buf);
|
||||||
|
// corrupt the payload explicitly
|
||||||
|
int payload_size = (int) getBlockDeviceSize() - header_size;
|
||||||
|
buf = ByteBuffer.allocate(payload_size);
|
||||||
|
channel.write(buf);
|
||||||
channel.force(true);
|
channel.force(true);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slog.e(TAG, "failed to format block", e);
|
Slog.e(TAG, "failed to format block", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user