ippool: Fix build errors found with hardening flags
PATCH v2 1/1 ippool: Fix build errors found with hardening flags
Fix build with musl
Signed-off-by Khem Raj <[email protected]>
Signed-off-by Martin Jansa <[email protected]>
---
v1 -> v2:
- Fix build on musl
- Respect env CPPFLAGS in makefiles
.../ippool/0001-Respect-flags-from-env.patch | 56 ++++ ...timer-Check-for-return-value-of-write-API.patch | 28 ++ .../ippool/ippool/0002-link-with-libtirpc.patch | 30 +++ .../ippool/ippool/0003-musl-fixes.patch | 283 +++++++++++++++++++++ .../recipes-daemons/ippool/ippool_1.3.bb | 31 ++- 5 files changed, 415 insertions(+), 13 deletions(-) create mode 100644 meta-networking/recipes-daemons/ippool/ippool/0001-Respect-flags-from-env.patch create mode 100644 meta-networking/recipes-daemons/ippool/ippool/0001-usl_timer-Check-for-return-value-of-write-API.patch create mode 100644 meta-networking/recipes-daemons/ippool/ippool/0002-link-with-libtirpc.patch create mode 100644 meta-networking/recipes-daemons/ippool/ippool/0003-musl-fixes.patch
meta-networking/recipes-daemons/ippool/ippool/0001-Respect-flags-from-env.patch new file +56 -0
@@ -0,0 +1,56 @@ +From 4848b9e4d516a9203c08432901a7b40419e8f43c Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Wed, 19 Jul 2017 15:54:35 -0700 +Subject: [PATCH 1/3] Respect flags from env + +Signed-off-by: Khem Raj <[email protected]> +--- + Makefile | 4 ++-- + cli/Makefile | 2 +- + pppd/Makefile | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Makefile b/Makefile +index a05a000..439a978 100644 +--- a/Makefile ++++ b/Makefile +@@ -81,8 +81,8 @@ LIBS.dmalloc= -ldmalloc + export USE_DMALLOC + endif + +-CPPFLAGS= $(CPPFLAGS.ippooltest) +-CFLAGS= -I. -Iusl -Icli -MMD -Wall -g $(CPPFLAGS) $(CPPFLAGS.dmalloc) ++CPPFLAGS+= $(CPPFLAGS.ippooltest) ++CFLAGS+= -I. -Iusl -Icli -MMD -Wall -g $(CPPFLAGS) $(CPPFLAGS.dmalloc) + LDFLAGS.ippoold= $(LDFLAGS) -Wl,-E -L. -Lusl -lusl -lnsl -ldl $(LIBS.dmalloc) -lc + LDFLAGS.ippoolconfig= $(LDFLAGS) -Lcli -lcli -lreadline -lcurses -lnsl $(LIBS.dmalloc) -lc + +diff --git a/cli/Makefile b/cli/Makefile +index 4b5dd59..56fbf2f 100644 +--- a/cli/Makefile ++++ b/cli/Makefile +@@ -7,7 +7,7 @@ CLI_SRCS_TEST.o= $(CLI_SRCS_TEST.c:%.c=%.o) + + LDFLAGS.cli_test= -L.. -L. $(READLINE_LDFLAGS) -lcli -lusl -lreadline -lcurses -lc + +-CFLAGS= $(CFLAGS.optimize) -MMD -Wall -Werror -I.. $(READLINE_CFLAGS) ++CFLAGS= $(CFLAGS.optimize) -MMD -Wall -Werror -I.. $(READLINE_CFLAGS) $(CPPFLAGS) + + .PHONY: all test clean + +diff --git a/pppd/Makefile b/pppd/Makefile +index 106deca..7fd815f 100644 +--- a/pppd/Makefile ++++ b/pppd/Makefile +@@ -10,7 +10,7 @@ endif + + # END CONFIGURABLE SETTINGS + +-CFLAGS += -g -I.. -I/usr/include/pppd $(CFLAGS.pppd) -fPIC ++CFLAGS += -g -I.. -I=/usr/include/pppd $(CFLAGS.pppd) -fPIC + LDFLAGS += -shared + + all: ippool.so +-- +2.13.3 +
meta-networking/recipes-daemons/ippool/ippool/0001-usl_timer-Check-for-return-value-of-write-API.patch new file +28 -0
@@ -0,0 +1,28 @@ +From 5d7f20c045b3c74dad2c53d65e30bd4840250082 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 27 Jun 2017 15:17:19 -0700 +Subject: [PATCH] usl_timer: Check for return value of write() API + +Signed-off-by: Khem Raj <[email protected]> +--- + usl/usl_timer.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/usl/usl_timer.c b/usl/usl_timer.c +index fda752b..d8414a6 100644 +--- a/usl/usl_timer.c ++++ b/usl/usl_timer.c +@@ -94,7 +94,9 @@ void usl_timer_tick(void) + + if (!usl_tick_pending) { + usl_tick_pending = 1; +- write(usl_tick_pipe[1], &msg, sizeof(msg)); ++ if (write(usl_tick_pipe[1], &msg, sizeof(msg)) != sizeof(msg)) { ++ fprintf(stderr, "write to fd %i failed: %s\n", usl_tick_pipe[1], strerror(errno)); ++ } + } + } + +-- +2.13.2 +
meta-networking/recipes-daemons/ippool/ippool/0002-link-with-libtirpc.patch new file +30 -0
@@ -0,0 +1,30 @@ +From 47aef26198431f7ad568c2277dded158bda3e36f Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Wed, 19 Jul 2017 16:00:35 -0700 +Subject: [PATCH 2/3] link with libtirpc + +musl needs it + +Signed-off-by: Khem Raj <[email protected]> +--- + Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 439a978..ea821eb 100644 +--- a/Makefile ++++ b/Makefile +@@ -83,8 +83,8 @@ endif + + CPPFLAGS+= $(CPPFLAGS.ippooltest) + CFLAGS+= -I. -Iusl -Icli -MMD -Wall -g $(CPPFLAGS) $(CPPFLAGS.dmalloc) +-LDFLAGS.ippoold= $(LDFLAGS) -Wl,-E -L. -Lusl -lusl -lnsl -ldl $(LIBS.dmalloc) -lc +-LDFLAGS.ippoolconfig= $(LDFLAGS) -Lcli -lcli -lreadline -lcurses -lnsl $(LIBS.dmalloc) -lc ++LDFLAGS.ippoold= $(LDFLAGS) -Wl,-E -L. -Lusl -lusl -ldl $(LIBS.dmalloc) -lc -ltirpc ++LDFLAGS.ippoolconfig= $(LDFLAGS) -Lcli -lcli -lreadline -lcurses $(LIBS.dmalloc) -lc -ltirpc + + OPT_CFLAGS?= -O + +-- +2.13.3 +
meta-networking/recipes-daemons/ippool/ippool/0003-musl-fixes.patch new file +283 -0
283 lines not on this page · raw message
meta-networking/recipes-daemons/ippool/ippool_1.3.bb +18 -13
@@ -11,16 +11,21 @@ HOMEPAGE = "http://www.openl2tp.org/" SECTION = "console/network" LICENSE = "GPLv2+" -SRC_URI = "\ - https://sourceforge.net/projects/openl2tp/files/${BPN}/${PV}/${BPN}-${PV}.tar.gz \ - file://ippool_usl_timer.patch \ - file://ippool_parallel_make_and_pic.patch \ - file://ippool_init.d.patch \ - file://always_syslog.patch \ - file://makefile-add-ldflags.patch \ - file://runtest.sh \ - file://ippool.service \ - " +SRC_URI = "https://sourceforge.net/projects/openl2tp/files/${BPN}/${PV}/${BPN}-${PV}.tar.gz \ + file://runtest.sh \ + file://ippool.service \ + file://ippool_usl_timer.patch \ + file://ippool_parallel_make_and_pic.patch \ + file://ippool_init.d.patch \ + file://always_syslog.patch \ + file://makefile-add-ldflags.patch \ + file://0001-usl_timer-Check-for-return-value-of-write-API.patch \ + file://0001-Respect-flags-from-env.patch \ +" +SRC_URI_append_libc-musl = "\ + file://0002-link-with-libtirpc.patch \ + file://0003-musl-fixes.patch \ + " LIC_FILES_CHKSUM = "file://LICENSE;md5=4c59283b82fc2b166455e0fc23c71c6f" SRC_URI[md5sum] = "e2401e65db26a3764585b97212888fae"
@@ -29,6 +34,7 @@ SRC_URI[sha256sum] = "d3eab7d6cad5da8ccc9d1e31d5303e27a39622c07bdb8fa3618eea3144 inherit systemd DEPENDS = "readline ppp ncurses gzip-native" +DEPENDS_append_libc-musl = " libtirpc" RDEPENDS_${PN} = "rpcbind" EXTRA_OEMAKE = "CC='${CC}' AS='${AS}' LD='${LD}' AR='${AR}' NM='${NM}' STRIP='${STRIP}'"
@@ -36,6 +42,8 @@ EXTRA_OEMAKE += "PPPD_VERSION=${PPPD_VERSION} SYS_LIBDIR=${libdir}" # enable self tests EXTRA_OEMAKE += "IPPOOL_TEST=y" +CPPFLAGS += "${SELECTED_OPTIMIZATION}" +CPPFLAGS_append_libc-musl = " -I${STAGING_INCDIR}/tirpc" SYSTEMD_SERVICE_${PN} = "ippool.service" SYSTEMD_AUTO_ENABLE = "disable"
@@ -48,9 +56,6 @@ do_compile_prepend() { sed -i -e "s:-I/usr/include/pppd:-I=/usr/include/pppd:" ${S}/pppd/Makefile - # ignore the OPT_CFLAGS?= in Makefile, - # it should be in CFLAGS from env - export OPT_CFLAGS= }
Signature · 1 line
2.13.3