Skip to content

Commit

Permalink
sort(1): fix -R
Browse files Browse the repository at this point in the history
It's necessary to initialize the hash context.

Fixes #15
  • Loading branch information
q66 committed Nov 17, 2023
1 parent 8d4b1d1 commit 4db160b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion patches/src.freebsd.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5514,7 +5514,17 @@
/* Use hint space to memoize md5 computations, at least. */
static void
randomcoll_init_hint(struct key_value *kv, void *hash)
@@ -1033,6 +1041,7 @@
@@ -1020,6 +1028,9 @@
memcpy(&ctx1, &md5_ctx, sizeof(MD5_CTX));
memcpy(&ctx2, &md5_ctx, sizeof(MD5_CTX));

+ MD5Init(&ctx1);
+ MD5Init(&ctx2);
+
MD5Update(&ctx1, bwsrawdata(s1), bwsrawlen(s1));
MD5Update(&ctx2, bwsrawdata(s2), bwsrawlen(s2));

@@ -1033,6 +1044,7 @@

return (memcmp(hash1, hash2, sizeof(hash1)));
}
Expand Down
3 changes: 3 additions & 0 deletions src.freebsd/coreutils/sort/coll.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,9 @@ randomcoll(struct key_value *kv1, struct key_value *kv2,
memcpy(&ctx1, &md5_ctx, sizeof(MD5_CTX));
memcpy(&ctx2, &md5_ctx, sizeof(MD5_CTX));

MD5Init(&ctx1);
MD5Init(&ctx2);

MD5Update(&ctx1, bwsrawdata(s1), bwsrawlen(s1));
MD5Update(&ctx2, bwsrawdata(s2), bwsrawlen(s2));

Expand Down

0 comments on commit 4db160b

Please sign in to comment.