Commit 2b0bf990 authored by Mike Hibler's avatar Mike Hibler

In imagezip, look for overlap in DOS partitions and fail if detected.

This is a brute-force hack.  We fail on ANY overlap even though some overlaps
(e.g., with unused partitions) could be handled.  But handling those is a lot
of work for little gain.

Also: removed one last reference to SHD.
parent aa34b74d
......@@ -11,8 +11,8 @@ SUBDIR = os/imagezip
DISTFILES = global.h imagehdr.h queue.h sliceinfo.h \
imagedump.c imagedump.8 imagezip.c imagezip.8 \
imageunzip.c crc.c disksize.c imageunzip.8 \
extfs/*.[hc] ext4fs/*.[hc] fat/*.[hc] ffs/*.[hc] ntfs/*.[hc] shd/*.[hc] \
hashmap/*.[hc]
extfs/*.[hc] ext4fs/*.[hc] fat/*.[hc] ffs/*.[hc] \
ntfs/*.[hc] hashmap/*.[hc]
EXPANDCOPYRIGHT = /usr/site/lib/copyright/expand-copyr
......@@ -182,7 +182,7 @@ imagehash: imagehash.o version.o
imagehash.o: imagehash.c
$(CC) -c $(HASHCFLAGS) -o imagehash.o $<
ffs extfs ext4fs ntfs fat shd hashmap:
$(SUBDIRS):
@$(MAKE) SUBDIRCFLAGS="$(SUBDIRCFLAGS)" -C $@ all
imagezip.o: sliceinfo.h imagehdr.h global.h
......@@ -231,4 +231,4 @@ imagezip.tar: Makefile.sa Makefile-linux.sa
tar cf imagezip.tar imagezip-dist
rm -rf imagezip-dist
.PHONY: $(SUBDIRS)
.PHONY: $(SUBDIRS)
......@@ -686,9 +686,9 @@ read_doslabel(int infd, int lsect, int pstart, struct doslabel *label)
fprintf(stderr, " P%d: ", bsdix + 1);
smap = getslicemap(label->parts[i].dp_typ);
if (smap == 0)
fprintf(stderr, "%-10s", "UNKNOWN");
fprintf(stderr, "%-12s", "UNKNOWN");
else
fprintf(stderr, "%-10s", smap->desc);
fprintf(stderr, "%-12s", smap->desc);
start = label->parts[i].dp_start;
#if 0
......@@ -720,6 +720,35 @@ read_image(u_int32_t bbstart, int pstart, u_int32_t extstart)
if (read_doslabel(infd, bbstart, pstart, &doslabel) != 0)
return 1;
/*
* Quick, brute-force check for overlap of partitions.
* XXX right now, any overlap is bad and we bail. In the future,
* we could determine all areas of intersection and be conservative
* with those areas; i.e., always save unless overlap is strictly
* between unused/ignored partitions.
*/
for (i = 0; i < NDOSPART-1; i++) {
u_int32_t start1, size1, start2, size2;
int i2;
if ((size1 = doslabel.parts[i].dp_size) == 0)
continue;
start1 = bbstart + doslabel.parts[i].dp_start;
for (i2 = i+1; i2 < NDOSPART; i2++) {
if ((size2 = doslabel.parts[i2].dp_size) == 0)
continue;
start2 = bbstart + doslabel.parts[i2].dp_start;
if (start2+size2 > start1 &&
start1+size1 > start2) {
warnx("P%d and P%d overlap!", i+1, i2+1);
rval++;
}
}
}
if (rval)
return 1;
/*
* Now operate on individual slices.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment