Hello community,

here is the log from the commit of package checkmedia for openSUSE:Factory 
checked in at 2018-12-03 10:09:20
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/checkmedia (Old)
 and      /work/SRC/openSUSE:Factory/.checkmedia.new.19453 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "checkmedia"

Mon Dec  3 10:09:20 2018 rev:31 rq:652463 version:4.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/checkmedia/checkmedia.changes    2018-07-02 
23:29:35.833536131 +0200
+++ /work/SRC/openSUSE:Factory/.checkmedia.new.19453/checkmedia.changes 
2018-12-03 10:09:22.499765243 +0100
@@ -1,0 +2,9 @@
+Wed Nov 28 15:35:46 UTC 2018 - snw...@suse.de
+
+- merge gh#openSUSE/checkmedia#8
+- fix digest calculation in tagmedia (bsc#1117499)
+- added testcases
+- adjust function descriptions
+- 4.1
+
+--------------------------------------------------------------------

Old:
----
  checkmedia-4.0.tar.xz

New:
----
  checkmedia-4.1.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ checkmedia.spec ++++++
--- /var/tmp/diff_new_pack.7aUw9T/_old  2018-12-03 10:09:22.971764807 +0100
+++ /var/tmp/diff_new_pack.7aUw9T/_new  2018-12-03 10:09:22.975764804 +0100
@@ -22,7 +22,7 @@
 Summary:        Check SUSE installation media
 License:        GPL-3.0-or-later
 Group:          System/Management
-Version:        4.0
+Version:        4.1
 Release:        0
 Url:            https://github.com/openSUSE/checkmedia
 Source:         %{name}-%{version}.tar.xz

++++++ checkmedia-4.0.tar.xz -> checkmedia-4.1.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/checkmedia-4.0/VERSION new/checkmedia-4.1/VERSION
--- old/checkmedia-4.0/VERSION  2018-06-29 14:17:02.000000000 +0200
+++ new/checkmedia-4.1/VERSION  2018-11-28 16:35:46.000000000 +0100
@@ -1 +1 @@
-4.0
+4.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/checkmedia-4.0/changelog new/checkmedia-4.1/changelog
--- old/checkmedia-4.0/changelog        2018-06-29 14:17:02.000000000 +0200
+++ new/checkmedia-4.1/changelog        2018-11-28 16:35:46.000000000 +0100
@@ -1,3 +1,9 @@
+2018-11-28:    4.1
+       - merge gh#openSUSE/checkmedia#8
+       - fix digest calculation in tagmedia (bsc#1117499)
+       - added testcases
+       - adjust function descriptions
+
 2018-06-29:    4.0
        - merge gh#openSUSE/checkmedia#6
        - change tagmedia to also store checksum over partition
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/checkmedia-4.0/tagmedia new/checkmedia-4.1/tagmedia
--- old/checkmedia-4.0/tagmedia 2018-06-29 14:17:02.000000000 +0200
+++ new/checkmedia-4.1/tagmedia 2018-11-28 16:35:46.000000000 +0100
@@ -80,6 +80,7 @@
 my $opt_clean = 0;
 my @opt_add_tag;
 my @opt_remove_tag;
+my $opt_verbose;
 
 GetOptions(
   'show'             => \$opt_show,
@@ -90,6 +91,7 @@
   'add-tag=s'        => \@opt_add_tag,
   'remove-tag=s'     => \@opt_remove_tag,
   'clean'            => \$opt_clean,
+  'verbose|v'        => \$opt_verbose,
   'help'             => sub { usage 0 },
 );
 
@@ -269,6 +271,8 @@
     }
   }
 
+  print "iso blocks = $image->{iso_blocks}, partition blocks = 
$image->{part_blocks} @ $image->{part_start}\n" if $opt_verbose;
+
   die "$image->{name}: unsupported image format\n" unless $image->{iso_blocks} 
|| $image->{part_blocks};
 }
 
@@ -466,31 +470,45 @@
 
 
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-# add_to_digest(image, blocks, to_iso, to_part)
+# process_digest(digest, start, blocks, buf_start, buf_blocks, buf)
+#
+# Update digest.
 #
-# Update digest reading blocks from $image->{fh}.
+# The total digest needs to be calculated from start to start + blocks. The
+# current buffer in buf holds file data from buf_start to buf_start + 
buf_blocks.
 #
-# blocks: number of blocks to read
-# to_iso: update $digest_iso
-# to_part: update $digest_part
+# digest: digest ref
+# start: region start block
+# blocks: region blocks
+# buf_start: buffer start block
+# buf_blocks: buffer blocks
+# buf: buffer ref
 #
 # Note: a block is 0.5 kB.
 #
