Skip to content

Commit 9cc1a8b

Browse files
authored
Merge pull request raymanfx#1 from invisiblek/master
check if patch is already applied first
2 parents e64b4bc + 3f319e7 commit 9cc1a8b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

cve_check.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,23 @@ def parse_linux_version(kernel_repo):
8080

8181
def basic_check(kernel_repo, cve_patch):
8282

83-
# try to apply the patch normally
84-
cmd = ["git", "-C", kernel_repo, "apply", "--3way", "--check", cve_patch]
83+
# try to apply the patch in reverse
84+
cmd = ["git", "-C", kernel_repo, "apply", "--3way", "--check", "--reverse",
85+
cve_patch]
8586
try:
8687
with open(os.devnull, 'w') as silence:
8788
subprocess.check_output(cmd, stderr=silence)
88-
return 0
89+
return 1
8990
except subprocess.CalledProcessError:
90-
# we still have one more optiion (reverse patch)
91+
# not already applied, attempt to apply it
9192
pass
9293

93-
# try to apply the patch in reverse
94-
cmd = ["git", "-C", kernel_repo, "apply", "--3way", "--check", "--reverse",
95-
cve_patch]
94+
# try to apply the patch normally
95+
cmd = ["git", "-C", kernel_repo, "apply", "--3way", "--check", cve_patch]
9696
try:
9797
with open(os.devnull, 'w') as silence:
9898
subprocess.check_output(cmd, stderr=silence)
99-
return 1
99+
return 0
100100
except subprocess.CalledProcessError:
101101
# we ran out of options, probably need the advanced check..
102102
return 2

0 commit comments

Comments
 (0)