explain why extractall is safe to use

This commit is contained in:
ed 2022-10-11 17:44:38 +02:00
parent 08977854b3
commit fdb969ea89

View file

@ -269,6 +269,12 @@ def unpack():
raise Exception(t.format(CKSUM, SIZE, ck, sz)) raise Exception(t.format(CKSUM, SIZE, ck, sz))
with tarfile.open(tar, "r:bz2") as tf: with tarfile.open(tar, "r:bz2") as tf:
# this is safe against traversal
# skip 1
# since it will never process user-provided data;
# the only possible input is a single tar.bz2
# which gets hardcoded into this script at build stage
# skip 0
tf.extractall(mine) tf.extractall(mine)
os.remove(tar) os.remove(tar)