From dc5b0fb0d35b9758f6eac7b0bd144db00eef7216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Tue, 9 May 2023 20:40:43 +0200 Subject: [PATCH] Fix age mask parsing from config - initialize age mask to zero - drop default bitstring for age mask, use string instead -remove default age mask bits, use string instead -strdup --- src/extensions/age_restriction/age_restriction.c | 6 +++--- src/include/taler_extensions.h | 4 ---- src/util/age_restriction.c | 3 +++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/extensions/age_restriction/age_restriction.c b/src/extensions/age_restriction/age_restriction.c index 2d6d0cbd7..481cb133d 100644 --- a/src/extensions/age_restriction/age_restriction.c +++ b/src/extensions/age_restriction/age_restriction.c @@ -207,10 +207,10 @@ libtaler_extension_age_restriction_init (void *arg) return NULL; } - mask.bits = TALER_EXTENSION_AGE_RESTRICTION_DEFAULT_AGE_MASK; + if (NULL == groups) + groups = GNUNET_strdup (TALER_EXTENSION_AGE_RESTRICTION_DEFAULT_AGE_GROUPS); - if ((groups != NULL) && - (GNUNET_OK != TALER_parse_age_group_string (groups, &mask))) + if (GNUNET_OK != TALER_parse_age_group_string (groups, &mask)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[age restriction] couldn't parse age groups: '%s'\n", diff --git a/src/include/taler_extensions.h b/src/include/taler_extensions.h index bd5b72480..75f225344 100644 --- a/src/include/taler_extensions.h +++ b/src/include/taler_extensions.h @@ -344,10 +344,6 @@ TALER_extensions_verify_manifests_signature ( * The default age mask represents the age groups * 0-7, 8-9, 10-11, 12-13, 14-15, 16-17, 18-20, 21-... */ -#define TALER_EXTENSION_AGE_RESTRICTION_DEFAULT_AGE_MASK (1 | 1 << 8 | 1 << 10 \ - | 1 << 12 | 1 << 14 \ - | 1 << 16 | 1 << 18 \ - | 1 << 21) #define TALER_EXTENSION_AGE_RESTRICTION_DEFAULT_AGE_GROUPS "8:10:12:14:16:18:21" diff --git a/src/util/age_restriction.c b/src/util/age_restriction.c index beb68e5a6..cf81d915b 100644 --- a/src/util/age_restriction.c +++ b/src/util/age_restriction.c @@ -513,6 +513,9 @@ TALER_parse_age_group_string ( unsigned int val = 0; char c; + /* reset mask */ + mask->bits = 0; + while (*pos) { c = *pos++;