safestringlib: add recipe
PATCH 1/2 safestringlib: add recipe
The Secure Development Lifecycle (SDL) recommends banning certain C Library functions because they directly contribute to security vulnerabilities such as buffer overflows.
However routines for the manipulation of strings and memory buffers are common in software and firmware, and are essential to accomplish certain programming tasks.
Safer replacements for these functions that avoid or prevent serious security vulnerabilities (e.g. buffer overflows, string format attacks, conversion overflows/underflows, etc.) are available in the SafeString Library.
Ref:
https://github.com/intel/safestringlib
--- .../safestringlib/safestringlib_git.bb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 meta-oe/recipes-support/safestringlib/safestringlib_git.bb
meta-oe/recipes-support/safestringlib/safestringlib_git.bb new file +26 -0
@@ -0,0 +1,26 @@ +SUMMARY = "Safe string operations and memory routines" +SECTION = "libs" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://LICENSE©ING.txt;md5=edd6f8c4c1072d72645ae28cb04bdbce \ + file://LICENSE;md5=54f68ba2c33474320fcc46b1f2d01249" + +SRC_URI = "git://github.com/intel/safestringlib.git;protocol=https \ + " + +PV = "1.0.0+git${SRCPV}" +SRCREV = "245c4b8cff1d2e7338b7f3a82828fc8e72b29549" + +S = "${WORKDIR}/git" + +inherit pkgconfig cmake + +do_install() { + install -d ${D}${libdir} + install -d ${D}${includedir} + install -m 0644 ${B}/libsafestring_shared.so ${D}${libdir} + install -m 0644 ${B}/libsafestring_static.a ${D}${libdir} + install -m 0644 ${S}/include/*.h ${D}${includedir} +} + +SOLIBS = ".so" +FILES_SOLIBSDEV = ""
Signature · 1 line
2.17.1
PATCH 2/2 safestringlib: add ptest
--- .../safestringlib/enable-logs-for-ptest.patch | 28 +++++++++++++++++ .../exclude-test-wmemmove-s-ptest.patch | 30 +++++++++++++++++++ .../safestringlib/safestringlib/run-ptest | 10 +++++++ .../safestringlib/safestringlib_git.bb | 13 +++++++- 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-support/safestringlib/safestringlib/enable-logs-for-ptest.patch create mode 100644 meta-oe/recipes-support/safestringlib/safestringlib/exclude-test-wmemmove-s-ptest.patch create mode 100755 meta-oe/recipes-support/safestringlib/safestringlib/run-ptest
meta-oe/recipes-support/safestringlib/safestringlib/enable-logs-for-ptest.patch new file +28 -0
@@ -0,0 +1,28 @@ +From 0375758a2225394bcf766e3d5c3611c44ea967f7 Mon Sep 17 00:00:00 2001 +From: Naveen Saini <[email protected]> +Date: Thu, 9 Jul 2020 13:12:05 +0800 +Subject: [PATCH] unittests/CMakeLists.txt: define DEBUG for logs + +Required for ptest testcase. + +Upstream-Status: Inappropriate + +Signed-off-by: Naveen Saini <[email protected]> +--- + unittests/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt +index 88cd835..9b285b2 100644 +--- a/unittests/CMakeLists.txt ++++ b/unittests/CMakeLists.txt +@@ -1,5 +1,6 @@ + cmake_minimum_required(VERSION 3.1) + project(safestring_test) ++add_compile_definitions(DEBUG) + + set(SOURCES + Safe_String_UnitTestMain.c +-- +2.17.1 +
meta-oe/recipes-support/safestringlib/safestringlib/exclude-test-wmemmove-s-ptest.patch new file +30 -0
@@ -0,0 +1,30 @@ +From 669ac8ccbf7259239ccfd3f2a4a6e53a3c69ad09 Mon Sep 17 00:00:00 2001 +From: Naveen Saini <[email protected]> +Date: Wed, 8 Jul 2020 17:47:20 +0800 +Subject: [PATCH] unittests/Safe_String_UnitTestMain.c: exclude test_wmemmove_s + +test_wmemmove_s cause segmentation fault, exclude it for now + +Upstream-Status: Inappropriate + +Signed-off-by: Naveen Saini <[email protected]> +--- + unittests/Safe_String_UnitTestMain.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/unittests/Safe_String_UnitTestMain.c b/unittests/Safe_String_UnitTestMain.c +index fa40511..e4b7e31 100644 +--- a/unittests/Safe_String_UnitTestMain.c ++++ b/unittests/Safe_String_UnitTestMain.c +@@ -159,7 +159,7 @@ int main(void) { + test_wcsncpy_s(); /* New - Done */ + test_wcsnlen_s(); /* New - Done */ + test_wmemcpy_s(); /* New - Done */ +- test_wmemmove_s(); /* New - Done */ ++// test_wmemmove_s(); /* New - Done */ + test_wmemset_s(); /* New - Done */ + test_wmemcmp_s(); /* New - Done */ + +-- +2.17.1 +
meta-oe/recipes-support/safestringlib/safestringlib/run-ptest new file +10 -0
@@ -0,0 +1,10 @@ +#!/bin/sh + +cd unittests +TOTALFAILS=$(./safestring_test | grep Error | wc -l) +if [ $TOTALFAILS -eq 0 ]; then + echo "PASS: safestring test" +else + echo "FAIL: safestring test" + echo "Total Saftstring tests failed: $TOTALFAILS" +fi
meta-oe/recipes-support/safestringlib/safestringlib_git.bb +12 -1
@@ -5,6 +5,9 @@ LIC_FILES_CHKSUM = "file://LICENSE©ING.txt;md5=edd6f8c4c1072d72645ae28cb04bd file://LICENSE;md5=54f68ba2c33474320fcc46b1f2d01249" SRC_URI = "git://github.com/intel/safestringlib.git;protocol=https \ + file://exclude-test-wmemmove-s-ptest.patch \ + file://enable-logs-for-ptest.patch \ + file://run-ptest \ " PV = "1.0.0+git${SRCPV}"
@@ -12,8 +15,11 @@ SRCREV = "245c4b8cff1d2e7338b7f3a82828fc8e72b29549" S = "${WORKDIR}/git" -inherit pkgconfig cmake +inherit pkgconfig cmake ptest +EXTRA_OECMAKE += " \ + ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '-DBUILD_UNITTESTS=ON', '', d)} \ + " do_install() { install -d ${D}${libdir} install -d ${D}${includedir}
@@ -22,5 +28,10 @@ do_install() { install -m 0644 ${S}/include/*.h ${D}${includedir} } +do_install_ptest () { + install -d ${D}${PTEST_PATH}/unittests + install -m 0755 ${B}/unittests/safestring_test ${D}${PTEST_PATH}/unittests +} + SOLIBS = ".so" FILES_SOLIBSDEV = ""
Signature · 1 line
2.17.1
Quoted 8 lines · Naveen Saini
The Secure Development Lifecycle (SDL) recommends banning certain C Library functions because they directly contribute to security vulnerabilities such as buffer overflows.
However routines for the manipulation of strings and memory buffers are common in software and firmware, and are essential to accomplish certain programming tasks.
Quoted 6 lines
Safer replacements for these functions that avoid or prevent serious security vulnerabilities (e.g. buffer overflows, string format attacks, conversion overflows/underflows, etc.) are available in the SafeString Library.
We also carry recipe for safec https://github.com/rurban/safeclib
is this a replacement in some sense ?
Quoted 43 lines
Signed-off-by Naveen Saini <[email protected]>--- .../safestringlib/safestringlib_git.bb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+)create mode 100644 meta-oe/recipes-support/safestringlib/safestringlib_git.bb
meta-oe/recipes-support/safestringlib/safestringlib_git.bb new file +26
-0@@ -0,0 +1,26 @@ +SUMMARY = "Safe string operations and memory routines" +SECTION = "libs" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://LICENSE©ING.txt;md5=edd6f8c4c1072d72645ae28cb04bdbce \ + file://LICENSE;md5=54f68ba2c33474320fcc46b1f2d01249" + +SRC_URI = "git://github.com/intel/safestringlib.git;protocol=https \ + " + +PV = "1.0.0+git${SRCPV}" +SRCREV = "245c4b8cff1d2e7338b7f3a82828fc8e72b29549" + +S = "${WORKDIR}/git" + +inherit pkgconfig cmake + +do_install() { + install -d ${D}${libdir} + install -d ${D}${includedir} + install -m 0644 ${B}/libsafestring_shared.so ${D}${libdir} + install -m 0644 ${B}/libsafestring_static.a ${D}${libdir} + install -m 0644 ${S}/include/*.h ${D}${includedir} +} + +SOLIBS = ".so" +FILES_SOLIBSDEV = ""
fails to compile on non-x86 targets
https://errors.yoctoproject.org/Errors/Details/420545/
https://errors.yoctoproject.org/Errors/Details/420538/
https://errors.yoctoproject.org/Errors/Details/420536/
Quoted 65 lines · Khem Raj
Quoted 8 lines · Naveen Saini
The Secure Development Lifecycle (SDL) recommends banning certain C Library functions because they directly contribute to security vulnerabilities such as buffer overflows.
However routines for the manipulation of strings and memory buffers are common in software and firmware, and are essential to accomplish certain programming tasks.
Quoted 6 lines
Safer replacements for these functions that avoid or prevent serious security vulnerabilities (e.g. buffer overflows, string format attacks, conversion overflows/underflows, etc.) are available in the SafeString Library.
We also carry recipe for safec https://github.com/rurban/safeclib
is this a replacement in some sense ?Quoted 43 lines
Signed-off-by Naveen Saini <[email protected]>--- .../safestringlib/safestringlib_git.bb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+)create mode 100644 meta-oe/recipes-support/safestringlib/safestringlib_git.bb
meta-oe/recipes-support/safestringlib/safestringlib_git.bb new file +26
-0@@ -0,0 +1,26 @@ +SUMMARY = "Safe string operations and memory routines" +SECTION = "libs" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://LICENSE©ING.txt;md5=edd6f8c4c1072d72645ae28cb04bdbce \ + file://LICENSE;md5=54f68ba2c33474320fcc46b1f2d01249" + +SRC_URI = "git://github.com/intel/safestringlib.git;protocol=https \ + " + +PV = "1.0.0+git${SRCPV}" +SRCREV = "245c4b8cff1d2e7338b7f3a82828fc8e72b29549" + +S = "${WORKDIR}/git" + +inherit pkgconfig cmake + +do_install() { + install -d ${D}${libdir} + install -d ${D}${includedir} + install -m 0644 ${B}/libsafestring_shared.so ${D}${libdir} + install -m 0644 ${B}/libsafestring_static.a ${D}${libdir} + install -m 0644 ${S}/include/*.h ${D}${includedir} +} + +SOLIBS = ".so" +FILES_SOLIBSDEV = ""