Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ def OSList = [
'ubuntu18',
'ubuntu20',
'ubuntu22',
'ubuntu24',
'rhel7',
'rhel8',
'rhel9',
Expand All @@ -13,6 +14,7 @@ def OSList = [
'debian9-64',
'debian10-64',
'debian11-64',
'debian12-64',
'test-asan',
'test-tsan',
'test-ubsan',
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ esac

# add specific flags for fortran depending on compiler version
AX_FORTRAN_FLAGS([FCFLAGS])
AX_C_FLAGS([CFLAGS])

AC_CHECK_SIZEOF(long)

Expand Down
1 change: 1 addition & 0 deletions deploy/os/debian12-64.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--platform=debian --valgrind=memcheck,helgrind --dockerimage=mdsplus/builder:debian_bookworm-64 --distname=DebianBookworm --arch=amd64
1 change: 1 addition & 0 deletions deploy/os/ubuntu24.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--platform=debian --valgrind=memcheck,helgrind --dockerimage=mdsplus/builder:ubuntu24-64 --distname=Ubuntu24 --arch=amd64
21 changes: 21 additions & 0 deletions m4/m4_ax_c_flags.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# SYNOPSIS
#
# AX_C_FLAGS([C variable name])
#
# DESCRIPTION
#

# AX_C_FLAGS([C variable name])
#
AC_DEFUN([AX_C_FLAGS],[
AX_COMPILER_VERSION

if [ test x"$GCC" = x"yes" ]; then
# GCC 12+ triggers a lot of false-positives
AX_COMPARE_VERSION([${ax_cv_c_compiler_version}], [ge], [12.0.0],
[AS_VAR_SET([_c_cxx_flags_fix],["-Wno-strict-aliasing -Wno-uninitialized -Wno-clobbered -Wno-stringop-overflow -Wno-array-bounds -Wno-use-after-free -Wno-nonnull"])])
AS_VAR_APPEND([$1],[" ${_c_cxx_flags_fix}"])
fi
])

41 changes: 23 additions & 18 deletions mdsdcl/cmdExecute.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "dcl_p.h"
#include "mdsdclthreadstatic.h"

#define ERROR_MESSAGE_LENGTH 512

/*! Free the memory associated with a parameter definition structure.
\param p [in,out] the address of a pointer to a dclParameter struct.
*/
Expand Down Expand Up @@ -672,8 +674,8 @@ static int dispatchToHandler(char *image, dclCommandPtr cmd,
}
if (j == cmdDef->qualifier_count)
{
char *errstr = malloc(100);
sprintf(errstr, "Qualifier \"%s\" is not valid for this command\n",
char *errstr = malloc(ERROR_MESSAGE_LENGTH);
snprintf(errstr, ERROR_MESSAGE_LENGTH, "Qualifier \"%s\" is not valid for this command\n",
cmd->qualifiers[i]->name);
*error = errstr;
return MdsdclIVQUAL;
Expand All @@ -683,8 +685,8 @@ static int dispatchToHandler(char *image, dclCommandPtr cmd,

if (cmd->parameter_count > cmdDef->parameter_count)
{
char *errstr = malloc(100);
sprintf(errstr,
char *errstr = malloc(ERROR_MESSAGE_LENGTH);
snprintf(errstr, ERROR_MESSAGE_LENGTH,
"Too many parameters specified in the command. Maximum supported "
"is %d. Provided was %d.\n",
cmdDef->parameter_count, cmd->parameter_count);
Expand All @@ -703,8 +705,9 @@ static int dispatchToHandler(char *image, dclCommandPtr cmd,
{
if ((i < cmd->parameter_count) && (cmd->parameters[i]->value_count > 1))
{
char *errstr = malloc(500);
sprintf(errstr,
char *errstr = malloc(ERROR_MESSAGE_LENGTH);
snprintf(errstr,
ERROR_MESSAGE_LENGTH,
"Parameter number %d does not accept a list of values. "
"Perhaps that parameter needs to enclosed in double quotes?\n",
i + 1);
Expand Down Expand Up @@ -775,8 +778,8 @@ static int dispatchToHandler(char *image, dclCommandPtr cmd,
{
if (cmd->qualifiers[q]->value_count == 0)
{
char *errstr = malloc(100);
sprintf(errstr,
char *errstr = malloc(ERROR_MESSAGE_LENGTH);
snprintf(errstr, ERROR_MESSAGE_LENGTH,
"Qualifier \"%s\" requires a value and none was provided\n",
cmdDef->qualifiers[i]->name);
*error = errstr;
Expand Down Expand Up @@ -870,8 +873,8 @@ static int dispatchToHandler(char *image, dclCommandPtr cmd,
if ((cmd->qualifiers[i]->value_count > 1) &&
(cmdDef->qualifiers[q]->listOk == 0))
{
char *errstr = malloc(100);
sprintf(errstr, "Qualifier \"%s\" does not permit a list of values\n",
char *errstr = malloc(ERROR_MESSAGE_LENGTH);
snprintf(errstr, ERROR_MESSAGE_LENGTH, "Qualifier \"%s\" does not permit a list of values\n",
cmdDef->qualifiers[i]->name);
*error = errstr;
return MdsdclTOO_MANY_VALS;
Expand All @@ -884,8 +887,8 @@ static int dispatchToHandler(char *image, dclCommandPtr cmd,
{
if (cmdDef->qualifiers[q]->nonnegatable)
{
char *errstr = malloc(100);
sprintf(errstr, "Qualifier \"%s\" cannot be negated\n", realname);
char *errstr = malloc(ERROR_MESSAGE_LENGTH);
snprintf(errstr, ERROR_MESSAGE_LENGTH, "Qualifier \"%s\" cannot be negated\n", realname);
*error = errstr;
return MdsdclNOTNEGATABLE;
}
Expand All @@ -904,8 +907,8 @@ static int dispatchToHandler(char *image, dclCommandPtr cmd,
}
if (q == cmdDef->qualifier_count)
{
char *errstr = malloc(100);
sprintf(errstr, "Qualifier \"%s\" is not valid for this command\n",
char *errstr = malloc(ERROR_MESSAGE_LENGTH);
snprintf(errstr, ERROR_MESSAGE_LENGTH, "Qualifier \"%s\" is not valid for this command\n",
cmd->qualifiers[i]->name);
*error = errstr;
return MdsdclIVQUAL;
Expand Down Expand Up @@ -938,8 +941,9 @@ static int dispatchToHandler(char *image, dclCommandPtr cmd,
if ((*error == 0) && (status != 0))
{
char *msg = MdsGetMsg(status);
*error = malloc(strlen(msg) + 100);
sprintf(*error, "Error message was: %s\n", msg);
size_t length = strlen(msg) + 100;
*error = malloc(length);
snprintf(*error, length, "Error message was: %s\n", msg);
}
else if (*error == 0)
*error = strdup("");
Expand Down Expand Up @@ -1320,8 +1324,9 @@ EXPORT int mdsdclAddCommands(const char *name_in, char **error)
if (doc == 0)
{
pthread_mutex_unlock(&lock);
char *errstr = malloc(strlen(filename) + 50);
sprintf(errstr, " Error: unable to parse %s\n", filename);
size_t length = strlen(filename) + 50;
char *errstr = malloc(length);
snprintf(errstr, length, " Error: unable to parse %s\n", filename);
*error = errstr;
status = -1;
}
Expand Down
14 changes: 12 additions & 2 deletions python/MDSplus/compound.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,20 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

import sys
import ctypes as _C
import numpy as _N

try:
import imp
except:
# imp was removed in 3.12
from types import ModuleType

class imp:
@staticmethod
def new_module(name):
return ModuleType(name)

def _mimport(name, level=1):
try:
Expand Down Expand Up @@ -249,8 +260,7 @@ class Conglom(_dat.TreeRefX, Compound):
def getDevice(self, *args, **kwargs):
if not self.image == '__python__':
raise _exc.DevNOT_A_PYDEVICE
import imp
import sys

model, unique = self.__model_unique
if unique is None:
module = imp.new_module(model)
Expand Down