From 6a5eaf58293348bd5347cb385fdecf1f1543e311 Mon Sep 17 00:00:00 2001 From: tsutsui Date: Fri, 17 Jul 2015 20:30:21 +0000 Subject: Fix botch in "make disklabel a MI tool" changes in rev 1.2. After that chanage, "MAXPARTITIONS" constant is not for the target port. If host's MAXPARTITIONS is larger than a value of the target label and target endianness is different from the build host, bswaplabel() could overwrite data beyond the disklabel and primary boot stored after LABELSECTOR in images might be corrupted. This fixes boot failure of sun2 liveimage built by "build.sh -U -m sun2 release live-image" on TME. Should be pulled up to netbsd-7. --- sbin/disklabel/bswap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sbin/disklabel') diff --git a/sbin/disklabel/bswap.c b/sbin/disklabel/bswap.c index 3b5a1c277b6..585beb5462d 100644 --- a/sbin/disklabel/bswap.c +++ b/sbin/disklabel/bswap.c @@ -1,4 +1,4 @@ -/* $NetBSD: bswap.c,v 1.2 2013/05/03 16:05:12 matt Exp $ */ +/* $NetBSD: bswap.c,v 1.3 2015/07/17 20:30:21 tsutsui Exp $ */ /*- * Copyright (c) 2009 Izumi Tsutsui. All rights reserved. @@ -120,7 +120,7 @@ bswaplabel(struct disklabel *nlp, const struct disklabel *olp) nlp->d_bbsize = bswap32(olp->d_bbsize); nlp->d_sbsize = bswap32(olp->d_sbsize); - for (i = 0; i < MAXPARTITIONS; i++) { + for (i = 0; i < maxpartitions; i++) { nlp->d_partitions[i].p_size = bswap32(olp->d_partitions[i].p_size); nlp->d_partitions[i].p_offset = -- cgit