• Bug#1034468: marked as done (unblock: inn2/2.7.1~20230322-1) (2/2)

    From Debian Bug Tracking System@21:1/5 to All on Wed Apr 26 07:40:01 2023
    [continued from previous message]

    + $len &= (1 << $lenlen * 7) - 1;
    + $len += $pack_length_bias[$lenlen - 1];
    + } else {
    + # Uncompressed overview data.
    + $lenlen = 0;
    + $len = length($data);
    + }
    + return ($lenlen, $len);
    +}
    +
    +# Return decompressed overview data, or undef if a failure occurs.
    +# This function can be called even on uncompressed data.
    +# The expected arguments are the newsgroup name, the article number, and the +# associated overview data.
    +sub decompress_overview {
    + my ($groupname, $artnum, $data) = @_;
    + my $result;
    +
    + if ($compress > 0) {
    + my ($lenlen, $len) = overview_length($data);
    + if (!defined($lenlen)) {
    + warn "$groupname:$artnum: Corrupt overview data\n";
    + return undef;
    + }
    + if ($len == 0) {
    + # No compression.
    + $result = substr($data, $lenlen);
    + } else {
    + my ($inflation, $status);
    +
    + ($inflation, $status)
    + = inflateInit(-Dictionary => "$basedict$groupname:$artnum\r\n"); + if ($status != Z_OK) {
    + warn
    + "$groupname:$artnum: inflateInit failed with code $status\n";
    + return undef;
    + }
    + ($result, $status) = $inflation->inflate(substr($data, $lenlen)); + if ($status != Z_STREAM_END) {
    + warn "$groupname:$artnum: inflate failed with code $status\n"; + return undef;
    + }
    + if (length($result) != $len) {
    + warn "$groupname:$artnum: Corrupt overview data\n";
    + return undef;
    + }
    + }
    + } else {
    + # Uncompressed overview data.
    + $result = $data;
    + }
    + return $result;
    +}
    +
    +# Perform consistency checks on low water marks, high water marks, and
    +# article counts in groupinfo. SQL commands were provided by Bo Lindbergh. +sub check_groupinfo_consistency {
    + my ($statement, $result);
    +
    + pragma_foreign_keys(0);
    + $dbh->do(
    + q{
    +create table temp.repairs (
    + groupid integer
    + primary key,
    + new_low integer
    + not null,
    + low_was_bad integer
    + not null,
    + new_high integer
    + not null,
    + high_was_bad integer
    + not null,
    + new_count integer
    + not null,
    + count_was_bad integer
    + not null,
    + expired integer
    + not null,
    + groupname blob
    + not null,
    + flag_alias blob
    + not null
    +);
    +
    +with new_stats (groupid, new_low, new_high, new_count) as
    + (select groupid,
    + coalesce(min(artnum), low),
    + coalesce(max(artnum), high),
    + count(artnum)
    + from groupinfo
    + natural left join artinfo
    + where not deleted
    + group by groupid)
    +insert into repairs
    + (groupid,
    + new_low, low_was_bad,
    + new_high, high_was_bad,
    + new_count, count_was_bad,
    + expired, groupname, flag_alias)
    + select groupid,
    + new_low, new_low != low as low_was_bad,
    + new_high, new_high != high as high_was_bad,
    + new_count, new_count != "count" as count_was_bad,
    + expired, groupname, flag_alias
    + from new_stats
    + natural join groupinfo
    + where low_was_bad
    + or high_was_bad
    + or count_was_bad;
    +}
    + );
    + pragma_foreign_keys(1);
    +
    + $statement = $dbh->prepare("select count(*) from repairs;");
    + ($result) = $dbh->selectrow_array($statement);
    +
    + if ($result > 0) {
    + printf STDERR (
    + "%d groupinfo record%s incoherent\n", $result,
    + ($result > 1) ? "s" : ""
    + );
    +
    + # Show incoherent records (L, H and C are for Low, High, Count).
    + $statement = $dbh->prepare(
    + q{
    +select case when low_was_bad then 'L' else '_' end
    + || case when high_was_bad then 'H' else '_' end
    + || case when count_was_bad then 'C' else '_' end as bad, groupname
    + from repairs;
    +}
    + );
    + $statement->execute();
    +
    + while (my @row = $statement->fetchrow_array()) {
    + print STDERR " $row[0] for $row[1]\n";
    + }
    +
    + if (defined($opt{'F'})) {
    + # Fix groupinfo table.
    + $result = $dbh->do(
    + q{
    +insert or replace into groupinfo
    + (groupid, low, high, "count", expired, groupname, flag_alias)
    + select groupid, new_low, new_high, new_count,
    + expired, groupname, flag_alias
    + from repairs;
    +}
    + );
    + $dbh->commit();
    +
    + printf STDERR (
    + "%d groupinfo record%s fixed\n", $result,
    + ($result > 1) ? "s" : ""
    + );
    + }
    +
    + }
    +}
    +
    +# Dump overview information (-g option).
    +sub dump_overview {
    + my $statement;
    +
    + $statement = $dbh->prepare(
    + qq{
    +select artnum, overview, arrived, expires, quote(token)
    + from artinfo $sql_extraclause_artinfo;
    +}
    + );
    + $statement->execute();
    +
    + while (my @row = $statement->fetchrow_array()) {
    + # quote(token) returns a string in the form "X'token'" without
    + # surrounding '@' characters.
    + my $len = (overview_length($row[1]))[1];
    + if (!defined($len)) {
    + warn "$opt{'n'}:$row[0]: Corrupt overview data\n";
    + $len = 0;
    + }
    + print "$row[0] $len $row[2] $row[3]";
    + print " @" . substr($row[4], 2, -1) . "@\n";
    + }
    +}
    +
    +# Dump newsgroup-related overview information (-i option).
    +sub dump_groupinfo {
    + my $statement;
    +
    + $statement = $dbh->prepare(
    + qq{
    +select groupname, high, low, count, flag_alias, expired, deleted
    + from groupinfo $sql_extraclause_groupinfo;
    +}
    + );
    + $statement->execute();
    +
    + while (my @row = $statement->fetchrow_array()) {
    + print join(" ", @row) . "\n";
    + }
    +}
    +
    +# Dump overview information in the format returned to clients (-o option). +sub dump_artinfo_clients {
    + my $statement;
    +
    + $statement = $dbh->prepare(
    + qq{
    +select overview, artnum, quote(token), arrived, expires
    + from artinfo $sql_extraclause_artinfo;
    +}
    + );
    + $statement->execute();
    +
    + # To generate valid Date header fields.
    + setlocale(LC_TIME, 'C');
    +
    + while (my @row = $statement->fetchrow_array()) {
    + my $overdata = decompress_overview($opt{'n'}, $row[1], $row[0]);
    + # Remove trailing CRLF from overview data.
    + $overdata =~ s/\r\n//g;
    + print "$overdata";
    + print "\tArticle: $row[1]";
    + print "\tToken: @" . substr($row[2], 2, -1) . "@";
    + print "\tArrived: "
    + . strftime('%a, %d %b %Y %H:%M:%S %z (%Z)', localtime($row[3]));
    + print "\tExpires: "
    + . strftime('%a, %d %b %Y %H:%M:%S %z (%Z)', localtime($row[4]))
    + if $row[4] > 0;
    + print "\n";
    + }
    +}
    +
    +# Dump overview information in the format used by overchan (-O option).
    +sub dump_artinfo_overchan {
    + my $statement;
    +
    + $statement = $dbh->prepare(
    + qq{
    +select quote(token), arrived, expires, overview, artnum
    + from artinfo $sql_extraclause_artinfo;
    +}
    + );
    + $statement->execute();
    +
    + while (my @row = $statement->fetchrow_array()) {
    + print "@" . substr($row[0], 2, -1) . "@";
    + my $overdata = decompress_overview($opt{'n'}, $row[4], $row[3]);
    + # Remove the first field (article number, not expected by overchan)
    + # and trailing CRLF from overview data.
    + $overdata =~ s/^\d+\t//;
    + $overdata =~ s/\r\n//;
    + print " $row[1] $row[2] $overdata\n";
    + }
    +}
    diff --git a/support/mkmanifest b/support/mkmanifest
    index b4694caf0..484090be5 100755
    --- a/support/mkmanifest
    +++ b/support/mkmanifest
    @@ -266,6 +266,7 @@ site/update
    storage/buffindexed/buffindexed_d
    storage/buildconfig
    storage/ovsqlite/ovsqlite-server
    +storage/ovsqlite/ovsqlite-util
    storage/ovsqlite/sqlite-helper-gen
    storage/tradindexed/tdx-util
    support/fixconfig

    --hnFZ2TXst6vG2Fb2--

    --Z769DmSxO17dZ2tJ
    Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iHUEABYIAB0WIQQnKUXNg20437dCfobLPsM64d7XgQUCZDu03gAKCRDLPsM64d7X gWPAAP9GOL8XGYLhOiIl7wwDK7AB0ruGlXjynXukvW31itUOQwD+NU4UuWR+6CiI 5vwk1OH3NjUH+NJwp4JXG3gS0kWIxAg=5tri
    -----END PGP SIGNATURE-----

    --Z769DmSxO17dZ2tJ--

    Received: (at 1034468-done) by bugs.debian.org; 26 Apr 2023 05:30:59 +0000 X-Spam-Checker-Version: SpamAssassin 3.4.6-bugs.debian.org_2005_01_02
    (2021-04-09) on buxtehude.debian.org
    X-Spam-Level:
    X-Spam-Status: No, score=-113.8 required=4.0 tests=BAYES_00,DKIMWL_WL_HIGH,
    DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROMDEVELOPER,
    HAS_BUG_N