File: 0004-Fix-out-of-bound-_hash_table__index-return-value.patch

package info (click to toggle)
austin 3.7.0-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 11,412 kB
  • sloc: ansic: 8,622; python: 2,663; sh: 106; makefile: 54
file content (27 lines) | stat: -rw-r--r-- 987 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
From: Helmut Grohne <helmut@subdivi.de>
Date: Fri, 16 May 2025 11:31:41 +0200
Subject: Fix out-of-bound _hash_table__index return value
Forwarded: https://github.com/P403n1x87/austin/pull/266

_hash_table__index computes a bucket by multiplying the unsigned key
with a signed MAGIC and then performing modulo the unsigned capacity.
Promotion rules imply that the modulo operation is performed signed and
thus the result may end up being negative. When converting the negative
value to unsigned, what we get is an out-of-bounds bucket index.
---
 src/cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cache.c b/src/cache.c
index 09c0469..b7d3b59 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -239,7 +239,7 @@ hash_table_new(int capacity) {
 }
 
 // ----------------------------------------------------------------------------
-#define MAGIC 2654435761
+#define MAGIC 2654435761u
 
 static inline index_t
 _hash_table__index(hash_table_t *self, key_dt key) {