]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 'maint'
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 31 Dec 2017 14:04:16 +0000 (15:04 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 31 Dec 2017 14:05:15 +0000 (15:05 +0100)
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.

bash_completion
gcrypt.c
resample_filter.c

index 4b1a4be55508d70f4f34a170327967d067ba24ef..88b37dc28fb0dc175f48ac9fa364f26a434bedde 100644 (file)
@@ -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]") {
index d5cb49a45c2d6da4e6249b6810a298a0460c8b1f..052546dd60733d143e6c12bdcfcc92ce36ac5e50 100644 (file)
--- 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. */
index 8a87b1f33fb063ca8d105683ddd74b091e4ffe2b..bbdda51c525630c6d1411dfa547193f8ccdae9ce 100644 (file)
@@ -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);