From 6c88849c9416ae44a0d0ea0dfe686d6515e9650a Mon Sep 17 00:00:00 2001 From: Robert Butora <robert.butora@inaf.it> Date: Tue, 10 Jun 2025 10:31:00 +0300 Subject: [PATCH] fix warnings: merge (compose paths to dir) --- data-access/engine/src/common/src/m4vl.cpp | 29 ++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/data-access/engine/src/common/src/m4vl.cpp b/data-access/engine/src/common/src/m4vl.cpp index 33a1c09..68f6e27 100644 --- a/data-access/engine/src/common/src/m4vl.cpp +++ b/data-access/engine/src/common/src/m4vl.cpp @@ -410,17 +410,32 @@ void M4VL_merge_config_init( s->dim = dim; char mdir[MPATHLEN];// to be created by timestamp and pid+tid - /* sprintf(mdir, "MERGE_%s_%s", - usec_timestamp(s->ts,TS_LEN), - get_pid_tid(s->pidtidstr)); - */ sprintf(mdir, "MERGE_%s",jobid); + /* sprintf(mdir, "MERGE_%s_%s", + usec_timestamp(s->ts,TS_LEN), + get_pid_tid(s->pidtidstr)); */ + sprintf(mdir, "MERGE_%s", jobid); + if((strlen(s->mpath) + strlen(s->mroot) + 2) > MPATHLEN) + throw runtime_error("too long path for mpath"); - sprintf(s->mpath, "%s/%s", s->mroot, mdir); + strcpy(s->mpath, s->mroot); + strcat(s->mpath, "/"); + strcat(s->mpath, mdir); + //sprintf(s->mpath, "%s/%s", s->mroot, mdir); - sprintf(s->mpathin, "%s/%s", s->mpath, "in"); - sprintf(s->mpathproj, "%s/%s", s->mpath, "proj"); + if((strlen(s->mpath) + 2 + 2) > MPATHLEN) + throw runtime_error("too long path for mapthin"); + strcpy(s->mpathin, s->mpath); + strcat(s->mpathin, "/in"); + //sprintf(s->mpathin, "%s/%s", s->mpath, "in"); + + if((strlen(s->mpath) + 4 + 2) > MPATHLEN) + throw runtime_error("too long path for mapthin"); + + strcpy(s->mpathproj, s->mpath); + strcat(s->mpathproj, "/proj"); + //sprintf(s->mpathproj, "%s/%s", s->mpath, "proj"); sprintf(s->cmnhdr,"%s/common.hdr",s->mpath); -- GitLab