667d792d6a
– possible integer overflows in memory allocation, mostly ‣ multiplication: all are checked now ‣ addition: reviewed them, most were “proven” or guessed to be “almost” impossible to run over (e.g. when we have a string whose length is taken it is assumed that the length will be more than only a few bytes below SIZE_MAX, since code and stack have to fit); some are checked now (e.g. when one of the summands is an off_t); most of the unchecked ones are annotated now ⇒ cost (MirBSD/i386 static): +76 .text ⇒ cost (Debian sid/i386): +779 .text -4 .data – on Linux targets, setuid() setresuid() setresgid() can fail with EAGAIN; check for that and, if so, warn once and retry infinitely (other targets to be added later once we know that they are “insane”) ⇒ cost (Debian sid/i386): +192 .text (includes .rodata) • setmode.c: Do overflow checking for realloc() too; switch back from calloc() to a checked malloc() for simplification while there • define -DIN_MKSH and let setmode.c look a tad nicer while here
87 lines
3.3 KiB
Makefile
87 lines
3.3 KiB
Makefile
# $MirOS: src/bin/mksh/Makefile,v 1.82 2010/09/14 21:26:05 tg Exp $
|
|
#-
|
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
|
# Thorsten Glaser <tg@mirbsd.org>
|
|
#
|
|
# Provided that these terms and disclaimer and all copyright notices
|
|
# are retained or reproduced in an accompanying document, permission
|
|
# is granted to deal in this work without restriction, including un-
|
|
# limited rights to use, publicly perform, distribute, sell, modify,
|
|
# merge, give away, or sublicence.
|
|
#
|
|
# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
|
|
# the utmost extent permitted by applicable law, neither express nor
|
|
# implied; without malicious intent or gross negligence. In no event
|
|
# may a licensor, author or contributor be held liable for indirect,
|
|
# direct, other damage, loss, or other issues arising in any way out
|
|
# of dealing in the work, even if advised of the possibility of such
|
|
# damage or existence of a defect, except proven that it results out
|
|
# of said person's immediate fault when using the work as intended.
|
|
#-
|
|
# use CPPFLAGS=-DDEBUG __CRAZY=Yes to check for certain more stuff
|
|
|
|
.include <bsd.own.mk>
|
|
|
|
PROG= mksh
|
|
SRCS= edit.c eval.c exec.c expr.c funcs.c histrap.c jobs.c \
|
|
lallo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ISTENT_HISTORY=1 -DIN_MKSH
|
|
COPTS+= -std=gnu99 -Wall
|
|
.endif
|
|
|
|
USE_PRINTF_BUILTIN?= 0
|
|
.if ${USE_PRINTF_BUILTIN} == 1
|
|
.PATH: ${BSDSRCDIR}/usr.bin/printf
|
|
SRCS+= printf.c
|
|
CPPFLAGS+= -DMKSH_PRINTF_BUILTIN
|
|
.endif
|
|
|
|
LINKS+= ${BINDIR}/${PROG} ${BINDIR}/sh
|
|
MLINKS+= ${PROG}.1 sh.1
|
|
|
|
regress: ${PROG} check.pl check.t
|
|
-rm -rf regress-dir
|
|
mkdir -p regress-dir
|
|
echo export FNORD=666 >regress-dir/.mkshrc
|
|
HOME=$$(realpath regress-dir) perl ${.CURDIR}/check.pl \
|
|
-s ${.CURDIR}/check.t -v -p ./${PROG}
|
|
|
|
test-build: .PHONY
|
|
-rm -rf build-dir
|
|
mkdir -p build-dir
|
|
cd build-dir; env CC=${CC:Q} CFLAGS=${CFLAGS:M*:Q} \
|
|
CPPFLAGS=${CPPFLAGS:M*:Q} LDFLAGS=${LDFLAGS:M*:Q} \
|
|
LIBS= NOWARN=-Wno-error TARGET_OS= CPP= /bin/sh \
|
|
${.CURDIR}/Build.sh -Q -r && ./test.sh -v
|
|
|
|
cleandir: clean-extra
|
|
|
|
clean-extra: .PHONY
|
|
-rm -rf build-dir regress-dir printf.o printf.ln
|
|
|
|
distribution:
|
|
sed 's!\$$I''d\([:$$]\)!$$M''irSecuCron\1!g' \
|
|
${.CURDIR}/dot.mkshrc >${DESTDIR}/etc/skel/.mkshrc
|
|
chown ${BINOWN}:${CONFGRP} ${DESTDIR}/etc/skel/.mkshrc
|
|
chmod 0644 ${DESTDIR}/etc/skel/.mkshrc
|
|
|
|
.include <bsd.prog.mk>
|