mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Fix unsafe use of fixed width arrays.
Fix crash when MathMatrix has more than 80 columns Patch from John McCabe-Dansted, approved from Andre. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33641 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
61e55ac197
commit
a7b921aeeb
@ -246,14 +246,14 @@ bool isValidGlueLength(string const & data, GlueLength * result)
|
|||||||
|
|
||||||
int pattern_index = 0;
|
int pattern_index = 0;
|
||||||
int table_index = 0;
|
int table_index = 0;
|
||||||
char pattern[20];
|
char pattern[22]; // 20 + 1 for pattern[20], + 1 for '\0'
|
||||||
|
|
||||||
number_index = 1;
|
number_index = 1;
|
||||||
unit_index = 1; // entries at index 0 are sentinels
|
unit_index = 1; // entries at index 0 are sentinels
|
||||||
|
|
||||||
// construct "pattern" from "data"
|
// construct "pattern" from "data"
|
||||||
while (!isEndOfData(buffer)) {
|
while (!isEndOfData(buffer)) {
|
||||||
if (pattern_index > 20)
|
if (pattern_index > (sizeof(pattern) - 2))
|
||||||
return false;
|
return false;
|
||||||
pattern[pattern_index] = nextToken(buffer);
|
pattern[pattern_index] = nextToken(buffer);
|
||||||
if (pattern[pattern_index] == 'E')
|
if (pattern[pattern_index] == 'E')
|
||||||
|
@ -108,8 +108,9 @@ static docstring const formatted(docstring const & text)
|
|||||||
void noAppDialog(QString const & title, QString const & msg, QMessageBox::Icon mode)
|
void noAppDialog(QString const & title, QString const & msg, QMessageBox::Icon mode)
|
||||||
{
|
{
|
||||||
int argc = 1;
|
int argc = 1;
|
||||||
char * argv[1];
|
const char *argv[] = { "lyx", 0 };
|
||||||
QApplication app(argc, argv);
|
|
||||||
|
QApplication app(argc, (char**)argv);
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case QMessageBox::Information: QMessageBox::information(0, title, msg); break;
|
case QMessageBox::Information: QMessageBox::information(0, title, msg); break;
|
||||||
|
@ -66,13 +66,8 @@ GuiMathMatrix::GuiMathMatrix(GuiView & lv)
|
|||||||
|
|
||||||
void GuiMathMatrix::columnsChanged(int)
|
void GuiMathMatrix::columnsChanged(int)
|
||||||
{
|
{
|
||||||
char h_align_str[80] = "c";
|
|
||||||
int const nx = int(columnsSB->value());
|
int const nx = int(columnsSB->value());
|
||||||
for (int i = 0; i < nx; ++i)
|
halignED->setText(QString(nx, 'c'));
|
||||||
h_align_str[i] = 'c';
|
|
||||||
|
|
||||||
h_align_str[nx] = '\0';
|
|
||||||
halignED->setText(h_align_str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -739,8 +739,7 @@ docstring const makeDisplayPath(string const & path, unsigned int threshold)
|
|||||||
bool readLink(FileName const & file, FileName & link)
|
bool readLink(FileName const & file, FileName & link)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_READLINK
|
#ifdef HAVE_READLINK
|
||||||
char linkbuffer[512];
|
char linkbuffer[PATH_MAX + 1];
|
||||||
// Should be PATH_MAX but that needs autconf support
|
|
||||||
string const encoded = file.toFilesystemEncoding();
|
string const encoded = file.toFilesystemEncoding();
|
||||||
int const nRead = ::readlink(encoded.c_str(),
|
int const nRead = ::readlink(encoded.c_str(),
|
||||||
linkbuffer, sizeof(linkbuffer) - 1);
|
linkbuffer, sizeof(linkbuffer) - 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user