Hello community, here is the log from the commit of package checkmedia for openSUSE:Factory checked in at 2017-12-06 08:54:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/checkmedia (Old) and /work/SRC/openSUSE:Factory/.checkmedia.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "checkmedia" Wed Dec 6 08:54:11 2017 rev:28 rq:547085 version:3.7 Changes: -------- --- /work/SRC/openSUSE:Factory/checkmedia/checkmedia.changes 2017-09-13 21:37:23.454629458 +0200 +++ /work/SRC/openSUSE:Factory/.checkmedia.new/checkmedia.changes 2017-12-06 08:54:14.678527129 +0100 @@ -1,0 +2,8 @@ +Fri Dec 1 12:07:37 UTC 2017 - [email protected] + +- merge gh#openSUSE/checkmedia#4 +- determine image size correctly (bsc#1070745) +- more comments +- 3.7 + +-------------------------------------------------------------------- Old: ---- checkmedia-3.6.tar.xz New: ---- checkmedia-3.7.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ checkmedia.spec ++++++ --- /var/tmp/diff_new_pack.pQXrnu/_old 2017-12-06 08:54:15.218507362 +0100 +++ /var/tmp/diff_new_pack.pQXrnu/_new 2017-12-06 08:54:15.222507215 +0100 @@ -20,7 +20,7 @@ Summary: Check Installation Media License: GPL-3.0+ Group: System/Management -Version: 3.6 +Version: 3.7 Release: 0 Url: https://github.com/wfeldt/checkmedia.git Source: %{name}-%{version}.tar.xz ++++++ checkmedia-3.6.tar.xz -> checkmedia-3.7.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/checkmedia-3.6/VERSION new/checkmedia-3.7/VERSION --- old/checkmedia-3.6/VERSION 2017-09-12 14:47:20.000000000 +0200 +++ new/checkmedia-3.7/VERSION 2017-12-01 13:07:37.000000000 +0100 @@ -1 +1 @@ -3.6 +3.7 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/checkmedia-3.6/changelog new/checkmedia-3.7/changelog --- old/checkmedia-3.6/changelog 2017-09-12 14:47:20.000000000 +0200 +++ new/checkmedia-3.7/changelog 2017-12-01 13:07:37.000000000 +0100 @@ -1,4 +1,8 @@ -2017-05-27: 08e84c9af261da0f70d2f0a661db909c43bf2966-3.6 +2017-12-01: 3e4db1283b3c552694550d8c20dc454d601d4383-3.7 + - more comments + - determine image size correctly (bsc #1070745) + +2017-05-27: 3.6 - sort input files (boo#1041090) 2015-09-28: 3.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/checkmedia-3.6/checkmedia.c new/checkmedia-3.7/checkmedia.c --- old/checkmedia-3.6/checkmedia.c 2017-09-12 14:47:20.000000000 +0200 +++ new/checkmedia-3.7/checkmedia.c 2017-12-01 13:07:37.000000000 +0100 @@ -6,6 +6,7 @@ #include <unistd.h> #include <ctype.h> #include <fcntl.h> +#include <stdint.h> #include <sys/types.h> #include <sys/stat.h> @@ -34,7 +35,8 @@ static void get_info(char *file, unsigned opt_verbose); static char *no_extra_spaces(char *str); static void update_progress(unsigned size); -static void check_mbr(unsigned char *mbr); +static uint32_t read_le32(const void *ptr); +static void check_mbr(const unsigned char *mbr); static void digest_media_init(digest_ctx_t *ctx); static void digest_media_process(digest_ctx_t *ctx, unsigned char *buffer, unsigned len); @@ -464,22 +466,49 @@ } -void check_mbr(unsigned char *mbr) +/* + * Read 32 bit value at pointer address, little-endian. + */ +uint32_t read_le32(const void *ptr) { - unsigned char *p = mbr + 0x1be; // partition table - unsigned s; + const uint8_t *s = ptr; - if(mbr[0x1fe] != 0x55 || mbr[0x1ff] != 0xaa) return; + return s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24); +} - if(p[0] & 0x7f) return; - s = p[0x0c] + (p[0x0d] << 8) + (p[0x0e] << 16) + (p[0x0f] << 24); +/* + * Analyze MBR to find image size. + * + * The result is stored in iso.hybrid_size; + */ +void check_mbr(const unsigned char *mbr) +{ + const uint8_t *p; + unsigned idx, image_size; + uint32_t start, length, end; - if(s <= 64) return; // at least iso header + // check MBR signature + if(mbr[0x1fe] != 0x55 || mbr[0x1ff] != 0xaa) return; + + /* + * Scan all 4 primary partition table entries. Find the maximum used + * address. + * + * Table starts at offset 0x1be, with 16 bytes per entry. + */ + for(p = mbr + 0x1be, idx = 0, image_size = 0; idx < 4; p += 0x10, idx++) { + if(p[0] & 0x7f) continue; // invalid data + if(p[4] == 0) continue; // empty slot (type == 0) + start = read_le32(p + 0x08); + length = read_le32(p + 0x0c); + end = start + length; + if(end > start && end > image_size) image_size = end; + } - if(s & 3) return; // 2k, really + if(image_size & 3) return; // assert 2 kB block size - iso.hybrid_size = s >> 1; + iso.hybrid_size = image_size >> 1; // in kB }
