Commit 1e9361f0 authored by Mike Hibler's avatar Mike Hibler

Wow, there is a lot of stuff to fix!

parent 6d96f549
......@@ -32,7 +32,7 @@
static int read_ext4group(struct ext4_super_block *super,
struct ext4_group_desc *group, int index,
u_int32_t sliceoffset, int infd);
uint64_t sliceoffset, int infd);
extern int fixup_lilo(int slice, int stype, u_int32_t start, u_int32_t size,
char *sname, int infd, int *found);
......@@ -60,7 +60,7 @@ read_linuxslice(int slice, iz_type stype, iz_lba start, iz_size size,
unsigned char groups[EXT4_MAX_BLOCK_SIZE];
int dosslice = slice + 1; /* DOS Numbering */
off_t soff;
u_int32_t fssect;
iz_lba fssect;
/*
* Check for a LILO boot block and create relocations as necessary
......@@ -216,7 +216,7 @@ static int
read_ext4group(struct ext4_super_block *super,
struct ext4_group_desc *group,
int index,
u_int32_t sliceoffset /* Sector offset of slice */,
uint64_t sliceoffset /* Sector offset of slice */,
int infd)
{
char *p, bitmap[EXT4_MAX_BLOCK_SIZE];
......
/*
* Copyright (c) 2000-2015 University of Utah and the Flux Group.
* Copyright (c) 2000-2018 University of Utah and the Flux Group.
*
* {{{EMULAB-LICENSE
*
......@@ -54,8 +54,8 @@ static int _read_bsdslice(int slice, iz_type bsdtype, iz_lba start,
iz_size size, char *sname, int infd,
int musthavelabel);
static int read_bsdpartition(int infd, struct disklabel *dlabel, int part);
static int read_bsdsblock(int infd, u_int32_t off, int part, struct fs *fsp);
static int read_bsdcg(struct fs *fsp, struct cg *cgp, int cg, u_int32_t off);
static int read_bsdsblock(int infd, uint64_t off, int part, struct fs *fsp);
static int read_bsdcg(struct fs *fsp, struct cg *cgp, int cg, uint64_t off);
#ifdef CLEAR_FREE_INODES
static void inodefixup(void *buf, off_t buflen, void *fdata);
#endif
......@@ -63,7 +63,7 @@ static void inodefixup(void *buf, off_t buflen, void *fdata);
/* Map partition number to letter */
#define BSDPARTNAME(i) ("abcdefghijklmnop"[(i)])
static int32_t freecount;
static int64_t freecount;
/*
* Operate on a BSD slice
......@@ -298,8 +298,8 @@ read_bsdpartition(int infd, struct disklabel *dlabel, int part)
struct cg cg;
char pad[MAXBSIZE];
} cg;
u_int32_t size, offset, fssect;
int32_t sbfree;
uint64_t size, offset, fssect;
int64_t sbfree;
offset = dlabel->d_partitions[part].p_offset;
size = dlabel->d_partitions[part].p_size;
......@@ -336,7 +336,7 @@ read_bsdpartition(int infd, struct disklabel *dlabel, int part)
fssect = bytestosec(fs.fs_fsize * (off_t)fs.fs_size);
if (excludenonfs && fssect < size) {
warnx("BSD Partition '%c': filesystem smaller than partition, "
"excluding [%u-%u]",
"excluding [%lu-%lu]",
BSDPARTNAME(part), offset+fssect, offset+size-1);
addskip(offset + fssect, size - fssect);
}
......@@ -377,7 +377,7 @@ read_bsdpartition(int infd, struct disklabel *dlabel, int part)
if (rval == 0 && freecount != sbfree) {
warnx("BSD Partition '%c': "
"computed free count (%d) != expected free count (%d)",
"computed free count (%ld) != expected free count (%ld)",
BSDPARTNAME(part), freecount, sbfree);
}
......@@ -388,7 +388,7 @@ read_bsdpartition(int infd, struct disklabel *dlabel, int part)
* Includes code yanked from UFS2 ffs_vfsops.c
*/
static int
read_bsdsblock(int infd, u_int32_t offset, int part, struct fs *fsp)
read_bsdsblock(int infd, uint64_t offset, int part, struct fs *fsp)
{
static int sblock_try[] = SBLOCKSEARCH;
union {
......@@ -489,7 +489,7 @@ read_bsdsblock(int infd, u_int32_t offset, int part, struct fs *fsp)
}
static int
read_bsdcg(struct fs *fsp, struct cg *cgp, int cg, u_int32_t offset)
read_bsdcg(struct fs *fsp, struct cg *cgp, int cg, uint64_t offset)
{
int i, max;
u_int8_t *p;
......
......@@ -42,7 +42,7 @@ extern void addfixupfunc(void (*func)(void *, off_t, void *), off_t offset,
off_t poffset, off_t size, void *data, off_t dsize,
int reloctype);
extern void applyfixups(off_t offset, off_t size, void *data);
extern int hasfixup(uint32_t soffset, uint32_t ssize);
extern int hasfixup(uint64_t soffset, uint64_t ssize);
extern void savefixups(void);
extern void restorefixups(int isempty);
extern void dumpfixups(int verbose, int count);
......
/*
* Copyright (c) 2000-2016 University of Utah and the Flux Group.
* Copyright (c) 2000-2018 University of Utah and the Flux Group.
*
* {{{EMULAB-LICENSE
*
......@@ -279,13 +279,6 @@ parse_gpt(int fd, struct iz_disk *disk, int dowarn)
parttab[i].offset = start;
parttab[i].size = size;
/* XXX right now imagezip only handles 32-bit off/size */
if ((uint64_t)(parttab[i].offset) != start ||
(uint64_t)(parttab[i].size) != size) {
warnx("P%d: Offset/size too large, ignoring", i+1);
parttab[i].flags |= IZFLAG_IGNORE;
}
if (type != IZTYPE_INVALID) {
if (start < losect)
losect = start;
......
......@@ -148,7 +148,7 @@ dumphash(struct hashinfo *hinfo)
* Read a range of the disk and compute the hash value.
*/
static int
hash_range(uint32_t start, uint32_t size, unsigned char *hash)
hash_range(uint64_t start, uint64_t size, unsigned char *hash)
{
unsigned char *bp;
size_t count, byte_size;
......@@ -191,7 +191,7 @@ hash_range(uint32_t start, uint32_t size, unsigned char *hash)
/* XXX apply fixups */
if (hasfixup(start, size)) {
#ifdef FOLLOW
fprintf(stderr, " h: [%u-%u] applying fixups\n",
fprintf(stderr, " h: [%lu-%lu] applying fixups\n",
start, start + size - 1);
#endif
applyfixups(byte_start, byte_size, hashdata);
......@@ -284,7 +284,7 @@ static int
readhashinfo(char *hfile, struct hashinfo **hinfop)
{
struct hashinfo hi, *hinfo;
int fd, nregbytes, cc, i;
int fd, nregbytes, cc, i, is32;
assert(poffset != ~0);
......@@ -303,10 +303,12 @@ readhashinfo(char *hfile, struct hashinfo **hinfop)
return -1;
}
if (strcmp((char *)hi.magic, HASH_MAGIC) != 0 ||
!(hi.version == HASH_VERSION_1 || hi.version == HASH_VERSION_2)) {
!(hi.version == HASH_VERSION_1 || hi.version == HASH_VERSION_2 ||
hi.version == HASH_VERSION_3)) {
fprintf(stderr, "%s: not a valid signature file\n", hfile);
return -1;
}
is32 = (hi.version < HASH_VERSION_3) ? 1 : 0;
nregbytes = hi.nregions * sizeof(struct hashregion);
hinfo = malloc(sizeof(hi) + nregbytes);
if (hinfo == 0) {
......@@ -314,7 +316,11 @@ readhashinfo(char *hfile, struct hashinfo **hinfop)
return -1;
}
*hinfo = hi;
cc = read(fd, hinfo->regions, nregbytes);
if (is32) {
FIXME
} else {
cc = read(fd, hinfo->regions, nregbytes);
}
if (cc != nregbytes) {
free(hinfo);
return -1;
......@@ -577,7 +583,7 @@ add_to_hashmap(struct hashinfo **hinfop, uint32_t rstart, uint32_t rsize,
* in the range, mark it special.
*/
void
hashmap_update_chunk(uint32_t ssect, uint32_t lsect, int chunkno)
hashmap_update_chunk(uint64_t ssect, uint64_t lsect, int chunkno)
{
int i;
assert(chunkno >= 0);
......@@ -622,10 +628,10 @@ hashmap_update_chunk(uint32_t ssect, uint32_t lsect, int chunkno)
*/
int
hashmap_compute_delta(struct range *curranges, char *hfile, int infd,
uint32_t ssect, char *newhashfile,
uint64_t ssect, char *newhashfile,
struct range **nranges)
{
uint32_t gapstart, gapsize, lastdrangeend = 0;
uint64_t gapstart, gapsize, lastdrangeend = 0;
unsigned char hash[HASH_MAXSIZE];
struct range dummy_head, *range_tail;
struct hashregion *hreg, *ereg;
......
/*
* Copyright (c) 2000-2015 University of Utah and the Flux Group.
* Copyright (c) 2000-2018 University of Utah and the Flux Group.
*
* {{{EMULAB-LICENSE
*
......@@ -74,6 +74,7 @@ static int report = 0;
static int withchunkno = 1;
static int regfile = 0;
static int nothreads = 0;
static int hashversion = HASH_VERSION;
static int hashtype = HASH_TYPE_SHA1;
static int hashlen = 20;
static long hashblksize = HASHBLK_SIZE;
......@@ -119,8 +120,8 @@ static void free_readbuf(readbuf_t *rbuf);
static void dump_readbufs(void);
static void dump_stats(int sig);
#define sectobytes(s) ((off_t)(s) * SECSIZE)
#define bytestosec(b) (uint32_t)((b) / SECSIZE)
#define sectobytes(s) ((uint64_t)(s) * SECSIZE)
#define bytestosec(b) (uint64_t)((b) / SECSIZE)
int
main(int argc, char **argv)
......@@ -129,7 +130,7 @@ main(int argc, char **argv)
extern char build_info[];
struct hashinfo *hashinfo = 0;
while ((ch = getopt(argc, argv, "cCb:dvhno:rD:NVRF:SXqT")) != -1)
while ((ch = getopt(argc, argv, "cCb:dvhno:rD:NVRF:SXqT2")) != -1)
switch(ch) {
case 'b':
hashblksize = atol(optarg);
......@@ -204,6 +205,9 @@ main(int argc, char **argv)
case 'T':
terse = 1;
break;
case '2':
hashversion = HASH_VERSION_2;
break;
case 'h':
case '?':
default:
......@@ -275,6 +279,24 @@ main(int argc, char **argv)
signame(argv[0]));
exit(1);
}
/*
* Need to use the same hash params when hashing the image
* as are already recorded in the signature.
*/
hashversion = hashinfo->version;
hashtype = hashinfo->hashtype;
switch (hashtype) {
case HASH_TYPE_MD5:
default:
hashlen = 16;
break;
case HASH_TYPE_SHA1:
hashlen = 20;
break;
}
hashblksizeinsec = hashinfo->blksize;
if (hashimage(argv[0], &ihashinfo) != 0) {
fprintf(stderr, "Could not compute hashinfo for %s\n",
argv[0]);
......@@ -282,7 +304,7 @@ main(int argc, char **argv)
}
assert(ihashinfo != NULL);
strcpy((char *)ihashinfo->magic, HASH_MAGIC);
ihashinfo->version = HASH_VERSION_2;
ihashinfo->version = hashversion;
ihashinfo->hashtype = hashtype;
ihashinfo->blksize = hashblksizeinsec;
......@@ -421,11 +443,20 @@ readhashinfo(char *name, struct hashinfo **hinfop)
return -1;
}
if (strcmp((char *)hi.magic, HASH_MAGIC) != 0 ||
!(hi.version == HASH_VERSION_1 || hi.version == HASH_VERSION_2)) {
!(hi.version == HASH_VERSION_1 || hi.version == HASH_VERSION_2 ||
hi.version == HASH_VERSION3)) {
fprintf(stderr, "%s: not a valid signature file\n", hname);
goto bad;
}
nbytes = hi.nregions * sizeof(struct hashregion);
switch (hi.version) {
case HASH_VERSION_1:
case HASH_VERSION_2:
nbytes = hi.nregions * sizeof(struct hashregion_32);
break;
default:
nbytes = hi.nregions * sizeof(struct hashregion);
break;
}
hinfo = malloc(sizeof(hi) + nbytes);
if (hinfo == 0) {
fprintf(stderr, "%s: not enough memory for info\n", hname);
......@@ -472,10 +503,11 @@ readhashinfo(char *name, struct hashinfo **hinfop)
#define REGPERBLK 8192 /* ~256KB -- must be power of 2 */
static void
addhash(struct hashinfo **hinfop, uint32_t chunkno, uint32_t start,
uint32_t size, unsigned char hash[HASH_MAXSIZE])
addhash32(struct hashinfo **hinfop, uint32_t chunkno, uint32_t start,
uint32_t size, unsigned char hash[HASH_MAXSIZE])
{
struct hashinfo *hinfo = *hinfop;
struct hasregion_32 regions;
int nreg;
if (report) {
......@@ -487,6 +519,47 @@ addhash(struct hashinfo **hinfop, uint32_t chunkno, uint32_t start,
return;
}
if (hinfo == 0) {
nreg = 0;
hinfo = calloc(1, sizeof(*hinfo));
} else {
nreg = hinfo->nregions;
}
if ((nreg % REGPERBLK) == 0) {
hinfo = realloc(hinfo, sizeof(*hinfo) +
(nreg+REGPERBLK)*sizeof(struct hashregion_32));
if (hinfo == 0) {
fprintf(stderr, "out of memory for hash map\n");
exit(1);
}
*hinfop = hinfo;
}
regions = (struct hashregion_32 *)&hinfo->regions[0];
regions[nreg].chunkno = chunkno;
regions[nreg].region.start = start;
regions[nreg].region.size = size;
memcpy(regions[nreg].hash, hash, HASH_MAXSIZE);
hinfo->nregions++;
nhregions = hinfo->nregions;
}
static void
addhash(struct hashinfo **hinfop, uint32_t chunkno, uint64_t start,
uint64_t size, unsigned char hash[HASH_MAXSIZE])
{
struct hashinfo *hinfo = *hinfop;
int nreg;
if (report) {
printf("%s\t%lu\t%lu",
spewhash(hash, hashlen), start, size);
if (report > 1)
printf("\t%u\tU\t%s", chunkno, fileid);
putchar('\n');
return;
}
if (hinfo == 0) {
nreg = 0;
hinfo = calloc(1, sizeof(*hinfo));
......@@ -528,6 +601,10 @@ dumphash(char *name, struct hashinfo *hinfo, int withchunk)
printf("sig version 2, blksize=%d sectors:\n",
hinfo->blksize);
break;
case HASH_VERSION_3:
printf("sig version 3, blksize=%d sectors:\n",
hinfo->blksize);
break;
default:
printf("unknown signature version (%x), "
"expect garbage:\n", hinfo->version);
......@@ -1464,7 +1541,7 @@ hashfilechunk(int chunkno, char *chunkbufp, int chunksize,
struct hashinfo **hinfop)
{
int resid;
uint32_t cursect = 0, nbytes;
uint64_t cursect = 0, nbytes;
unsigned char hash[HASH_MAXSIZE];
unsigned char *(*hashfunc)(const unsigned char *, size_t,
unsigned char *);
......@@ -1495,7 +1572,7 @@ hashfilechunk(int chunkno, char *chunkbufp, int chunksize,
*/
resid = chunksize - sectobytes(bytestosec(chunksize));
while (chunksize > 0) {
uint32_t rstart, rsize;
uint64_t rstart, rsize;
if (chunksize > hashblksize)
nbytes = hashblksize;
......
......@@ -25,7 +25,8 @@
#define HASH_VERSION_1 0x20031107
#define HASH_VERSION_2 0x20140618
#define HASH_VERSION HASH_VERSION_2
#define HASH_VERSION_3 0x20180415
#define HASH_VERSION HASH_VERSION_3
#define HASH_MAGIC ".ndzsig"
#define HASHBLK_SIZE (64*1024)
......@@ -36,6 +37,12 @@
#define HASH_CHUNKSETSPAN(c) ((c) | (1 << 31))
struct hashregion {
struct region_64 region;
uint32_t chunkno;
unsigned char hash[HASH_MAXSIZE];
};
struct hashregion_32 {
struct region_32 region;
uint32_t chunkno;
unsigned char hash[HASH_MAXSIZE];
......@@ -48,7 +55,7 @@ struct hashinfo {
uint32_t nregions;
uint32_t blksize; /* V2: make hash blocksize explicit */
uint8_t pad[8];
struct hashregion regions[0];
struct hashregion regions[0]; /* V3: hash regions have 64 byte vals */
};
#define HASH_TYPE_MD5 1
......
......@@ -351,8 +351,11 @@ if (is32) { \
* area before filling the region header. Since the latter is more likely
* to be common, we tend to the small-ish side.
*
* At 4K with 8 byte region descriptors, we can fix 512 regions into a
* single chunk.
* At 4K, with a V2 image having a 36 byte header and 8 byte region
* descriptors, we can fix 507 regions into a single chunk.
*
* At 4K, with a V5 image having a 360 byte header and 16 byte region
* descriptors, we can fix 233 regions into a single chunk.
*/
#define DEFAULTREGIONSIZE 4096
......
......@@ -150,7 +150,7 @@ static void sortrange(struct range **head, int domerge,
int (*rangecmp)(struct range *, struct range *));
int mergeskips(int verbose);
int mergeranges(struct range *head);
void makeranges(void);
void makeranges(int *need64);
void dumpranges(int verbose);
uint64_t sectinranges(struct range *range);
void addreloc(off_t offset, off_t size, int reloctype);
......@@ -397,6 +397,7 @@ main(int argc, char *argv[])
char *outfilename = 0;
int rawmode = 0;
int slicetype = 0;
int need64 = 0;
struct timeval sstamp;
extern char build_info[];
......@@ -711,43 +712,6 @@ main(int argc, char *argv[])
}
#endif
#ifdef WITH_V3COMPAT
/*
* Deal with pre-crypto backward compatibility.
* We don't want to generate V4 images unless we really need it.
* Note that this means we do NOT generate a UUID if none was provided.
*/
if (!compat &&
#ifdef WITH_CRYPTO
!do_encrypt && !do_checksum &&
#endif
!got_imageid)
compat = COMPRESSED_V3;
#endif
/*
* Generate a random UUID if one was not provided and we are
* not operating in compatibility mode.
*/
if (!compat && !got_imageid) {
int fd = open("/dev/urandom", O_RDONLY, 0);
if (fd < 0 ||
read(fd, imageid, sizeof(imageid)) != sizeof(imageid)) {
fprintf(stderr, "WARNING: no UUID generated\n");
memset(imageid, '\0', UUID_LENGTH);
} else {
char uuidstr[UUID_LENGTH*2+1];
mem_to_hexstr(uuidstr, imageid, UUID_LENGTH);
output_uuid(outfilename, uuidstr);
got_imageid = 1;
}
if (fd >= 0)
close(fd);
}
/*
* Create the skip list by scanning the filesystems on
* the disk or indicated partition.
......@@ -788,7 +752,7 @@ main(int argc, char *argv[])
(void) mergeskips(debug > 1);
if (debug)
dumpskips(debug > 1);
makeranges();
makeranges(&need64);
#ifdef TEST_RANGEMAP
dumpranges(debug > 1);
#else
......@@ -814,6 +778,57 @@ main(int argc, char *argv[])
dumpfixups(debug > 2, 0);
fflush(stderr);
/*
* Now that we have computed the range map, see if there are any
* offsets/sizes > 32-bits and fail if they are trying to create
* an old image.
*/
if (compat && compat < COMPRESSED_V5 && need64) {
fprintf(stderr,
"Offset or size > 32-bits detected, cannot use -3\n");
usage();
}
#ifdef WITH_V3COMPAT
/*
* Deal with pre-crypto/pre-64-bit backward compatibility.
*
* We don't want to generate V4/V5 images unless we really need it.
* For V4, we don't have to if none of encryption, checksuming, or
* a UUID is specified. For V5, it also means that no region sector
* number or size exceeds 32-bits. This is determined for us by
* makeranges().
*/
if (!compat &&
#ifdef WITH_CRYPTO
!do_encrypt && !do_checksum &&
#endif
!got_imageid && !need64)
compat = COMPRESSED_V3;
#endif
/*
* Generate a random UUID if one was not provided and we are
* not operating in compatibility mode.
*/
if (!compat && !got_imageid) {
int fd = open("/dev/urandom", O_RDONLY, 0);
if (fd < 0 ||
read(fd, imageid, sizeof(imageid)) != sizeof(imageid)) {
fprintf(stderr, "WARNING: no UUID generated\n");
memset(imageid, '\0', UUID_LENGTH);
} else {
char uuidstr[UUID_LENGTH*2+1];
mem_to_hexstr(uuidstr, imageid, UUID_LENGTH);
output_uuid(outfilename, uuidstr);
got_imageid = 1;
}
if (fd >= 0)
close(fd);
}
#ifdef WITH_HASH
/*
* If we are creating a "delta" image from a hash signature,
......@@ -1534,9 +1549,9 @@ mergeskips(int verbose)
{
struct range *prange, **prevp;
int freed = 0, culled = 0;
uint32_t total = 0;
uint64_t total = 0;
#ifdef DOHISTO
uint32_t histo[64];
uint64_t histo[64];
memset(histo, 0, sizeof(histo));
#endif
......@@ -1607,7 +1622,7 @@ mergeskips(int verbose)
prevp = &prange->next;
} else
#endif
if (prange->size < (uint32_t)frangesize) {
if (prange->size < (uint64_t)frangesize) {
#ifdef WITH_HASHALIGN
dropall:
#endif
......@@ -1635,8 +1650,8 @@ mergeskips(int verbose)
}
if (verbose && culled) {
fprintf(stderr,
"\nFree Sectors Ignored: %d (%lld bytes) in %d ranges\n",
total, (long long)sectobytes(total), culled);
"\nFree Sectors Ignored: %lu (%ld bytes) in %d ranges\n",
total, sectobytes(total), culled);
#ifdef DOHISTO
{
int i;
......@@ -1650,7 +1665,7 @@ mergeskips(int verbose)
s = (double)(histo[i]*i)/total*100.0;
cums += s;
fprintf(stderr,
"%d: %u, %4.1f%% (%4.1f%%) of ranges "
"%d: %lu, %4.1f%% (%4.1f%%) of ranges "
"%4.1f%% (%4.1f%%) of sectors)\n",
i, histo[i], r, cumr, s, cums);
}
......@@ -1828,17 +1843,22 @@ mergeranges(struct range *head)
* we create a single range covering the entire partition.
*/
void
makeranges(void)
makeranges(int *need64p)
{
struct range *pskip, *ptmp;
uint32_t offset;
uint64_t offset, size;
int need64 = 0;
offset = inputminsec;
pskip = skips;
while (pskip) {
if ((pskip->start - offset) > 0)
addvalid(offset, pskip->start - offset);
size = pskip->start - offset;
if (!need64 && (offset > UINT32_MAX || size > UINT32_MAX))
need64 = 1;
if (size > 0)
addvalid(offset, size);
offset = pskip->start + pskip->size;
ptmp = pskip;
......@@ -1861,8 +1881,18 @@ makeranges(void)
* Mark the last range with 0 so compression goes to end
* if we don't know where it is.
*/
addvalid(offset, inputmaxsec ? (inputmaxsec - offset) : 0);
if (inputmaxsec) {
size = inputmaxsec - offset;
if (!need64 &&
(inputmaxsec > UINT32_MAX || size > UINT32_MAX))
need64 = 1;
} else
size = 0;
addvalid(offset, size);
}
if (need64p)
*need64p = need64;
}
void
......@@ -1894,7 +1924,7 @@ void
dumpranges(int verbose)
{
struct range *range;
uint32_t total = 0;
uint64_t total = 0;
int nranges = 0;
if (verbose)
......@@ -1909,8 +1939,8 @@ dumpranges(int verbose)
range = range->next;
}
fprintf(stderr,
"Total Number of Valid Sectors: %u (bytes %llu) in %d ranges\n",
(unsigned)total, (unsigned long long)sectobytes(total), nranges);
"Total Number of Valid Sectors: %lu (bytes %lu) in %d ranges\n",
total, sectobytes(total), nranges);
#ifdef TEST_RANGEMAP
comparemap(verbose);
#endif
......@@ -2034,7 +2064,7 @@ cmpfixups(struct range *r1, struct range *r2)
* Returns 1 if so, 0 otherwise.
*/
int
hasfixup(uint32_t soffset, uint32_t ssize)
hasfixup(uint64_t soffset, uint64_t ssize)
{
struct range *rp;
struct fixup *fp;
......@@ -2055,12 +2085,12 @@ hasfixup(uint32_t soffset, uint32_t ssize)
/* otherwise, there is overlap */
#ifdef FOLLOW
fprintf(stderr, "R: [%u-%u] overlaps with F: [%u/%u-%u/%u]\n",
fprintf(stderr, "R: [%lu-%lu] overlaps with F: [%lu/%lu-%lu/%lu]\n",
soffset, soffset+ssize-1,
bytestosec(fp->offset),
(uint32_t)fp->offset % SECSIZE,
fp->offset % SECSIZE,
bytestosec(fp->offset+fp->size-1),
(uint32_t)(fp->offset+fp->size-1) % SECSIZE);
(fp->offset+fp->size-1) % SECSIZE);
#endif
return 1;
}
......@@ -2138,7 +2168,7 @@ applyfixups(off_t offset, off_t size, void *data)
{
struct range **prev, *entry;
struct fixup *fp;
uint32_t coff, clen;
uint64_t coff, clen;
#ifdef FOLLOW
fprintf(stderr, "D: [%u-%u], %d fixups\n",
......@@ -2149,12 +2179,12 @@ applyfixups(off_t offset, off_t size, void *data)
assert(entry->data != NULL);
fp = entry->data;
#ifdef FOLLOW
fprintf(stderr, " F%p: [%u/%u-%u/%u]: ",
fprintf(stderr, " F%p: [%lu/%lu-%lu/%lu]: ",
fp,
bytestosec(fp->offset),
(uint32_t)fp->offset % SECSIZE,
fp->offset % SECSIZE,
bytestosec(fp->offset+fp->size-1),
(uint32_t)(fp->offset+fp->size-1) % SECSIZE);
(fp->offset+fp->size-1) % SECSIZE);
#endif
/*
......@@ -2184,24 +2214,22 @@ applyfixups(off_t offset, off_t size, void *data)
*/
if (fp->offset+fp->size > offset+size) {
assert(fp->reloctype == RELOC_NONE);
coff = (u_int32_t)(fp->offset - offset);
coff = (uint64_t)(fp->offset - offset);
clen = (offset + size) - fp->offset;
} else {
coff = (u_int32_t)(fp->offset - offset);
clen = (u_int32_t)fp->size;
coff = (uint64_t)(fp->offset - offset);
clen = (uint64_t)fp->size;
}
assert(offset+coff == fp->offset);
assert(offset+coff+clen <= fp->offset+fp->size);
if (debug >