]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix a bug where the result of rehash is unstable
authorminyong.ha <minyong.ha@lge.com>
Mon, 22 May 2023 05:44:13 +0000 (14:44 +0900)
committerTomas Mraz <tomas@openssl.org>
Thu, 25 May 2023 13:46:40 +0000 (15:46 +0200)
The root cause is that the file entries targeted for rehash are not actually sorted.
Sort was skipped because the compare function was null.
So a compare function has been implemented to allow file entries to be sorted.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21013)

apps/rehash.c

index 67dfe49a707947e88742bf767c62ffae8a0ea09e..5b979288b0e94082ec93e0c3c64cb119977fb188 100644 (file)
@@ -340,6 +340,11 @@ static int ends_with_dirsep(const char *path)
     return *path == '/';
 }
 
+static int sk_strcmp(const char * const *a, const char * const *b)
+{
+    return strcmp(*a, *b);
+}
+
 /*
  * Process a directory; return number of errors found.
  */
@@ -369,7 +374,7 @@ static int do_dir(const char *dirname, enum Hash h)
     if (verbose)
         BIO_printf(bio_out, "Doing %s\n", dirname);
 
-    if ((files = sk_OPENSSL_STRING_new_null()) == NULL) {
+    if ((files = sk_OPENSSL_STRING_new(sk_strcmp)) == NULL) {
         BIO_printf(bio_err, "Skipping %s, out of memory\n", dirname);
         errs = 1;
         goto err;