From 33fb4653f01ed8099a5f7ccf6b1c69dbc41d62fb Mon Sep 17 00:00:00 2001 From: Chris Renshaw Date: Thu, 16 Mar 2023 13:02:09 -0300 Subject: [PATCH] Sanitize any bad chars from mount_apex apex_manifest.pb string parsing For example, Lineage's com.android.ondevicepersonalization apex_manifest.pb has a # char, which strings keeps in its output, and breaks the mount for that apex before this fix --- scripts/util_functions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index 642411f4d..0e2ead32e 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -336,7 +336,7 @@ mount_apex() { [ -f /apex/original_apex ] && APEX=/apex/original_apex # unzip doesn't do return codes # APEX APKs, extract and loop mount unzip -qo $APEX apex_payload.img -d /apex - DEST=$(unzip -qp $APEX apex_manifest.pb | strings | head -n 1) + DEST=$(unzip -qp $APEX apex_manifest.pb | strings | head -n 1 | tr -dc [:alnum:].-_'\n') [ -z $DEST ] && DEST=$(unzip -qp $APEX apex_manifest.json | sed -n $PATTERN) [ -z $DEST ] && continue DEST=/apex/$DEST @@ -352,7 +352,7 @@ mount_apex() { if [ -f $APEX/apex_manifest.json ]; then DEST=/apex/$(sed -n $PATTERN $APEX/apex_manifest.json) elif [ -f $APEX/apex_manifest.pb ]; then - DEST=/apex/$(strings $APEX/apex_manifest.pb | head -n 1) + DEST=/apex/$(strings $APEX/apex_manifest.pb | head -n 1 | tr -dc [:alnum:].-_'\n') else continue fi