Skip to content
Open
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
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#
# Changelog
# ---------
# 29Oct25 mab add prefix program
# 18Sep15 gwb Specifically copy the gcat and GPL.BP directories if a previous
# installation exists. (Git issue #90)
# 03Sep25 gwb Updated CFLAGS for newer gcc versions.
Expand Down Expand Up @@ -138,15 +139,15 @@ QMUSERS := $(shell cat /etc/group | grep qmusers)
qm: ARCH :=
qm: BITSIZE := 64
qm: C_FLAGS := $(CSTD) -Wall -Wformat=2 -Wno-format-nonliteral -D_DEFAULT_SOURCE=1 -DLINUX -D_FILE_OFFSET_BITS=64 -I$(GPLSRC) -DGPL -g $(ARCH) -fPIE
qm: $(QMOBJS) qmclilib.so qmtic qmfix qmconv qmidx qmlnxd
qm: $(QMOBJS) qmclilib.so qmtic qmfix qmconv qmidx qmlnxd prefix
@echo Linking $@
@cd $(GPLOBJ)
@$(COMP) $(ARCH) $(L_FLAGS) $(QMOBJSD) -o $(GPLBIN)qm

qm32: ARCH := -m32
qm32: BITSIZE := 32
qm32: C_FLAGS := -Wall -Wformat=2 -Wno-format-nonliteral -DLINUX -D_FILE_OFFSET_BITS=64 -I$(GPLSRC) -DGPL -g $(ARCH)
qm32: $(QMOBJS) qmclilib.so qmtic qmfix qmconv qmidx qmlnxd
qm32: $(QMOBJS) qmclilib.so qmtic qmfix qmconv qmidx qmlnxd prefix
@echo Linking $@
@$(COMP) $(ARCH) $(L_FLAGS) $(QMOBJSD) -o $(GPLBIN)qm

Expand All @@ -163,6 +164,11 @@ qmfix: qmfix.o ctype.o linuxlb.o dh_hash.o inipath.o
@echo Linking $@
@$(COMP) $(C_FLAGS) -lc $(GPLOBJ)qmfix.o $(GPLOBJ)ctype.o $(GPLOBJ)linuxlb.o $(GPLOBJ)dh_hash.o $(GPLOBJ)inipath.o -o $(GPLBIN)qmfix

prefix: prefix.o ctype.o linuxlb.o inipath.o
@echo Linking $@
@$(COMP) $(C_FLAGS) -lc $(GPLOBJ)prefix.o $(GPLOBJ)ctype.o $(GPLOBJ)linuxlb.o $(GPLOBJ)inipath.o -o $(GPLBIN)prefix


qmconv: qmconv.o ctype.o linuxlb.o dh_hash.o
@echo Linking $@
@$(COMP) $(C_FLAGS) -lc $(GPLOBJ)qmconv.o $(GPLOBJ)ctype.o $(GPLOBJ)linuxlb.o $(GPLOBJ)dh_hash.o -o $(GPLBIN)qmconv
Expand Down Expand Up @@ -211,6 +217,9 @@ qmconv.o: qmconv.c qm.h dh_int.h header.h revstamp.h

qmfix.o: qmfix.c qm.h dh_int.h revstamp.h
@$(COMP) $(C_FLAGS) -c $< -o $(GPLOBJ)qmfix.o

prefix.o: prefix.c qm.h dh_int.h revstamp.h
@$(COMP) $(C_FLAGS) -c $< -o $(GPLOBJ)prefix.o

