argon2: update to 20190702.

This commit is contained in:
Piraty 2019-07-08 19:05:39 +02:00
parent f607333d32
commit 0a213fac05
4 changed files with 31 additions and 71 deletions

View file

@ -1,34 +1,12 @@
# the idea is picked up from upstream/master
# (80dca8559b929a9a08f4344d7dcda0d61677ef9a)
# but the patch is simplified to always use `explicit_bzero()`, so it works
# with musl too
# reason: use explizit_bzero on musl too!
--- src/core.c
+++ src/core.c
@@ -25,6 +25,9 @@
#endif
#define VC_GE_2005(version) (version >= 1400)
@@ -27,6 +27,7 @@
/* for explicit_bzero() on glibc */
#define _DEFAULT_SOURCE
+#define HAVE_EXPLICIT_BZERO 1
+/* for explicit_bzero() */
+#define _DEFAULT_SOURCE
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -121,16 +124,7 @@
}
void NOT_OPTIMIZED secure_wipe_memory(void *v, size_t n) {
-#if defined(_MSC_VER) && VC_GE_2005(_MSC_VER)
- SecureZeroMemory(v, n);
-#elif defined memset_s
- memset_s(v, n, 0, n);
-#elif defined(__OpenBSD__)
explicit_bzero(v, n);
-#else
- static void *(*const volatile memset_sec)(void *, int, size_t) = &memset;
- memset_sec(v, 0, n);
-#endif
}
/* Memory clear flag defaults to true. */

View file

@ -0,0 +1,21 @@
# reason:
# upstream believes Ubuntu/Debian are the only ones
# to report "$(uname -s)-$(uname -m)" as Linux-x86_64 ...
--- Makefile
+++ Makefile
@@ -140,14 +140,6 @@
else ifeq ($(KERNEL_NAME)-$(MACHINE_NAME), Linux-x86_64)
-# default for Debian/Ubuntu x86_64
-BINARY_REL ?= bin
-INCLUDE_REL ?= include
-LIBRARY_REL ?= lib/x86_64-linux-gnu
-PKGCONFIG_REL ?= $(LIBRARY_REL)
-
-else
-
# NetBSD, ... and Linux64/Linux32 variants that use plain lib directory
BINARY_REL ?= bin
INCLUDE_REL ?= include

View file

@ -1,40 +0,0 @@
# picked from upstream/master
From cfa4385e728116989ad88b4be7c23b4868422778 Mon Sep 17 00:00:00 2001
From: Milan Broz <gmazyland@gmail.com>
Date: Mon, 11 Mar 2019 21:21:57 +0100
Subject: [PATCH] Wait for already running threads if a thread creation failed.
On memory-constrained systems (like cgroups limited processes)
thread creation often fails.
The code needs to wait for already running threads on error path;
otherwise these threads can access deallocated memory
(and cause a segfault or another crash).
---
src/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/core.c b/src/core.c
index 8361175..65f0537 100644
--- src/core.c
+++ src/core.c
@@ -310,7 +310,7 @@ static int fill_memory_blocks_mt(argon2_instance_t *instance) {
for (r = 0; r < instance->passes; ++r) {
for (s = 0; s < ARGON2_SYNC_POINTS; ++s) {
- uint32_t l;
+ uint32_t l, ll;
/* 2. Calling threads */
for (l = 0; l < instance->lanes; ++l) {
@@ -335,6 +335,9 @@ static int fill_memory_blocks_mt(argon2_instance_t *instance) {
sizeof(argon2_position_t));
if (argon2_thread_create(&thread[l], &fill_segment_thr,
(void *)&thr_data[l])) {
+ /* Wait for already running threads */
+ for (ll = 0; ll < l; ++ll)
+ argon2_thread_join(thread[ll]);
rc = ARGON2_THREAD_FAIL;
goto fail;
}

View file

@ -1,7 +1,7 @@
# Template file for 'argon2'
pkgname=argon2
version=20171227
revision=4
version=20190702
revision=1
wrksrc="phc-winner-argon2-${version}"
build_style=gnu-makefile
make_use_env=yes
@ -13,7 +13,7 @@ maintainer="Piraty <piraty1@inbox.ru>"
license="CC0-1.0, Apache-2.0"
homepage="https://github.com/P-H-C/phc-winner-argon2"
distfiles="https://github.com/P-H-C/phc-winner-argon2/archive/${version}.tar.gz"
checksum=eaea0172c1f4ee4550d1b6c9ce01aab8d1ab66b4207776aa67991eb5872fdcd8
checksum=daf972a89577f8772602bf2eb38b6a3dd3d922bf5724d45e7f9589b5e830442c
libargon2_package() {
short_desc+="Password hashing library"
@ -29,5 +29,6 @@ libargon2-devel_package() {
vmove usr/include
vmove "usr/lib/*.a"
vmove "usr/lib/*.so"
vmove usr/lib/pkgconfig
}
}