On Sun, Jun 02 2019, Rafael Sadowski <[email protected]> wrote:
> Update keepassxc to 2.4.2
>
> CHANGELOG:
> https://github.com/keepassxreboot/keepassxc/releases/tag/2.4.2
>
> I send the Alloc class patch upsteream as usual. Tests and feedback
> welcome.

I didn't check anything else, but the Alloc class patch shouldn't be
sent upstream as-is, IMO.  Please see below.

> RS
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/security/keepassxc/Makefile,v
> retrieving revision 1.20
> diff -u -p -u -p -r1.20 Makefile
> --- Makefile  21 Apr 2019 11:29:44 -0000      1.20
> +++ Makefile  2 Jun 2019 09:44:06 -0000
> @@ -2,7 +2,7 @@
>  
>  COMMENT =    management tool for password and sensitive data
>  
> -V =          2.4.1
> +V =          2.4.2
>  DISTNAME =   keepassxc-${V}
>  
>  CATEGORIES = security
> @@ -16,7 +16,7 @@ PERMIT_PACKAGE_CDROM =      Yes
>  
>  WANTLIB += ${COMPILER_LIBCXX} Qt5Concurrent Qt5Core Qt5DBus Qt5Gui
>  WANTLIB += Qt5Network Qt5Svg Qt5Widgets Qt5X11Extras X11 Xi Xtst
> -WANTLIB += argon2 c gcrypt gpg-error m qrencode z
> +WANTLIB += argon2 c gcrypt gpg-error m qrencode sodium z
>  
>  MASTER_SITES =       
> https://github.com/keepassxreboot/keepassxc/releases/download/${V}/
>  EXTRACT_SUFX =       -src.tar.xz
> @@ -25,6 +25,7 @@ MODULES =   x11/qt5 \
>               devel/cmake
>  
>  LIB_DEPENDS =        security/libgcrypt \
> +             security/libsodium \
>               security/argon2 \
>               graphics/libqrencode \
>               x11/qt5/qtsvg \
> @@ -36,8 +37,8 @@ RUN_DEPENDS =       devel/desktop-file-utils \
>  
>  CONFIGURE_ARGS=      -DCMAKE_INSTALL_MANDIR="man" \
>               -DWITH_GUI_TESTS=ON \
> -             -DWITH_XC_SSHAGENT=ON \
> -             -DWITH_XC_AUTOTYPE=ON
> +             -DWITH_XC_AUTOTYPE=ON \
> +             -DWITH_XC_SSHAGENT=ON
>  
>  TEST_IS_INTERACTIVE =        X11
>  
> @@ -52,10 +53,8 @@ WANTLIB += yubikey ykpers-1
>  .endif
>  
>  .if ${FLAVOR:Mbrowser}
> -LIB_DEPENDS +=               security/libsodium
>  CONFIGURE_ARGS +=    -DWITH_XC_BROWSER=ON \
>                       -DWITH_XC_NETWORKING=ON
> -WANTLIB      +=              sodium
>  .endif
>  
>  post-patch:
> Index: distinfo
> ===================================================================
> RCS file: /cvs/ports/security/keepassxc/distinfo,v
> retrieving revision 1.11
> diff -u -p -u -p -r1.11 distinfo
> --- distinfo  21 Apr 2019 11:29:44 -0000      1.11
> +++ distinfo  2 Jun 2019 09:44:06 -0000
> @@ -1,2 +1,2 @@
> -SHA256 (keepassxc-2.4.1-src.tar.xz) = 
> Dal70SedG5sGpjufcjtDq4wHi38SA9bBNQT91HNUias=
> -SIZE (keepassxc-2.4.1-src.tar.xz) = 3277856
> +SHA256 (keepassxc-2.4.2-src.tar.xz) = 
> FfptCikgVYZLGXnGcfE+W65QVuGeKAwwzBzwuW6lYTg=
> +SIZE (keepassxc-2.4.2-src.tar.xz) = 3290468
> Index: patches/patch-src_core_Alloc_cpp
> ===================================================================
> RCS file: patches/patch-src_core_Alloc_cpp
> diff -N patches/patch-src_core_Alloc_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_core_Alloc_cpp  2 Jun 2019 09:44:06 -0000
> @@ -0,0 +1,23 @@
> +$OpenBSD$
> +
> +Index: src/core/Alloc.cpp
> +--- src/core/Alloc.cpp.orig
> ++++ src/core/Alloc.cpp
> +@@ -20,6 +20,8 @@
> + #include <sodium.h>
> + #ifdef Q_OS_MACOS
> + #include <malloc/malloc.h>
> ++#elif defined(Q_OS_OPENBSD)
> ++#include <stdlib.h>
> + #else
> + #include <malloc.h>
> + #endif
> +@@ -61,7 +63,7 @@ void operator delete(void* ptr) noexcept
> +     ::operator delete(ptr, _msize(ptr));
> + #elif defined(Q_OS_MACOS)
> +     ::operator delete(ptr, malloc_size(ptr));
> +-#elif defined(Q_OS_UNIX)
> ++#elif defined(Q_OS_LINUX)
> +     ::operator delete(ptr, malloc_usable_size(ptr));
> + #else
> +     // whatever OS this is, give up and simply free stuff
>

I think the port's cmake setup should check for malloc_usable_size and
malloc.h, use them if available, and fall back on stdlib.h / std::free()
if not.  OpenBSD is not the only OS where malloc.h isn't available, and
Linux (glibc really) isn't the only OS where malloc_usable_size() is
available.  This kind of #ifdef practice is actively harmful for
portability.

Also if the goal is to securely erase memory before freeing it,
maybe freezero(3) is a possible alternative?

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to