summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--urpm/media.pm16
2 files changed, 16 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index bb95dc69..40959cb0 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@
o add missing mark in "Do you want to add media '%s'?" message (from Nikos)
- urpmi.addmedia, urpmi.update:
o fix checking synthesis MD5SUM
+ o check downloaded synthesis is not invalid HTML code (#39918)
+ (useful for servers not returning a valid HTTP error)
Version 5.19 - 3 April 2008, by Pascal "Pixel" Rigaux
diff --git a/urpm/media.pm b/urpm/media.pm
index 82338da8..5d788f5a 100644
--- a/urpm/media.pm
+++ b/urpm/media.pm
@@ -1230,7 +1230,7 @@ sub get_synthesis__remote {
my $ok = try__maybe_mirrorlist($urpm, $medium, sub {
urpm::download::sync($urpm, $medium, [ _url_with_synthesis($medium) ],
quiet => $quiet, callback => $callback) &&
- file_size(cachedir_with_synthesis($urpm, $medium)) >= 20;
+ _check_synthesis(cachedir_with_synthesis($urpm, $medium));
});
if (!$ok) {
chomp(my $err = $@);
@@ -1239,6 +1239,18 @@ sub get_synthesis__remote {
$ok;
}
+sub _check_synthesis {
+ my ($synthesis_file) = @_;
+
+ file_size($synthesis_file) >= 20 or return;
+
+ # check first 2 lines do not contain typical html code
+ # this is useful for servers not returning a valid HTTP error (#39918)
+ open(my $F, '<', $synthesis_file) or return;
+ my $s = <$F>; $s .= <$F>;
+ $s !~ /<html>|<!DOCTYPE\s/i;
+}
+
#- check copied/downloaded file has right signature.
sub check_synthesis_md5sum {
my ($urpm, $medium) = @_;
@@ -1393,7 +1405,7 @@ sub _update_medium__parse_if_unmodified__remote {
my $f = "$urpm->{cachedir}/partial/" . basename($url);
$options->{force} and unlink $f;
if (urpm::download::sync($urpm, $medium, [ $url ],
- quiet => $options->{quiet}, callback => $options->{callback}) && file_size($f) >= 20) {
+ quiet => $options->{quiet}, callback => $options->{callback}) && _check_synthesis($f)) {
$urpm->{log}(N("found probed synthesis as %s", $url));
1;
} else {