Skip to content
Commits on Source (5)
......@@ -32,23 +32,22 @@
UI_Aboutwindow::UI_Aboutwindow(UI_Mainwindow *mainwindow)
{
char str[512];
char str[1024];
strcpy(str, " QT version at runtime is ");
strncat(str, qVersion(), 32);
strcat(str, "\n QT version at compiletime is ");
strncat(str, QT_VERSION_STR, 32);
strncat(str, "\n Compiled on " __DATE__ " " __TIME__, 40);
sprintf(str + strlen(str), "\n CPU-cores detected on this system: %i", mainwindow->maincurve->cpu_cnt);
strlcpy(str, " QT version at runtime is ", 512);
strlcat(str, qVersion(), 512);
strlcat(str, "\n QT version at compiletime is ", 512);
strlcat(str, QT_VERSION_STR, 512);
strlcat(str, "\n Compiled on " __DATE__ " " __TIME__, 512);
snprintf(str + strlen(str), 512, "\n CPU-cores detected on this system: %i", mainwindow->maincurve->cpu_cnt);
if(mainwindow->use_threads == 1)
{
strcat(str, "\n Multi-Threading is enabled.");
strlcat(str, "\n Multi-Threading is enabled.", 1024);
}
else
{
strcat(str, "\n Multi-Threading is disabled.");
strlcat(str, "\n Multi-Threading is disabled.", 1024);
}
str[511] = 0;
AboutDialog = new QDialog;
......
......@@ -44,6 +44,7 @@
#include "global.h"
#include "mainwindow.h"
#include "utils.h"
......
......@@ -44,6 +44,7 @@
#include "global.h"
#include "mainwindow.h"
#include "utils.h"
......
......@@ -69,14 +69,14 @@ AdjustFilterSettings::AdjustFilterSettings(struct signalcompblock *signal_comp,
filtersettings_dialog->setMinimumSize(460, 255);
filtersettings_dialog->setMaximumSize(460, 255);
strcpy(txtbuf, "Filter settings ");
strlcpy(txtbuf, "Filter settings ", 2048);
if(signalcomp->alias[0] != 0)
{
strcat(txtbuf, signalcomp->alias);
strlcat(txtbuf, signalcomp->alias, 2048);
}
else
{
strcat(txtbuf, signalcomp->signallabel);
strlcat(txtbuf, signalcomp->signallabel, 2048);
}
filtersettings_dialog->setWindowTitle(txtbuf);
filtersettings_dialog->setModal(true);
......@@ -161,9 +161,7 @@ void AdjustFilterSettings::loadFilterSettings(void)
{
int i;
char txtbuf[2048];
txtbuf[0] = 0;
char txtbuf[2048]={""};
filterbox->clear();
......@@ -183,17 +181,17 @@ void AdjustFilterSettings::loadFilterSettings(void)
{
if(model == 0)
{
sprintf(txtbuf, "HighPass Butterworth");
snprintf(txtbuf, 2048, "HighPass Butterworth");
}
if(model == 1)
{
sprintf(txtbuf, "HighPass Chebyshev %.1fdB ripple", ripple);
snprintf(txtbuf, 2048, "HighPass Chebyshev %.1fdB ripple", ripple);
}
if(model == 2)
{
sprintf(txtbuf, "HighPass Bessel");
snprintf(txtbuf, 2048, "HighPass Bessel");
}
}
......@@ -201,40 +199,40 @@ void AdjustFilterSettings::loadFilterSettings(void)
{
if(model == 0)
{
sprintf(txtbuf, "LowPass Butterworth");
snprintf(txtbuf, 2048, "LowPass Butterworth");
}
if(model == 1)
{
sprintf(txtbuf, "LowPass Chebyshev %.1fdB ripple", ripple);
snprintf(txtbuf, 2048, "LowPass Chebyshev %.1fdB ripple", ripple);
}
if(model == 2)
{
sprintf(txtbuf, "LowPass Bessel");
snprintf(txtbuf, 2048, "LowPass Bessel");
}
}
if(type == 2)
{
sprintf(txtbuf, "Notch (resonator)");
snprintf(txtbuf, 2048, "Notch (resonator)");
}
if(type == 3)
{
if(model == 0)
{
sprintf(txtbuf, "BandPass Butterworth");
snprintf(txtbuf, 2048, "BandPass Butterworth");
}
if(model == 1)
{
sprintf(txtbuf, "BandPass Chebyshev %.1fdB ripple", ripple);
snprintf(txtbuf, 2048, "BandPass Chebyshev %.1fdB ripple", ripple);
}
if(model == 2)
{
sprintf(txtbuf, "BandPass Bessel");
snprintf(txtbuf, 2048, "BandPass Bessel");
}
}
......@@ -242,25 +240,25 @@ void AdjustFilterSettings::loadFilterSettings(void)
{
if(model == 0)
{
sprintf(txtbuf, "BandStop Butterworth");
snprintf(txtbuf, 2048, "BandStop Butterworth");
}
if(model == 1)
{
sprintf(txtbuf, "BandStop Chebyshev %.1fdB ripple", ripple);
snprintf(txtbuf, 2048, "BandStop Chebyshev %.1fdB ripple", ripple);
}
if(model == 2)
{
sprintf(txtbuf, "BandStop Bessel");
snprintf(txtbuf, 2048, "BandStop Bessel");
}
}
sprintf(txtbuf + strlen(txtbuf), " %f", frequency1);
snprintf(txtbuf + strlen(txtbuf), 2048, " %f", frequency1);
remove_trailing_zeros(txtbuf);
strcat(txtbuf, " Hz");
strlcat(txtbuf, " Hz", 2048);
filterbox->addItem(txtbuf);
......@@ -275,12 +273,12 @@ void AdjustFilterSettings::loadFilterSettings(void)
if(type == 0)
{
sprintf(txtbuf, "Highpass Moving Average %i samples", size);
snprintf(txtbuf, 2048, "Highpass Moving Average %i samples", size);
}
if(type == 1)
{
sprintf(txtbuf, "Lowpass Moving Average %i samples", size);
snprintf(txtbuf, 2048, "Lowpass Moving Average %i samples", size);
}
filterbox->addItem(txtbuf);
......@@ -589,17 +587,17 @@ void AdjustFilterSettings::update_filter()
{
if(model == 0)
{
sprintf(spec_str_1, "HpBu%i/%f", order, frequency1);
snprintf(spec_str_1, 256, "HpBu%i/%f", order, frequency1);
}
if(model == 1)
{
sprintf(spec_str_1, "HpCh%i/%f/%f", order, ripple, frequency1);
snprintf(spec_str_1, 256, "HpCh%i/%f/%f", order, ripple, frequency1);
}
if(model == 2)
{
sprintf(spec_str_1, "HpBe%i/%f", order, frequency1);
snprintf(spec_str_1, 256, "HpBe%i/%f", order, frequency1);
}
}
......@@ -607,40 +605,40 @@ void AdjustFilterSettings::update_filter()
{
if(model == 0)
{
sprintf(spec_str_1, "LpBu%i/%f", order, frequency1);
snprintf(spec_str_1, 256, "LpBu%i/%f", order, frequency1);
}
if(model == 1)
{
sprintf(spec_str_1, "LpCh%i/%f/%f", order, ripple, frequency1);
snprintf(spec_str_1, 256, "LpCh%i/%f/%f", order, ripple, frequency1);
}
if(model == 2)
{
sprintf(spec_str_1, "LpBe%i/%f", order, frequency1);
snprintf(spec_str_1, 256, "LpBe%i/%f", order, frequency1);
}
}
if(type == 2)
{
sprintf(spec_str_1, "BsRe/%i/%f", order, frequency1);
snprintf(spec_str_1, 256, "BsRe/%i/%f", order, frequency1);
}
if(type == 3)
{
if(model == 0)
{
sprintf(spec_str_1, "BpBu%i/%f-%f", order, frequency1, frequency2);
snprintf(spec_str_1, 256, "BpBu%i/%f-%f", order, frequency1, frequency2);
}
if(model == 1)
{
sprintf(spec_str_1, "BpCh%i/%f/%f-%f", order, ripple, frequency1, frequency2);
snprintf(spec_str_1, 256, "BpCh%i/%f/%f-%f", order, ripple, frequency1, frequency2);
}
if(model == 2)
{
sprintf(spec_str_1, "BpBe%i/%f-%f", order, frequency1, frequency2);
snprintf(spec_str_1, 256, "BpBe%i/%f-%f", order, frequency1, frequency2);
}
}
......@@ -648,21 +646,21 @@ void AdjustFilterSettings::update_filter()
{
if(model == 0)
{
sprintf(spec_str_1, "BsBu%i/%f-%f", order, frequency1, frequency2);
snprintf(spec_str_1, 256, "BsBu%i/%f-%f", order, frequency1, frequency2);
}
if(model == 1)
{
sprintf(spec_str_1, "BsCh%i/%f/%f-%f", order, ripple, frequency1, frequency2);
snprintf(spec_str_1, 256, "BsCh%i/%f/%f-%f", order, ripple, frequency1, frequency2);
}
if(model == 2)
{
sprintf(spec_str_1, "BsBe%i/%f-%f", order, frequency1, frequency2);
snprintf(spec_str_1, 256, "BsBe%i/%f-%f", order, frequency1, frequency2);
}
}
strcpy(spec_str_2, spec_str_1);
strlcpy(spec_str_2, spec_str_1, 256);
filter_spec = spec_str_2;
......
......@@ -195,7 +195,7 @@ void UI_Annotationswindow::show_stats(bool)
annot_list = &mainwindow->edfheaderlist[file_num]->annot_list;
if(annot_list == NULL)
{
sprintf(str, "Nullpointer returned: file: %s line %i", __FILE__, __LINE__);
snprintf(str, 4096, "Nullpointer returned: file: %s line %i", __FILE__, __LINE__);
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
messagewindow.exec();
return;
......@@ -204,7 +204,7 @@ void UI_Annotationswindow::show_stats(bool)
annot = edfplus_annotation_get_item_visible_only(annot_list, list->currentRow());
if(annot == NULL)
{
sprintf(str, "Nullpointer returned: file: %s line %i", __FILE__, __LINE__);
snprintf(str, 4096, "Nullpointer returned: file: %s line %i", __FILE__, __LINE__);
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
messagewindow.exec();
return;
......@@ -402,7 +402,7 @@ void UI_Annotationswindow::filter_edited(const QString text)
return;
}
strcpy(filter_str, lineedit1->text().toUtf8().data());
strlcpy(filter_str, lineedit1->text().toUtf8().data(), 32);
len = strlen(filter_str);
......@@ -648,7 +648,7 @@ void UI_Annotationswindow::hide_same_annots(bool)
annot = edfplus_annotation_get_item_visible_only(annot_list, n);
strcpy(str1, annot->annotation);
strlcpy(str1, annot->annotation, MAX_ANNOTATION_LEN);
remove_leading_spaces(str1);
......@@ -658,7 +658,7 @@ void UI_Annotationswindow::hide_same_annots(bool)
{
annot = edfplus_annotation_get_item(annot_list, i);
strcpy(str2, annot->annotation);
strlcpy(str2, annot->annotation, MAX_ANNOTATION_LEN);
remove_leading_spaces(str2);
......@@ -699,7 +699,7 @@ void UI_Annotationswindow::unhide_same_annots(bool)
annot = edfplus_annotation_get_item_visible_only(annot_list, n);
strcpy(str1, annot->annotation);
strlcpy(str1, annot->annotation, MAX_ANNOTATION_LEN);
remove_leading_spaces(str1);
......@@ -709,7 +709,7 @@ void UI_Annotationswindow::unhide_same_annots(bool)
{
annot = edfplus_annotation_get_item(annot_list, i);
strcpy(str2, annot->annotation);
strlcpy(str2, annot->annotation, MAX_ANNOTATION_LEN);
remove_leading_spaces(str2);
......@@ -958,7 +958,7 @@ void UI_Annotationswindow::updateList(void)
remove_trailing_zeros(str);
strcat(str, "\n\n");
strlcat(str, "\n\n", MAX_ANNOTATION_LEN + 32);
string = QString::fromLatin1(str);
......
......@@ -137,7 +137,7 @@ UI_AnnotFilterWindow::UI_AnnotFilterWindow(QWidget *w_parent, struct annotationb
CloseButton->setText("Close");
sel_annot_ptr = annot;
strcpy(sel_annot_str, sel_annot_ptr->annotation);
strlcpy(sel_annot_str, sel_annot_ptr->annotation, MAX_ANNOTATION_LEN + 1);
remove_leading_spaces(sel_annot_str);
remove_trailing_spaces(sel_annot_str);
......@@ -244,7 +244,7 @@ void UI_AnnotFilterWindow::apply_filter()
{
annot = edfplus_annotation_get_item(annot_list, i);
strcpy(annot_str, annot->annotation);
strlcpy(annot_str, annot->annotation, MAX_ANNOTATION_LEN + 1);
remove_leading_spaces(sel_annot_str);
remove_trailing_spaces(annot_str);
......
......@@ -359,7 +359,7 @@ void UI_ASCII2EDFapp::gobuttonpressed()
return;
}
strcpy(path, QFileDialog::getOpenFileName(0, "Open ASCII file", QString::fromLocal8Bit(recent_opendir), "ASCII files (*.txt *.TXT *.csv *.CSV)").toLocal8Bit().data());
strlcpy(path, QFileDialog::getOpenFileName(0, "Open ASCII file", QString::fromLocal8Bit(recent_opendir), "ASCII files (*.txt *.TXT *.csv *.CSV)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(path, ""))
{
......@@ -672,23 +672,23 @@ void UI_ASCII2EDFapp::gobuttonpressed()
outputfilename[0] = 0;
if(recent_savedir[0]!=0)
{
strcpy(outputfilename, recent_savedir);
strcat(outputfilename, "/");
strlcpy(outputfilename, recent_savedir, MAX_PATH_LENGTH);
strlcat(outputfilename, "/", MAX_PATH_LENGTH);
}
len = strlen(outputfilename);
get_filename_from_path(outputfilename + len, path, MAX_PATH_LENGTH - len);
remove_extension_from_filename(outputfilename);
if(edf_format)
{
strcat(outputfilename, ".edf");
strlcat(outputfilename, ".edf", MAX_PATH_LENGTH);
strcpy(outputfilename, QFileDialog::getSaveFileName(0, "Output file", QString::fromLocal8Bit(outputfilename), "EDF files (*.edf *.EDF)").toLocal8Bit().data());
strlcpy(outputfilename, QFileDialog::getSaveFileName(0, "Output file", QString::fromLocal8Bit(outputfilename), "EDF files (*.edf *.EDF)").toLocal8Bit().data(), MAX_PATH_LENGTH);
}
else
{
strcat(outputfilename, ".bdf");
strlcat(outputfilename, ".bdf", MAX_PATH_LENGTH);
strcpy(outputfilename, QFileDialog::getSaveFileName(0, "Output file", QString::fromLocal8Bit(outputfilename), "BDF files (*.bdf *.BDF)").toLocal8Bit().data());
strlcpy(outputfilename, QFileDialog::getSaveFileName(0, "Output file", QString::fromLocal8Bit(outputfilename), "BDF files (*.bdf *.BDF)").toLocal8Bit().data(), MAX_PATH_LENGTH);
}
if(!strcmp(outputfilename, ""))
......@@ -816,8 +816,8 @@ void UI_ASCII2EDFapp::gobuttonpressed()
{
if(autoPhysicalMaximum)
{
sprintf(str, "%.8f", physmax[edf_signal++] * -1.0);
strcat(str, " ");
snprintf(str, 256, "%.8f", physmax[edf_signal++] * -1.0);
strlcat(str, " ", 256);
str[8] = 0;
fprintf(outputfile, "%s", str);
}
......@@ -841,8 +841,8 @@ void UI_ASCII2EDFapp::gobuttonpressed()
{
if(autoPhysicalMaximum)
{
sprintf(str, "%.8f", physmax[edf_signal++]);
strcat(str, " ");
snprintf(str, 256, "%.8f", physmax[edf_signal++]);
strlcat(str, " ", 256);
str[8] = 0;
fprintf(outputfile, "%s", str);
}
......@@ -1196,7 +1196,7 @@ void UI_ASCII2EDFapp::gobuttonpressed()
void UI_ASCII2EDFapp::savebuttonpressed()
{
int i, j, len;
int i;
char path[MAX_PATH_LENGTH],
str[128];
......@@ -1215,12 +1215,12 @@ void UI_ASCII2EDFapp::savebuttonpressed()
path[0] = 0;
if(recent_savedir[0]!=0)
{
strcpy(path, recent_savedir);
strcat(path, "/");
strlcpy(path, recent_savedir, MAX_PATH_LENGTH);
strlcat(path, "/", MAX_PATH_LENGTH);
}
strcat(path, "ascii_to_edf.template");
strlcat(path, "ascii_to_edf.template", MAX_PATH_LENGTH);
strcpy(path, QFileDialog::getSaveFileName(0, "Save parameters", QString::fromLocal8Bit(path), "Template files (*.template *.TEMPLATE)").toLocal8Bit().data());
strlcpy(path, QFileDialog::getSaveFileName(0, "Save parameters", QString::fromLocal8Bit(path), "Template files (*.template *.TEMPLATE)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(path, ""))
{
......@@ -1273,36 +1273,21 @@ void UI_ASCII2EDFapp::savebuttonpressed()
fprintf(outputfile, " <checked>0</checked>\n");
}
strcpy(str, ((QLineEdit *)SignalsTablewidget->cellWidget(i, 1))->text().toLatin1().data());
strlcpy(str, ((QLineEdit *)SignalsTablewidget->cellWidget(i, 1))->text().toLatin1().data(), 128);
len = strlen(str);
for(j=len-1; j>0; j--)
{
if(str[j]!=' ') break;
}
str[j+1] = 0;
remove_trailing_spaces(str);
fprintf(outputfile, " <label>%s</label>\n", str);
strcpy(str, ((QLineEdit *)SignalsTablewidget->cellWidget(i, 2))->text().toLatin1().data());
strlcpy(str, ((QLineEdit *)SignalsTablewidget->cellWidget(i, 2))->text().toLatin1().data(), 128);
len = strlen(str);
for(j=len-1; j>0; j--)
{
if(str[j]!=' ') break;
}
str[j+1] = 0;
remove_trailing_spaces(str);
fprintf(outputfile, " <physical_maximum>%s</physical_maximum>\n", str);
strcpy(str, ((QLineEdit *)SignalsTablewidget->cellWidget(i, 3))->text().toLatin1().data());
strlcpy(str, ((QLineEdit *)SignalsTablewidget->cellWidget(i, 3))->text().toLatin1().data(), 128);
len = strlen(str);
for(j=len-1; j>0; j--)
{
if(str[j]!=' ') break;
}
str[j+1] = 0;
remove_trailing_spaces(str);
fprintf(outputfile, " <physical_dimension>%s</physical_dimension>\n", str);
......@@ -1331,7 +1316,7 @@ void UI_ASCII2EDFapp::loadbuttonpressed()
struct xml_handle *xml_hdl;
strcpy(path, QFileDialog::getOpenFileName(0, "Load parameters", QString::fromLocal8Bit(recent_opendir), "Template files (*.template *.TEMPLATE)").toLocal8Bit().data());
strlcpy(path, QFileDialog::getOpenFileName(0, "Load parameters", QString::fromLocal8Bit(recent_opendir), "Template files (*.template *.TEMPLATE)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(path, ""))
{
......@@ -1649,7 +1634,7 @@ int UI_ASCII2EDFapp::check_input(void)
const char *columnname[]={"", "Label", "Physical maximum", "Physical dimension"};
strcpy(str, SeparatorLineEdit->text().toLatin1().data());
strlcpy(str, SeparatorLineEdit->text().toLatin1().data(), 128);
if(!strcmp(str, "tab"))
{
......@@ -1722,7 +1707,7 @@ int UI_ASCII2EDFapp::check_input(void)
dot = 0;
strcpy(str, ((QLineEdit *)SignalsTablewidget->cellWidget(i, j))->text().toLatin1().data());
strlcpy(str, ((QLineEdit *)SignalsTablewidget->cellWidget(i, j))->text().toLatin1().data(), 128);
len = strlen(str);
......@@ -1878,9 +1863,9 @@ void UI_ASCII2EDFapp::helpbuttonpressed()
#ifdef Q_OS_WIN32
char p_path[MAX_PATH_LENGTH];
strcpy(p_path, "file:///");
strcat(p_path, mainwindow->specialFolder(CSIDL_PROGRAM_FILES).toLocal8Bit().data());
strcat(p_path, "\\EDFbrowser\\manual.html#ASCII_to_EDF_converter");
strlcpy(p_path, "file:///", MAX_PATH_LENGTH);
strlcat(p_path, mainwindow->specialFolder(CSIDL_PROGRAM_FILES).toLocal8Bit().data(), MAX_PATH_LENGTH);
strlcat(p_path, "\\EDFbrowser\\manual.html#ASCII_to_EDF_converter", MAX_PATH_LENGTH);
QDesktopServices::openUrl(QUrl(p_path));
#endif
}
......
......@@ -152,15 +152,15 @@ void UI_AsciiExportwindow::ExportButtonClicked()
path[0] = 0;
if(mainwindow->recent_savedir[0]!=0)
{
strcpy(path, mainwindow->recent_savedir);
strcat(path, "/");
strlcpy(path, mainwindow->recent_savedir, MAX_PATH_LENGTH);
strlcat(path, "/", MAX_PATH_LENGTH);
}
len = strlen(path);
get_filename_from_path(path + len, mainwindow->edfheaderlist[n]->filename, MAX_PATH_LENGTH - len);
remove_extension_from_filename(path);
strcat(path, "_data.txt");
strlcat(path, "_data.txt", MAX_PATH_LENGTH);
strcpy(path, QFileDialog::getSaveFileName(0, "Export to ASCII", QString::fromLocal8Bit(path), "Text files (*.txt *.TXT)").toLocal8Bit().data());
strlcpy(path, QFileDialog::getSaveFileName(0, "Export to ASCII", QString::fromLocal8Bit(path), "Text files (*.txt *.TXT)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(path, ""))
{
......@@ -391,9 +391,9 @@ void UI_AsciiExportwindow::ExportButtonClicked()
/***************** write header ******************************/
strcpy(ascii_path, path);
strlcpy(ascii_path, path, MAX_PATH_LENGTH);
remove_extension_from_filename(ascii_path);
strcat(ascii_path, "_header.txt");
strlcat(ascii_path, "_header.txt", MAX_PATH_LENGTH);
outputfile = fopeno(ascii_path, "wb");
if(outputfile==NULL)
{
......@@ -434,9 +434,9 @@ void UI_AsciiExportwindow::ExportButtonClicked()
/***************** write signals ******************************/
strcpy(ascii_path, path);
strlcpy(ascii_path, path, MAX_PATH_LENGTH);
remove_extension_from_filename(ascii_path);
strcat(ascii_path, "_signals.txt");
strlcat(ascii_path, "_signals.txt", MAX_PATH_LENGTH);
outputfile = fopeno(ascii_path, "wb");
if(outputfile==NULL)
{
......@@ -485,9 +485,9 @@ void UI_AsciiExportwindow::ExportButtonClicked()
/***************** open annotation file ******************************/
strcpy(ascii_path, path);
strlcpy(ascii_path, path, MAX_PATH_LENGTH);
remove_extension_from_filename(ascii_path);
strcat(ascii_path, "_annotations.txt");
strlcat(ascii_path, "_annotations.txt", MAX_PATH_LENGTH);
annotationfile = fopeno(ascii_path, "wb");
if(annotationfile==NULL)
{
......@@ -507,9 +507,9 @@ void UI_AsciiExportwindow::ExportButtonClicked()
/***************** write data ******************************/
strcpy(ascii_path, path);
strlcpy(ascii_path, path, MAX_PATH_LENGTH);
remove_extension_from_filename(ascii_path);
strcat(ascii_path, "_data.txt");
strlcat(ascii_path, "_data.txt", MAX_PATH_LENGTH);
outputfile = fopeno(ascii_path, "wb");
if(outputfile==NULL)
{
......@@ -700,7 +700,7 @@ void UI_AsciiExportwindow::ExportButtonClicked()
if(duration)
{
scratchpad[n] = 0;
strcpy(duration_in_txt, scratchpad);
strlcpy(duration_in_txt, scratchpad, max_tal_ln + 3);
n = 0;
duration = 0;
scratchpad[0] = 0;
......@@ -735,7 +735,7 @@ void UI_AsciiExportwindow::ExportButtonClicked()
else
{
scratchpad[n] = 0;
strcpy(time_in_txt, scratchpad);
strlcpy(time_in_txt, scratchpad, max_tal_ln + 3);
n = 0;
onset = 1;
duration = 0;
......@@ -750,7 +750,7 @@ void UI_AsciiExportwindow::ExportButtonClicked()
if(!onset)
{
scratchpad[n] = 0;
strcpy(time_in_txt, scratchpad);
strlcpy(time_in_txt, scratchpad, max_tal_ln + 3);
onset = 1;
}
n = 0;
......
......@@ -73,7 +73,7 @@ UI_AverageCurveWindow::UI_AverageCurveWindow(struct signalcompblock *signal_comp
avg_period = avg__period;
strcpy(avg_annotation, annotation);
strlcpy(avg_annotation, annotation, MAX_ANNOTATION_LEN + 1);
flywheel_value = 1000;
......@@ -85,8 +85,8 @@ UI_AverageCurveWindow::UI_AverageCurveWindow(struct signalcompblock *signal_comp
averager_curve_dialog->setWindowFlags(Qt::Window | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
averager_curve_dialog->setWindowIcon(QIcon(":/images/edf.png"));
strcpy(str, "Averaging ");
strcat(str, signalcomp->signallabel);
strlcpy(str, "Averaging ", 1024);
strlcat(str, signalcomp->signallabel, 1024);
averager_curve_dialog->setWindowTitle(str);
curve1 = new SignalCurve;
......@@ -102,7 +102,7 @@ UI_AverageCurveWindow::UI_AverageCurveWindow(struct signalcompblock *signal_comp
curve1->setMarker1Color(Qt::yellow);
curve1->create_button("to EDF/BDF");
sprintf(str, "Averaging %i triggers \"%s\"", avg_cnt, avg_annotation);
snprintf(str, 1024, "Averaging %i triggers \"%s\"", avg_cnt, avg_annotation);
curve1->setUpperLabel1(str);
flywheel1 = new UI_Flywheel;
......@@ -254,27 +254,27 @@ void UI_AverageCurveWindow::export_edf(void)
path[0] = 0;
if(mainwindow->recent_savedir[0]!=0)
{
strcpy(path, mainwindow->recent_savedir);
strcat(path, "/");
strlcpy(path, mainwindow->recent_savedir, MAX_PATH_LENGTH);
strlcat(path, "/", MAX_PATH_LENGTH);
}
get_filename_from_path(path + strlen(path), signalcomp->edfhdr->filename, 512);
remove_extension_from_filename(path);
sprintf(path + strlen(path), " averaging %s %i triggers [%s]",
snprintf(path + strlen(path), MAX_PATH_LENGTH - strlen(path), " averaging %s %i triggers [%s]",
signalcomp->signallabel,
avg_cnt,
avg_annotation);
if(signalcomp->edfhdr->edf)
{
strcat(path, ".edf");
strlcat(path, ".edf", MAX_PATH_LENGTH);
strcpy(path, QFileDialog::getSaveFileName(0, "Save as EDF", QString::fromLocal8Bit(path), "EDF files (*.edf *.EDF)").toLocal8Bit().data());
strlcpy(path, QFileDialog::getSaveFileName(0, "Save as EDF", QString::fromLocal8Bit(path), "EDF files (*.edf *.EDF)").toLocal8Bit().data(), MAX_PATH_LENGTH);
}
else
{
strcat(path, ".bdf");
strlcat(path, ".bdf", MAX_PATH_LENGTH);
strcpy(path, QFileDialog::getSaveFileName(0, "Save as BDF", QString::fromLocal8Bit(path), "BDF files (*.bdf *.BDF)").toLocal8Bit().data());
strlcpy(path, QFileDialog::getSaveFileName(0, "Save as BDF", QString::fromLocal8Bit(path), "BDF files (*.bdf *.BDF)").toLocal8Bit().data(), MAX_PATH_LENGTH);
}
if(!strcmp(path, ""))
......@@ -337,27 +337,27 @@ void UI_AverageCurveWindow::export_edf(void)
if(type == 0)
{
p += sprintf(str + p, "HP:%f", frequency);
p += snprintf(str + p, 4096 - p, "HP:%f", frequency);
}
if(type == 1)
{
p += sprintf(str + p, "LP:%f", frequency);
p += snprintf(str + p, 4096 - p, "LP:%f", frequency);
}
if(type == 2)
{
p += sprintf(str + p, "N:%f", frequency);
p += snprintf(str + p, 4096 - p, "N:%f", frequency);
}
if(type == 3)
{
p += sprintf(str + p, "BP:%f", frequency);
p += snprintf(str + p, 4096 - p, "BP:%f", frequency);
}
if(type == 4)
{
p += sprintf(str + p, "BS:%f", frequency);
p += snprintf(str + p, 4096 - p, "BS:%f", frequency);
}
for(k=(p-1); k>0; k--)
......@@ -372,7 +372,7 @@ void UI_AverageCurveWindow::export_edf(void)
if((type == 3) || (type == 4))
{
p += sprintf(str + p, "-%f", frequency2);
p += snprintf(str + p, 4096 - p, "-%f", frequency2);
for(k=(p-1); k>0; k--)
{
......@@ -383,7 +383,7 @@ void UI_AverageCurveWindow::export_edf(void)
else str[k+1] = 0;
}
strcat(str, "Hz ");
strlcat(str, "Hz ", 4096);
p = strlen(str);
......@@ -394,12 +394,12 @@ void UI_AverageCurveWindow::export_edf(void)
{
if(signalcomp->ravg_filter_type[j] == 0)
{
p += sprintf(str + p, "HP:%iSmpls ", signalcomp->ravg_filter[j]->size);
p += snprintf(str + p, 4096 - p, "HP:%iSmpls ", signalcomp->ravg_filter[j]->size);
}
if(signalcomp->ravg_filter_type[j] == 1)
{
p += sprintf(str + p, "LP:%iSmpls ", signalcomp->ravg_filter[j]->size);
p += snprintf(str + p, 4096 - p, "LP:%iSmpls ", signalcomp->ravg_filter[j]->size);
}
p = strlen(str);
......@@ -409,17 +409,17 @@ void UI_AverageCurveWindow::export_edf(void)
if(signalcomp->fir_filter)
{
p += sprintf(str + p, "FIR ");
p += snprintf(str + p, 4096 - p, "FIR ");
}
strcat(str, signalcomp->edfhdr->edfparam[signalcomp->edfsignal[0]].prefilter);
strlcat(str, signalcomp->edfhdr->edfparam[signalcomp->edfsignal[0]].prefilter, 4096);
edf_set_prefilter(edf_hdl, 0, str);
edf_set_transducer(edf_hdl, 0, signalcomp->edfhdr->edfparam[signalcomp->edfsignal[0]].transducer);
if((signalcomp->edfhdr->edfplus) || (signalcomp->edfhdr->bdfplus))
{
edf_set_patientname(edf_hdl, signalcomp->edfhdr->plus_patient_name);
sprintf(str, "%i triggers \"%s\" averaged. %s", avg_cnt, avg_annotation, signalcomp->edfhdr->plus_recording_additional);
snprintf(str, 4096, "%i triggers \"%s\" averaged. %s", avg_cnt, avg_annotation, signalcomp->edfhdr->plus_recording_additional);
edf_set_recording_additional(edf_hdl, str);
edf_set_patientcode(edf_hdl, signalcomp->edfhdr->plus_patientcode);
if(signalcomp->edfhdr->plus_gender[0] == 'M')
......@@ -438,7 +438,7 @@ void UI_AverageCurveWindow::export_edf(void)
else
{
edf_set_patientname(edf_hdl, signalcomp->edfhdr->patient);
sprintf(str, "%i triggers \"%s\" averaged. %s", avg_cnt, avg_annotation, signalcomp->edfhdr->recording);
snprintf(str, 4096, "%i triggers \"%s\" averaged. %s", avg_cnt, avg_annotation, signalcomp->edfhdr->recording);
edf_set_recording_additional(edf_hdl, str);
}
......
......@@ -142,7 +142,7 @@ UI_AveragerWindow::UI_AveragerWindow(QWidget *w_parent, int annot_nr, int file_n
annot_ptr = edfplus_annotation_get_item_visible_only(&mainwindow->edfheaderlist[file_num]->annot_list, annot_nr);
strcpy(annot_str, annot_ptr->annotation);
strlcpy(annot_str, annot_ptr->annotation, MAX_ANNOTATION_LEN + 1);
remove_leading_spaces(annot_str);
remove_trailing_spaces(annot_str);
......@@ -198,7 +198,7 @@ void UI_AveragerWindow::startButtonClicked()
if(itemCnt > MAXAVERAGECURVEDIALOGS)
{
sprintf(scratchpad,"You can not select more than %i signals.", MAXAVERAGECURVEDIALOGS);
snprintf(scratchpad, 1024, "You can not select more than %i signals.", MAXAVERAGECURVEDIALOGS);
QMessageBox messagewindow(QMessageBox::Critical, "Error", scratchpad);
messagewindow.exec();
return;
......@@ -250,7 +250,7 @@ void UI_AveragerWindow::startButtonClicked()
if(((annot_ptr->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) >= l_time1)
&& ((annot_ptr->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) <= l_time2))
{
strcpy(str, annot_ptr->annotation);
strlcpy(str, annot_ptr->annotation, MAX_ANNOTATION_LEN + 1);
remove_leading_spaces(str);
remove_trailing_spaces(str);
......@@ -345,7 +345,7 @@ void UI_AveragerWindow::startButtonClicked()
if(((annot_ptr->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) >= l_time1)
&& ((annot_ptr->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) <= l_time2))
{
strcpy(str, annot_ptr->annotation);
strlcpy(str, annot_ptr->annotation, MAX_ANNOTATION_LEN + 1);
remove_leading_spaces(str);
remove_trailing_spaces(str);
......@@ -393,7 +393,8 @@ void UI_AveragerWindow::startButtonClicked()
if(!avg_cnt)
{
sprintf(scratchpad, "The selected annotation/trigger \"%s\" is not in the selected timewindow\n"
snprintf(scratchpad, 1024,
"The selected annotation/trigger \"%s\" is not in the selected timewindow\n"
"%i:%02i:%02i - %i:%02i:%02i",
annot_str,
timeEdit1->time().hour(), timeEdit1->time().minute(), timeEdit1->time().second(),
......
#ifndef BANNED_H
#define BANNED_H
/*
* This header lists functions that have been banned from our code base,
* because they're too easy to misuse (and even if used correctly,
* complicate audits). Including this header turns them into compile-time
* errors.
*/
#define BANNED(func) sorry_##func##_is_a_banned_function
#undef strcpy
#define strcpy(x,y) BANNED(strcpy)
#undef strcat
#define strcat(x,y) BANNED(strcat)
// #undef strncpy
// #define strncpy(x,y,n) BANNED(strncpy)
// #undef strncat
// #define strncat(x,y,n) BANNED(strncat)
#undef sprintf
#undef vsprintf
#ifdef HAVE_VARIADIC_MACROS
#define sprintf(...) BANNED(sprintf)
#define vsprintf(...) BANNED(vsprintf)
#else
#define sprintf(buf,fmt,arg) BANNED(sprintf)
#define vsprintf(buf,fmt,arg) BANNED(vsprintf)
#endif
#endif /* BANNED_H */
......@@ -241,7 +241,7 @@ void UI_BDF2EDFwindow::SelectFileButton()
pushButton5->setEnabled(false);
}
strcpy(inputpath, QFileDialog::getOpenFileName(0, "Select inputfile", QString::fromLocal8Bit(recent_opendir), "BDF files (*.bdf *.BDF)").toLocal8Bit().data());
strlcpy(inputpath, QFileDialog::getOpenFileName(0, "Select inputfile", QString::fromLocal8Bit(recent_opendir), "BDF files (*.bdf *.BDF)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(inputpath, ""))
{
......@@ -263,7 +263,7 @@ void UI_BDF2EDFwindow::SelectFileButton()
EDFfileCheck EDFfilechecker;
edfhdr = EDFfilechecker.check_edf_file(inputfile, txt_string);
edfhdr = EDFfilechecker.check_edf_file(inputfile, txt_string, 2048);
if(edfhdr==NULL)
{
fclose(inputfile);
......@@ -423,16 +423,16 @@ void UI_BDF2EDFwindow::StartConversion()
if(recent_savedir[0]!=0)
{
strcpy(outputpath, recent_savedir);
strcat(outputpath, "/");
strlcpy(outputpath, recent_savedir, MAX_PATH_LENGTH);
strlcat(outputpath, "/", MAX_PATH_LENGTH);
}
len = strlen(outputpath);
get_filename_from_path(outputpath + len, inputpath, MAX_PATH_LENGTH - len);
remove_extension_from_filename(outputpath);
strcat(outputpath, ".edf");
strlcat(outputpath, ".edf", MAX_PATH_LENGTH);
strcpy(outputpath, QFileDialog::getSaveFileName(0, "Select outputfile", QString::fromLocal8Bit(outputpath), "EDF files (*.edf *.EDF)").toLocal8Bit().data());
strlcpy(outputpath, QFileDialog::getSaveFileName(0, "Select outputfile", QString::fromLocal8Bit(outputpath), "EDF files (*.edf *.EDF)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(outputpath, ""))
{
......@@ -582,9 +582,9 @@ void UI_BDF2EDFwindow::StartConversion()
{
snprintf(scratchpad, 256, "HP:%f", ((QDoubleSpinBox *)(SignalsTablewidget->cellWidget(signalslist[i], 1)))->value());
remove_trailing_zeros(scratchpad);
strcat(scratchpad, "Hz ");
strlcat(scratchpad, "Hz ", 256);
strcat(scratchpad, edfhdr->edfparam[signalslist[i]].prefilter);
strlcat(scratchpad, edfhdr->edfparam[signalslist[i]].prefilter, 256);
for(j=strlen(scratchpad); j<200; j++)
{
......
......@@ -215,7 +215,7 @@ int BDF_triggers::get_triggers(struct edfhdrblock *hdr)
annotation.file_num = hdr->file_num;
annotation.onset = (records_read * TIME_DIMENSION) + ((long long)(i / 3) * status_sample_duration);
annotation.onset += hdr->starttime_offset;
sprintf(annotation.annotation, "new epoch");
strlcpy(annotation.annotation, "new epoch", MAX_ANNOTATION_LEN_II + 1);
annotation.ident = (1 << ANNOT_ID_BS_TRIGGER);
if(edfplus_annotation_add_item(annot_list, annotation))
{
......@@ -247,7 +247,7 @@ int BDF_triggers::get_triggers(struct edfhdrblock *hdr)
{
annotation.onset = (records_read * TIME_DIMENSION) + ((long long)(i / 3) * status_sample_duration);
annotation.onset += hdr->starttime_offset;
sprintf(annotation.annotation, "Trigger Input %i", j + 1);
snprintf(annotation.annotation, MAX_ANNOTATION_LEN_II + 1, "Trigger Input %i", j + 1);
annotation.ident = (1 << ANNOT_ID_BS_TRIGGER);
if(edfplus_annotation_add_item(annot_list, annotation))
{
......
......@@ -45,6 +45,7 @@
#include "global.h"
#include "edf_annot_list.h"
#include "utils.h"
......
......@@ -98,7 +98,7 @@ void UI_BI98002EDFwindow::SelectFileButton()
strcpy(path, QFileDialog::getOpenFileName(0, "Select inputfile", QString::fromLocal8Bit(recent_opendir), "DCM files (*.dcm *.DCM)").toLocal8Bit().data());
strlcpy(path, QFileDialog::getOpenFileName(0, "Select inputfile", QString::fromLocal8Bit(recent_opendir), "DCM files (*.dcm *.DCM)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(path, ""))
{
......@@ -119,12 +119,12 @@ void UI_BI98002EDFwindow::SelectFileButton()
}
remove_extension_from_filename(path);
strcat(path, ".EVT");
strlcat(path, ".EVT", MAX_PATH_LENGTH);
evtfile = fopeno(path, "rb");
if(evtfile==NULL)
{
remove_extension_from_filename(path);
strcat(path, ".evt");
strlcat(path, ".evt", MAX_PATH_LENGTH);
evtfile = fopeno(path, "rb");
if(evtfile==NULL)
{
......@@ -306,14 +306,14 @@ void UI_BI98002EDFwindow::SelectFileButton()
path[0] = 0;
if(recent_savedir[0]!=0)
{
strcpy(path, recent_savedir);
strcat(path, "/");
strlcpy(path, recent_savedir, MAX_PATH_LENGTH);
strlcat(path, "/", MAX_PATH_LENGTH);
}
strcat(path, outputfilename);
strlcat(path, outputfilename, MAX_PATH_LENGTH);
remove_extension_from_filename(path);
strcat(path, ".edf");
strlcat(path, ".edf", MAX_PATH_LENGTH);
strcpy(path, QFileDialog::getSaveFileName(0, "Select outputfile", QString::fromLocal8Bit(path), "EDF files (*.edf *.EDF)").toLocal8Bit().data());
strlcpy(path, QFileDialog::getSaveFileName(0, "Select outputfile", QString::fromLocal8Bit(path), "EDF files (*.edf *.EDF)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(path, ""))
{
......
......@@ -70,12 +70,12 @@ UI_BIOSEMI2BDFPLUSwindow::UI_BIOSEMI2BDFPLUSwindow(QWidget *w_parent)
{
label1[i] = new QLabel(myobjectDialog);
label1[i]->setGeometry(20, 50 + (i * 30), 20, 25);
sprintf(str, "%i", i + 1);
snprintf(str, 128, "%i", i + 1);
label1[i]->setText(str);
lineEdit1[i] = new QLineEdit(myobjectDialog);
lineEdit1[i]->setGeometry(70, 50 + (i * 30), 120, 25);
sprintf(str, "Trigger Input %i", i + 1);
snprintf(str, 128, "Trigger Input %i", i + 1);
lineEdit1[i]->setText(str);
lineEdit1[i]->setMaxLength(16);
}
......@@ -158,7 +158,7 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
{
if(!lineEdit1[i]->text().length())
{
sprintf(str, "Trigger Input label %i is empty!", i + 1);
snprintf(str, 2048, "Trigger Input label %i is empty!", i + 1);
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
messagewindow.exec();
return;
......@@ -173,7 +173,7 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
{
if(!strcmp(lineEdit1[i]->text().toLocal8Bit().data(), lineEdit1[j]->text().toLocal8Bit().data()))
{
sprintf(str, "Trigger Input labels %i and %i are the same!", i + 1, j + 1);
snprintf(str, 2048, "Trigger Input labels %i and %i are the same!", i + 1, j + 1);
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
messagewindow.exec();
return;
......@@ -184,7 +184,7 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
str[0] = 0;
strcpy(inputpath, QFileDialog::getOpenFileName(0, "Select inputfile", QString::fromLocal8Bit(recent_opendir), "BDF files (*.bdf *.BDF)").toLocal8Bit().data());
strlcpy(inputpath, QFileDialog::getOpenFileName(0, "Select inputfile", QString::fromLocal8Bit(recent_opendir), "BDF files (*.bdf *.BDF)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(inputpath, ""))
{
......@@ -201,29 +201,29 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
switch(error)
{
case EDFLIB_MALLOC_ERROR : strcpy(str, "EDFlib: malloc error.");
case EDFLIB_MALLOC_ERROR : strlcpy(str, "EDFlib: malloc error.", 2048);
break;
case EDFLIB_NO_SUCH_FILE_OR_DIRECTORY : strcpy(str, "EDFlib: no such file or directory.");
case EDFLIB_NO_SUCH_FILE_OR_DIRECTORY : strlcpy(str, "EDFlib: no such file or directory.", 2048);
break;
case EDFLIB_FILE_CONTAINS_FORMAT_ERRORS : strcpy(str, "EDFlib: file contains format errors.\nOpen the file in EDFbrowser to get more info.");
case EDFLIB_FILE_CONTAINS_FORMAT_ERRORS : strlcpy(str, "EDFlib: file contains format errors.\nOpen the file in EDFbrowser to get more info.", 2048);
break;
case EDFLIB_MAXFILES_REACHED : strcpy(str, "EDFlib: maximum amount of files reached.");
case EDFLIB_MAXFILES_REACHED : strlcpy(str, "EDFlib: maximum amount of files reached.", 2048);
break;
case EDFLIB_FILE_READ_ERROR : strcpy(str, "EDFlib: a file read error occurred.");
case EDFLIB_FILE_READ_ERROR : strlcpy(str, "EDFlib: a file read error occurred.", 2048);
break;
case EDFLIB_FILE_ALREADY_OPENED : strcpy(str, "EDFlib: file is already opened.");
case EDFLIB_FILE_ALREADY_OPENED : strlcpy(str, "EDFlib: file is already opened.", 2048);
break;
case EDFLIB_FILETYPE_ERROR : strcpy(str, "EDFlib: filetype error.");
case EDFLIB_FILETYPE_ERROR : strlcpy(str, "EDFlib: filetype error.", 2048);
break;
case EDFLIB_FILE_WRITE_ERROR : strcpy(str, "EDFlib: file write error.");
case EDFLIB_FILE_WRITE_ERROR : strlcpy(str, "EDFlib: file write error.", 2048);
break;
case EDFLIB_NUMBER_OF_SIGNALS_INVALID : strcpy(str, "EDFlib: invalid number of signals.");
case EDFLIB_NUMBER_OF_SIGNALS_INVALID : strlcpy(str, "EDFlib: invalid number of signals.", 2048);
break;
case EDFLIB_FILE_IS_DISCONTINUOUS : strcpy(str, "EDFlib: file is discontinuous.");
case EDFLIB_FILE_IS_DISCONTINUOUS : strlcpy(str, "EDFlib: file is discontinuous.", 2048);
break;
case EDFLIB_INVALID_READ_ANNOTS_VALUE : strcpy(str, "EDFlib: invalid read annotations argument.");
case EDFLIB_INVALID_READ_ANNOTS_VALUE : strlcpy(str, "EDFlib: invalid read annotations argument.", 2048);
break;
default : strcpy(str, "EDFlib: unknown error.");
default : strlcpy(str, "EDFlib: unknown error.", 2048);
}
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
......@@ -353,11 +353,11 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
for(i=0; i<16; i++)
{
strcpy(&triggerlabel[i][0], lineEdit1[i]->text().toUtf8().data());
strlcpy(&triggerlabel[i][0], lineEdit1[i]->text().toUtf8().data(), 64);
triggerlabel[i][16] = 0;
}
strcpy(&triggerlabel[16][0], "new epoch");
strlcpy(&triggerlabel[16][0], "new epoch", 64);
if(radioButton1->isChecked() == true)
{
......@@ -392,19 +392,19 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
status[i] = 1;
}
strcpy(outputfilename, inputpath);
strlcpy(outputfilename, inputpath, MAX_PATH_LENGTH);
remove_extension_from_filename(outputfilename);
strcat(outputfilename, "_+.bdf");
strlcat(outputfilename, "_+.bdf", MAX_PATH_LENGTH);
outputpath[0] = 0;
if(recent_savedir[0]!=0)
{
strcpy(outputpath, recent_savedir);
strcat(outputpath, "/");
strlcpy(outputpath, recent_savedir, MAX_PATH_LENGTH);
strlcat(outputpath, "/", MAX_PATH_LENGTH);
}
strcat(outputpath, outputfilename);
strlcat(outputpath, outputfilename, MAX_PATH_LENGTH);
strcpy(outputpath, QFileDialog::getSaveFileName(0, "Output file", QString::fromLocal8Bit(outputpath), "BDF files (*.bdf *.BDF)").toLocal8Bit().data());
strlcpy(outputpath, QFileDialog::getSaveFileName(0, "Output file", QString::fromLocal8Bit(outputpath), "BDF files (*.bdf *.BDF)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(outputpath, ""))
{
......@@ -436,23 +436,23 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
{
switch(hdl_out)
{
case EDFLIB_MALLOC_ERROR : strcpy(str, "EDFlib: malloc error.");
case EDFLIB_MALLOC_ERROR : strlcpy(str, "EDFlib: malloc error.", 2048);
break;
case EDFLIB_NO_SUCH_FILE_OR_DIRECTORY : strcpy(str, "EDFlib: no such file or directory.");
case EDFLIB_NO_SUCH_FILE_OR_DIRECTORY : strlcpy(str, "EDFlib: no such file or directory.", 2048);
break;
case EDFLIB_MAXFILES_REACHED : strcpy(str, "EDFlib: maximum amount of files reached.");
case EDFLIB_MAXFILES_REACHED : strlcpy(str, "EDFlib: maximum amount of files reached.", 2048);
break;
case EDFLIB_FILE_READ_ERROR : strcpy(str, "EDFlib: a file read error occurred.");
case EDFLIB_FILE_READ_ERROR : strlcpy(str, "EDFlib: a file read error occurred.", 2048);
break;
case EDFLIB_FILE_ALREADY_OPENED : strcpy(str, "EDFlib: file is already opened.");
case EDFLIB_FILE_ALREADY_OPENED : strlcpy(str, "EDFlib: file is already opened.", 2048);
break;
case EDFLIB_FILETYPE_ERROR : strcpy(str, "EDFlib: filetype error.");
case EDFLIB_FILETYPE_ERROR : strlcpy(str, "EDFlib: filetype error.", 2048);
break;
case EDFLIB_FILE_WRITE_ERROR : strcpy(str, "EDFlib: file write error.");
case EDFLIB_FILE_WRITE_ERROR : strlcpy(str, "EDFlib: file write error.", 2048);
break;
case EDFLIB_NUMBER_OF_SIGNALS_INVALID : strcpy(str, "EDFlib: invalid number of signals.");
case EDFLIB_NUMBER_OF_SIGNALS_INVALID : strlcpy(str, "EDFlib: invalid number of signals.", 2048);
break;
default : strcpy(str, "EDFlib: unknown error.");
default : strlcpy(str, "EDFlib: unknown error.", 2048);
}
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
......@@ -557,7 +557,7 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
{
annotation.onset = (datarecords * EDFLIB_TIME_DIMENSION) + ((long long)i * status_sample_duration);
annotation.onset += hdr.starttime_subsecond;
strcpy(annotation.annotation, triggerlabel[j]);
strlcpy(annotation.annotation, triggerlabel[j], MAX_ANNOTATION_LEN_II + 1);
if(edfplus_annotation_add_item(&annot_list, annotation))
{
progress.reset();
......@@ -586,9 +586,9 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
}
if(!strcmp(annot_ptr->annotation, triggerlabel[j]))
{
sprintf(str, "%.4f", (double)((datarecords * EDFLIB_TIME_DIMENSION) + ((long long)i * status_sample_duration) - annot_ptr->onset) / (double)EDFLIB_TIME_DIMENSION);
snprintf(str, 2048, "%.4f", (double)((datarecords * EDFLIB_TIME_DIMENSION) + ((long long)i * status_sample_duration) - annot_ptr->onset) / (double)EDFLIB_TIME_DIMENSION);
str[15] = 0;
strcpy(annot_ptr->duration, str);
strlcpy(annot_ptr->duration, str, MAX_ANNOTATION_LEN_II + 1);
annot_ptr->long_duration = edfplus_annotation_get_long_from_number(str);
break;
}
......@@ -604,7 +604,7 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
{
annotation.onset = (datarecords * EDFLIB_TIME_DIMENSION) + ((long long)i * status_sample_duration);
annotation.onset += hdr.starttime_subsecond;
strcpy(annotation.annotation, triggerlabel[j]);
strlcpy(annotation.annotation, triggerlabel[j], MAX_ANNOTATION_LEN_II + 1);
if(edfplus_annotation_add_item(&annot_list, annotation))
{
progress.reset();
......@@ -633,9 +633,9 @@ void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
}
if(!strcmp(annot_ptr->annotation, triggerlabel[j]))
{
sprintf(str, "%.4f", (double)((datarecords * EDFLIB_TIME_DIMENSION) + ((long long)i * status_sample_duration) - annot_ptr->onset) / (double)EDFLIB_TIME_DIMENSION);
snprintf(str, 2048, "%.4f", (double)((datarecords * EDFLIB_TIME_DIMENSION) + ((long long)i * status_sample_duration) - annot_ptr->onset) / (double)EDFLIB_TIME_DIMENSION);
str[15] = 0;
strcpy(annot_ptr->duration, str);
strlcpy(annot_ptr->duration, str, MAX_ANNOTATION_LEN_II + 1);
break;
}
}
......
......@@ -54,6 +54,7 @@
#include "mainwindow.h"
#include "edflib.h"
#include "edf_annot_list.h"
#include "utils.h"
......
......@@ -49,8 +49,6 @@
UI_BIOX2EDFwindow::UI_BIOX2EDFwindow(char *recent_dir, char *save_dir)
{
char txt_string[2048];
recent_opendir = recent_dir;
recent_savedir = save_dir;
......@@ -75,8 +73,7 @@ UI_BIOX2EDFwindow::UI_BIOX2EDFwindow(char *recent_dir, char *save_dir)
textEdit1->setFrameStyle(QFrame::Panel | QFrame::Sunken);
textEdit1->setReadOnly(true);
textEdit1->setLineWrapMode(QTextEdit::NoWrap);
sprintf(txt_string, "Biox CB-1305-C to EDF converter.\n");
textEdit1->append(txt_string);
textEdit1->append("Biox CB-1305-C to EDF converter.\n");
QObject::connect(pushButton1, SIGNAL(clicked()), this, SLOT(SelectFileButton()));
QObject::connect(pushButton2, SIGNAL(clicked()), myobjectDialog, SLOT(close()));
......@@ -109,7 +106,7 @@ void UI_BIOX2EDFwindow::SelectFileButton()
pushButton1->setEnabled(false);
strcpy(data_filename, QFileDialog::getOpenFileName(0, "Select inputfile", QString::fromLocal8Bit(recent_opendir), "Biox CB-1305-C data files (*.dat *.DAT)").toLocal8Bit().data());
strlcpy(data_filename, QFileDialog::getOpenFileName(0, "Select inputfile", QString::fromLocal8Bit(recent_opendir), "Biox CB-1305-C data files (*.dat *.DAT)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(data_filename, ""))
{
......@@ -189,12 +186,12 @@ void UI_BIOX2EDFwindow::SelectFileButton()
edf_filename[0] = 0;
if(recent_savedir[0]!=0)
{
strcpy(edf_filename, recent_savedir);
strcat(edf_filename, "/");
strlcpy(edf_filename, recent_savedir, MAX_PATH_LENGTH);
strlcat(edf_filename, "/", MAX_PATH_LENGTH);
}
strcat(edf_filename, "biox_ecg.edf");
strlcat(edf_filename, "biox_ecg.edf", MAX_PATH_LENGTH);
strcpy(edf_filename, QFileDialog::getSaveFileName(0, "Output file", QString::fromLocal8Bit(edf_filename), "EDF files (*.edf *.EDF)").toLocal8Bit().data());
strlcpy(edf_filename, QFileDialog::getSaveFileName(0, "Output file", QString::fromLocal8Bit(edf_filename), "EDF files (*.edf *.EDF)").toLocal8Bit().data(), MAX_PATH_LENGTH);
if(!strcmp(edf_filename, ""))
{
......@@ -289,7 +286,7 @@ void UI_BIOX2EDFwindow::SelectFileButton()
for(i=0; i<chns; i++)
{
sprintf(str, "chan. %i", i + 1);
snprintf(str, 512, "chan. %i", i + 1);
if(edf_set_label(hdl, i, str))
{
......
This diff is collapsed.
......@@ -50,7 +50,7 @@ class EDFfileCheck
public:
struct edfhdrblock * check_edf_file(FILE *, char *, int live_stream=0);
struct edfhdrblock * check_edf_file(FILE *, char *, int, int live_stream=0);
private:
......