Package: osmo-bsc Version: 1.3.0-3 Severity: normal Tags: patch User: ubuntu-de...@lists.ubuntu.com Usertags: origin-ubuntu hirsute ubuntu-patch
Dear maintainers, As in bug #976866, osmo-bsc is failing to build fro source on s390x in Ubuntu, because the compiler detects that certain pointer dereferences may be acting on a null pointer: [...] In file included from /usr/include/osmocom/core/msgb.h:24, from /usr/include/osmocom/gsm/tlv.h:6, from /usr/include/osmocom/gsm/gsm48.h:7, from bsc_subscriber.c:29: bsc_subscriber.c: In function ‘bsc_subscr_find_or_create_by_imsi’: bsc_subscriber.c:132:18: error: potential null pointer dereference [-Werror=null-dereference] 132 | OSMO_ASSERT(bsub->use_count < INT_MAX); | ~~~~^~~~~~~~~~~ cc1: some warnings being treated as errors [...] (https://launchpad.net/ubuntu/+source/osmo-bsc/1.3.0-3/+build/20177922) I haven't looked into why this build failure doesn't happen on other archs, or why it wasn't seen on s390x in Debian; but I've confirmed that the compiler's errors are correct. In addition, while investigating this I found some errors from the compiler due to possible snprintf truncation. As far as I can see the right solution here is to suppress that error. The attached patch avoids the possible null-pointer dereferences and lets the package build. Thanks for considering, -- Steve Langasek Give me a lever long enough and a Free OS Debian Developer to set it on, and I can move the world. Ubuntu Developer https://www.debian.org/ slanga...@ubuntu.com vor...@debian.org
diff -Nru osmo-bsc-1.3.0/debian/patches/no-null-pointer-derefence.patch osmo-bsc-1.3.0/debian/patches/no-null-pointer-derefence.patch --- osmo-bsc-1.3.0/debian/patches/no-null-pointer-derefence.patch 1969-12-31 16:00:00.000000000 -0800 +++ osmo-bsc-1.3.0/debian/patches/no-null-pointer-derefence.patch 2020-12-08 13:15:17.000000000 -0800 @@ -0,0 +1,30 @@ +Description: avoid possible null dereferences + Detected by the compiler on Ubuntu s390x +Author: Steve Langasek <steve.langa...@ubuntu.com> +Last-Update: 2020-12-08 + +Index: osmo-bsc-1.3.0/include/osmocom/bsc/gsm_data.h +=================================================================== +--- osmo-bsc-1.3.0.orig/include/osmocom/bsc/gsm_data.h ++++ osmo-bsc-1.3.0/include/osmocom/bsc/gsm_data.h +@@ -1026,6 +1026,8 @@ + + static inline char *gsm_lchan_name(const struct gsm_lchan *lchan) + { ++ if (!lchan) ++ return NULL; + return lchan->name; + } + +Index: osmo-bsc-1.3.0/src/osmo-bsc/bsc_subscriber.c +=================================================================== +--- osmo-bsc-1.3.0.orig/src/osmo-bsc/bsc_subscriber.c ++++ osmo-bsc-1.3.0/src/osmo-bsc/bsc_subscriber.c +@@ -129,6 +129,7 @@ + struct bsc_subscr *_bsc_subscr_get(struct bsc_subscr *bsub, + const char *file, int line) + { ++ OSMO_ASSERT(bsub != NULL); + OSMO_ASSERT(bsub->use_count < INT_MAX); + bsub->use_count++; + LOGPSRC(DREF, LOGL_DEBUG, file, line, diff -Nru osmo-bsc-1.3.0/debian/patches/series osmo-bsc-1.3.0/debian/patches/series --- osmo-bsc-1.3.0/debian/patches/series 2020-08-09 10:28:26.000000000 -0700 +++ osmo-bsc-1.3.0/debian/patches/series 2020-12-08 12:59:17.000000000 -0800 @@ -2,3 +2,4 @@ 0002-Fix-one-struct-for-big-endian-archs.patch 0003-Hack-in-test-suite-at-the-right-place-to-make-it-pas.patch gcc10.patch +no-null-pointer-derefence.patch diff -Nru osmo-bsc-1.3.0/debian/rules osmo-bsc-1.3.0/debian/rules --- osmo-bsc-1.3.0/debian/rules 2018-11-15 12:41:35.000000000 -0800 +++ osmo-bsc-1.3.0/debian/rules 2020-12-08 13:08:39.000000000 -0800 @@ -6,6 +6,8 @@ CHANGELOG_DATE ?= $(shell LC_ALL=C date -u -d @$(SOURCE_DATE_EPOCH) +"%d %B %Y") +export DEB_CFLAGS_MAINT_APPEND = -Wno-format-truncation + export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed export DEB_BUILD_MAINT_OPTIONS = hardening=+all