From owner-svn-src-all@freebsd.org Fri Jan 8 16:37:24 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 54A2DA687A1; Fri, 8 Jan 2016 16:37:24 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 088981EA7; Fri, 8 Jan 2016 16:37:23 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u08GbNse002550; Fri, 8 Jan 2016 16:37:23 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u08GbM7S002548; Fri, 8 Jan 2016 16:37:22 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201601081637.u08GbM7S002548@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 8 Jan 2016 16:37:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r293425 - head/sys/boot/efi/boot1 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2016 16:37:24 -0000 Author: emaste Date: Fri Jan 8 16:37:22 2016 New Revision: 293425 URL: https://svnweb.freebsd.org/changeset/base/293425 Log: Add safety belt for boot1.efi file size Reviewed by: smh Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D4833 Modified: head/sys/boot/efi/boot1/Makefile head/sys/boot/efi/boot1/generate-fat.sh Modified: head/sys/boot/efi/boot1/Makefile ============================================================================== --- head/sys/boot/efi/boot1/Makefile Fri Jan 8 16:25:11 2016 (r293424) +++ head/sys/boot/efi/boot1/Makefile Fri Jan 8 16:37:22 2016 (r293425) @@ -79,8 +79,15 @@ boot1.o: ${.CURDIR}/../../common/ufsread # created by generate-fat.sh .include "${.CURDIR}/Makefile.fat" +BOOT1_MAXSIZE?= 131072 boot1.efifat: boot1.efi + @set -- `ls -l boot1.efi`; \ + x=$$(($$5-${BOOT1_MAXSIZE})); \ + if [ $$x -ge 0 ]; then \ + echo "boot1 $$x bytes too large; regenerate FAT templates?" >&2 ;\ + exit 1; \ + fi echo ${.OBJDIR} uudecode ${.CURDIR}/fat-${MACHINE}.tmpl.bz2.uu mv fat-${MACHINE}.tmpl.bz2 ${.TARGET}.bz2 Modified: head/sys/boot/efi/boot1/generate-fat.sh ============================================================================== --- head/sys/boot/efi/boot1/generate-fat.sh Fri Jan 8 16:25:11 2016 (r293424) +++ head/sys/boot/efi/boot1/generate-fat.sh Fri Jan 8 16:37:22 2016 (r293425) @@ -55,9 +55,20 @@ BOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'B # Convert to number of blocks BOOT1_OFFSET=$(echo 0x$BOOT1_OFFSET | awk '{printf("%x\n",$1/512);}') +# Record maximum boot1 size in bytes +case $BOOT1_SIZE in +*k) + BOOT1_MAXSIZE=$(expr ${BOOT1_SIZE%k} '*' 1024) + ;; +*) + BOOT1_MAXSIZE=$BOOT1_SIZE + ;; +esac + echo '# This file autogenerated by generate-fat.sh - DO NOT EDIT' > Makefile.fat echo '# $FreeBSD$' >> Makefile.fat echo "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.fat +echo "BOOT1_MAXSIZE=$BOOT1_MAXSIZE" >> Makefile.fat bzip2 $OUTPUT_FILE echo 'FAT template boot filesystem created by generate-fat.sh' > $OUTPUT_FILE.bz2.uu