From: Andre Noll Date: Sun, 31 Dec 2017 14:04:16 +0000 (+0100) Subject: Merge branch 'maint' X-Git-Tag: v0.6.2~48 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=767a4a54c967bc4b80bd14d02e89fe91acd848dd;hp=129ce40eff6bc09734a82280dec61827b5342759 Merge branch 'maint' A conflict in init_random_seed_or_die() of gcrypt.c. The fix added in the maint branch conflicted against the master branch which also modified the function to bump the required libgcrypt version. * maint: resample filter: Don't discard const. gcrypt: Seed PRNG in init_random_seed_or_die(). bash_completion: Get rid of weird retry logic. --- diff --git a/bash_completion b/bash_completion index 4b1a4be5..88b37dc2 100644 --- a/bash_completion +++ b/bash_completion @@ -6,10 +6,6 @@ _para_complete() local line="$COMP_LINE" OLD_IFS="$IFS" local opts n - if [[ "$COMP_WORDBREAKS" != ' ' ]]; then - COMP_WORDBREAKS=' ' - return 124 # try again with proper value - fi # This extracts short and long options from the help output local script='{ if ($1 ~ "-[a-zA-Z]," && $2 ~ "--[a-zA-Z]") { diff --git a/gcrypt.c b/gcrypt.c index d5cb49a4..052546dd 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -52,21 +52,22 @@ void get_random_bytes_or_die(unsigned char *buf, int num) } /* - * This is called at the beginning of every program that uses libgcrypt. We - * don't have to initialize any random seed here, but we must initialize the - * gcrypt library. This task is performed by gcry_check_version() which can - * also check that the gcrypt library version is at least the minimal required - * version. + * This is called at the beginning of every program that uses libgcrypt. The + * call to gcry_check_version() initializes the gcrypt library and checks that + * we have at least the minimal required version. */ void init_random_seed_or_die(void) { const char *req_ver = "1.5.0"; + int seed; - if (gcry_check_version(req_ver)) - return; - PARA_EMERG_LOG("fatal: need at least libgcrypt-%s, have: %s\n", - req_ver, gcry_check_version(NULL)); - exit(EXIT_FAILURE); + if (!gcry_check_version(req_ver)) { + PARA_EMERG_LOG("fatal: need at least libgcrypt-%s, have: %s\n", + req_ver, gcry_check_version(NULL)); + exit(EXIT_FAILURE); + } + get_random_bytes_or_die((unsigned char *)&seed, sizeof(seed)); + srandom(seed); } /** S-expression for the public part of an RSA key. */ diff --git a/resample_filter.c b/resample_filter.c index 8a87b1f3..bbdda51c 100644 --- a/resample_filter.c +++ b/resample_filter.c @@ -155,6 +155,7 @@ static int resample_frames(int16_t *in, size_t num_frames, bool have_more, size_t *result_frames) { int ret, num_samples, out_samples; + float *in_float; int16_t *out; SRC_DATA data; @@ -166,11 +167,12 @@ static int resample_frames(int16_t *in, size_t num_frames, bool have_more, data.output_frames = num_frames * ctx->ratio + 1; out_samples = data.output_frames * ctx->channels; - data.data_in = para_malloc(num_samples * sizeof(float)); - src_short_to_float_array(in, data.data_in, num_samples); + in_float = para_malloc(num_samples * sizeof(float)); + src_short_to_float_array(in, in_float, num_samples); + data.data_in = in_float; data.data_out = para_malloc(out_samples * sizeof(float)); ret = src_process(ctx->src_state, &data); - free(data.data_in); + free(in_float); if (ret != 0) { PARA_ERROR_LOG("%s\n", src_strerror(ret)); free(data.data_out);