Skip to content

Commit b52275c

Browse files
committed
Prevent NPE when backing up or restoring su binary
1 parent 9954c9d commit b52275c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/com/noshufou/android/su/util/Util.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,15 +647,15 @@ public static boolean backupSu(Context context, boolean removeOriginal) {
647647

648648
os.writeBytes(suTools + " mount -o remount,rw /system\n");
649649
String inLine = is.readLine();
650-
if (!inLine.equals("0")) return false;
650+
if (inLine == null || !inLine.equals("0")) return false;
651651

652652
os.writeBytes(suTools + " cp " + installedSu + " /system/bacon\n");
653653
inLine = is.readLine();
654-
if (!inLine.equals("0")) return false;
654+
if (inLine == null || !inLine.equals("0")) return false;
655655

656656
os.writeBytes(suTools + " chmod 06755 /system/bacon\n");
657657
inLine = is.readLine();
658-
if (!inLine.equals("0")) return false;
658+
if (inLine == null || !inLine.equals("0")) return false;
659659

660660
if (removeOriginal) {
661661
os.writeBytes(suTools + " rm " + installedSu + "\n");
@@ -687,15 +687,15 @@ public static boolean restoreSu(Context context, boolean removeBackup, String ke
687687

688688
os.writeBytes(suTools + " mount -o remount,rw /system\n");
689689
String inLine = is.readLine();
690-
if (!inLine.equals("0")) return false;
690+
if (inLine == null || !inLine.equals("0")) return false;
691691

692692
os.writeBytes(suTools + " cp /system/bacon /system/xbin/su\n");
693693
inLine = is.readLine();
694-
if (!inLine.equals("0")) return false;
694+
if (inLine == null || !inLine.equals("0")) return false;
695695

696696
os.writeBytes(suTools + " chmod 06755 /system/xbin/su\n");
697697
inLine = is.readLine();
698-
if (!inLine.equals("0")) return false;
698+
if (inLine == null || !inLine.equals("0")) return false;
699699

700700
if (removeBackup) {
701701
os.writeBytes(suTools + " rm /system/bacon\n");

0 commit comments

Comments
 (0)