summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/selinux/android-tools/android-tools/core/0005-fastboot-don-t-use-sparse_file_import_auto-in-load_b.patch
blob: d465ad6bfc97f5bf8509b8b344ca52237b13848d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From a4839f29e1286b0c53208a45b9c237d81021f829 Mon Sep 17 00:00:00 2001
From: Etienne Cordonnier <ecordonnier@snap.com>
Date: Fri, 3 Mar 2023 13:15:47 +0100
Subject: [PATCH 05/15] fastboot: don't use sparse_file_import_auto() in
 load_buf_fd()

upstream commit taken as below Original Issue link https://android-review.googlesource.com/c/platform/system/core/+/1123485

Commit taken below:

fastboot: don't use sparse_file_import_auto() in load_buf_fd()

load_buf_fd() attempts to find the size of the file that it is about
to load by first calling sparse_file_import_auto() then using
sparse_file_len() upon success or falling back to the file size on the
filesystem on failure.

This is problematic however as sparse_file_import_auto() creates a
sparse_file out of the normal file, but does not resparse it, so an
assertion fails during the sparse_file_len() call.

This is fixed by using sparse_file_import() instead.  This will fail
in the case that the file is not sparse and the call to
sparse_file_len() will be properly skipped.

Bug: 140538105
Test: flash blueline factory image with assertions enabled in
      libsparse/sparse.cpp

Change-Id: I0283be33563a3301ce5b09bde41105a20f91086c

https://android.googlesource.com/platform/system/core/+/fbb9535aaea5ae4011f3c3edf4c00b27452f57ec
Upstream-Status: Backport [commit fbb9535aaea5ae4011f3c3edf4c00b27452f57ec]
Signed-off-by: Nisha Parrakat <Nisha.Parrakat@kpit.com>
---
 fastboot/fastboot.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 3b7b5571..0ae9402e 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -869,7 +869,7 @@ static bool load_buf_fd(int fd, struct fastboot_buffer* buf) {
         return false;
     }
 
-    if (sparse_file* s = sparse_file_import_auto(fd, false, false)) {
+    if (sparse_file* s = sparse_file_import(fd, false, false)) {
         buf->image_size = sparse_file_len(s, false, false);
         sparse_file_destroy(s);
     } else {
-- 
2.36.1.vfs.0.0