-sub add_to_digest
+sub process_digest
 {
-  my ($image, $blocks, $to_iso, $to_part) = @_;
+  my ($digest, $start, $blocks, $buf_start, $buf_blocks, $buf) = @_;
 
-  my $buf;
+  my $end = $start + $blocks;
+  my $buf_end = $buf_start + $buf_blocks;
+
+  return if $start >= $buf_end || $end <= $buf_start;
 
-  while($blocks > 0) {
-    # try to read up to 1 MB at a time
-    my $len = $blocks > (1 << 11) ? 1 << 11 : $blocks;
-    my $read_len = sysread $image->{fh}, $buf, $len << 9;
-    die "$image->{name}: read error\n" if $read_len != $len << 9;
-    $digest_iso->add($buf) if $to_iso && $image->{iso_blocks};
-    $digest_part->add($buf) if $to_part && $image->{part_blocks};
-    $blocks -= $len;
+  if($start > $buf_start) {
+    my $skip = $start - $buf_start;
+    $buf_blocks -= $skip;
+    $buf_start = $start;
+    $buf = substr($buf, $skip << 9);
   }
+
+  if($buf_end > $end) {
+    $buf_blocks -= $buf_end - $end;
+    $buf_end = $end;
+    $buf = substr($buf, 0, $buf_blocks << 9);
+  }
+
+  $digest->add($buf);
 }
 
 
@@ -509,52 +527,38 @@
 #
 # $image->{blob_blocks} have already been read and are cached in 
$image->{blob}.
 #
-# Both regions partly overlap and region 2 can overlap $image->{blob}.
-#
-# This function makes some effort to read the file in only one go.
-#
 # Note: padding has been subtracted from $image->{iso_blocks}.
 #
 sub calculate_digest
 {
   my ($image) = @_;
 
-  $digest_iso->add($image->{blob}) if $image->{iso_blocks};
+  my $iso_start = 0;
+  my $iso_blocks = $image->{iso_blocks};
+  my $part_start = $image->{part_start};
+  my $part_blocks = $image->{part_blocks};
 
-  my $next_stop = $image->{iso_blocks};
-  my $idx = $image->{blob_blocks};
+  my $full_blocks = $part_start + $part_blocks;
+  $full_blocks = $iso_blocks if $iso_blocks > $full_blocks;
 
-  my $iso_rem;
-  my $part_rem;
+  my $pos = $image->{blob_blocks};
+  my $step_blocks = 2048;      # 1 MiB chunks
 
-  if($image->{part_start}) {
-    if($image->{part_start} < $image->{blob_blocks}) {
-      $digest_part->add(
-        substr($image->{blob}, $image->{part_start} << 9, 
($image->{blob_blocks} - $image->{part_start}) << 9)
-      );
-      $idx = $image->{blob_blocks};
-    }
-    else {
-      add_to_digest $image, $image->{part_start} - $image->{blob_blocks}, 1, 0;
-      $idx = $image->{part_start};
-    }
+  process_digest $digest_iso, $iso_start, $iso_blocks, 0, $pos, $image->{blob};
+  process_digest $digest_part, $part_start, $part_blocks, 0, $pos, 
$image->{blob};
 
-    $next_stop = $image->{part_start} + $image->{part_blocks};
-    $next_stop = $image->{iso_blocks} if $image->{iso_blocks} && 
$image->{iso_blocks} < $next_stop;
+  while($pos < $full_blocks) {
+    my $buf;
+    my $to_read = $full_blocks - $pos;
+    $to_read = $step_blocks if $step_blocks < $to_read;
 
-    $part_rem = $image->{part_start} + $image->{part_blocks} - $next_stop;
-  }
-
-  add_to_digest $image, $next_stop - $idx, 1, 1;
+    my $read_len = sysread $image->{fh}, $buf, $to_read << 9;
+    die "$image->{name}: read error: $to_read blocks @ $pos\n" if $read_len != 
$to_read << 9;
 
-  $iso_rem = $image->{iso_blocks} - $next_stop if $image->{iso_blocks};
+    process_digest $digest_iso, $iso_start, $iso_blocks, $pos, $to_read, $buf;
+    process_digest $digest_part, $part_start, $part_blocks, $pos, $to_read, 
$buf;
 
-  if($part_rem) {
-    die "oops, assumption failed\n" if $iso_rem;
-    add_to_digest $image, $part_rem, 0, 1;
-  }
-  elsif($iso_rem) {
-    add_to_digest $image, $iso_rem, 1, 0;
+    $pos += $to_read;
   }
 
   if($image->{iso_blocks}) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/checkmedia-4.0/testmediacheck 
new/checkmedia-4.1/testmediacheck
--- old/checkmedia-4.0/testmediacheck   2018-06-29 14:17:02.000000000 +0200
+++ new/checkmedia-4.1/testmediacheck   2018-11-28 16:35:46.000000000 +0100
@@ -144,6 +144,36 @@
     part_blocks => 998,
   },
 
+  {
+    name => "iso_too_small_ends_before_partition_start",
+    digest => "sha256",
+    full_blocks => 1000,
+    iso_blocks => 600,
+    pad_blocks => 100,
+    part_start => 700,
+    part_blocks => 300,
+  },
+
+  {
+    name => "iso_too_small_ends_at_partition_start",
+    digest => "sha256",
+    full_blocks => 1000,
+    iso_blocks => 700,
+    pad_blocks => 100,
+    part_start => 700,
+    part_blocks => 300,
+  },
+
+  {
+    name => "iso_too_small_ends_after_partition_start",
+    digest => "sha256",
+    full_blocks => 1000,
+    iso_blocks => 800,
+    pad_blocks => 100,
+    part_start => 700,
+    part_blocks => 300,
+  },
+
 
 ];
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/checkmedia-4.0/tests/iso_too_small_ends_after_partition_start.sha256.check.ref
 
new/checkmedia-4.1/tests/iso_too_small_ends_after_partition_start.sha256.check.ref
--- 
old/checkmedia-4.0/tests/iso_too_small_ends_after_partition_start.sha256.check.ref
  1970-01-01 01:00:00.000000000 +0100
+++ 
new/checkmedia-4.1/tests/iso_too_small_ends_after_partition_start.sha256.check.ref
  2018-11-28 16:35:46.000000000 +0100
@@ -0,0 +1,15 @@
+       tags: key = "pad", value = "25"
+       tags: key = "sha256sum", value = 
"624430d33fff980caf6e9801e119719419932f7399e9a73169d60ca61268ba6e"
+       tags: key = "partition", value = 
"700,300,a4e0d25439ddfc8f8e353fc94f02688bf86ea6987872d034e884dd3125b47ef6"
+        app: iso_too_small_ends_after_partition_start
+   iso size: 400 kB
+        pad: 50 kB
+  partition: start 350 kB, size 150 kB
+  full size: 500 kB
+    iso ref: 624430d33fff980caf6e9801e119719419932f7399e9a73169d60ca61268ba6e
+   part ref: a4e0d25439ddfc8f8e353fc94f02688bf86ea6987872d034e884dd3125b47ef6
+   checking:       0% 12% 25% 38% 51% 64% 76% 
89%100%
+     result: iso sha256 ok, partition sha256 ok
+ iso sha256: 624430d33fff980caf6e9801e119719419932f7399e9a73169d60ca61268ba6e
+part sha256: a4e0d25439ddfc8f8e353fc94f02688bf86ea6987872d034e884dd3125b47ef6
+     sha256: 0305e1d8b51dd38285f36990a615f4d7229a2862a0d901e4107900ddf5212919
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/checkmedia-4.0/tests/iso_too_small_ends_after_partition_start.sha256.tag.ref
 
new/checkmedia-4.1/tests/iso_too_small_ends_after_partition_start.sha256.tag.ref
--- 
old/checkmedia-4.0/tests/iso_too_small_ends_after_partition_start.sha256.tag.ref
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/checkmedia-4.1/tests/iso_too_small_ends_after_partition_start.sha256.tag.ref
    2018-11-28 16:35:46.000000000 +0100
@@ -0,0 +1,3 @@
+pad = 25
+sha256sum = 624430d33fff980caf6e9801e119719419932f7399e9a73169d60ca61268ba6e
+partition = 
700,300,a4e0d25439ddfc8f8e353fc94f02688bf86ea6987872d034e884dd3125b47ef6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/checkmedia-4.0/tests/iso_too_small_ends_at_partition_start.sha256.check.ref 
new/checkmedia-4.1/tests/iso_too_small_ends_at_partition_start.sha256.check.ref
--- 
old/checkmedia-4.0/tests/iso_too_small_ends_at_partition_start.sha256.check.ref 
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/checkmedia-4.1/tests/iso_too_small_ends_at_partition_start.sha256.check.ref 
    2018-11-28 16:35:46.000000000 +0100
@@ -0,0 +1,15 @@
+       tags: key = "pad", value = "25"
+       tags: key = "sha256sum", value = 
"b19501e0668c87a857877c84d1514e3c73393fd97f371903d1555e21b4582359"
+       tags: key = "partition", value = 
"700,300,5e54749a2cd7cf135d8469df48f3047124527e21c138049980941c3153e5e0d8"
+        app: iso_too_small_ends_at_partition_start
+   iso size: 350 kB
+        pad: 50 kB
+  partition: start 350 kB, size 150 kB
+  full size: 500 kB
+    iso ref: b19501e0668c87a857877c84d1514e3c73393fd97f371903d1555e21b4582359
+   part ref: 5e54749a2cd7cf135d8469df48f3047124527e21c138049980941c3153e5e0d8
+   checking:       0% 12% 25% 38% 51% 64% 76% 
89%100%
+     result: iso sha256 ok, partition sha256 ok
+ iso sha256: b19501e0668c87a857877c84d1514e3c73393fd97f371903d1555e21b4582359
+part sha256: 5e54749a2cd7cf135d8469df48f3047124527e21c138049980941c3153e5e0d8
+     sha256: d5bbdb09b68c6be36b030a1cf9551fde826881d337290b37de67f3a5877c1896
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/checkmedia-4.0/tests/iso_too_small_ends_at_partition_start.sha256.tag.ref 
new/checkmedia-4.1/tests/iso_too_small_ends_at_partition_start.sha256.tag.ref
--- 
old/checkmedia-4.0/tests/iso_too_small_ends_at_partition_start.sha256.tag.ref   
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/checkmedia-4.1/tests/iso_too_small_ends_at_partition_start.sha256.tag.ref   
    2018-11-28 16:35:46.000000000 +0100
@@ -0,0 +1,3 @@
+pad = 25
+sha256sum = b19501e0668c87a857877c84d1514e3c73393fd97f371903d1555e21b4582359
+partition = 
700,300,5e54749a2cd7cf135d8469df48f3047124527e21c138049980941c3153e5e0d8
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/checkmedia-4.0/tests/iso_too_small_ends_before_partition_start.sha256.check.ref
 
new/checkmedia-4.1/tests/iso_too_small_ends_before_partition_start.sha256.check.ref
--- 
old/checkmedia-4.0/tests/iso_too_small_ends_before_partition_start.sha256.check.ref
 1970-01-01 01:00:00.000000000 +0100
+++ 
new/checkmedia-4.1/tests/iso_too_small_ends_before_partition_start.sha256.check.ref
 2018-11-28 16:35:46.000000000 +0100
@@ -0,0 +1,15 @@
+       tags: key = "pad", value = "25"
+       tags: key = "sha256sum", value = 
"670a5364e2dbd0353bfdcc4fd285b345366e55eb66708b1f3d728f9a31c30b6f"
+       tags: key = "partition", value = 
"700,300,5e54749a2cd7cf135d8469df48f3047124527e21c138049980941c3153e5e0d8"
+        app: iso_too_small_ends_before_partition_start
+   iso size: 300 kB
+        pad: 50 kB
+  partition: start 350 kB, size 150 kB
+  full size: 500 kB
+    iso ref: 670a5364e2dbd0353bfdcc4fd285b345366e55eb66708b1f3d728f9a31c30b6f
+   part ref: 5e54749a2cd7cf135d8469df48f3047124527e21c138049980941c3153e5e0d8
+   checking:       0% 12% 25% 38% 51% 64% 76% 
89%100%
+     result: iso sha256 ok, partition sha256 ok
+ iso sha256: 670a5364e2dbd0353bfdcc4fd285b345366e55eb66708b1f3d728f9a31c30b6f
+part sha256: 5e54749a2cd7cf135d8469df48f3047124527e21c138049980941c3153e5e0d8
+     sha256: 9c84b2c850265959879166902195d88853ffc4ffe71559833ecde1be64805b3d
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/checkmedia-4.0/tests/iso_too_small_ends_before_partition_start.sha256.tag.ref
 
new/checkmedia-4.1/tests/iso_too_small_ends_before_partition_start.sha256.tag.ref
--- 
old/checkmedia-4.0/tests/iso_too_small_ends_before_partition_start.sha256.tag.ref
   1970-01-01 01:00:00.000000000 +0100
+++ 
new/checkmedia-4.1/tests/iso_too_small_ends_before_partition_start.sha256.tag.ref
   2018-11-28 16:35:46.000000000 +0100
@@ -0,0 +1,3 @@
+pad = 25
+sha256sum = 670a5364e2dbd0353bfdcc4fd285b345366e55eb66708b1f3d728f9a31c30b6f
+partition = 
700,300,5e54749a2cd7cf135d8469df48f3047124527e21c138049980941c3153e5e0d8


Reply via email to