I just saw this on oss-security,

https://github.com/EnableSecurity/advisories/tree/master/ES2018-05-kamailio-heap-overflow

The release containing the fix has been out for a couple of weeks but
the advisory is new. It's getting late for OpenBSD release but I think
this one is worth fixing if it can be tested soon.

The patch itself is a one-liner but this is the 'old stable' branch
and only getting bugfixes so I think updating to the newest on that
branch makes sense.

I've dropped the CFLAGS patches for gcc on amd64/i386 because they're
no longer needed and were conflicting. Also dropped some libressl
patches that no longer make sense. (The arc4random patches could
be dropped too because rand/random use arc4random anyway in normal
use on recent OpenBSD, but that's a bigger change than I'd like to
make now).

Roman, could you test please?  OK?

Index: Makefile
===================================================================
RCS file: /cvs/ports/telephony/kamailio/Makefile,v
retrieving revision 1.43
diff -u -p -r1.43 Makefile
--- Makefile    11 Jan 2018 19:27:11 -0000      1.43
+++ Makefile    20 Mar 2018 12:06:18 -0000
@@ -2,7 +2,7 @@
 
 COMMENT-main =         mature and flexible open source SIP server
 
-VERSION =              5.0.3
+VERSION =              5.0.6
 
 DISTNAME =             kamailio-${VERSION}_src
 
@@ -17,7 +17,6 @@ PKGNAME-snmpstats =   kamailio-snmpstats-$
 PKGNAME-perl =         kamailio-perl-${VERSION}
 PKGNAME-presence =     kamailio-presence-${VERSION}
 PKGNAME-radius =       kamailio-radius-${VERSION}
-REVISION-main =                0
 
 CATEGORIES =           telephony
 MAINTAINER =           Roman Kravchuk <[email protected]>
@@ -40,7 +39,7 @@ MASTER_SITES =                http://www.kamailio.org/
 WRKDIST =              ${WRKDIR}/kamailio-${VERSION}
 
 WANTLIB-main =         c crypto curl expat event_core event_extra iconv m \
-                       pcre pthread ssl lzma xml2 ncurses readline unistring z
+                       pcre pthread ssl lzma xml2 curses readline unistring z
 
 LIB_DEPENDS-main =     converters/libiconv \
                        converters/libunistring \
Index: distinfo
===================================================================
RCS file: /cvs/ports/telephony/kamailio/distinfo,v
retrieving revision 1.9
diff -u -p -r1.9 distinfo
--- distinfo    21 Sep 2017 09:34:32 -0000      1.9
+++ distinfo    20 Mar 2018 12:06:18 -0000
@@ -1,2 +1,2 @@
-SHA256 (kamailio-5.0.3_src.tar.gz) = 
+nX3Oh1AxLorMy3mqk/pqqUxZ5NMb6rfoEJH0tMLVwo=
-SIZE (kamailio-5.0.3_src.tar.gz) = 11678360
+SHA256 (kamailio-5.0.6_src.tar.gz) = 
yhYma1WYZtWMa3fyNfvPXwcfYnSSwo8z7PWY5B2V1Co=
+SIZE (kamailio-5.0.6_src.tar.gz) = 11724268
Index: patches/patch-src_Makefile_defs
===================================================================
RCS file: /cvs/ports/telephony/kamailio/patches/patch-src_Makefile_defs,v
retrieving revision 1.2
diff -u -p -r1.2 patch-src_Makefile_defs
--- patches/patch-src_Makefile_defs     21 Sep 2017 09:34:32 -0000      1.2
+++ patches/patch-src_Makefile_defs     20 Mar 2018 12:06:18 -0000
@@ -2,7 +2,7 @@ $OpenBSD: patch-src_Makefile_defs,v 1.2 
 Index: src/Makefile.defs
 --- src/Makefile.defs.orig
 +++ src/Makefile.defs
