//
// RAND_file_name from 0x82a358 to 0x82a454 (252 bytes)
//
// 3 xrefs:
// > sub_643938 @ 0x643a0e
// > sub_64518C @ 0x645210
// > ??> @ 0x5511c
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
char *__fastcall RAND_file_name(char *a1, size_t a2)
{
char *v5; // r0
const char *v6; // r6
size_t v7; // r0
char *v8; // r0
if ( OPENSSL_issetugid() )
goto LABEL_2;
v5 = getenv("RANDFILE");
v6 = v5;
if ( v5 && *v5 )
{
v7 = strlen(v5);
if ( v7 + 1 < a2 )
{
if ( a2 <= OPENSSL_strlcpy(a1, v6, a2) )
return nullptr;
goto LABEL_8;
}
}
else
{
v8 = getenv("HOME");
v6 = v8;
if ( !v8 || !*v8 )
{
LABEL_2:
*a1 = 0;
return nullptr;
}
v7 = strlen(v8);
}
if ( a2 > v7 + 6 )
{
OPENSSL_strlcpy(a1, v6, a2);
OPENSSL_strlcat(a1, (const char *)&word_9B1F2C, a2);
OPENSSL_strlcat(a1, ".rnd", a2);
}
LABEL_8:
if ( *a1 )
return a1;
return nullptr;
}