[projects/pld-builder.new] rpm_builder: reject a truncated src.rpm download

arekm arekm at pld-linux.org
Mon Oct 26 17:16:26 CET 2026


commit 0ff9ed8dfb3164eff72a6adf3b3e7cc36401aaad
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Oct 24 11:42:38 2026 +0200

    rpm_builder: reject a truncated src.rpm download
    
    A dropped connection ends read() early without an error.

 PLD_Builder/rpm_builder.py | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/PLD_Builder/rpm_builder.py b/PLD_Builder/rpm_builder.py
index 28fbad4..628d984 100644
--- a/PLD_Builder/rpm_builder.py
+++ b/PLD_Builder/rpm_builder.py
@@ -140,6 +140,12 @@ def fetch_src(r, b):
         msg = f"error: writing `{b.src_rpm}' into the chroot failed with exit code {rc}"
         b.log_line(msg)
         raise OSError(msg)
+    # a dropped connection ends read() early without an error
+    length = f.headers.get('Content-Length')
+    if length is not None and int(length) != size:
+        msg = f"error: fetched {size} of {length} bytes of {src_url}"
+        b.log_line(msg)
+        raise OSError(msg)
 
     t = time.time() - start
     if t == 0:
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/ce9feb3c796ed049b6dd260a50d94d80feb1656d



More information about the pld-cvs-commit mailing list