--- freem/src/mumps.c 2025/04/16 05:33:15 1.23 +++ freem/src/mumps.c 2025/04/16 05:37:06 1.24 @@ -1,5 +1,5 @@ /* - * $Id: mumps.c,v 1.23 2025/04/16 05:33:15 snw Exp $ + * $Id: mumps.c,v 1.24 2025/04/16 05:37:06 snw Exp $ * main module of freem * * @@ -24,6 +24,9 @@ * along with FreeM. If not, see . * * $Log: mumps.c,v $ + * Revision 1.24 2025/04/16 05:37:06 snw + * Refine FreeBSD ASLR fix + * * Revision 1.23 2025/04/16 05:33:15 snw * Try to use procctl function to fix ASLR problem on FreeBSD * @@ -197,13 +200,6 @@ int main (int argc, char **argv, char ** char cli_rtn_name[256]; char env_ena[25]; - -#if defined(__FreeBSD__) - int prcdta = PROC_ASLR_FORCE_DISABLE; - if (procctl (P_PID, getpid (), PROC_ASLR_CTL, &prcdta) == -1) { - fprintf (stderr, "freem: could not disable address space layout randomization for pid %ld; program operation may be unreliable [error %s]\n", getpid(), strerror (errno)); - } -#endif routine_mode = FALSE; strcpy (m_dialect, "FREEM"); @@ -222,6 +218,9 @@ int main (int argc, char **argv, char ** strcpy (stack0, argv[0]); stcnv_c2m (stack0); +#if defined(__FreeBSD__) + int prcdta = PROC_ASLR_FORCE_DISABLE; +#endif /* strncpy (config_file, SYSCONFDIR"/freem.conf", 100); */ @@ -763,6 +762,13 @@ int main (int argc, char **argv, char ** } } +#if defined(__FreeBSD__) + if ((first_process == FALSE) && (procctl (P_PID, getpid (), PROC_ASLR_CTL, &prcdta) == -1)) { + fprintf (stderr, "freem: could not disable address space layout randomization for pid %ld; program operation may be unreliable [error %s]\n", getpid(), strerror (errno)); + } +#endif + + if (first_process == TRUE) { char verstr[500];