Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/agievich/bee2
Browse files Browse the repository at this point in the history
  • Loading branch information
agievich committed Jun 4, 2024
2 parents eeb07c9 + e148c5c commit ae7d1d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)
project(BEE2 C)

set(BEE2_VERSION_MAJOR "2")
Expand Down
19 changes: 12 additions & 7 deletions cmd/core/whereami.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
#endif
#endif

#if !defined(WAI_STRINGIZE)
#define WAI_STRINGIZE(s)
#define WAI_STRINGIZE_(s) #s
#endif

#if defined(__ANDROID__) || defined(ANDROID)
#include <fcntl.h>
#include <sys/mman.h>
Expand All @@ -272,20 +277,20 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)

for (;;)
{
char buffer[PATH_MAX < 1024 ? 1024 : PATH_MAX];
uint64_t low, high;
char buffer[128 + PATH_MAX];
uintptr_t low, high;
char perms[5];
uint64_t offset;
uint32_t major, minor;
char path[PATH_MAX];
uint32_t inode;
uint32_t major, minor, inode;
char path[PATH_MAX + 1];

if (!fgets(buffer, sizeof(buffer), maps))
break;

if (sscanf(buffer, "%" PRIx64 "-%" PRIx64 " %s %" PRIx64 " %x:%x %u %s\n", &low, &high, perms, &offset, &major, &minor, &inode, path) == 8)
if (sscanf(buffer, "%" SCNxPTR "-%" SCNxPTR " %s %" SCNx64 " %x:%x %u %" WAI_STRINGIZE(PATH_MAX) "[^\n]\n", &low, &high, perms, &offset, &major, &minor, &inode, path) == 8)
{
uint64_t addr = (uintptr_t)WAI_RETURN_ADDRESS();
void* _addr = WAI_RETURN_ADDRESS();
uintptr_t addr = (uintptr_t)_addr;
if (low <= addr && addr <= high)
{
char* resolved;
Expand Down

0 comments on commit ae7d1d2

Please sign in to comment.