-@@ -316,9 +316,9 @@ ppc_macros= __powerpc __powerpc__ __POWERPC__ __ppc__ 
+@@ -318,9 +318,9 @@ ppc_macros= __powerpc __powerpc__ __POWERPC__ __ppc__ 
  ppc64_macros= __ppc64__ _ARCH_PPC64
  
  mips_macros= __mips__ __mips _MIPS_ARCH_MIPS1
@@ -14,27 +14,7 @@ Index: src/Makefile.defs
  
  alpha_macros= __alpha__ __alpha _M_ALPHA_
  
-@@ -879,16 +879,12 @@ ifeq     ($(ARCH), i386)
- ifeq          ($(CC_NAME), gcc)
-                               C_DEFS+=-DCC_GCC_LIKE_ASM
-                               #common stuff
--                              CFLAGS=-g $(CC_OPT) -funroll-loops  
-Wcast-align $(PROFILE)
-+                              CFLAGS=
-                       #if gcc 6.0+, 5.0+, 4.5+ or 4.2+
- ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+,$(CC_SHORTVER))))
- $(call                                set_if_empty,CPUTYPE,athlon64)
--                                      CFLAGS+=-m32 -minline-all-stringops \
--                                                      -falign-loops \
--                                                      -ftree-vectorize \
--                                                      -fno-strict-overflow \
--                                                      -mtune=$(CPUTYPE)
--                                      LDFLAGS+=-m32
-+                                      CFLAGS+=
-+                                      LDFLAGS+=
- else
-                       #if gcc 4.0+
- ifeq                  ($(CC_SHORTVER), 4.x)
-@@ -936,8 +932,8 @@ else               # CC_NAME, gcc
+@@ -938,8 +938,8 @@ else               # CC_NAME, gcc
  ifeq          ($(CC_NAME), clang)
  $(call                          set_if_empty,CPUTYPE,athlon64)
                                        C_DEFS+=-DCC_GCC_LIKE_ASM
@@ -45,31 +25,7 @@ Index: src/Makefile.defs
  else                  # CC_NAME, clang
  ifeq          ($(CC_NAME), icc)
                        C_DEFS+=-DCC_GCC_LIKE_ASM
-@@ -961,7 +957,7 @@ ifeq       ($(ARCH), x86_64)
- ifeq          ($(CC_NAME), gcc)
-                               C_DEFS+=-DCC_GCC_LIKE_ASM
-                               #common stuff
--                              CFLAGS=-g $(CC_OPT) -funroll-loops  
-Wcast-align $(PROFILE)
-+                              CFLAGS=
-                       #if gcc 4.5+
-                       # don't add '-mtune=$(CPUTYPE)' - gcc failure
- ifeq                  ($(CC_SHORTVER),$(filter $(CC_SHORTVER),4.5+ 5.0+ 6.0+))
-@@ -975,12 +971,8 @@ else
-                       #if gcc 4.2+
- ifeq                  ($(CC_SHORTVER), 4.2+)
- $(call                                set_if_empty,CPUTYPE,opteron)
--                                      CFLAGS+=-m64 -minline-all-stringops \
--                                                      -falign-loops \
--                                                      -ftree-vectorize \
--                                                      -fno-strict-overflow \
--                                                      -mtune=$(CPUTYPE)
--                                      LDFLAGS+=-m64
-+                                      CFLAGS+=
-+                                      LDFLAGS+=
- else
-                       #if gcc 4.0+
- ifeq                  ($(CC_SHORTVER), 4.x)
-@@ -1029,9 +1021,8 @@ else             # CC_NAME, gcc
+@@ -1031,9 +1031,8 @@ else             # CC_NAME, gcc
  ifeq            ($(CC_NAME), clang)
  $(call                          set_if_empty,CPUTYPE,opteron)
                                        C_DEFS+=-DCC_GCC_LIKE_ASM