qmidx.o: qmidx.c qm.h dh_int.h revstamp.h
@$(COMP) $(C_FLAGS) -c $< -o $(GPLOBJ)qmidx.o
Expand Down
17 changes: 11 additions & 6 deletions gplsrc/dh_ak.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* ScarletDME Wiki: https://scarlet.deltasoft.com
*
* START-HISTORY (Scarlet DME):
* 17Oct25 mab Change dyn file prefix to %
* 03Sep25 gwb Fix for potential buffer overrun due to an insufficiently sized sprintf() target.
* git issue #82
* 06Feb22 gwb Fixed an uninitialized variable warning in ak_read().
Expand Down Expand Up @@ -1729,7 +1730,8 @@ Private int16_t create_ak(char *data_path, /* Data file path name */
/* Open primary subfile. We do this outside of the file sharing mechanism
to guarantee that we are the only user of the file. */

sprintf(path, "%s%c~0", data_path, DS);
// 17Oct25 mab Change dyn file prefix to %
sprintf(path, "%s%c%%0", data_path, DS);
fu = dio_open(path, DIO_UPDATE);
if (!ValidFileHandle(fu)) {
dh_err = DHE_FILE_NOT_FOUND;
Expand Down Expand Up @@ -1787,7 +1789,8 @@ Private int16_t create_ak(char *data_path, /* Data file path name */
strcpy(header.akpath, ak_path); /* Only relevant on first index */
}

sprintf(path, "%s%c~%d", ak_path, DS, subfile);
// 17Oct25 mab Change dyn file prefix to %
sprintf(path, "%s%c%%%d", ak_path, DS, subfile);
akfu = dio_open(path, DIO_NEW);
if (!ValidFileHandle(akfu)) {
dh_err = DHE_AK_CREATE_ERR;
Expand Down Expand Up @@ -1927,8 +1930,9 @@ Private bool delete_ak(char *pathname, /* File path name */

/* Open primary subfile. We do this outside of the file sharing mechanism
to guarantee that we are the only user of the file. */

sprintf(path, "%s%c~0", pathname, DS);

// 17Oct25 mab Change dyn file prefix to %
sprintf(path, "%s%c%%0", pathname, DS);
fu = dio_open(path, DIO_UPDATE);
if (!ValidFileHandle(fu)) {
dh_err = DHE_FILE_NOT_FOUND;
Expand Down Expand Up @@ -1966,8 +1970,9 @@ Private bool delete_ak(char *pathname, /* File path name */
relocated = (header.akpath[0] != '\0');

/* Delete the AK subfile */

sprintf(path, "%s%c~%d", (relocated) ? header.akpath : pathname, DS, (int)(akno + AK_BASE_SUBFILE));

// 17Oct25 mab Change dyn file prefix to %
sprintf(path, "%s%c%%%d", (relocated) ? header.akpath : pathname, DS, (int)(akno + AK_BASE_SUBFILE));
if (remove(path) != 0) {
dh_err = DHE_AK_DELETE_ERROR;
process.os_error = OSError;
Expand Down
9 changes: 6 additions & 3 deletions gplsrc/dh_creat.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* ScarletDME Wiki: https://scarlet.deltasoft.com
*
* START-HISTORY (ScarletDME):
* 17Oct25 mab Change dyn file prefix to %
* 28Feb20 gwb Changed integer declarations to be portable across address
* space sizes (32 vs 64 bit)
*
Expand Down Expand Up @@ -143,8 +144,9 @@ bool dh_create_file(char path[],
}

/* Create primary subfile */

sprintf(primary_subfile, "%s%c~0", path, DS);

// 17Oct25 mab Change dyn file prefix to %
sprintf(primary_subfile, "%s%c%%0", path, DS);
fu = dio_open(primary_subfile, DIO_NEW);

if (!ValidFileHandle(fu)) {
Expand Down Expand Up @@ -206,7 +208,8 @@ bool dh_create_file(char path[],

/* Create overflow subfile */

sprintf(overflow_subfile, "%s%c~1", path, DS);
// 17Oct25 mab Change dyn file prefix to %
sprintf(overflow_subfile, "%s%c%%1", path, DS);
fu = dio_open(overflow_subfile, DIO_NEW);

if (!ValidFileHandle(fu)) {
Expand Down
7 changes: 5 additions & 2 deletions gplsrc/dh_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* ScarletDME Wiki: https://scarlet.deltasoft.com
*
* START-HISTORY (ScarletDME):

* 17Oct25 mab Change dyn file prefix to %
* 15Jan22 gwb Fixed argument formatting issues (CwE-686)
*
* 29Feb20 gwb Changed LONG_MAX to INT32_MAX. When building for a 64 bit
Expand Down Expand Up @@ -141,9 +143,10 @@ bool dh_open_subfile(DH_FILE* dh_file,
mode = DIO_UPDATE;

if ((subfile >= AK_BASE_SUBFILE) && (dh_file->akpath != NULL)) {
sprintf(filename, "%s%c~%d", dh_file->akpath, DS, (int)subfile);
// 17Oct25 mab Change dyn file prefix to %
sprintf(filename, "%s%c%%%d", dh_file->akpath, DS, (int)subfile);
} else {
sprintf(filename, "%s%c~%d", pathname, DS, (int)subfile);
sprintf(filename, "%s%c%%%d", pathname, DS, (int)subfile);
}

dh_file->sf[subfile].fu = dio_open(filename, mode);
Expand Down
7 changes: 5 additions & 2 deletions gplsrc/dh_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* ScarletDME Wiki: https://scarlet.deltasoft.com
*
* START-HISTORY (ScarletDME):
* 17Oct25 mab Change dyn file prefix to %
* 28Feb20 gwb Changed integer declarations to be portable across address
* space sizes (32 vs 64 bit)
* 22Feb20 gwb Replaced a pair of sprintf() with snprintf() in dh_open().
Expand Down Expand Up @@ -138,7 +139,8 @@ DH_FILE* dh_open(char path[]) {

/* Open primary subfile */
/* replaced sprintf() -gwb 22Feb20 */
if (snprintf(pathname, MAX_PATHNAME_LEN + 1, "%s%c~0", filename, DS) >= (MAX_PATHNAME_LEN + 1)) {
// 17Oct25 mab Change dyn file prefix to %
if (snprintf(pathname, MAX_PATHNAME_LEN + 1, "%s%c%%0", filename, DS) >= (MAX_PATHNAME_LEN + 1)) {
/* TODO: this should be added to the system log file. */
k_error("Overflowed directory/filename path length in dh_open()!");
goto exit_dh_open;
Expand Down Expand Up @@ -197,7 +199,8 @@ DH_FILE* dh_open(char path[]) {

/* Open overflow subfile */
/* converted to snprintf() -gwb 22Feb20 */
if (snprintf(pathname, MAX_PATHNAME_LEN + 1, "%s%c~1", filename, DS) >= (MAX_PATHNAME_LEN + 1)) {
// 17Oct25 mab Change dyn file prefix to %
if (snprintf(pathname, MAX_PATHNAME_LEN + 1, "%s%c%%1", filename, DS) >= (MAX_PATHNAME_LEN + 1)) {
/* TODO: this should be added to the system log file. */
k_error("Overflowed directory/filename path length in dh_open()!");
goto exit_dh_open;
Expand Down
9 changes: 6 additions & 3 deletions gplsrc/op_dio1.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* ScarletDME Wiki: https://scarlet.deltasoft.com
*
* START-HISTORY (ScarletDME):
* 17Oct25 mab Change dyn file prefix to %
* 28Feb20 gwb Changed integer declarations to be portable across address
* space sizes (32 vs 64 bit)
*
Expand Down Expand Up @@ -709,18 +710,20 @@ Private void open_file(bool map_name) /* Map file name via VOC entry */
/* !LINUX! There appears to be no reliable way to do this */

/* Determine file type by examination of the directory. This should contain
a file named ~0 if it is a DH file. Otherwise assume it to be directory. */
a file named %0 if it is a DH file. Otherwise assume it to be directory. */

if (pathname[strlen(pathname) - 1] == DS) {
/* converted to snprintf() -gwb 22Feb20 */
if (snprintf(s, MAX_PATHNAME_LEN + 1, "%s~0", pathname) >= (MAX_PATHNAME_LEN + 1)) {
// 17Oct25 mab Change dyn file prefix to %
if (snprintf(s, MAX_PATHNAME_LEN + 1, "%s%%0", pathname) >= (MAX_PATHNAME_LEN + 1)) {
/* TODO: this error should be sent out to a log file with more info */
k_error("Overflow of path/filename max lengthn in open_file()");
goto exit_op_open;
}
} else
/* converted to snprintf() - gwb 22Feb20 */
if (snprintf(s, MAX_PATHNAME_LEN + 1,"%s%c~0", pathname, DS) >= (MAX_PATHNAME_LEN + 1)) {
// 17Oct25 mab Change dyn file prefix to %
if (snprintf(s, MAX_PATHNAME_LEN + 1,"%s%c%%0", pathname, DS) >= (MAX_PATHNAME_LEN + 1)) {
/* TODO: this error should be sent out to a log file with more info */
k_error("Overflow of path/filename max lengthn in open_file()");
goto exit_op_open;
Expand Down
7 changes: 4 additions & 3 deletions gplsrc/op_seqio.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* ScarletDME Wiki: https://scarlet.deltasoft.com
*
* START-HISTORY (ScarletDME):
* 17Oct25 mab Change dyn file prefix to %
* 28Feb20 gwb Changed integer declarations to be portable across address
* space sizes (32 vs 64 bit)
*
Expand Down Expand Up @@ -488,11 +489,11 @@ Private void openseq(bool map_name) {
process.status = ER_FNF;
goto exit_op_openseq;
}

// 17Oct25 mab Change dyn file prefix to %
/* Check if it is a directory file. The best we can do here is to check that
it is a directory and that there is no ~0 subfile. */
it is a directory and that there is no %0 subfile. */
/* converted to snprintf() -gwb 22Feb20 */
if (snprintf(pathname, MAX_PATHNAME_LEN + 1, "%s%c~0", file_name, DS) >=
if (snprintf(pathname, MAX_PATHNAME_LEN + 1, "%s%c%%0", file_name, DS) >=
(MAX_PATHNAME_LEN + 1)) {
/* TODO: this should be logged to disk with more information */
k_error("Overflowed path/filename size in openseq()");
Expand Down
Loading