Skip to content

Commit

Permalink
Linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
giridharprasath committed Apr 18, 2024
1 parent 082e3ea commit 3f7d856
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
50 changes: 25 additions & 25 deletions librz/core/linux_heap_glibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ RZ_API bool GH(rz_heap_update_main_arena)(RzCore *core, GHT m_arena, MallocState
}
(void)rz_io_read_at(core->io, m_arena, (ut8 *)cmain_arena, sizeof(GH(RzHeap_MallocState_tcache)));
/* arena->next should point to itself even if there is only one thread */
if(!cmain_arena->next) {
if (!cmain_arena->next) {
return false;
}
GH(update_arena_with_tc)
Expand Down Expand Up @@ -863,7 +863,7 @@ static bool GH(parse_tcache_from_addr)(RzCore *core, const GHT tls_addr, const G

#if __aarch64__
/* We will encounter main_arena pointer somewhere in ARM64 */
if(GH(is_arena)(core, tcache_guess, NULL)) {
if (GH(is_arena)(core, tcache_guess, GHT_MIN)) {
break;
}
#endif
Expand Down Expand Up @@ -913,33 +913,33 @@ static bool GH(parse_tls_data)(RzCore *core, RZ_NONNULL RzDebugPid *th, GHT tid)
addr = GH(read_val)(core, dtv, false);
memset(dtv, 0, sizeof(dtv));
/*
* TLS memory layout on x86_64:
* get_tls_data()
* │
* %fs
* Thread_local │
* ┌───┬──────────┬──────────┼───┐
* │ .tbss │tib│
* └───┴──────────┴──────────┼───┘
* │
* x86 %gs
*/
* TLS memory layout on x86_64:
* get_tls_data()
* │
* %fs
* Thread_local │
* ┌───┬──────────┬──────────┼───┐
* │ .tbss │tib│
* └───┴──────────┴──────────┼───┘
* │
* x86 %gs
*/
// size of dtv is SZ*2
rz_io_nread_at(core->io, addr + SZ * 2, dtv, sizeof(GHT));
addr = GH(read_val)(core, dtv, false);
#elif __aarch64__
/*
* TLS memory layout on aarch64:
*
* %tpidr_el0
* │
* │ Thread_local
* ┌───┼───┬──────────┬──────────┐
* │tib│dtv│ │ │
* ├───┴───┴──────────┴──────────┘
* │
* get_tls_data()
*/
* TLS memory layout on aarch64:
*
* %tpidr_el0
* │
* │ Thread_local
* ┌───┼───┬──────────┬──────────┐
* │tib│dtv│ │ │
* ├───┴───┴──────────┴──────────┘
* │
* get_tls_data()
*/
addr = th->tls + SZ * 2;
#endif
const GHT end = addr + SZ * SZ * 2 * 2;

Check failure

Code scanning / CodeQL

Multiplication result converted to larger type High

Multiplication result may overflow 'int' before it is converted to 'unsigned long long'.
Expand Down Expand Up @@ -1157,7 +1157,7 @@ static bool GH(is_arena)(RzCore *core, GHT m_arena, GHT m_state) {
}
}
free(ta);
if (!m_state) {
if (m_state == GHT_MIN) {
return true;
}
return false;
Expand Down
3 changes: 3 additions & 0 deletions librz/core/linux_heap_glibc.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
#undef GH
#undef GHT
#undef GHT_MAX
#undef GHT_MIN
#undef read_le

#if HEAP64
#define GH(x) x##_64
#define GHT ut64
#define GHT_MAX UT64_MAX
#define GHT_MIN UT64_MIN
#define read_le(x) rz_read_le##64(x)
#else
#define GH(x) x##_32
#define GHT ut32
#define GHT_MAX UT32_MAX
#define GHT_MIN UT32_MIN
#define read_le(x) rz_read_le##32(x)
#endif

Expand Down
4 changes: 2 additions & 2 deletions librz/debug/p/native/linux/linux_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,13 +903,13 @@ RZ_API ut64 get_linux_tls_val(RZ_NONNULL RzDebug *dbg, int tid) {
}
#endif
#if __aarch64__
struct iovec iovec = {0};
struct iovec iovec = { 0 };
ut64 reg;

iovec.iov_base = ®
iovec.iov_len = sizeof(reg);
RzRegItem *ri = rz_reg_get(dbg->reg, "tpidr_el0", RZ_REG_TYPE_ANY);
if (ri == NULL && rz_debug_ptrace(dbg, PTRACE_GETREGSET, dbg->tid, (void*)NT_ARM_TLS, &iovec) != -1) {
if (ri == NULL && rz_debug_ptrace(dbg, PTRACE_GETREGSET, dbg->tid, (void *)NT_ARM_TLS, &iovec) != -1) {
tls = reg;
} else {
tls = rz_reg_get_value(dbg->reg, ri);
Expand Down

0 comments on commit 3f7d856

Please sign in to comment.