From 3b5a081ea0eca3bc8e2f15e8fe85a71c0730673a Mon Sep 17 00:00:00 2001 From: pjmaechling Date: Sat, 14 Mar 2026 11:16:01 -0700 Subject: [PATCH] Fix SDSU ray tracer buffer overflow and modernize Python tests --- bbp/src/sdsu/bbtoolbox/ray3DJHfor.c | 8 +++++--- bbp/tests/test_python_code.py | 18 +++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bbp/src/sdsu/bbtoolbox/ray3DJHfor.c b/bbp/src/sdsu/bbtoolbox/ray3DJHfor.c index 92668302..4cb54fe8 100644 --- a/bbp/src/sdsu/bbtoolbox/ray3DJHfor.c +++ b/bbp/src/sdsu/bbtoolbox/ray3DJHfor.c @@ -89,6 +89,8 @@ if I don't answer the e-mail (our computers are in a state of flux). */ #include #include #include +#include +#include #define PI 3.141592654 #define SQR2 1.414213562 @@ -202,8 +204,8 @@ void raytracing_(hypo,grid,step,PS_flag) /*timefile[80], file in which travel times appear at the end */ wallfile[80]; /* file containing input wall values of traveltimes */ - char *velfile=malloc(11); - char *timefile=malloc(12); + char *velfile=malloc(80); + char *timefile=malloc(80); FILE *vfint, *tfint; /* ARRAY TO ORDER SIDE FOR SOLUTION IN THE RIGHT ORDER */ @@ -1701,7 +1703,7 @@ void raytracing_(hypo,grid,step,PS_flag) /* -------------------------------------------------------------------------- */ -compar(a,b) +int compar(a,b) struct sorted *a, *b; { if(a->time > b->time) return(1); diff --git a/bbp/tests/test_python_code.py b/bbp/tests/test_python_code.py index e57a7bbb..ae14b6cf 100755 --- a/bbp/tests/test_python_code.py +++ b/bbp/tests/test_python_code.py @@ -52,29 +52,29 @@ def test_execute_platform_bbp(self): Run Broadband Plotform to make sure we can start it """ self.install = InstallCfg() - cmd = ("python3 %s -v >/dev/null" % - (os.path.join(self.install.A_COMP_DIR, - "run_bbp.py"))) + cmd = ("%s %s -v >/dev/null" % + (sys.executable, os.path.join(self.install.A_COMP_DIR, + "run_bbp.py"))) self.assertFalse(bband_utils.runprog(cmd, False) != 0, "Cannot start Broadband plotform!") def test_python_code_comps(self): """ - Run Python with -tt flag to detect mix of tabs and spaces in the code + Run Python compileall to detect mix of tabs and spaces in the code """ self.install = InstallCfg() - cmd = ("python3 -tt -m compileall -f -q -l %s" % - (self.install.A_COMP_DIR)) + cmd = ("%s -m compileall -f -q -l %s" % + (sys.executable, self.install.A_COMP_DIR)) self.assertFalse(bband_utils.runprog(cmd, False) != 0, "Python code in comps directory mixes tabs and spaces!") def test_python_code_tests(self): """ - Run Python with -tt flag to detect mix of tabs and spaces in the code + Run Python compileall to detect mix of tabs and spaces in the code """ self.install = InstallCfg() - cmd = ("python -tt -m compileall -f -q -l %s" % - (self.install.A_TEST_DIR)) + cmd = ("%s -m compileall -f -q -l %s" % + (sys.executable, self.install.A_TEST_DIR)) self.assertFalse(bband_utils.runprog(cmd, False) != 0, "Python code in test directory mixes tabs and spaces!")