Index: patches/patch-src_core_core_cmd_c
===================================================================
RCS file: patches/patch-src_core_core_cmd_c
diff -N patches/patch-src_core_core_cmd_c
--- patches/patch-src_core_core_cmd_c   21 Sep 2017 09:34:32 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-$OpenBSD: patch-src_core_core_cmd_c,v 1.1 2017/09/21 09:34:32 sthen Exp $
-
-Index: src/core/core_cmd.c
---- src/core/core_cmd.c.orig
-+++ src/core/core_cmd.c
-@@ -943,7 +943,7 @@ static void core_sockets_list(rpc_t* rpc, void* c)
-                               rpc->struct_add(ha, "ss",
-                                               "proto", get_proto_name(proto),
-                                               "address", si->name.s);
--                              if (!si->flags & SI_IS_IP)
-+                              if (!(si->flags & SI_IS_IP))
-                                       rpc->struct_add(ha, "s",
-                                               "ipaddress", si->address_str.s);
-                               rpc->struct_add(ha, "sss",
Index: patches/patch-src_core_pt_c
===================================================================
RCS file: /cvs/ports/telephony/kamailio/patches/patch-src_core_pt_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-src_core_pt_c
--- patches/patch-src_core_pt_c 21 Sep 2017 09:34:32 -0000      1.2
+++ patches/patch-src_core_pt_c 20 Mar 2018 12:06:18 -0000
@@ -2,7 +2,7 @@ $OpenBSD: patch-src_core_pt_c,v 1.2 2017
 Index: src/core/pt.c
 --- src/core/pt.c.orig
 +++ src/core/pt.c
-@@ -249,8 +249,10 @@ int fork_process(int child_id, char *desc, int make_so
+@@ -255,8 +255,10 @@ int fork_process(int child_id, char *desc, int make_so
  {
        int pid, child_process_no;
        int ret;
@@ -13,7 +13,7 @@ Index: src/core/pt.c
  #ifdef USE_TCP
        int sockfd[2];
  #endif
-@@ -289,8 +291,10 @@ int fork_process(int child_id, char *desc, int make_so
+@@ -295,8 +297,10 @@ int fork_process(int child_id, char *desc, int make_so
        }
  
        child_process_no = *process_count;
@@ -24,7 +24,7 @@ Index: src/core/pt.c
        pid = fork();
        if (pid<0) {
                lock_release(process_lock);
-@@ -305,9 +309,11 @@ int fork_process(int child_id, char *desc, int make_so
+@@ -311,9 +315,11 @@ int fork_process(int child_id, char *desc, int make_so
  #ifdef USE_TCP
                close_extra_socks(child_id, process_no);
  #endif /* USE_TCP */
@@ -36,7 +36,7 @@ Index: src/core/pt.c
                shm_malloc_on_fork();
  #ifdef PROFILING
                monstartup((u_long) &_start, (u_long) &etext);
-@@ -384,8 +390,10 @@ int fork_tcp_process(int child_id, char *desc, int r, 
+@@ -390,8 +396,10 @@ int fork_tcp_process(int child_id, char *desc, int r, 
        int reader_fd[2]; /* for comm. with the tcp children read  */
        int ret;
        int i;
@@ -47,7 +47,7 @@ Index: src/core/pt.c
  
        /* init */
        sockfd[0]=sockfd[1]=-1;
-@@ -423,8 +431,10 @@ int fork_tcp_process(int child_id, char *desc, int r, 
+@@ -429,8 +437,10 @@ int fork_tcp_process(int child_id, char *desc, int r, 
        }
  
        child_process_no = *process_count;
@@ -58,7 +58,7 @@ Index: src/core/pt.c
        pid = fork();
        if (pid<0) {
                lock_release(process_lock);
-@@ -446,9 +456,11 @@ int fork_tcp_process(int child_id, char *desc, int r, 
+@@ -452,9 +462,11 @@ int fork_tcp_process(int child_id, char *desc, int r, 
                        }
                }
                daemon_status_on_fork_cleanup();
Index: patches/patch-src_core_socket_info_c
===================================================================
RCS file: patches/patch-src_core_socket_info_c
diff -N patches/patch-src_core_socket_info_c
--- patches/patch-src_core_socket_info_c        21 Sep 2017 09:34:32 -0000      
1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-$OpenBSD: patch-src_core_socket_info_c,v 1.1 2017/09/21 09:34:32 sthen Exp $
-
-Index: src/core/socket_info.c
---- src/core/socket_info.c.orig
-+++ src/core/socket_info.c
-@@ -1912,7 +1912,7 @@ void print_all_socket_lists()
-                               printf("             %s: %s",
-                                               get_valid_proto_name(proto),
-                                               si->name.s);
--                              if (!si->flags & SI_IS_IP)
-+                              if (!(si->flags & SI_IS_IP))
-                                       printf(" [%s]", si->address_str.s);
-                               printf( ":%s%s%s",
-                                               si->port_no_str.s, 
Index: patches/patch-src_core_tcp_read_c
===================================================================
RCS file: /cvs/ports/telephony/kamailio/patches/patch-src_core_tcp_read_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-src_core_tcp_read_c
--- patches/patch-src_core_tcp_read_c   21 Sep 2017 09:34:32 -0000      1.2
+++ patches/patch-src_core_tcp_read_c   20 Mar 2018 12:06:18 -0000
@@ -3,7 +3,7 @@ $OpenBSD: patch-src_core_tcp_read_c,v 1.
 Index: src/core/tcp_read.c
 --- src/core/tcp_read.c.orig
 +++ src/core/tcp_read.c
-@@ -1503,6 +1503,14 @@ void release_tcpconn(struct tcp_connection* c, long st
+@@ -1530,6 +1530,14 @@ void release_tcpconn(struct tcp_connection* c, long st
                                ip_addr2a(&c->rcv.src_ip), c->rcv.src_port,
                                ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port);
                LM_DBG("extra_data %p\n", c->extra_data);
Index: patches/patch-src_modules_auth_identity_auth_crypt_c
===================================================================
RCS file: patches/patch-src_modules_auth_identity_auth_crypt_c
diff -N patches/patch-src_modules_auth_identity_auth_crypt_c
--- patches/patch-src_modules_auth_identity_auth_crypt_c        3 Jul 2017 
22:14:20 -0000       1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-$OpenBSD: patch-src_modules_auth_identity_auth_crypt_c,v 1.1 2017/07/03 
22:14:20 sthen Exp $
-
-Index: src/modules/auth_identity/auth_crypt.c
---- src/modules/auth_identity/auth_crypt.c.orig
-+++ src/modules/auth_identity/auth_crypt.c
-@@ -114,7 +114,7 @@ int check_x509_subj(X509 *pcert, str* sdom)
- 
-                       if (actname->type == GEN_DNS || actname->type == 
GEN_URI) {
-                               /* we've found one */
--#if OPENSSL_VERSION_NUMBER >= 0x010100000L
-+#if OPENSSL_VERSION_NUMBER >= 0x010100000L && 
!defined(LIBRESSL_VERSION_NUMBER)
-                               altptr = (char 
*)ASN1_STRING_get0_data(actname->d.ia5);
- #else
-                               altptr = (char 
*)ASN1_STRING_data(actname->d.ia5);
Index: patches/patch-src_modules_db_mysql_my_cmd_c
===================================================================
RCS file: 
/cvs/ports/telephony/kamailio/patches/patch-src_modules_db_mysql_my_cmd_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-src_modules_db_mysql_my_cmd_c
--- patches/patch-src_modules_db_mysql_my_cmd_c 3 Jul 2017 22:14:20 -0000       
1.1
+++ patches/patch-src_modules_db_mysql_my_cmd_c 20 Mar 2018 12:06:18 -0000
@@ -9,7 +9,7 @@ Index: src/modules/db_mysql/my_cmd.c
  /* the following macro will break the compile on solaris */
 -#if !defined (__SVR4) && !defined (__sun)
 +#if !defined (__SVR4) && !defined (__sun) && !defined (__OpenBSD__)
-    #define _XOPEN_SOURCE 4     /* bsd */
+ #define _XOPEN_SOURCE 4     /* bsd */
  #endif
  #define _XOPEN_SOURCE_EXTENDED 1    /* solaris */
 @@ -45,6 +45,7 @@
Index: patches/patch-src_modules_nat_traversal_nat_traversal_c
===================================================================
RCS file: 
/cvs/ports/telephony/kamailio/patches/patch-src_modules_nat_traversal_nat_traversal_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-src_modules_nat_traversal_nat_traversal_c
--- patches/patch-src_modules_nat_traversal_nat_traversal_c     21 Sep 2017 
09:34:32 -0000      1.2
+++ patches/patch-src_modules_nat_traversal_nat_traversal_c     20 Mar 2018 
12:06:18 -0000
@@ -3,7 +3,7 @@ $OpenBSD: patch-src_modules_nat_traversa
 Index: src/modules/nat_traversal/nat_traversal.c
 --- src/modules/nat_traversal/nat_traversal.c.orig
 +++ src/modules/nat_traversal/nat_traversal.c
-@@ -1691,7 +1691,7 @@ restore_keepalive_state(void)
+@@ -1724,7 +1724,7 @@ restore_keepalive_state(void)
      res = fscanf(f, STATE_FILE_HEADER); // skip header
  
      while (true) {
Index: patches/patch-src_modules_tls_tls_bio_c
===================================================================
RCS file: 
/cvs/ports/telephony/kamailio/patches/patch-src_modules_tls_tls_bio_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-src_modules_tls_tls_bio_c
--- patches/patch-src_modules_tls_tls_bio_c     19 Feb 2018 22:43:28 -0000      
1.1
+++ patches/patch-src_modules_tls_tls_bio_c     20 Mar 2018 12:06:18 -0000
@@ -23,17 +23,3 @@ Index: src/modules/tls/tls_bio.c
        return &tls_mbuf_method;
  #else
        if(tls_mbuf_method != NULL) {
-@@ -123,7 +125,13 @@ BIO_METHOD* tls_BIO_mbuf(void)
-       BIO_meth_set_ctrl(tls_mbuf_method, tls_bio_mbuf_ctrl);
-       BIO_meth_set_create(tls_mbuf_method, tls_bio_mbuf_new);
-       BIO_meth_set_destroy(tls_mbuf_method, tls_bio_mbuf_free);
-+#if defined(LIBRESSL_VERSION_NUMBER)
-+/*
-+ * libressl doesn't have this accessor yet, however it's a noop here
-+ * as BIO_meth_new returns zeroed space
-+ */
-       BIO_meth_set_callback_ctrl(tls_mbuf_method, NULL);
-+#endif
-       return tls_mbuf_method;
- #endif
- }
Index: patches/patch-utils_kamctl_kamctlrc
===================================================================
RCS file: /cvs/ports/telephony/kamailio/patches/patch-utils_kamctl_kamctlrc,v
retrieving revision 1.4
diff -u -p -r1.4 patch-utils_kamctl_kamctlrc
--- patches/patch-utils_kamctl_kamctlrc 3 Jul 2017 22:14:20 -0000       1.4
+++ patches/patch-utils_kamctl_kamctlrc 20 Mar 2018 12:06:18 -0000
@@ -1,7 +1,8 @@
 $OpenBSD: patch-utils_kamctl_kamctlrc,v 1.4 2017/07/03 22:14:20 sthen Exp $
---- utils/kamctl/kamctlrc.orig Wed Apr  5 16:32:39 2017
-+++ utils/kamctl/kamctlrc      Mon May 15 21:52:23 2017
-@@ -64,7 +64,7 @@
+Index: utils/kamctl/kamctlrc
+--- utils/kamctl/kamctlrc.orig
++++ utils/kamctl/kamctlrc
+@@ -69,7 +69,7 @@
  
  
  # Program to calculate a message-digest fingerprint
@@ -10,7 +11,7 @@ $OpenBSD: patch-utils_kamctl_kamctlrc,v 
  
  # awk tool
  # AWK="awk"
-@@ -146,8 +146,11 @@
+@@ -151,8 +151,11 @@
  
  ## Kamailio START Options
  ## PID file path - default is: /var/run/kamailio.pid

Reply via email to