idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
7,900
bool Part::saveFile() { return true; }
Exec Code
0
bool Part::saveFile() { return true; }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,901
void Part::selectionChanged() { m_infoPanel->setIndexes(m_view->selectionModel()->selectedRows()); }
Exec Code
0
void Part::selectionChanged() { m_infoPanel->setIndexes(m_view->selectionModel()->selectedRows()); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,902
void Part::setFileNameFromArchive() { const QString prettyName = url().fileName(); m_infoPanel->setPrettyFileName(prettyName); m_infoPanel->updateWithDefaults(); emit setWindowCaption(prettyName); }
Exec Code
0
void Part::setFileNameFromArchive() { const QString prettyName = url().fileName(); m_infoPanel->setPrettyFileName(prettyName); m_infoPanel->updateWithDefaults(); emit setWindowCaption(prettyName); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,903
void Part::setReadyGui() { QApplication::restoreOverrideCursor(); m_busy = false; if (m_statusBarExtension->statusBar()) { m_statusBarExtension->statusBar()->hide(); } m_view->setEnabled(true); updateActions(); }
Exec Code
0
void Part::setReadyGui() { QApplication::restoreOverrideCursor(); m_busy = false; if (m_statusBarExtension->statusBar()) { m_statusBarExtension->statusBar()->hide(); } m_view->setEnabled(true); updateActions(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,904
void Part::setupActions() { m_signalMapper = new QSignalMapper(this); m_showInfoPanelAction = new KToggleAction(i18nc("@action:inmenu", "Show Information Panel"), this); actionCollection()->addAction(QStringLiteral( "show-infopanel" ), m_showInfoPanelAction); m_showInfoPanelAction->setChecked(ArkSettings::showInfoPanel()); connect(m_showInfoPanelAction, &QAction::triggered, this, &Part::slotToggleInfoPanel); m_saveAsAction = actionCollection()->addAction(KStandardAction::SaveAs, QStringLiteral("ark_file_save_as"), this, SLOT(slotSaveAs())); m_openFileAction = actionCollection()->addAction(QStringLiteral("openfile")); m_openFileAction->setText(i18nc("open a file with external program", "&Open")); m_openFileAction->setIcon(QIcon::fromTheme(QStringLiteral("document-open"))); m_openFileAction->setToolTip(i18nc("@info:tooltip", "Click to open the selected file with the associated application")); connect(m_openFileAction, &QAction::triggered, m_signalMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map)); m_signalMapper->setMapping(m_openFileAction, OpenFile); m_openFileWithAction = actionCollection()->addAction(QStringLiteral("openfilewith")); m_openFileWithAction->setText(i18nc("open a file with external program", "Open &With...")); m_openFileWithAction->setIcon(QIcon::fromTheme(QStringLiteral("document-open"))); m_openFileWithAction->setToolTip(i18nc("@info:tooltip", "Click to open the selected file with an external program")); connect(m_openFileWithAction, &QAction::triggered, m_signalMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map)); m_signalMapper->setMapping(m_openFileWithAction, OpenFileWith); m_previewAction = actionCollection()->addAction(QStringLiteral("preview")); m_previewAction->setText(i18nc("to preview a file inside an archive", "Pre&view")); m_previewAction->setIcon(QIcon::fromTheme(QStringLiteral("document-preview-archive"))); m_previewAction->setToolTip(i18nc("@info:tooltip", "Click to preview the selected file")); actionCollection()->setDefaultShortcut(m_previewAction, Qt::CTRL + Qt::Key_P); connect(m_previewAction, &QAction::triggered, m_signalMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map)); m_signalMapper->setMapping(m_previewAction, Preview); m_extractArchiveAction = actionCollection()->addAction(QStringLiteral("extract_all")); m_extractArchiveAction->setText(i18nc("@action:inmenu", "E&xtract All")); m_extractArchiveAction->setIcon(QIcon::fromTheme(QStringLiteral("archive-extract"))); m_extractArchiveAction->setToolTip(i18n("Click to open an extraction dialog, where you can choose how to extract all the files in the archive")); actionCollection()->setDefaultShortcut(m_extractArchiveAction, Qt::CTRL + Qt::SHIFT + Qt::Key_E); connect(m_extractArchiveAction, &QAction::triggered, this, &Part::slotExtractArchive); m_extractAction = actionCollection()->addAction(QStringLiteral("extract")); m_extractAction->setText(i18nc("@action:inmenu", "&Extract")); m_extractAction->setIcon(QIcon::fromTheme(QStringLiteral("archive-extract"))); actionCollection()->setDefaultShortcut(m_extractAction, Qt::CTRL + Qt::Key_E); m_extractAction->setToolTip(i18n("Click to open an extraction dialog, where you can choose to extract either all files or just the selected ones")); connect(m_extractAction, &QAction::triggered, this, &Part::slotShowExtractionDialog); m_addFilesAction = actionCollection()->addAction(QStringLiteral("add")); m_addFilesAction->setIcon(QIcon::fromTheme(QStringLiteral("archive-insert"))); m_addFilesAction->setText(i18n("Add &Files...")); m_addFilesAction->setToolTip(i18nc("@info:tooltip", "Click to add files to the archive")); actionCollection()->setDefaultShortcut(m_addFilesAction, Qt::ALT + Qt::Key_A); connect(m_addFilesAction, &QAction::triggered, this, static_cast<void (Part::*)()>(&Part::slotAddFiles)); m_renameFileAction = actionCollection()->addAction(QStringLiteral("rename")); m_renameFileAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename"))); m_renameFileAction->setText(i18n("&Rename")); actionCollection()->setDefaultShortcut(m_renameFileAction, Qt::Key_F2); m_renameFileAction->setToolTip(i18nc("@info:tooltip", "Click to rename the selected file")); connect(m_renameFileAction, &QAction::triggered, this, &Part::slotEditFileName); m_deleteFilesAction = actionCollection()->addAction(QStringLiteral("delete")); m_deleteFilesAction->setIcon(QIcon::fromTheme(QStringLiteral("archive-remove"))); m_deleteFilesAction->setText(i18n("De&lete")); actionCollection()->setDefaultShortcut(m_deleteFilesAction, Qt::Key_Delete); m_deleteFilesAction->setToolTip(i18nc("@info:tooltip", "Click to delete the selected files")); connect(m_deleteFilesAction, &QAction::triggered, this, &Part::slotDeleteFiles); m_cutFilesAction = actionCollection()->addAction(QStringLiteral("cut")); m_cutFilesAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut"))); m_cutFilesAction->setText(i18nc("@action:inmenu", "C&ut")); actionCollection()->setDefaultShortcut(m_cutFilesAction, Qt::CTRL + Qt::Key_X); m_cutFilesAction->setToolTip(i18nc("@info:tooltip", "Click to cut the selected files")); connect(m_cutFilesAction, &QAction::triggered, this, &Part::slotCutFiles); m_copyFilesAction = actionCollection()->addAction(QStringLiteral("copy")); m_copyFilesAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"))); m_copyFilesAction->setText(i18nc("@action:inmenu", "C&opy")); actionCollection()->setDefaultShortcut(m_copyFilesAction, Qt::CTRL + Qt::Key_C); m_copyFilesAction->setToolTip(i18nc("@info:tooltip", "Click to copy the selected files")); connect(m_copyFilesAction, &QAction::triggered, this, &Part::slotCopyFiles); m_pasteFilesAction = actionCollection()->addAction(QStringLiteral("paste")); m_pasteFilesAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-paste"))); m_pasteFilesAction->setText(i18nc("@action:inmenu", "Pa&ste")); actionCollection()->setDefaultShortcut(m_pasteFilesAction, Qt::CTRL + Qt::Key_V); m_pasteFilesAction->setToolTip(i18nc("@info:tooltip", "Click to paste the files here")); connect(m_pasteFilesAction, &QAction::triggered, this, static_cast<void (Part::*)()>(&Part::slotPasteFiles)); m_propertiesAction = actionCollection()->addAction(QStringLiteral("properties")); m_propertiesAction->setIcon(QIcon::fromTheme(QStringLiteral("document-properties"))); m_propertiesAction->setText(i18nc("@action:inmenu", "&Properties")); actionCollection()->setDefaultShortcut(m_propertiesAction, Qt::ALT + Qt::Key_Return); m_propertiesAction->setToolTip(i18nc("@info:tooltip", "Click to see properties for archive")); connect(m_propertiesAction, &QAction::triggered, this, &Part::slotShowProperties); m_editCommentAction = actionCollection()->addAction(QStringLiteral("edit_comment")); m_editCommentAction->setIcon(QIcon::fromTheme(QStringLiteral("document-edit"))); actionCollection()->setDefaultShortcut(m_editCommentAction, Qt::ALT + Qt::Key_C); m_editCommentAction->setToolTip(i18nc("@info:tooltip", "Click to add or edit comment")); connect(m_editCommentAction, &QAction::triggered, this, &Part::slotShowComment); m_testArchiveAction = actionCollection()->addAction(QStringLiteral("test_archive")); m_testArchiveAction->setIcon(QIcon::fromTheme(QStringLiteral("checkmark"))); m_testArchiveAction->setText(i18nc("@action:inmenu", "&Test Integrity")); actionCollection()->setDefaultShortcut(m_testArchiveAction, Qt::ALT + Qt::Key_T); m_testArchiveAction->setToolTip(i18nc("@info:tooltip", "Click to test the archive for integrity")); connect(m_testArchiveAction, &QAction::triggered, this, &Part::slotTestArchive); connect(m_signalMapper, static_cast<void (QSignalMapper::*)(int)>(&QSignalMapper::mapped), this, &Part::slotOpenEntry); updateActions(); updateQuickExtractMenu(m_extractArchiveAction); updateQuickExtractMenu(m_extractAction); }
Exec Code
0
void Part::setupActions() { m_signalMapper = new QSignalMapper(this); m_showInfoPanelAction = new KToggleAction(i18nc("@action:inmenu", "Show Information Panel"), this); actionCollection()->addAction(QStringLiteral( "show-infopanel" ), m_showInfoPanelAction); m_showInfoPanelAction->setChecked(ArkSettings::showInfoPanel()); connect(m_showInfoPanelAction, &QAction::triggered, this, &Part::slotToggleInfoPanel); m_saveAsAction = actionCollection()->addAction(KStandardAction::SaveAs, QStringLiteral("ark_file_save_as"), this, SLOT(slotSaveAs())); m_openFileAction = actionCollection()->addAction(QStringLiteral("openfile")); m_openFileAction->setText(i18nc("open a file with external program", "&Open")); m_openFileAction->setIcon(QIcon::fromTheme(QStringLiteral("document-open"))); m_openFileAction->setToolTip(i18nc("@info:tooltip", "Click to open the selected file with the associated application")); connect(m_openFileAction, &QAction::triggered, m_signalMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map)); m_signalMapper->setMapping(m_openFileAction, OpenFile); m_openFileWithAction = actionCollection()->addAction(QStringLiteral("openfilewith")); m_openFileWithAction->setText(i18nc("open a file with external program", "Open &With...")); m_openFileWithAction->setIcon(QIcon::fromTheme(QStringLiteral("document-open"))); m_openFileWithAction->setToolTip(i18nc("@info:tooltip", "Click to open the selected file with an external program")); connect(m_openFileWithAction, &QAction::triggered, m_signalMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map)); m_signalMapper->setMapping(m_openFileWithAction, OpenFileWith); m_previewAction = actionCollection()->addAction(QStringLiteral("preview")); m_previewAction->setText(i18nc("to preview a file inside an archive", "Pre&view")); m_previewAction->setIcon(QIcon::fromTheme(QStringLiteral("document-preview-archive"))); m_previewAction->setToolTip(i18nc("@info:tooltip", "Click to preview the selected file")); actionCollection()->setDefaultShortcut(m_previewAction, Qt::CTRL + Qt::Key_P); connect(m_previewAction, &QAction::triggered, m_signalMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map)); m_signalMapper->setMapping(m_previewAction, Preview); m_extractArchiveAction = actionCollection()->addAction(QStringLiteral("extract_all")); m_extractArchiveAction->setText(i18nc("@action:inmenu", "E&xtract All")); m_extractArchiveAction->setIcon(QIcon::fromTheme(QStringLiteral("archive-extract"))); m_extractArchiveAction->setToolTip(i18n("Click to open an extraction dialog, where you can choose how to extract all the files in the archive")); actionCollection()->setDefaultShortcut(m_extractArchiveAction, Qt::CTRL + Qt::SHIFT + Qt::Key_E); connect(m_extractArchiveAction, &QAction::triggered, this, &Part::slotExtractArchive); m_extractAction = actionCollection()->addAction(QStringLiteral("extract")); m_extractAction->setText(i18nc("@action:inmenu", "&Extract")); m_extractAction->setIcon(QIcon::fromTheme(QStringLiteral("archive-extract"))); actionCollection()->setDefaultShortcut(m_extractAction, Qt::CTRL + Qt::Key_E); m_extractAction->setToolTip(i18n("Click to open an extraction dialog, where you can choose to extract either all files or just the selected ones")); connect(m_extractAction, &QAction::triggered, this, &Part::slotShowExtractionDialog); m_addFilesAction = actionCollection()->addAction(QStringLiteral("add")); m_addFilesAction->setIcon(QIcon::fromTheme(QStringLiteral("archive-insert"))); m_addFilesAction->setText(i18n("Add &Files...")); m_addFilesAction->setToolTip(i18nc("@info:tooltip", "Click to add files to the archive")); actionCollection()->setDefaultShortcut(m_addFilesAction, Qt::ALT + Qt::Key_A); connect(m_addFilesAction, &QAction::triggered, this, static_cast<void (Part::*)()>(&Part::slotAddFiles)); m_renameFileAction = actionCollection()->addAction(QStringLiteral("rename")); m_renameFileAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename"))); m_renameFileAction->setText(i18n("&Rename")); actionCollection()->setDefaultShortcut(m_renameFileAction, Qt::Key_F2); m_renameFileAction->setToolTip(i18nc("@info:tooltip", "Click to rename the selected file")); connect(m_renameFileAction, &QAction::triggered, this, &Part::slotEditFileName); m_deleteFilesAction = actionCollection()->addAction(QStringLiteral("delete")); m_deleteFilesAction->setIcon(QIcon::fromTheme(QStringLiteral("archive-remove"))); m_deleteFilesAction->setText(i18n("De&lete")); actionCollection()->setDefaultShortcut(m_deleteFilesAction, Qt::Key_Delete); m_deleteFilesAction->setToolTip(i18nc("@info:tooltip", "Click to delete the selected files")); connect(m_deleteFilesAction, &QAction::triggered, this, &Part::slotDeleteFiles); m_cutFilesAction = actionCollection()->addAction(QStringLiteral("cut")); m_cutFilesAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-cut"))); m_cutFilesAction->setText(i18nc("@action:inmenu", "C&ut")); actionCollection()->setDefaultShortcut(m_cutFilesAction, Qt::CTRL + Qt::Key_X); m_cutFilesAction->setToolTip(i18nc("@info:tooltip", "Click to cut the selected files")); connect(m_cutFilesAction, &QAction::triggered, this, &Part::slotCutFiles); m_copyFilesAction = actionCollection()->addAction(QStringLiteral("copy")); m_copyFilesAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"))); m_copyFilesAction->setText(i18nc("@action:inmenu", "C&opy")); actionCollection()->setDefaultShortcut(m_copyFilesAction, Qt::CTRL + Qt::Key_C); m_copyFilesAction->setToolTip(i18nc("@info:tooltip", "Click to copy the selected files")); connect(m_copyFilesAction, &QAction::triggered, this, &Part::slotCopyFiles); m_pasteFilesAction = actionCollection()->addAction(QStringLiteral("paste")); m_pasteFilesAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-paste"))); m_pasteFilesAction->setText(i18nc("@action:inmenu", "Pa&ste")); actionCollection()->setDefaultShortcut(m_pasteFilesAction, Qt::CTRL + Qt::Key_V); m_pasteFilesAction->setToolTip(i18nc("@info:tooltip", "Click to paste the files here")); connect(m_pasteFilesAction, &QAction::triggered, this, static_cast<void (Part::*)()>(&Part::slotPasteFiles)); m_propertiesAction = actionCollection()->addAction(QStringLiteral("properties")); m_propertiesAction->setIcon(QIcon::fromTheme(QStringLiteral("document-properties"))); m_propertiesAction->setText(i18nc("@action:inmenu", "&Properties")); actionCollection()->setDefaultShortcut(m_propertiesAction, Qt::ALT + Qt::Key_Return); m_propertiesAction->setToolTip(i18nc("@info:tooltip", "Click to see properties for archive")); connect(m_propertiesAction, &QAction::triggered, this, &Part::slotShowProperties); m_editCommentAction = actionCollection()->addAction(QStringLiteral("edit_comment")); m_editCommentAction->setIcon(QIcon::fromTheme(QStringLiteral("document-edit"))); actionCollection()->setDefaultShortcut(m_editCommentAction, Qt::ALT + Qt::Key_C); m_editCommentAction->setToolTip(i18nc("@info:tooltip", "Click to add or edit comment")); connect(m_editCommentAction, &QAction::triggered, this, &Part::slotShowComment); m_testArchiveAction = actionCollection()->addAction(QStringLiteral("test_archive")); m_testArchiveAction->setIcon(QIcon::fromTheme(QStringLiteral("checkmark"))); m_testArchiveAction->setText(i18nc("@action:inmenu", "&Test Integrity")); actionCollection()->setDefaultShortcut(m_testArchiveAction, Qt::ALT + Qt::Key_T); m_testArchiveAction->setToolTip(i18nc("@info:tooltip", "Click to test the archive for integrity")); connect(m_testArchiveAction, &QAction::triggered, this, &Part::slotTestArchive); connect(m_signalMapper, static_cast<void (QSignalMapper::*)(int)>(&QSignalMapper::mapped), this, &Part::slotOpenEntry); updateActions(); updateQuickExtractMenu(m_extractArchiveAction); updateQuickExtractMenu(m_extractAction); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,905
void Part::setupView() { m_view->setContextMenuPolicy(Qt::CustomContextMenu); m_view->setModel(m_model); connect(m_view->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Part::updateActions); connect(m_view->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Part::selectionChanged); connect(m_view, &QTreeView::activated, this, &Part::slotActivated); connect(m_view, &QWidget::customContextMenuRequested, this, &Part::slotShowContextMenu); }
Exec Code
0
void Part::setupView() { m_view->setContextMenuPolicy(Qt::CustomContextMenu); m_view->setModel(m_model); connect(m_view->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Part::updateActions); connect(m_view->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Part::selectionChanged); connect(m_view, &QTreeView::activated, this, &Part::slotActivated); connect(m_view, &QWidget::customContextMenuRequested, this, &Part::slotShowContextMenu); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,906
void Part::slotActivated(const QModelIndex &index) { Q_UNUSED(index) if (QGuiApplication::keyboardModifiers() != Qt::ShiftModifier && QGuiApplication::keyboardModifiers() != Qt::ControlModifier) { ArkSettings::defaultOpenAction() == ArkSettings::EnumDefaultOpenAction::Preview ? slotOpenEntry(Preview) : slotOpenEntry(OpenFile); } }
Exec Code
0
void Part::slotActivated(const QModelIndex &index) { Q_UNUSED(index) if (QGuiApplication::keyboardModifiers() != Qt::ShiftModifier && QGuiApplication::keyboardModifiers() != Qt::ControlModifier) { ArkSettings::defaultOpenAction() == ArkSettings::EnumDefaultOpenAction::Preview ? slotOpenEntry(Preview) : slotOpenEntry(OpenFile); } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,907
void Part::slotAddComment() { CommentJob *job = m_model->archive()->addComment(m_commentView->toPlainText()); if (!job) { return; } registerJob(job); job->start(); m_commentMsgWidget->hide(); if (m_commentView->toPlainText().isEmpty()) { m_commentBox->hide(); } }
Exec Code
0
void Part::slotAddComment() { CommentJob *job = m_model->archive()->addComment(m_commentView->toPlainText()); if (!job) { return; } registerJob(job); job->start(); m_commentMsgWidget->hide(); if (m_commentView->toPlainText().isEmpty()) { m_commentBox->hide(); } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,908
void Part::slotCommentChanged() { if (!m_model->archive()) { return; } if (m_commentMsgWidget->isHidden() && m_commentView->toPlainText() != m_model->archive()->comment()) { m_commentMsgWidget->animatedShow(); } else if (m_commentMsgWidget->isVisible() && m_commentView->toPlainText() == m_model->archive()->comment()) { m_commentMsgWidget->hide(); } }
Exec Code
0
void Part::slotCommentChanged() { if (!m_model->archive()) { return; } if (m_commentMsgWidget->isHidden() && m_commentView->toPlainText() != m_model->archive()->comment()) { m_commentMsgWidget->animatedShow(); } else if (m_commentMsgWidget->isVisible() && m_commentView->toPlainText() == m_model->archive()->comment()) { m_commentMsgWidget->hide(); } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,909
void Part::slotCopyFiles() { m_model->filesToCopy = ArchiveModel::entryMap(filesForIndexes(addChildren(m_view->selectionModel()->selectedRows()))); qCDebug(ARK) << "Entries marked to copy:" << m_model->filesToCopy.values(); foreach (const QModelIndex &row, m_cutIndexes) { m_view->dataChanged(row, row); } m_cutIndexes.clear(); m_model->filesToMove.clear(); updateActions(); }
Exec Code
0
void Part::slotCopyFiles() { m_model->filesToCopy = ArchiveModel::entryMap(filesForIndexes(addChildren(m_view->selectionModel()->selectedRows()))); qCDebug(ARK) << "Entries marked to copy:" << m_model->filesToCopy.values(); foreach (const QModelIndex &row, m_cutIndexes) { m_view->dataChanged(row, row); } m_cutIndexes.clear(); m_model->filesToMove.clear(); updateActions(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,910
void Part::slotDeleteFiles() { const int selectionsCount = m_view->selectionModel()->selectedRows().count(); const auto reallyDelete = KMessageBox::questionYesNo(widget(), i18ncp("@info", "Deleting this file is not undoable. Are you sure you want to do this?", "Deleting these files is not undoable. Are you sure you want to do this?", selectionsCount), i18ncp("@title:window", "Delete File", "Delete Files", selectionsCount), KStandardGuiItem::del(), KStandardGuiItem::no(), QString(), KMessageBox::Dangerous | KMessageBox::Notify); if (reallyDelete == KMessageBox::No) { return; } DeleteJob *job = m_model->deleteFiles(filesForIndexes(addChildren(m_view->selectionModel()->selectedRows()))); connect(job, &KJob::result, this, &Part::slotDeleteFilesDone); registerJob(job); job->start(); }
Exec Code
0
void Part::slotDeleteFiles() { const int selectionsCount = m_view->selectionModel()->selectedRows().count(); const auto reallyDelete = KMessageBox::questionYesNo(widget(), i18ncp("@info", "Deleting this file is not undoable. Are you sure you want to do this?", "Deleting these files is not undoable. Are you sure you want to do this?", selectionsCount), i18ncp("@title:window", "Delete File", "Delete Files", selectionsCount), KStandardGuiItem::del(), KStandardGuiItem::no(), QString(), KMessageBox::Dangerous | KMessageBox::Notify); if (reallyDelete == KMessageBox::No) { return; } DeleteJob *job = m_model->deleteFiles(filesForIndexes(addChildren(m_view->selectionModel()->selectedRows()))); connect(job, &KJob::result, this, &Part::slotDeleteFilesDone); registerJob(job); job->start(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,911
void Part::slotDeleteFilesDone(KJob* job) { if (job->error() && job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } m_cutIndexes.clear(); m_model->filesToMove.clear(); m_model->filesToCopy.clear(); }
Exec Code
0
void Part::slotDeleteFilesDone(KJob* job) { if (job->error() && job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } m_cutIndexes.clear(); m_model->filesToMove.clear(); m_model->filesToCopy.clear(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,912
void Part::slotExtractArchive() { if (m_view->selectionModel()->selectedRows().count() > 0) { m_view->selectionModel()->clear(); } slotShowExtractionDialog(); }
Exec Code
0
void Part::slotExtractArchive() { if (m_view->selectionModel()->selectedRows().count() > 0) { m_view->selectionModel()->clear(); } slotShowExtractionDialog(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,913
void Part::slotExtractionDone(KJob* job) { if (job->error() && job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } else { ExtractJob *extractJob = qobject_cast<ExtractJob*>(job); Q_ASSERT(extractJob); if (ArkSettings::openDestinationFolderAfterExtraction()) { qCDebug(ARK) << "Shall open" << extractJob->destinationDirectory(); QUrl destinationDirectory = QUrl::fromLocalFile(extractJob->destinationDirectory()).adjusted(QUrl::NormalizePathSegments); qCDebug(ARK) << "Shall open URL" << destinationDirectory; KRun::runUrl(destinationDirectory, QStringLiteral("inode/directory"), widget()); } if (ArkSettings::closeAfterExtraction()) { emit quit(); } } }
Exec Code
0
void Part::slotExtractionDone(KJob* job) { if (job->error() && job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } else { ExtractJob *extractJob = qobject_cast<ExtractJob*>(job); Q_ASSERT(extractJob); if (ArkSettings::openDestinationFolderAfterExtraction()) { qCDebug(ARK) << "Shall open" << extractJob->destinationDirectory(); QUrl destinationDirectory = QUrl::fromLocalFile(extractJob->destinationDirectory()).adjusted(QUrl::NormalizePathSegments); qCDebug(ARK) << "Shall open URL" << destinationDirectory; KRun::runUrl(destinationDirectory, QStringLiteral("inode/directory"), widget()); } if (ArkSettings::closeAfterExtraction()) { emit quit(); } } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,914
void Part::slotLoadingFinished(KJob *job) { if (job->error()) { if (arguments().metaData()[QStringLiteral("createNewArchive")] != QLatin1String("true")) { if (job->error() != KJob::KilledJobError) { displayMsgWidget(KMessageWidget::Error, xi18nc("@info", "Loading the archive <filename>%1</filename> failed with the following error:<nl/><message>%2</message>", localFilePath(), job->errorString())); } m_model->reset(); m_infoPanel->setPrettyFileName(QString()); m_infoPanel->updateWithDefaults(); emit setWindowCaption(QString()); } } m_view->sortByColumn(0, Qt::AscendingOrder); if (m_view->model()->rowCount() == 1) { m_view->expandToDepth(0); } m_view->header()->resizeSections(QHeaderView::ResizeToContents); m_view->setDropsEnabled(true); updateActions(); if (!m_model->archive()) { return; } if (!m_model->archive()->comment().isEmpty()) { m_commentView->setPlainText(m_model->archive()->comment()); slotShowComment(); } else { m_commentView->clear(); m_commentBox->hide(); } if (m_model->rowCount() == 0) { qCWarning(ARK) << "No entry listed by the plugin"; displayMsgWidget(KMessageWidget::Warning, xi18nc("@info", "The archive is empty or Ark could not open its content.")); } else if (m_model->rowCount() == 1) { if (m_model->archive()->mimeType().inherits(QStringLiteral("application/x-cd-image")) && m_model->entryForIndex(m_model->index(0, 0))->fullPath() == QLatin1String("README.TXT")) { qCWarning(ARK) << "Detected ISO image with UDF filesystem"; displayMsgWidget(KMessageWidget::Warning, xi18nc("@info", "Ark does not currently support ISO files with UDF filesystem.")); } } if (arguments().metaData()[QStringLiteral("showExtractDialog")] == QLatin1String("true")) { QTimer::singleShot(0, this, &Part::slotShowExtractionDialog); } }
Exec Code
0
void Part::slotLoadingFinished(KJob *job) { if (job->error()) { if (arguments().metaData()[QStringLiteral("createNewArchive")] != QLatin1String("true")) { if (job->error() != KJob::KilledJobError) { displayMsgWidget(KMessageWidget::Error, xi18nc("@info", "Loading the archive <filename>%1</filename> failed with the following error:<nl/><message>%2</message>", localFilePath(), job->errorString())); } m_model->reset(); m_infoPanel->setPrettyFileName(QString()); m_infoPanel->updateWithDefaults(); emit setWindowCaption(QString()); } } m_view->sortByColumn(0, Qt::AscendingOrder); if (m_view->model()->rowCount() == 1) { m_view->expandToDepth(0); } m_view->header()->resizeSections(QHeaderView::ResizeToContents); m_view->setDropsEnabled(true); updateActions(); if (!m_model->archive()) { return; } if (!m_model->archive()->comment().isEmpty()) { m_commentView->setPlainText(m_model->archive()->comment()); slotShowComment(); } else { m_commentView->clear(); m_commentBox->hide(); } if (m_model->rowCount() == 0) { qCWarning(ARK) << "No entry listed by the plugin"; displayMsgWidget(KMessageWidget::Warning, xi18nc("@info", "The archive is empty or Ark could not open its content.")); } else if (m_model->rowCount() == 1) { if (m_model->archive()->mimeType().inherits(QStringLiteral("application/x-cd-image")) && m_model->entryForIndex(m_model->index(0, 0))->fullPath() == QLatin1String("README.TXT")) { qCWarning(ARK) << "Detected ISO image with UDF filesystem"; displayMsgWidget(KMessageWidget::Warning, xi18nc("@info", "Ark does not currently support ISO files with UDF filesystem.")); } } if (arguments().metaData()[QStringLiteral("showExtractDialog")] == QLatin1String("true")) { QTimer::singleShot(0, this, &Part::slotShowExtractionDialog); } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,915
void Part::slotLoadingStarted() { m_model->filesToMove.clear(); m_model->filesToCopy.clear(); }
Exec Code
0
void Part::slotLoadingStarted() { m_model->filesToMove.clear(); m_model->filesToCopy.clear(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,916
void Part::slotOpenEntry(int mode) { qCDebug(ARK) << "Opening with mode" << mode; QModelIndex index = m_view->selectionModel()->currentIndex(); Archive::Entry *entry = m_model->entryForIndex(index); if (entry->isDir()) { return; } if (!entry->property("link").toString().isEmpty()) { displayMsgWidget(KMessageWidget::Information, i18n("Ark cannot open symlinks.")); return; } if (!entry->fullPath().isEmpty()) { m_openFileMode = static_cast<OpenFileMode>(mode); KJob *job = Q_NULLPTR; if (m_openFileMode == Preview) { job = m_model->preview(entry); connect(job, &KJob::result, this, &Part::slotPreviewExtractedEntry); } else { job = (m_openFileMode == OpenFile) ? m_model->open(entry) : m_model->openWith(entry); connect(job, &KJob::result, this, &Part::slotOpenExtractedEntry); } registerJob(job); job->start(); } }
Exec Code
0
void Part::slotOpenEntry(int mode) { qCDebug(ARK) << "Opening with mode" << mode; QModelIndex index = m_view->selectionModel()->currentIndex(); Archive::Entry *entry = m_model->entryForIndex(index); if (entry->isDir()) { return; } if (!entry->property("link").toString().isEmpty()) { displayMsgWidget(KMessageWidget::Information, i18n("Ark cannot open symlinks.")); return; } if (!entry->fullPath().isEmpty()) { m_openFileMode = static_cast<OpenFileMode>(mode); KJob *job = Q_NULLPTR; if (m_openFileMode == Preview) { job = m_model->preview(entry); connect(job, &KJob::result, this, &Part::slotPreviewExtractedEntry); } else { job = (m_openFileMode == OpenFile) ? m_model->open(entry) : m_model->openWith(entry); connect(job, &KJob::result, this, &Part::slotOpenExtractedEntry); } registerJob(job); job->start(); } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,917
void Part::slotPasteFiles() { m_destination = (m_view->selectionModel()->selectedRows().count() > 0) ? m_model->entryForIndex(m_view->selectionModel()->currentIndex()) : Q_NULLPTR; if (m_destination == Q_NULLPTR) { m_destination = new Archive::Entry(Q_NULLPTR, QString()); } else { m_destination = new Archive::Entry(Q_NULLPTR, m_destination->fullPath()); } if (m_model->filesToMove.count() > 0) { QVector<Archive::Entry*> entriesWithoutChildren = ReadOnlyArchiveInterface::entriesWithoutChildren(QVector<Archive::Entry*>::fromList(m_model->filesToMove.values())); if (entriesWithoutChildren.count() == 1) { const Archive::Entry *entry = entriesWithoutChildren.first(); auto entryName = entry->name(); if (entry->isDir()) { entryName += QLatin1Char('/'); } m_destination->setFullPath(m_destination->fullPath() + entryName); } foreach (const Archive::Entry *entry, entriesWithoutChildren) { if (entry->isDir() && m_destination->fullPath().startsWith(entry->fullPath())) { KMessageBox::error(widget(), i18n("Folders can't be moved into themselves."), i18n("Moving a folder into itself")); delete m_destination; return; } } auto entryList = QVector<Archive::Entry*>::fromList(m_model->filesToMove.values()); slotPasteFiles(entryList, m_destination, entriesWithoutChildren.count()); m_model->filesToMove.clear(); } else { auto entryList = QVector<Archive::Entry*>::fromList(m_model->filesToCopy.values()); slotPasteFiles(entryList, m_destination, 0); m_model->filesToCopy.clear(); } m_cutIndexes.clear(); updateActions(); }
Exec Code
0
void Part::slotPasteFiles() { m_destination = (m_view->selectionModel()->selectedRows().count() > 0) ? m_model->entryForIndex(m_view->selectionModel()->currentIndex()) : Q_NULLPTR; if (m_destination == Q_NULLPTR) { m_destination = new Archive::Entry(Q_NULLPTR, QString()); } else { m_destination = new Archive::Entry(Q_NULLPTR, m_destination->fullPath()); } if (m_model->filesToMove.count() > 0) { QVector<Archive::Entry*> entriesWithoutChildren = ReadOnlyArchiveInterface::entriesWithoutChildren(QVector<Archive::Entry*>::fromList(m_model->filesToMove.values())); if (entriesWithoutChildren.count() == 1) { const Archive::Entry *entry = entriesWithoutChildren.first(); auto entryName = entry->name(); if (entry->isDir()) { entryName += QLatin1Char('/'); } m_destination->setFullPath(m_destination->fullPath() + entryName); } foreach (const Archive::Entry *entry, entriesWithoutChildren) { if (entry->isDir() && m_destination->fullPath().startsWith(entry->fullPath())) { KMessageBox::error(widget(), i18n("Folders can't be moved into themselves."), i18n("Moving a folder into itself")); delete m_destination; return; } } auto entryList = QVector<Archive::Entry*>::fromList(m_model->filesToMove.values()); slotPasteFiles(entryList, m_destination, entriesWithoutChildren.count()); m_model->filesToMove.clear(); } else { auto entryList = QVector<Archive::Entry*>::fromList(m_model->filesToCopy.values()); slotPasteFiles(entryList, m_destination, 0); m_model->filesToCopy.clear(); } m_cutIndexes.clear(); updateActions(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,918
void Part::slotPasteFiles(QVector<Kerfuffle::Archive::Entry*> &files, Kerfuffle::Archive::Entry *destination, int entriesWithoutChildren) { if (files.isEmpty()) { delete m_destination; return; } QStringList filesPaths = ReadOnlyArchiveInterface::entryFullPaths(files); QStringList newPaths = ReadOnlyArchiveInterface::entryPathsFromDestination(filesPaths, destination, entriesWithoutChildren); if (ArchiveModel::hasDuplicatedEntries(newPaths)) { displayMsgWidget(KMessageWidget::Error, i18n("Entries with the same names can't be pasted to the same destination.")); delete m_destination; return; } QList<const Archive::Entry*> conflictingEntries; bool error = m_model->conflictingEntries(conflictingEntries, newPaths, false); if (conflictingEntries.count() != 0) { QPointer<OverwriteDialog> overwriteDialog = new OverwriteDialog(widget(), conflictingEntries, m_model->entryIcons(), error); int ret = overwriteDialog->exec(); delete overwriteDialog; if (ret == QDialog::Rejected) { delete m_destination; return; } } if (entriesWithoutChildren > 0) { qCDebug(ARK) << "Moving" << files << "to" << destination; } else { qCDebug(ARK) << "Copying " << files << "to" << destination; } KJob *job; if (entriesWithoutChildren != 0) { job = m_model->moveFiles(files, destination, CompressionOptions()); } else { job = m_model->copyFiles(files, destination, CompressionOptions()); } if (job) { connect(job, &KJob::result, this, &Part::slotPasteFilesDone); registerJob(job); job->start(); } else { delete m_destination; } }
Exec Code
0
void Part::slotPasteFiles(QVector<Kerfuffle::Archive::Entry*> &files, Kerfuffle::Archive::Entry *destination, int entriesWithoutChildren) { if (files.isEmpty()) { delete m_destination; return; } QStringList filesPaths = ReadOnlyArchiveInterface::entryFullPaths(files); QStringList newPaths = ReadOnlyArchiveInterface::entryPathsFromDestination(filesPaths, destination, entriesWithoutChildren); if (ArchiveModel::hasDuplicatedEntries(newPaths)) { displayMsgWidget(KMessageWidget::Error, i18n("Entries with the same names can't be pasted to the same destination.")); delete m_destination; return; } QList<const Archive::Entry*> conflictingEntries; bool error = m_model->conflictingEntries(conflictingEntries, newPaths, false); if (conflictingEntries.count() != 0) { QPointer<OverwriteDialog> overwriteDialog = new OverwriteDialog(widget(), conflictingEntries, m_model->entryIcons(), error); int ret = overwriteDialog->exec(); delete overwriteDialog; if (ret == QDialog::Rejected) { delete m_destination; return; } } if (entriesWithoutChildren > 0) { qCDebug(ARK) << "Moving" << files << "to" << destination; } else { qCDebug(ARK) << "Copying " << files << "to" << destination; } KJob *job; if (entriesWithoutChildren != 0) { job = m_model->moveFiles(files, destination, CompressionOptions()); } else { job = m_model->copyFiles(files, destination, CompressionOptions()); } if (job) { connect(job, &KJob::result, this, &Part::slotPasteFilesDone); registerJob(job); job->start(); } else { delete m_destination; } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,919
void Part::slotPasteFilesDone(KJob *job) { if (job->error() && job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } m_cutIndexes.clear(); m_model->filesToMove.clear(); m_model->filesToCopy.clear(); }
Exec Code
0
void Part::slotPasteFilesDone(KJob *job) { if (job->error() && job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } m_cutIndexes.clear(); m_model->filesToMove.clear(); m_model->filesToCopy.clear(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,920
void Part::slotPreviewExtractedEntry(KJob *job) { if (!job->error()) { PreviewJob *previewJob = qobject_cast<PreviewJob*>(job); Q_ASSERT(previewJob); m_tmpExtractDirList << previewJob->tempDir(); ArkViewer::view(previewJob->validatedFilePath()); } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } setReadyGui(); }
Exec Code
0
void Part::slotPreviewExtractedEntry(KJob *job) { if (!job->error()) { PreviewJob *previewJob = qobject_cast<PreviewJob*>(job); Q_ASSERT(previewJob); m_tmpExtractDirList << previewJob->tempDir(); ArkViewer::view(previewJob->validatedFilePath()); } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } setReadyGui(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,921
void Part::slotQuickExtractFiles(QAction *triggeredAction) { if (!triggeredAction->data().isNull()) { QString userDestination = triggeredAction->data().toString(); QString finalDestinationDirectory; const QString detectedSubfolder = detectSubfolder(); qCDebug(ARK) << "Detected subfolder" << detectedSubfolder; if (!isSingleFolderArchive()) { if (!userDestination.endsWith(QDir::separator())) { userDestination.append(QDir::separator()); } finalDestinationDirectory = userDestination + detectedSubfolder; QDir(userDestination).mkdir(detectedSubfolder); } else { finalDestinationDirectory = userDestination; } qCDebug(ARK) << "Extracting to:" << finalDestinationDirectory; ExtractJob *job = m_model->extractFiles(filesAndRootNodesForIndexes(addChildren(m_view->selectionModel()->selectedRows())), finalDestinationDirectory, ExtractionOptions()); registerJob(job); connect(job, &KJob::result, this, &Part::slotExtractionDone); job->start(); } }
Exec Code
0
void Part::slotQuickExtractFiles(QAction *triggeredAction) { if (!triggeredAction->data().isNull()) { QString userDestination = triggeredAction->data().toString(); QString finalDestinationDirectory; const QString detectedSubfolder = detectSubfolder(); qCDebug(ARK) << "Detected subfolder" << detectedSubfolder; if (!isSingleFolderArchive()) { if (!userDestination.endsWith(QDir::separator())) { userDestination.append(QDir::separator()); } finalDestinationDirectory = userDestination + detectedSubfolder; QDir(userDestination).mkdir(detectedSubfolder); } else { finalDestinationDirectory = userDestination; } qCDebug(ARK) << "Extracting to:" << finalDestinationDirectory; ExtractJob *job = m_model->extractFiles(filesAndRootNodesForIndexes(addChildren(m_view->selectionModel()->selectedRows())), finalDestinationDirectory, ExtractionOptions()); registerJob(job); connect(job, &KJob::result, this, &Part::slotExtractionDone); job->start(); } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,922
void Part::slotRenameFile(const QString &name) { if (name == QLatin1String(".") || name == QLatin1String("..") || name.contains(QLatin1Char('/'))) { displayMsgWidget(KMessageWidget::Error, i18n("Filename can't contain slashes and can't be equal to \".\" or \"..\"")); return; } const Archive::Entry *entry = m_model->entryForIndex(m_view->selectionModel()->currentIndex()); QVector<Archive::Entry*> entriesToMove = filesForIndexes(addChildren(m_view->selectionModel()->selectedRows())); m_destination = new Archive::Entry(); const QString &entryPath = entry->fullPath(NoTrailingSlash); const QString rootPath = entryPath.left(entryPath.count() - entry->name().count()); auto path = rootPath + name; if (entry->isDir()) { path += QLatin1Char('/'); } m_destination->setFullPath(path); slotPasteFiles(entriesToMove, m_destination, 1); }
Exec Code
0
void Part::slotRenameFile(const QString &name) { if (name == QLatin1String(".") || name == QLatin1String("..") || name.contains(QLatin1Char('/'))) { displayMsgWidget(KMessageWidget::Error, i18n("Filename can't contain slashes and can't be equal to \".\" or \"..\"")); return; } const Archive::Entry *entry = m_model->entryForIndex(m_view->selectionModel()->currentIndex()); QVector<Archive::Entry*> entriesToMove = filesForIndexes(addChildren(m_view->selectionModel()->selectedRows())); m_destination = new Archive::Entry(); const QString &entryPath = entry->fullPath(NoTrailingSlash); const QString rootPath = entryPath.left(entryPath.count() - entry->name().count()); auto path = rootPath + name; if (entry->isDir()) { path += QLatin1Char('/'); } m_destination->setFullPath(path); slotPasteFiles(entriesToMove, m_destination, 1); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,923
void Part::slotSaveAs() { QUrl saveUrl = QFileDialog::getSaveFileUrl(widget(), i18nc("@title:window", "Save Archive As"), url()); if ((saveUrl.isValid()) && (!saveUrl.isEmpty())) { auto statJob = KIO::stat(saveUrl, KIO::StatJob::DestinationSide, 0); KJobWidgets::setWindow(statJob, widget()); if (statJob->exec()) { int overwrite = KMessageBox::warningContinueCancel(widget(), xi18nc("@info", "An archive named <filename>%1</filename> already exists. Are you sure you want to overwrite it?", saveUrl.fileName()), QString(), KStandardGuiItem::overwrite()); if (overwrite != KMessageBox::Continue) { return; } } QUrl srcUrl = QUrl::fromLocalFile(localFilePath()); if (!QFile::exists(localFilePath())) { if (url().isLocalFile()) { KMessageBox::error(widget(), xi18nc("@info", "The archive <filename>%1</filename> cannot be copied to the specified location. The archive does not exist anymore.", localFilePath())); return; } else { srcUrl = url(); } } KIO::Job *copyJob = KIO::file_copy(srcUrl, saveUrl, -1, KIO::Overwrite); KJobWidgets::setWindow(copyJob, widget()); copyJob->exec(); if (copyJob->error()) { KMessageBox::error(widget(), xi18nc("@info", "The archive could not be saved as <filename>%1</filename>. Try saving it to another location.", saveUrl.path())); } } }
Exec Code
0
void Part::slotSaveAs() { QUrl saveUrl = QFileDialog::getSaveFileUrl(widget(), i18nc("@title:window", "Save Archive As"), url()); if ((saveUrl.isValid()) && (!saveUrl.isEmpty())) { auto statJob = KIO::stat(saveUrl, KIO::StatJob::DestinationSide, 0); KJobWidgets::setWindow(statJob, widget()); if (statJob->exec()) { int overwrite = KMessageBox::warningContinueCancel(widget(), xi18nc("@info", "An archive named <filename>%1</filename> already exists. Are you sure you want to overwrite it?", saveUrl.fileName()), QString(), KStandardGuiItem::overwrite()); if (overwrite != KMessageBox::Continue) { return; } } QUrl srcUrl = QUrl::fromLocalFile(localFilePath()); if (!QFile::exists(localFilePath())) { if (url().isLocalFile()) { KMessageBox::error(widget(), xi18nc("@info", "The archive <filename>%1</filename> cannot be copied to the specified location. The archive does not exist anymore.", localFilePath())); return; } else { srcUrl = url(); } } KIO::Job *copyJob = KIO::file_copy(srcUrl, saveUrl, -1, KIO::Overwrite); KJobWidgets::setWindow(copyJob, widget()); copyJob->exec(); if (copyJob->error()) { KMessageBox::error(widget(), xi18nc("@info", "The archive could not be saved as <filename>%1</filename>. Try saving it to another location.", saveUrl.path())); } } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,924
void Part::slotShowExtractionDialog() { if (!m_model) { return; } QPointer<Kerfuffle::ExtractionDialog> dialog(new Kerfuffle::ExtractionDialog); dialog.data()->setModal(true); if (m_view->selectionModel()->selectedRows().count() > 0) { dialog.data()->setShowSelectedFiles(true); } dialog.data()->setSingleFolderArchive(isSingleFolderArchive()); dialog.data()->setSubfolder(detectSubfolder()); dialog.data()->setCurrentUrl(QUrl::fromLocalFile(QFileInfo(m_model->archive()->fileName()).absolutePath())); dialog.data()->show(); dialog.data()->restoreWindowSize(); if (dialog.data()->exec()) { updateQuickExtractMenu(m_extractArchiveAction); updateQuickExtractMenu(m_extractAction); QVector<Archive::Entry*> files; if (!dialog.data()->extractAllFiles()) { files = filesAndRootNodesForIndexes(addChildren(m_view->selectionModel()->selectedRows())); } qCDebug(ARK) << "Selected " << files; Kerfuffle::ExtractionOptions options; options.setPreservePaths(dialog->preservePaths()); const QString destinationDirectory = dialog.data()->destinationDirectory().toLocalFile(); ExtractJob *job = m_model->extractFiles(files, destinationDirectory, options); registerJob(job); connect(job, &KJob::result, this, &Part::slotExtractionDone); job->start(); } delete dialog.data(); }
Exec Code
0
void Part::slotShowExtractionDialog() { if (!m_model) { return; } QPointer<Kerfuffle::ExtractionDialog> dialog(new Kerfuffle::ExtractionDialog); dialog.data()->setModal(true); if (m_view->selectionModel()->selectedRows().count() > 0) { dialog.data()->setShowSelectedFiles(true); } dialog.data()->setSingleFolderArchive(isSingleFolderArchive()); dialog.data()->setSubfolder(detectSubfolder()); dialog.data()->setCurrentUrl(QUrl::fromLocalFile(QFileInfo(m_model->archive()->fileName()).absolutePath())); dialog.data()->show(); dialog.data()->restoreWindowSize(); if (dialog.data()->exec()) { updateQuickExtractMenu(m_extractArchiveAction); updateQuickExtractMenu(m_extractAction); QVector<Archive::Entry*> files; if (!dialog.data()->extractAllFiles()) { files = filesAndRootNodesForIndexes(addChildren(m_view->selectionModel()->selectedRows())); } qCDebug(ARK) << "Selected " << files; Kerfuffle::ExtractionOptions options; options.setPreservePaths(dialog->preservePaths()); const QString destinationDirectory = dialog.data()->destinationDirectory().toLocalFile(); ExtractJob *job = m_model->extractFiles(files, destinationDirectory, options); registerJob(job); connect(job, &KJob::result, this, &Part::slotExtractionDone); job->start(); } delete dialog.data(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,925
void Part::slotTestArchive() { TestJob *job = m_model->archive()->testArchive(); if (!job) { return; } registerJob(job); connect(job, &KJob::result, this, &Part::slotTestingDone); job->start(); }
Exec Code
0
void Part::slotTestArchive() { TestJob *job = m_model->archive()->testArchive(); if (!job) { return; } registerJob(job); connect(job, &KJob::result, this, &Part::slotTestingDone); job->start(); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,926
void Part::slotTestingDone(KJob* job) { if (job->error() && job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } else if (static_cast<TestJob*>(job)->testSucceeded()) { KMessageBox::information(widget(), i18n("The archive passed the integrity test."), i18n("Test Results")); } else { KMessageBox::error(widget(), i18n("The archive failed the integrity test."), i18n("Test Results")); } }
Exec Code
0
void Part::slotTestingDone(KJob* job) { if (job->error() && job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } else if (static_cast<TestJob*>(job)->testSucceeded()) { KMessageBox::information(widget(), i18n("The archive passed the integrity test."), i18n("Test Results")); } else { KMessageBox::error(widget(), i18n("The archive failed the integrity test."), i18n("Test Results")); } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,927
void Part::slotToggleInfoPanel(bool visible) { if (visible) { m_splitter->setSizes(ArkSettings::splitterSizes()); m_infoPanel->show(); } else { ArkSettings::setSplitterSizes(m_splitter->sizes()); m_infoPanel->hide(); } }
Exec Code
0
void Part::slotToggleInfoPanel(bool visible) { if (visible) { m_splitter->setSizes(ArkSettings::splitterSizes()); m_infoPanel->show(); } else { ArkSettings::setSplitterSizes(m_splitter->sizes()); m_infoPanel->hide(); } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,928
void Part::slotWatchedFileModified(const QString& file) { qCDebug(ARK) << "Watched file modified:" << file; QString relPath = file; foreach (QTemporaryDir *tmpDir, m_tmpExtractDirList) { relPath.remove(tmpDir->path()); //Remove tmpDir. } relPath = relPath.mid(1); //Remove leading slash. if (relPath.contains(QLatin1Char('/'))) { relPath = relPath.section(QLatin1Char('/'), 0, -2); //Remove filename. } else { relPath = QString(); } QString prettyFilename; if (relPath.isEmpty()) { prettyFilename = file.section(QLatin1Char('/'), -1); } else { prettyFilename = relPath + QLatin1Char('/') + file.section(QLatin1Char('/'), -1); } if (KMessageBox::questionYesNo(widget(), xi18n("The file <filename>%1</filename> was modified. Do you want to update the archive?", prettyFilename), i18nc("@title:window", "File Modified")) == KMessageBox::Yes) { QStringList list = QStringList() << file; qCDebug(ARK) << "Updating file" << file << "with path" << relPath; slotAddFiles(list, Q_NULLPTR, relPath); } m_fileWatcher->addPath(file); }
Exec Code
0
void Part::slotWatchedFileModified(const QString& file) { qCDebug(ARK) << "Watched file modified:" << file; QString relPath = file; foreach (QTemporaryDir *tmpDir, m_tmpExtractDirList) { relPath.remove(tmpDir->path()); //Remove tmpDir. } relPath = relPath.mid(1); //Remove leading slash. if (relPath.contains(QLatin1Char('/'))) { relPath = relPath.section(QLatin1Char('/'), 0, -2); //Remove filename. } else { relPath = QString(); } QString prettyFilename; if (relPath.isEmpty()) { prettyFilename = file.section(QLatin1Char('/'), -1); } else { prettyFilename = relPath + QLatin1Char('/') + file.section(QLatin1Char('/'), -1); } if (KMessageBox::questionYesNo(widget(), xi18n("The file <filename>%1</filename> was modified. Do you want to update the archive?", prettyFilename), i18nc("@title:window", "File Modified")) == KMessageBox::Yes) { QStringList list = QStringList() << file; qCDebug(ARK) << "Updating file" << file << "with path" << relPath; slotAddFiles(list, Q_NULLPTR, relPath); } m_fileWatcher->addPath(file); }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,929
void Part::updateActions() { bool isWritable = m_model->archive() && !m_model->archive()->isReadOnly(); const Archive::Entry *entry = m_model->entryForIndex(m_view->selectionModel()->currentIndex()); int selectedEntriesCount = m_view->selectionModel()->selectedRows().count(); const bool isEncryptedButUnknownPassword = m_model->archive() && m_model->archive()->encryptionType() != Archive::Unencrypted && m_model->archive()->password().isEmpty(); if (isEncryptedButUnknownPassword) { m_addFilesAction->setToolTip(xi18nc("@info:tooltip", "Adding files to existing password-protected archives with no header-encryption is currently not supported." "<nl/><nl/>Extract the files and create a new archive if you want to add files.")); m_testArchiveAction->setToolTip(xi18nc("@info:tooltip", "Testing password-protected archives with no header-encryption is currently not supported.")); } else { m_addFilesAction->setToolTip(i18nc("@info:tooltip", "Click to add files to the archive")); m_testArchiveAction->setToolTip(i18nc("@info:tooltip", "Click to test the archive for integrity")); } const int maxPreviewSize = ArkSettings::previewFileSizeLimit() * 1024 * 1024; const bool limit = ArkSettings::limitPreviewFileSize(); bool isPreviewable = (!limit || (limit && entry != Q_NULLPTR && entry->property("size").toLongLong() < maxPreviewSize)); const bool isDir = (entry == Q_NULLPTR) ? false : entry->isDir(); m_previewAction->setEnabled(!isBusy() && isPreviewable && !isDir && (selectedEntriesCount == 1)); m_extractArchiveAction->setEnabled(!isBusy() && (m_model->rowCount() > 0)); m_extractAction->setEnabled(!isBusy() && (m_model->rowCount() > 0)); m_saveAsAction->setEnabled(!isBusy() && m_model->rowCount() > 0); m_addFilesAction->setEnabled(!isBusy() && isWritable && !isEncryptedButUnknownPassword); m_deleteFilesAction->setEnabled(!isBusy() && isWritable && (selectedEntriesCount > 0)); m_openFileAction->setEnabled(!isBusy() && isPreviewable && !isDir && (selectedEntriesCount == 1)); m_openFileWithAction->setEnabled(!isBusy() && isPreviewable && !isDir && (selectedEntriesCount == 1)); m_propertiesAction->setEnabled(!isBusy() && m_model->archive()); m_renameFileAction->setEnabled(!isBusy() && isWritable && (selectedEntriesCount == 1)); m_cutFilesAction->setEnabled(!isBusy() && isWritable && (selectedEntriesCount > 0)); m_copyFilesAction->setEnabled(!isBusy() && isWritable && (selectedEntriesCount > 0)); m_pasteFilesAction->setEnabled(!isBusy() && isWritable && (selectedEntriesCount == 0 || (selectedEntriesCount == 1 && isDir)) && (m_model->filesToMove.count() > 0 || m_model->filesToCopy.count() > 0)); m_commentView->setEnabled(!isBusy()); m_commentMsgWidget->setEnabled(!isBusy()); m_editCommentAction->setEnabled(false); m_testArchiveAction->setEnabled(false); if (m_model->archive()) { const KPluginMetaData metadata = PluginManager().preferredPluginFor(m_model->archive()->mimeType())->metaData(); bool supportsWriteComment = ArchiveFormat::fromMetadata(m_model->archive()->mimeType(), metadata).supportsWriteComment(); m_editCommentAction->setEnabled(!isBusy() && supportsWriteComment); m_commentView->setReadOnly(!supportsWriteComment); m_editCommentAction->setText(m_model->archive()->hasComment() ? i18nc("@action:inmenu mutually exclusive with Add &Comment", "Edit &Comment") : i18nc("@action:inmenu mutually exclusive with Edit &Comment", "Add &Comment")); bool supportsTesting = ArchiveFormat::fromMetadata(m_model->archive()->mimeType(), metadata).supportsTesting(); m_testArchiveAction->setEnabled(!isBusy() && supportsTesting && !isEncryptedButUnknownPassword); } else { m_commentView->setReadOnly(true); m_editCommentAction->setText(i18nc("@action:inmenu mutually exclusive with Edit &Comment", "Add &Comment")); } }
Exec Code
0
void Part::updateActions() { bool isWritable = m_model->archive() && !m_model->archive()->isReadOnly(); const Archive::Entry *entry = m_model->entryForIndex(m_view->selectionModel()->currentIndex()); int selectedEntriesCount = m_view->selectionModel()->selectedRows().count(); const bool isEncryptedButUnknownPassword = m_model->archive() && m_model->archive()->encryptionType() != Archive::Unencrypted && m_model->archive()->password().isEmpty(); if (isEncryptedButUnknownPassword) { m_addFilesAction->setToolTip(xi18nc("@info:tooltip", "Adding files to existing password-protected archives with no header-encryption is currently not supported." "<nl/><nl/>Extract the files and create a new archive if you want to add files.")); m_testArchiveAction->setToolTip(xi18nc("@info:tooltip", "Testing password-protected archives with no header-encryption is currently not supported.")); } else { m_addFilesAction->setToolTip(i18nc("@info:tooltip", "Click to add files to the archive")); m_testArchiveAction->setToolTip(i18nc("@info:tooltip", "Click to test the archive for integrity")); } const int maxPreviewSize = ArkSettings::previewFileSizeLimit() * 1024 * 1024; const bool limit = ArkSettings::limitPreviewFileSize(); bool isPreviewable = (!limit || (limit && entry != Q_NULLPTR && entry->property("size").toLongLong() < maxPreviewSize)); const bool isDir = (entry == Q_NULLPTR) ? false : entry->isDir(); m_previewAction->setEnabled(!isBusy() && isPreviewable && !isDir && (selectedEntriesCount == 1)); m_extractArchiveAction->setEnabled(!isBusy() && (m_model->rowCount() > 0)); m_extractAction->setEnabled(!isBusy() && (m_model->rowCount() > 0)); m_saveAsAction->setEnabled(!isBusy() && m_model->rowCount() > 0); m_addFilesAction->setEnabled(!isBusy() && isWritable && !isEncryptedButUnknownPassword); m_deleteFilesAction->setEnabled(!isBusy() && isWritable && (selectedEntriesCount > 0)); m_openFileAction->setEnabled(!isBusy() && isPreviewable && !isDir && (selectedEntriesCount == 1)); m_openFileWithAction->setEnabled(!isBusy() && isPreviewable && !isDir && (selectedEntriesCount == 1)); m_propertiesAction->setEnabled(!isBusy() && m_model->archive()); m_renameFileAction->setEnabled(!isBusy() && isWritable && (selectedEntriesCount == 1)); m_cutFilesAction->setEnabled(!isBusy() && isWritable && (selectedEntriesCount > 0)); m_copyFilesAction->setEnabled(!isBusy() && isWritable && (selectedEntriesCount > 0)); m_pasteFilesAction->setEnabled(!isBusy() && isWritable && (selectedEntriesCount == 0 || (selectedEntriesCount == 1 && isDir)) && (m_model->filesToMove.count() > 0 || m_model->filesToCopy.count() > 0)); m_commentView->setEnabled(!isBusy()); m_commentMsgWidget->setEnabled(!isBusy()); m_editCommentAction->setEnabled(false); m_testArchiveAction->setEnabled(false); if (m_model->archive()) { const KPluginMetaData metadata = PluginManager().preferredPluginFor(m_model->archive()->mimeType())->metaData(); bool supportsWriteComment = ArchiveFormat::fromMetadata(m_model->archive()->mimeType(), metadata).supportsWriteComment(); m_editCommentAction->setEnabled(!isBusy() && supportsWriteComment); m_commentView->setReadOnly(!supportsWriteComment); m_editCommentAction->setText(m_model->archive()->hasComment() ? i18nc("@action:inmenu mutually exclusive with Add &Comment", "Edit &Comment") : i18nc("@action:inmenu mutually exclusive with Edit &Comment", "Add &Comment")); bool supportsTesting = ArchiveFormat::fromMetadata(m_model->archive()->mimeType(), metadata).supportsTesting(); m_testArchiveAction->setEnabled(!isBusy() && supportsTesting && !isEncryptedButUnknownPassword); } else { m_commentView->setReadOnly(true); m_editCommentAction->setText(i18nc("@action:inmenu mutually exclusive with Edit &Comment", "Add &Comment")); } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,930
void Part::updateQuickExtractMenu(QAction *extractAction) { if (!extractAction) { return; } QMenu *menu = extractAction->menu(); if (!menu) { menu = new QMenu(); extractAction->setMenu(menu); connect(menu, &QMenu::triggered, this, &Part::slotQuickExtractFiles); QAction *extractTo = menu->addAction(i18n("Extract To...")); extractTo->setIcon(extractAction->icon()); extractTo->setToolTip(extractAction->toolTip()); if (extractAction == m_extractArchiveAction) { connect(extractTo, &QAction::triggered, this, &Part::slotExtractArchive); } else { connect(extractTo, &QAction::triggered, this, &Part::slotShowExtractionDialog); } menu->addSeparator(); QAction *header = menu->addAction(i18n("Quick Extract To...")); header->setEnabled(false); header->setIcon(QIcon::fromTheme(QStringLiteral("archive-extract"))); } while (menu->actions().size() > 3) { menu->removeAction(menu->actions().last()); } const KConfigGroup conf(KSharedConfig::openConfig(), "ExtractDialog"); const QStringList dirHistory = conf.readPathEntry("DirHistory", QStringList()); for (int i = 0; i < qMin(10, dirHistory.size()); ++i) { const QString dir = QUrl(dirHistory.value(i)).toString(QUrl::RemoveScheme | QUrl::NormalizePathSegments | QUrl::PreferLocalFile); if (QDir(dir).exists()) { QAction *newAction = menu->addAction(dir); newAction->setData(dir); } } }
Exec Code
0
void Part::updateQuickExtractMenu(QAction *extractAction) { if (!extractAction) { return; } QMenu *menu = extractAction->menu(); if (!menu) { menu = new QMenu(); extractAction->setMenu(menu); connect(menu, &QMenu::triggered, this, &Part::slotQuickExtractFiles); QAction *extractTo = menu->addAction(i18n("Extract To...")); extractTo->setIcon(extractAction->icon()); extractTo->setToolTip(extractAction->toolTip()); if (extractAction == m_extractArchiveAction) { connect(extractTo, &QAction::triggered, this, &Part::slotExtractArchive); } else { connect(extractTo, &QAction::triggered, this, &Part::slotShowExtractionDialog); } menu->addSeparator(); QAction *header = menu->addAction(i18n("Quick Extract To...")); header->setEnabled(false); header->setIcon(QIcon::fromTheme(QStringLiteral("archive-extract"))); } while (menu->actions().size() > 3) { menu->removeAction(menu->actions().last()); } const KConfigGroup conf(KSharedConfig::openConfig(), "ExtractDialog"); const QStringList dirHistory = conf.readPathEntry("DirHistory", QStringList()); for (int i = 0; i < qMin(10, dirHistory.size()); ++i) { const QString dir = QUrl(dirHistory.value(i)).toString(QUrl::RemoveScheme | QUrl::NormalizePathSegments | QUrl::PreferLocalFile); if (QDir(dir).exists()) { QAction *newAction = menu->addAction(dir); newAction->setData(dir); } } }
@@ -988,7 +988,7 @@ void Part::slotOpenExtractedEntry(KJob *job) } else { KRun::runUrl(QUrl::fromUserInput(fullName, QString(), QUrl::AssumeLocalFile), QMimeDatabase().mimeTypeForFile(fullName).name(), - widget()); + widget(), false, false); } } else if (job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString());
CWE-78
null
null
7,931
Chunk::Chunk(Container* parent, WEBP_MetaHandler* handler) { this->needsRewrite = (parent) ? parent->needsRewrite : false; this->parent = parent; XMP_IO* file = handler->parent->ioRef; this->pos = file->Offset(); this->tag = XIO::ReadUns32_LE(file); this->size = XIO::ReadUns32_LE(file); if ((this->pos + this->size + 8) > handler->initialFileSize) { XMP_Throw("Bad RIFF chunk size", kXMPErr_BadFileFormat); } this->data.reserve((XMP_Int32) this->size); this->data.assign((XMP_Int32) this->size, '\0'); file->ReadAll((void*)this->data.data(), (XMP_Int32) this->size); if (this->size & 1) { file->Seek(1, kXMP_SeekFromCurrent); } }
null
0
Chunk::Chunk(Container* parent, WEBP_MetaHandler* handler) { this->needsRewrite = (parent) ? parent->needsRewrite : false; this->parent = parent; XMP_IO* file = handler->parent->ioRef; this->pos = file->Offset(); this->tag = XIO::ReadUns32_LE(file); this->size = XIO::ReadUns32_LE(file); if ((this->pos + this->size + 8) > handler->initialFileSize) { XMP_Throw("Bad RIFF chunk size", kXMPErr_BadFileFormat); } this->data.reserve((XMP_Int32) this->size); this->data.assign((XMP_Int32) this->size, '\0'); file->ReadAll((void*)this->data.data(), (XMP_Int32) this->size); if (this->size & 1) { file->Seek(1, kXMP_SeekFromCurrent); } }
@@ -120,8 +120,10 @@ VP8XChunk::VP8XChunk(Container* parent) this->data.assign(this->size, 0); XMP_Uns8* bitstream = (XMP_Uns8*)parent->chunks[WEBP_CHUNK_IMAGE][0]->data.data(); - XMP_Uns32 width = ((bitstream[7] << 8) | bitstream[6]) & 0x3fff; - XMP_Uns32 height = ((bitstream[9] << 8) | bitstream[8]) & 0x3fff; + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105247 + // bitstream could be NULL. + XMP_Uns32 width = bitstream ? ((bitstream[7] << 8) | bitstream[6]) & 0x3fff : 0; + XMP_Uns32 height = bitstream ? ((bitstream[9] << 8) | bitstream[8]) & 0x3fff : 0; this->width(width); this->height(height); parent->vp8x = this;
CWE-476
null
null
7,932
Chunk::Chunk(Container* parent, XMP_Uns32 tag) : parent(parent), tag(tag) { this->needsRewrite = true; }
null
0
Chunk::Chunk(Container* parent, XMP_Uns32 tag) : parent(parent), tag(tag) { this->needsRewrite = true; }
@@ -120,8 +120,10 @@ VP8XChunk::VP8XChunk(Container* parent) this->data.assign(this->size, 0); XMP_Uns8* bitstream = (XMP_Uns8*)parent->chunks[WEBP_CHUNK_IMAGE][0]->data.data(); - XMP_Uns32 width = ((bitstream[7] << 8) | bitstream[6]) & 0x3fff; - XMP_Uns32 height = ((bitstream[9] << 8) | bitstream[8]) & 0x3fff; + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105247 + // bitstream could be NULL. + XMP_Uns32 width = bitstream ? ((bitstream[7] << 8) | bitstream[6]) & 0x3fff : 0; + XMP_Uns32 height = bitstream ? ((bitstream[9] << 8) | bitstream[8]) & 0x3fff : 0; this->width(width); this->height(height); parent->vp8x = this;
CWE-476
null
null
7,933
XMPChunk::XMPChunk(Container* parent) : Chunk(parent, kChunk_XMP_) { this->size = 0; }
null
0
XMPChunk::XMPChunk(Container* parent) : Chunk(parent, kChunk_XMP_) { this->size = 0; }
@@ -120,8 +120,10 @@ VP8XChunk::VP8XChunk(Container* parent) this->data.assign(this->size, 0); XMP_Uns8* bitstream = (XMP_Uns8*)parent->chunks[WEBP_CHUNK_IMAGE][0]->data.data(); - XMP_Uns32 width = ((bitstream[7] << 8) | bitstream[6]) & 0x3fff; - XMP_Uns32 height = ((bitstream[9] << 8) | bitstream[8]) & 0x3fff; + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105247 + // bitstream could be NULL. + XMP_Uns32 width = bitstream ? ((bitstream[7] << 8) | bitstream[6]) & 0x3fff : 0; + XMP_Uns32 height = bitstream ? ((bitstream[9] << 8) | bitstream[8]) & 0x3fff : 0; this->width(width); this->height(height); parent->vp8x = this;
CWE-476
null
null
7,934
XMPChunk::XMPChunk(Container* parent, WEBP_MetaHandler* handler) : Chunk(parent, handler) { handler->packetInfo.offset = this->pos + 8; handler->packetInfo.length = (XMP_Int32) this->data.size(); handler->xmpPacket.reserve(handler->packetInfo.length); handler->xmpPacket.assign(handler->packetInfo.length, '\0'); handler->xmpPacket.insert(handler->xmpPacket.begin(), this->data.begin(), this->data.end()); handler->containsXMP = true; // last, after all possible failure handler->xmpChunk = this; }
null
0
XMPChunk::XMPChunk(Container* parent, WEBP_MetaHandler* handler) : Chunk(parent, handler) { handler->packetInfo.offset = this->pos + 8; handler->packetInfo.length = (XMP_Int32) this->data.size(); handler->xmpPacket.reserve(handler->packetInfo.length); handler->xmpPacket.assign(handler->packetInfo.length, '\0'); handler->xmpPacket.insert(handler->xmpPacket.begin(), this->data.begin(), this->data.end()); handler->containsXMP = true; // last, after all possible failure handler->xmpChunk = this; }
@@ -120,8 +120,10 @@ VP8XChunk::VP8XChunk(Container* parent) this->data.assign(this->size, 0); XMP_Uns8* bitstream = (XMP_Uns8*)parent->chunks[WEBP_CHUNK_IMAGE][0]->data.data(); - XMP_Uns32 width = ((bitstream[7] << 8) | bitstream[6]) & 0x3fff; - XMP_Uns32 height = ((bitstream[9] << 8) | bitstream[8]) & 0x3fff; + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105247 + // bitstream could be NULL. + XMP_Uns32 width = bitstream ? ((bitstream[7] << 8) | bitstream[6]) & 0x3fff : 0; + XMP_Uns32 height = bitstream ? ((bitstream[9] << 8) | bitstream[8]) & 0x3fff : 0; this->width(width); this->height(height); parent->vp8x = this;
CWE-476
null
null
7,935
void Chunk::write(WEBP_MetaHandler* handler) { XMP_IO* file = handler->parent->ioRef; if (this->needsRewrite) { this->pos = file->Offset(); XIO::WriteUns32_LE(file, this->tag); XIO::WriteUns32_LE(file, (XMP_Uns32) this->size); file->Write(this->data.data(), (XMP_Int32) this->size); } else { file->Seek(this->pos + this->size + 8, kXMP_SeekFromStart); } if (this->size & 1) { const XMP_Uns8 zero = 0; file->Write(&zero, 1); } }
null
0
void Chunk::write(WEBP_MetaHandler* handler) { XMP_IO* file = handler->parent->ioRef; if (this->needsRewrite) { this->pos = file->Offset(); XIO::WriteUns32_LE(file, this->tag); XIO::WriteUns32_LE(file, (XMP_Uns32) this->size); file->Write(this->data.data(), (XMP_Int32) this->size); } else { file->Seek(this->pos + this->size + 8, kXMP_SeekFromStart); } if (this->size & 1) { const XMP_Uns8 zero = 0; file->Write(&zero, 1); } }
@@ -120,8 +120,10 @@ VP8XChunk::VP8XChunk(Container* parent) this->data.assign(this->size, 0); XMP_Uns8* bitstream = (XMP_Uns8*)parent->chunks[WEBP_CHUNK_IMAGE][0]->data.data(); - XMP_Uns32 width = ((bitstream[7] << 8) | bitstream[6]) & 0x3fff; - XMP_Uns32 height = ((bitstream[9] << 8) | bitstream[8]) & 0x3fff; + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105247 + // bitstream could be NULL. + XMP_Uns32 width = bitstream ? ((bitstream[7] << 8) | bitstream[6]) & 0x3fff : 0; + XMP_Uns32 height = bitstream ? ((bitstream[9] << 8) | bitstream[8]) & 0x3fff : 0; this->width(width); this->height(height); parent->vp8x = this;
CWE-476
null
null
7,936
void XMPChunk::write(WEBP_MetaHandler* handler) { XMP_IO* file = handler->parent->ioRef; this->size = handler->xmpPacket.size(); XIO::WriteUns32_LE(file, this->tag); XIO::WriteUns32_LE(file, (XMP_Uns32) this->size); file->Write(handler->xmpPacket.data(), (XMP_Int32) this->size); if (this->size & 1) { const XMP_Uns8 zero = 0; file->Write(&zero, 1); } }
null
0
void XMPChunk::write(WEBP_MetaHandler* handler) { XMP_IO* file = handler->parent->ioRef; this->size = handler->xmpPacket.size(); XIO::WriteUns32_LE(file, this->tag); XIO::WriteUns32_LE(file, (XMP_Uns32) this->size); file->Write(handler->xmpPacket.data(), (XMP_Int32) this->size); if (this->size & 1) { const XMP_Uns8 zero = 0; file->Write(&zero, 1); } }
@@ -120,8 +120,10 @@ VP8XChunk::VP8XChunk(Container* parent) this->data.assign(this->size, 0); XMP_Uns8* bitstream = (XMP_Uns8*)parent->chunks[WEBP_CHUNK_IMAGE][0]->data.data(); - XMP_Uns32 width = ((bitstream[7] << 8) | bitstream[6]) & 0x3fff; - XMP_Uns32 height = ((bitstream[9] << 8) | bitstream[8]) & 0x3fff; + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105247 + // bitstream could be NULL. + XMP_Uns32 width = bitstream ? ((bitstream[7] << 8) | bitstream[6]) & 0x3fff : 0; + XMP_Uns32 height = bitstream ? ((bitstream[9] << 8) | bitstream[8]) & 0x3fff : 0; this->width(width); this->height(height); parent->vp8x = this;
CWE-476
null
null
7,937
Chunk::~Chunk() { }
null
0
Chunk::~Chunk() { }
@@ -120,8 +120,10 @@ VP8XChunk::VP8XChunk(Container* parent) this->data.assign(this->size, 0); XMP_Uns8* bitstream = (XMP_Uns8*)parent->chunks[WEBP_CHUNK_IMAGE][0]->data.data(); - XMP_Uns32 width = ((bitstream[7] << 8) | bitstream[6]) & 0x3fff; - XMP_Uns32 height = ((bitstream[9] << 8) | bitstream[8]) & 0x3fff; + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105247 + // bitstream could be NULL. + XMP_Uns32 width = bitstream ? ((bitstream[7] << 8) | bitstream[6]) & 0x3fff : 0; + XMP_Uns32 height = bitstream ? ((bitstream[9] << 8) | bitstream[8]) & 0x3fff : 0; this->width(width); this->height(height); parent->vp8x = this;
CWE-476
null
null
7,938
bool PSIR_FileWriter::GetImgRsrc ( XMP_Uns16 id, ImgRsrcInfo* info ) const { InternalRsrcMap::const_iterator rsrcPos = this->imgRsrcs.find ( id ); if ( rsrcPos == this->imgRsrcs.end() ) return false; const InternalRsrcInfo & rsrcInfo = rsrcPos->second; if ( info != 0 ) { info->id = rsrcInfo.id; info->dataLen = rsrcInfo.dataLen; info->dataPtr = rsrcInfo.dataPtr; info->origOffset = rsrcInfo.origOffset; } return true; } // PSIR_FileWriter::GetImgRsrc
null
0
bool PSIR_FileWriter::GetImgRsrc ( XMP_Uns16 id, ImgRsrcInfo* info ) const { InternalRsrcMap::const_iterator rsrcPos = this->imgRsrcs.find ( id ); if ( rsrcPos == this->imgRsrcs.end() ) return false; const InternalRsrcInfo & rsrcInfo = rsrcPos->second; if ( info != 0 ) { info->id = rsrcInfo.id; info->dataLen = rsrcInfo.dataLen; info->dataPtr = rsrcInfo.dataPtr; info->origOffset = rsrcInfo.origOffset; } return true; } // PSIR_FileWriter::GetImgRsrc
@@ -319,6 +319,12 @@ void PSIR_FileWriter::ParseFileResources ( XMP_IO* fileRef, XMP_Uns32 length ) XMP_Uns32 dataLen = XIO::ReadUns32_BE ( fileRef ); XMP_Uns32 dataTotal = ((dataLen + 1) & 0xFFFFFFFEUL); // Round up to an even total. + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105204 + // If dataLen is 0xffffffff, then dataTotal might be 0 + // and therefor make the CheckFileSpace test pass. + if (dataTotal < dataLen) { + break; + } if ( ! XIO::CheckFileSpace ( fileRef, dataTotal ) ) break; // Bad image resource. XMP_Int64 thisDataPos = fileRef->Offset();
CWE-125
null
null
7,939
bool PSIR_FileWriter::IsLegacyChanged() { if ( ! this->changed ) return false; if ( this->legacyDeleted ) return true; InternalRsrcMap::iterator irPos = this->imgRsrcs.begin(); InternalRsrcMap::iterator irEnd = this->imgRsrcs.end(); for ( ; irPos != irEnd; ++irPos ) { const InternalRsrcInfo & rsrcInfo = irPos->second; if ( rsrcInfo.changed && (rsrcInfo.id != kPSIR_XMP) ) return true; } return false; // Can get here if the XMP is the only thing changed. } // PSIR_FileWriter::IsLegacyChanged
null
0
bool PSIR_FileWriter::IsLegacyChanged() { if ( ! this->changed ) return false; if ( this->legacyDeleted ) return true; InternalRsrcMap::iterator irPos = this->imgRsrcs.begin(); InternalRsrcMap::iterator irEnd = this->imgRsrcs.end(); for ( ; irPos != irEnd; ++irPos ) { const InternalRsrcInfo & rsrcInfo = irPos->second; if ( rsrcInfo.changed && (rsrcInfo.id != kPSIR_XMP) ) return true; } return false; // Can get here if the XMP is the only thing changed. } // PSIR_FileWriter::IsLegacyChanged
@@ -319,6 +319,12 @@ void PSIR_FileWriter::ParseFileResources ( XMP_IO* fileRef, XMP_Uns32 length ) XMP_Uns32 dataLen = XIO::ReadUns32_BE ( fileRef ); XMP_Uns32 dataTotal = ((dataLen + 1) & 0xFFFFFFFEUL); // Round up to an even total. + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105204 + // If dataLen is 0xffffffff, then dataTotal might be 0 + // and therefor make the CheckFileSpace test pass. + if (dataTotal < dataLen) { + break; + } if ( ! XIO::CheckFileSpace ( fileRef, dataTotal ) ) break; // Bad image resource. XMP_Int64 thisDataPos = fileRef->Offset();
CWE-125
null
null
7,940
static inline bool IsMetadataImgRsrc ( XMP_Uns16 id ) { if ( id == 0 ) return false; int i; for ( i = 0; id < kPSIR_MetadataIDs[i]; ++i ) {} if ( id == kPSIR_MetadataIDs[i] ) return true; return false; } // IsMetadataImgRsrc
null
0
static inline bool IsMetadataImgRsrc ( XMP_Uns16 id ) { if ( id == 0 ) return false; int i; for ( i = 0; id < kPSIR_MetadataIDs[i]; ++i ) {} if ( id == kPSIR_MetadataIDs[i] ) return true; return false; } // IsMetadataImgRsrc
@@ -319,6 +319,12 @@ void PSIR_FileWriter::ParseFileResources ( XMP_IO* fileRef, XMP_Uns32 length ) XMP_Uns32 dataLen = XIO::ReadUns32_BE ( fileRef ); XMP_Uns32 dataTotal = ((dataLen + 1) & 0xFFFFFFFEUL); // Round up to an even total. + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105204 + // If dataLen is 0xffffffff, then dataTotal might be 0 + // and therefor make the CheckFileSpace test pass. + if (dataTotal < dataLen) { + break; + } if ( ! XIO::CheckFileSpace ( fileRef, dataTotal ) ) break; // Bad image resource. XMP_Int64 thisDataPos = fileRef->Offset();
CWE-125
null
null
7,941
void PSIR_FileWriter::ParseMemoryResources ( const void* data, XMP_Uns32 length, bool copyData /* = true */ ) { this->DeleteExistingInfo(); this->memParsed = true; if ( length == 0 ) return; if ( ! copyData ) { this->memContent = (XMP_Uns8*) data; XMP_Assert ( ! this->ownedContent ); } else { if ( length > 100*1024*1024 ) XMP_Throw ( "Outrageous length for memory-based PSIR", kXMPErr_BadPSIR ); this->memContent = (XMP_Uns8*) malloc ( length ); if ( this->memContent == 0 ) XMP_Throw ( "Out of memory", kXMPErr_NoMemory ); memcpy ( this->memContent, data, length ); // AUDIT: Safe, malloc'ed length bytes above. this->ownedContent = true; } this->memLength = length; XMP_Uns8* psirPtr = this->memContent; XMP_Uns8* psirEnd = psirPtr + length; XMP_Uns8* psirLimit = psirEnd - kMinImgRsrcSize; while ( psirPtr <= psirLimit ) { XMP_Uns8* origin = psirPtr; // The beginning of this resource. XMP_Uns32 type = GetUns32BE(psirPtr); XMP_Uns16 id = GetUns16BE(psirPtr+4); psirPtr += 6; // Advance to the resource name. XMP_Uns8* namePtr = psirPtr; XMP_Uns16 nameLen = namePtr[0]; // ! The length for the Pascal string, w/ room for "+2". psirPtr += ((nameLen + 2) & 0xFFFE); // ! Round up to an even offset. Yes, +2! if ( psirPtr > psirEnd-4 ) break; // Bad image resource. Throw instead? XMP_Uns32 dataLen = GetUns32BE(psirPtr); psirPtr += 4; // Advance to the resource data. XMP_Uns32 dataOffset = (XMP_Uns32) ( psirPtr - this->memContent ); XMP_Uns8* nextRsrc = psirPtr + ((dataLen + 1) & 0xFFFFFFFEUL); // ! Round up to an even offset. if ( (dataLen > length) || (psirPtr > psirEnd-dataLen) ) break; // Bad image resource. Throw instead? if ( type != k8BIM ) { XMP_Uns32 rsrcOffset = XMP_Uns32( origin - this->memContent ); XMP_Uns32 rsrcLength = XMP_Uns32( nextRsrc - origin ); // Includes trailing pad. XMP_Assert ( (rsrcLength & 1) == 0 ); this->otherRsrcs.push_back ( OtherRsrcInfo ( rsrcOffset, rsrcLength ) ); } else { InternalRsrcInfo newInfo ( id, dataLen, kIsMemoryBased ); newInfo.dataPtr = psirPtr; newInfo.origOffset = dataOffset; if ( nameLen != 0 ) newInfo.rsrcName = namePtr; InternalRsrcMap::iterator rsrcPos = this->imgRsrcs.find ( id ); if ( rsrcPos == this->imgRsrcs.end() ) { this->imgRsrcs.insert ( rsrcPos, InternalRsrcMap::value_type ( id, newInfo ) ); } else if ( (rsrcPos->second.dataLen == 0) && (newInfo.dataLen != 0) ) { rsrcPos->second = newInfo; } } psirPtr = nextRsrc; } } // PSIR_FileWriter::ParseMemoryResources
null
0
void PSIR_FileWriter::ParseMemoryResources ( const void* data, XMP_Uns32 length, bool copyData /* = true */ ) { this->DeleteExistingInfo(); this->memParsed = true; if ( length == 0 ) return; if ( ! copyData ) { this->memContent = (XMP_Uns8*) data; XMP_Assert ( ! this->ownedContent ); } else { if ( length > 100*1024*1024 ) XMP_Throw ( "Outrageous length for memory-based PSIR", kXMPErr_BadPSIR ); this->memContent = (XMP_Uns8*) malloc ( length ); if ( this->memContent == 0 ) XMP_Throw ( "Out of memory", kXMPErr_NoMemory ); memcpy ( this->memContent, data, length ); // AUDIT: Safe, malloc'ed length bytes above. this->ownedContent = true; } this->memLength = length; XMP_Uns8* psirPtr = this->memContent; XMP_Uns8* psirEnd = psirPtr + length; XMP_Uns8* psirLimit = psirEnd - kMinImgRsrcSize; while ( psirPtr <= psirLimit ) { XMP_Uns8* origin = psirPtr; // The beginning of this resource. XMP_Uns32 type = GetUns32BE(psirPtr); XMP_Uns16 id = GetUns16BE(psirPtr+4); psirPtr += 6; // Advance to the resource name. XMP_Uns8* namePtr = psirPtr; XMP_Uns16 nameLen = namePtr[0]; // ! The length for the Pascal string, w/ room for "+2". psirPtr += ((nameLen + 2) & 0xFFFE); // ! Round up to an even offset. Yes, +2! if ( psirPtr > psirEnd-4 ) break; // Bad image resource. Throw instead? XMP_Uns32 dataLen = GetUns32BE(psirPtr); psirPtr += 4; // Advance to the resource data. XMP_Uns32 dataOffset = (XMP_Uns32) ( psirPtr - this->memContent ); XMP_Uns8* nextRsrc = psirPtr + ((dataLen + 1) & 0xFFFFFFFEUL); // ! Round up to an even offset. if ( (dataLen > length) || (psirPtr > psirEnd-dataLen) ) break; // Bad image resource. Throw instead? if ( type != k8BIM ) { XMP_Uns32 rsrcOffset = XMP_Uns32( origin - this->memContent ); XMP_Uns32 rsrcLength = XMP_Uns32( nextRsrc - origin ); // Includes trailing pad. XMP_Assert ( (rsrcLength & 1) == 0 ); this->otherRsrcs.push_back ( OtherRsrcInfo ( rsrcOffset, rsrcLength ) ); } else { InternalRsrcInfo newInfo ( id, dataLen, kIsMemoryBased ); newInfo.dataPtr = psirPtr; newInfo.origOffset = dataOffset; if ( nameLen != 0 ) newInfo.rsrcName = namePtr; InternalRsrcMap::iterator rsrcPos = this->imgRsrcs.find ( id ); if ( rsrcPos == this->imgRsrcs.end() ) { this->imgRsrcs.insert ( rsrcPos, InternalRsrcMap::value_type ( id, newInfo ) ); } else if ( (rsrcPos->second.dataLen == 0) && (newInfo.dataLen != 0) ) { rsrcPos->second = newInfo; } } psirPtr = nextRsrc; } } // PSIR_FileWriter::ParseMemoryResources
@@ -319,6 +319,12 @@ void PSIR_FileWriter::ParseFileResources ( XMP_IO* fileRef, XMP_Uns32 length ) XMP_Uns32 dataLen = XIO::ReadUns32_BE ( fileRef ); XMP_Uns32 dataTotal = ((dataLen + 1) & 0xFFFFFFFEUL); // Round up to an even total. + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105204 + // If dataLen is 0xffffffff, then dataTotal might be 0 + // and therefor make the CheckFileSpace test pass. + if (dataTotal < dataLen) { + break; + } if ( ! XIO::CheckFileSpace ( fileRef, dataTotal ) ) break; // Bad image resource. XMP_Int64 thisDataPos = fileRef->Offset();
CWE-125
null
null
7,942
void PSIR_FileWriter::SetImgRsrc ( XMP_Uns16 id, const void* clientPtr, XMP_Uns32 length ) { InternalRsrcInfo* rsrcPtr = 0; InternalRsrcMap::iterator rsrcPos = this->imgRsrcs.find ( id ); if ( rsrcPos == this->imgRsrcs.end() ) { InternalRsrcMap::value_type mapValue ( id, InternalRsrcInfo ( id, length, this->fileParsed ) ); rsrcPos = this->imgRsrcs.insert ( rsrcPos, mapValue ); rsrcPtr = &rsrcPos->second; } else { rsrcPtr = &rsrcPos->second; if ( (length == rsrcPtr->dataLen) && (memcmp ( rsrcPtr->dataPtr, clientPtr, length ) == 0) ) { return; } rsrcPtr->FreeData(); // Release any existing data allocation. rsrcPtr->dataLen = length; // And this might be changing. } rsrcPtr->changed = true; rsrcPtr->dataPtr = malloc ( length ); if ( rsrcPtr->dataPtr == 0 ) XMP_Throw ( "Out of memory", kXMPErr_NoMemory ); memcpy ( rsrcPtr->dataPtr, clientPtr, length ); // AUDIT: Safe, malloc'ed length bytes above. this->changed = true; } // PSIR_FileWriter::SetImgRsrc
null
0
void PSIR_FileWriter::SetImgRsrc ( XMP_Uns16 id, const void* clientPtr, XMP_Uns32 length ) { InternalRsrcInfo* rsrcPtr = 0; InternalRsrcMap::iterator rsrcPos = this->imgRsrcs.find ( id ); if ( rsrcPos == this->imgRsrcs.end() ) { InternalRsrcMap::value_type mapValue ( id, InternalRsrcInfo ( id, length, this->fileParsed ) ); rsrcPos = this->imgRsrcs.insert ( rsrcPos, mapValue ); rsrcPtr = &rsrcPos->second; } else { rsrcPtr = &rsrcPos->second; if ( (length == rsrcPtr->dataLen) && (memcmp ( rsrcPtr->dataPtr, clientPtr, length ) == 0) ) { return; } rsrcPtr->FreeData(); // Release any existing data allocation. rsrcPtr->dataLen = length; // And this might be changing. } rsrcPtr->changed = true; rsrcPtr->dataPtr = malloc ( length ); if ( rsrcPtr->dataPtr == 0 ) XMP_Throw ( "Out of memory", kXMPErr_NoMemory ); memcpy ( rsrcPtr->dataPtr, clientPtr, length ); // AUDIT: Safe, malloc'ed length bytes above. this->changed = true; } // PSIR_FileWriter::SetImgRsrc
@@ -319,6 +319,12 @@ void PSIR_FileWriter::ParseFileResources ( XMP_IO* fileRef, XMP_Uns32 length ) XMP_Uns32 dataLen = XIO::ReadUns32_BE ( fileRef ); XMP_Uns32 dataTotal = ((dataLen + 1) & 0xFFFFFFFEUL); // Round up to an even total. + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105204 + // If dataLen is 0xffffffff, then dataTotal might be 0 + // and therefor make the CheckFileSpace test pass. + if (dataTotal < dataLen) { + break; + } if ( ! XIO::CheckFileSpace ( fileRef, dataTotal ) ) break; // Bad image resource. XMP_Int64 thisDataPos = fileRef->Offset();
CWE-125
null
null
7,943
bool PostScript_MetaHandler::ExtractContainsXMPHint(IOBuffer &ioBuf,XMP_Int64 containsXMPStartpos) { XMP_IO* fileRef = this->parent->ioRef; int xmpHint = kPSHint_NoMain; // ! From here on, a failure means "no main", not "no marker". if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return false; if ( ! IsSpaceOrTab ( *ioBuf.ptr ) ) return false; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( IsNewline ( *ioBuf.ptr ) ) return false; // Reached the end of the ContainsXMP comment. if ( ! CheckFileSpace ( fileRef, &ioBuf, 6 ) ) return false ; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("NoMain"), 6 ) ) { ioBuf.ptr += 6; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( ! IsNewline( *ioBuf.ptr) ) return false; this->psHint = kPSHint_NoMain; setTokenInfo(kPS_ADOContainsXMP,containsXMPStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-containsXMPStartpos); } else if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("MainFi"), 6 ) ) { ioBuf.ptr += 6; if ( ! CheckFileSpace ( fileRef, &ioBuf, 3 ) ) return false; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("rst"), 3 ) ) { ioBuf.ptr += 3; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( ! IsNewline( *ioBuf.ptr) ) return false; this->psHint = kPSHint_MainFirst; setTokenInfo(kPS_ADOContainsXMP,containsXMPStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-containsXMPStartpos); containsXMPHint=true; } } else if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("MainLa"), 6 ) ) { ioBuf.ptr += 6; if ( ! CheckFileSpace ( fileRef, &ioBuf, 2 ) ) return false; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("st"), 2 ) ) { ioBuf.ptr += 2; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( ! IsNewline( *ioBuf.ptr) ) return false; this->psHint = kPSHint_MainLast; setTokenInfo(kPS_ADOContainsXMP,containsXMPStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-containsXMPStartpos); containsXMPHint=true; } } else { if ( ! PostScript_Support::SkipUntilNewline(fileRef,ioBuf) ) return false; } return true; }
null
0
bool PostScript_MetaHandler::ExtractContainsXMPHint(IOBuffer &ioBuf,XMP_Int64 containsXMPStartpos) { XMP_IO* fileRef = this->parent->ioRef; int xmpHint = kPSHint_NoMain; // ! From here on, a failure means "no main", not "no marker". if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return false; if ( ! IsSpaceOrTab ( *ioBuf.ptr ) ) return false; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( IsNewline ( *ioBuf.ptr ) ) return false; // Reached the end of the ContainsXMP comment. if ( ! CheckFileSpace ( fileRef, &ioBuf, 6 ) ) return false ; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("NoMain"), 6 ) ) { ioBuf.ptr += 6; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( ! IsNewline( *ioBuf.ptr) ) return false; this->psHint = kPSHint_NoMain; setTokenInfo(kPS_ADOContainsXMP,containsXMPStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-containsXMPStartpos); } else if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("MainFi"), 6 ) ) { ioBuf.ptr += 6; if ( ! CheckFileSpace ( fileRef, &ioBuf, 3 ) ) return false; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("rst"), 3 ) ) { ioBuf.ptr += 3; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( ! IsNewline( *ioBuf.ptr) ) return false; this->psHint = kPSHint_MainFirst; setTokenInfo(kPS_ADOContainsXMP,containsXMPStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-containsXMPStartpos); containsXMPHint=true; } } else if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("MainLa"), 6 ) ) { ioBuf.ptr += 6; if ( ! CheckFileSpace ( fileRef, &ioBuf, 2 ) ) return false; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("st"), 2 ) ) { ioBuf.ptr += 2; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( ! IsNewline( *ioBuf.ptr) ) return false; this->psHint = kPSHint_MainLast; setTokenInfo(kPS_ADOContainsXMP,containsXMPStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-containsXMPStartpos); containsXMPHint=true; } } else { if ( ! PostScript_Support::SkipUntilNewline(fileRef,ioBuf) ) return false; } return true; }
@@ -885,7 +885,9 @@ void PostScript_MetaHandler::ParsePSFile() if (CheckBytes ( ioBuf.ptr, Uns8Ptr("iler"), 4 )) { ioBuf.ptr+=4; - while(!IsNewline(*ioBuf.ptr)) ++ioBuf.ptr; + while(ioBuf.ptr < ioBuf.limit && + !IsNewline(*ioBuf.ptr)) + ++ioBuf.ptr; setTokenInfo(kPS_Trailer,begStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-begStartpos); } }
CWE-125
null
null
7,944
bool PostScript_MetaHandler::FindLastPacket() { size_t bufPos, bufLen; XMP_IO* fileRef = this->parent->ioRef; XMP_Int64 fileLen = fileRef->Length(); XMP_PacketInfo & packetInfo = this->packetInfo; XMPScanner scanner ( fileLen ); enum { kBufferSize = 64*1024 }; XMP_Uns8 buffer [kBufferSize]; XMP_AbortProc abortProc = this->parent->abortProc; void * abortArg = this->parent->abortArg; const bool checkAbort = (abortProc != 0); fileRef->Rewind(); // Seek back to the beginning of the file. for ( bufPos = 0; bufPos < (size_t)fileLen; bufPos += bufLen ) { if ( checkAbort && abortProc(abortArg) ) { XMP_Throw ( "PostScript_MetaHandler::FindLastPacket - User abort", kXMPErr_UserAbort ); } bufLen = fileRef->Read ( buffer, kBufferSize ); if ( bufLen == 0 ) XMP_Throw ( "PostScript_MetaHandler::FindLastPacket: Read failure", kXMPErr_ExternalFailure ); scanner.Scan ( buffer, bufPos, bufLen ); } int snipCount = scanner.GetSnipCount(); XMPScanner::SnipInfoVector snips ( snipCount ); scanner.Report ( snips ); bool lastfound=false; for ( int i = 0; i < snipCount; ++i ) { if ( snips[i].fState == XMPScanner::eValidPacketSnip ) { if (!lastfound) { if ( snips[i].fLength > 0x7FFFFFFF ) XMP_Throw ( "PostScript_MetaHandler::FindLastPacket: Oversize packet", kXMPErr_BadXMP ); packetInfo.offset = snips[i].fOffset; packetInfo.length = (XMP_Int32)snips[i].fLength; packetInfo.charForm = snips[i].fCharForm; packetInfo.writeable = (snips[i].fAccess == 'w'); firstPacketInfo=packetInfo; lastPacketInfo=packetInfo; lastfound=true; } else { lastPacketInfo.offset = snips[i].fOffset; lastPacketInfo.length = (XMP_Int32)snips[i].fLength; lastPacketInfo.charForm = snips[i].fCharForm; lastPacketInfo.writeable = (snips[i].fAccess == 'w'); packetInfo=lastPacketInfo; } } } return lastfound; } // PostScript_MetaHandler::FindLastPacket
null
0
bool PostScript_MetaHandler::FindLastPacket() { size_t bufPos, bufLen; XMP_IO* fileRef = this->parent->ioRef; XMP_Int64 fileLen = fileRef->Length(); XMP_PacketInfo & packetInfo = this->packetInfo; XMPScanner scanner ( fileLen ); enum { kBufferSize = 64*1024 }; XMP_Uns8 buffer [kBufferSize]; XMP_AbortProc abortProc = this->parent->abortProc; void * abortArg = this->parent->abortArg; const bool checkAbort = (abortProc != 0); fileRef->Rewind(); // Seek back to the beginning of the file. for ( bufPos = 0; bufPos < (size_t)fileLen; bufPos += bufLen ) { if ( checkAbort && abortProc(abortArg) ) { XMP_Throw ( "PostScript_MetaHandler::FindLastPacket - User abort", kXMPErr_UserAbort ); } bufLen = fileRef->Read ( buffer, kBufferSize ); if ( bufLen == 0 ) XMP_Throw ( "PostScript_MetaHandler::FindLastPacket: Read failure", kXMPErr_ExternalFailure ); scanner.Scan ( buffer, bufPos, bufLen ); } int snipCount = scanner.GetSnipCount(); XMPScanner::SnipInfoVector snips ( snipCount ); scanner.Report ( snips ); bool lastfound=false; for ( int i = 0; i < snipCount; ++i ) { if ( snips[i].fState == XMPScanner::eValidPacketSnip ) { if (!lastfound) { if ( snips[i].fLength > 0x7FFFFFFF ) XMP_Throw ( "PostScript_MetaHandler::FindLastPacket: Oversize packet", kXMPErr_BadXMP ); packetInfo.offset = snips[i].fOffset; packetInfo.length = (XMP_Int32)snips[i].fLength; packetInfo.charForm = snips[i].fCharForm; packetInfo.writeable = (snips[i].fAccess == 'w'); firstPacketInfo=packetInfo; lastPacketInfo=packetInfo; lastfound=true; } else { lastPacketInfo.offset = snips[i].fOffset; lastPacketInfo.length = (XMP_Int32)snips[i].fLength; lastPacketInfo.charForm = snips[i].fCharForm; lastPacketInfo.writeable = (snips[i].fAccess == 'w'); packetInfo=lastPacketInfo; } } } return lastfound; } // PostScript_MetaHandler::FindLastPacket
@@ -885,7 +885,9 @@ void PostScript_MetaHandler::ParsePSFile() if (CheckBytes ( ioBuf.ptr, Uns8Ptr("iler"), 4 )) { ioBuf.ptr+=4; - while(!IsNewline(*ioBuf.ptr)) ++ioBuf.ptr; + while(ioBuf.ptr < ioBuf.limit && + !IsNewline(*ioBuf.ptr)) + ++ioBuf.ptr; setTokenInfo(kPS_Trailer,begStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-begStartpos); } }
CWE-125
null
null
7,945
int PostScript_MetaHandler::FindPostScriptHint() { bool found = false; IOBuffer ioBuf; XMP_Uns8 ch; XMP_IO* fileRef = this->parent->ioRef; XMP_AbortProc abortProc = this->parent->abortProc; void * abortArg = this->parent->abortArg; const bool checkAbort = (abortProc != 0); fileRef->Rewind(); if ( ! CheckFileSpace ( fileRef, &ioBuf, 4 ) ) return false; XMP_Uns32 fileheader = GetUns32BE ( ioBuf.ptr ); if ( fileheader == 0xC5D0D3C6 ) { if ( ! CheckFileSpace ( fileRef, &ioBuf, 30 ) ) return false; XMP_Uns32 psOffset = GetUns32LE ( ioBuf.ptr+4 ); // PostScript offset. XMP_Uns32 psLength = GetUns32LE ( ioBuf.ptr+8 ); // PostScript length. MoveToOffset ( fileRef, psOffset, &ioBuf ); } while ( true ) { if ( checkAbort && abortProc(abortArg) ) { XMP_Throw ( "PostScript_MetaHandler::FindPostScriptHint - User abort", kXMPErr_UserAbort ); } if ( ! CheckFileSpace ( fileRef, &ioBuf, kPSContainsXMPString.length() ) ) return kPSHint_NoMarker; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr(kPSEndCommentString.c_str()), kPSEndCommentString.length() ) ) { return kPSHint_NoMarker; } else if ( ! CheckBytes ( ioBuf.ptr, Uns8Ptr(kPSContainsXMPString.c_str()), kPSContainsXMPString.length() ) ) { do { if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return kPSHint_NoMarker; ch = *ioBuf.ptr; ++ioBuf.ptr; } while ( ! IsNewline ( ch ) ); } else { ioBuf.ptr += kPSContainsXMPString.length(); int xmpHint = kPSHint_NoMain; // ! From here on, a failure means "no main", not "no marker". if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return kPSHint_NoMain; if ( ! IsSpaceOrTab ( *ioBuf.ptr ) ) return kPSHint_NoMain; while ( true ) { while ( true ) { // Skip leading spaces and tabs. if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return kPSHint_NoMain; if ( ! IsSpaceOrTab ( *ioBuf.ptr ) ) break; ++ioBuf.ptr; } if ( IsNewline ( *ioBuf.ptr ) ) return kPSHint_NoMain; // Reached the end of the ContainsXMP comment. if ( ! CheckFileSpace ( fileRef, &ioBuf, 6 ) ) return kPSHint_NoMain; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("NoMain"), 6 ) ) { ioBuf.ptr += 6; xmpHint = kPSHint_NoMain; break; } else if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("MainFi"), 6 ) ) { ioBuf.ptr += 6; if ( ! CheckFileSpace ( fileRef, &ioBuf, 3 ) ) return kPSHint_NoMain; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("rst"), 3 ) ) { ioBuf.ptr += 3; xmpHint = kPSHint_MainFirst; } break; } else if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("MainLa"), 6 ) ) { ioBuf.ptr += 6; if ( ! CheckFileSpace ( fileRef, &ioBuf, 2 ) ) return kPSHint_NoMain; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("st"), 2 ) ) { ioBuf.ptr += 2; xmpHint = kPSHint_MainLast; } break; } else { while ( true ) { // Skip until whitespace. if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return kPSHint_NoMain; if ( IsWhitespace ( *ioBuf.ptr ) ) break; ++ioBuf.ptr; } } } // Look for the main packet location option. if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return kPSHint_NoMain; if ( ! IsWhitespace ( *ioBuf.ptr ) ) return kPSHint_NoMain; return xmpHint; } // Found "%ADO_ContainsXMP:". } // Outer marker loop. return kPSHint_NoMarker; // Should never reach here. } // PostScript_MetaHandler::FindPostScriptHint
null
0
int PostScript_MetaHandler::FindPostScriptHint() { bool found = false; IOBuffer ioBuf; XMP_Uns8 ch; XMP_IO* fileRef = this->parent->ioRef; XMP_AbortProc abortProc = this->parent->abortProc; void * abortArg = this->parent->abortArg; const bool checkAbort = (abortProc != 0); fileRef->Rewind(); if ( ! CheckFileSpace ( fileRef, &ioBuf, 4 ) ) return false; XMP_Uns32 fileheader = GetUns32BE ( ioBuf.ptr ); if ( fileheader == 0xC5D0D3C6 ) { if ( ! CheckFileSpace ( fileRef, &ioBuf, 30 ) ) return false; XMP_Uns32 psOffset = GetUns32LE ( ioBuf.ptr+4 ); // PostScript offset. XMP_Uns32 psLength = GetUns32LE ( ioBuf.ptr+8 ); // PostScript length. MoveToOffset ( fileRef, psOffset, &ioBuf ); } while ( true ) { if ( checkAbort && abortProc(abortArg) ) { XMP_Throw ( "PostScript_MetaHandler::FindPostScriptHint - User abort", kXMPErr_UserAbort ); } if ( ! CheckFileSpace ( fileRef, &ioBuf, kPSContainsXMPString.length() ) ) return kPSHint_NoMarker; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr(kPSEndCommentString.c_str()), kPSEndCommentString.length() ) ) { return kPSHint_NoMarker; } else if ( ! CheckBytes ( ioBuf.ptr, Uns8Ptr(kPSContainsXMPString.c_str()), kPSContainsXMPString.length() ) ) { do { if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return kPSHint_NoMarker; ch = *ioBuf.ptr; ++ioBuf.ptr; } while ( ! IsNewline ( ch ) ); } else { ioBuf.ptr += kPSContainsXMPString.length(); int xmpHint = kPSHint_NoMain; // ! From here on, a failure means "no main", not "no marker". if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return kPSHint_NoMain; if ( ! IsSpaceOrTab ( *ioBuf.ptr ) ) return kPSHint_NoMain; while ( true ) { while ( true ) { // Skip leading spaces and tabs. if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return kPSHint_NoMain; if ( ! IsSpaceOrTab ( *ioBuf.ptr ) ) break; ++ioBuf.ptr; } if ( IsNewline ( *ioBuf.ptr ) ) return kPSHint_NoMain; // Reached the end of the ContainsXMP comment. if ( ! CheckFileSpace ( fileRef, &ioBuf, 6 ) ) return kPSHint_NoMain; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("NoMain"), 6 ) ) { ioBuf.ptr += 6; xmpHint = kPSHint_NoMain; break; } else if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("MainFi"), 6 ) ) { ioBuf.ptr += 6; if ( ! CheckFileSpace ( fileRef, &ioBuf, 3 ) ) return kPSHint_NoMain; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("rst"), 3 ) ) { ioBuf.ptr += 3; xmpHint = kPSHint_MainFirst; } break; } else if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("MainLa"), 6 ) ) { ioBuf.ptr += 6; if ( ! CheckFileSpace ( fileRef, &ioBuf, 2 ) ) return kPSHint_NoMain; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("st"), 2 ) ) { ioBuf.ptr += 2; xmpHint = kPSHint_MainLast; } break; } else { while ( true ) { // Skip until whitespace. if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return kPSHint_NoMain; if ( IsWhitespace ( *ioBuf.ptr ) ) break; ++ioBuf.ptr; } } } // Look for the main packet location option. if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return kPSHint_NoMain; if ( ! IsWhitespace ( *ioBuf.ptr ) ) return kPSHint_NoMain; return xmpHint; } // Found "%ADO_ContainsXMP:". } // Outer marker loop. return kPSHint_NoMarker; // Should never reach here. } // PostScript_MetaHandler::FindPostScriptHint
@@ -885,7 +885,9 @@ void PostScript_MetaHandler::ParsePSFile() if (CheckBytes ( ioBuf.ptr, Uns8Ptr("iler"), 4 )) { ioBuf.ptr+=4; - while(!IsNewline(*ioBuf.ptr)) ++ioBuf.ptr; + while(ioBuf.ptr < ioBuf.limit && + !IsNewline(*ioBuf.ptr)) + ++ioBuf.ptr; setTokenInfo(kPS_Trailer,begStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-begStartpos); } }
CWE-125
null
null
7,946
bool PostScript_CheckFormat ( XMP_FileFormat format, XMP_StringPtr filePath, XMP_IO* fileRef, XMPFiles * parent ) { IgnoreParam(filePath); IgnoreParam(parent); XMP_Assert ( (format == kXMP_EPSFile) || (format == kXMP_PostScriptFile) ); return PostScript_Support::IsValidPSFile(fileRef,format) ; } // PostScript_CheckFormat
null
0
bool PostScript_CheckFormat ( XMP_FileFormat format, XMP_StringPtr filePath, XMP_IO* fileRef, XMPFiles * parent ) { IgnoreParam(filePath); IgnoreParam(parent); XMP_Assert ( (format == kXMP_EPSFile) || (format == kXMP_PostScriptFile) ); return PostScript_Support::IsValidPSFile(fileRef,format) ; } // PostScript_CheckFormat
@@ -885,7 +885,9 @@ void PostScript_MetaHandler::ParsePSFile() if (CheckBytes ( ioBuf.ptr, Uns8Ptr("iler"), 4 )) { ioBuf.ptr+=4; - while(!IsNewline(*ioBuf.ptr)) ++ioBuf.ptr; + while(ioBuf.ptr < ioBuf.limit && + !IsNewline(*ioBuf.ptr)) + ++ioBuf.ptr; setTokenInfo(kPS_Trailer,begStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-begStartpos); } }
CWE-125
null
null
7,947
PostScript_MetaHandler::PostScript_MetaHandler ( XMPFiles * _parent ):dscFlags(0),docInfoFlags(0) ,containsXMPHint(false),fileformat(kXMP_UnknownFile) { this->parent = _parent; this->handlerFlags = kPostScript_HandlerFlags; this->stdCharForm = kXMP_Char8Bit; this->psHint = kPSHint_NoMarker; } // PostScript_MetaHandler::PostScript_MetaHandler
null
0
PostScript_MetaHandler::PostScript_MetaHandler ( XMPFiles * _parent ):dscFlags(0),docInfoFlags(0) ,containsXMPHint(false),fileformat(kXMP_UnknownFile) { this->parent = _parent; this->handlerFlags = kPostScript_HandlerFlags; this->stdCharForm = kXMP_Char8Bit; this->psHint = kPSHint_NoMarker; } // PostScript_MetaHandler::PostScript_MetaHandler
@@ -885,7 +885,9 @@ void PostScript_MetaHandler::ParsePSFile() if (CheckBytes ( ioBuf.ptr, Uns8Ptr("iler"), 4 )) { ioBuf.ptr+=4; - while(!IsNewline(*ioBuf.ptr)) ++ioBuf.ptr; + while(ioBuf.ptr < ioBuf.limit && + !IsNewline(*ioBuf.ptr)) + ++ioBuf.ptr; setTokenInfo(kPS_Trailer,begStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-begStartpos); } }
CWE-125
null
null
7,948
XMPFileHandler * PostScript_MetaHandlerCTor ( XMPFiles * parent ) { XMPFileHandler * newHandler = new PostScript_MetaHandler ( parent ); return newHandler; } // PostScript_MetaHandlerCTor
null
0
XMPFileHandler * PostScript_MetaHandlerCTor ( XMPFiles * parent ) { XMPFileHandler * newHandler = new PostScript_MetaHandler ( parent ); return newHandler; } // PostScript_MetaHandlerCTor
@@ -885,7 +885,9 @@ void PostScript_MetaHandler::ParsePSFile() if (CheckBytes ( ioBuf.ptr, Uns8Ptr("iler"), 4 )) { ioBuf.ptr+=4; - while(!IsNewline(*ioBuf.ptr)) ++ioBuf.ptr; + while(ioBuf.ptr < ioBuf.limit && + !IsNewline(*ioBuf.ptr)) + ++ioBuf.ptr; setTokenInfo(kPS_Trailer,begStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-begStartpos); } }
CWE-125
null
null
7,949
PostScript_MetaHandler::TokenLocation& PostScript_MetaHandler::getTokenInfo(TokenFlag tFlag) { if ((docInfoFlags&tFlag)&&tFlag>=kPS_ADOContainsXMP && tFlag<=kPS_EndPostScript) { size_t index=0; XMP_Uns64 flag=tFlag; while(flag>>=1) index++; return fileTokenInfo[index]; } return fileTokenInfo[kPS_NoData]; }
null
0
PostScript_MetaHandler::TokenLocation& PostScript_MetaHandler::getTokenInfo(TokenFlag tFlag) { if ((docInfoFlags&tFlag)&&tFlag>=kPS_ADOContainsXMP && tFlag<=kPS_EndPostScript) { size_t index=0; XMP_Uns64 flag=tFlag; while(flag>>=1) index++; return fileTokenInfo[index]; } return fileTokenInfo[kPS_NoData]; }
@@ -885,7 +885,9 @@ void PostScript_MetaHandler::ParsePSFile() if (CheckBytes ( ioBuf.ptr, Uns8Ptr("iler"), 4 )) { ioBuf.ptr+=4; - while(!IsNewline(*ioBuf.ptr)) ++ioBuf.ptr; + while(ioBuf.ptr < ioBuf.limit && + !IsNewline(*ioBuf.ptr)) + ++ioBuf.ptr; setTokenInfo(kPS_Trailer,begStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-begStartpos); } }
CWE-125
null
null
7,950
PostScript_MetaHandler::~PostScript_MetaHandler() { } // PostScript_MetaHandler::~PostScript_MetaHandler
null
0
PostScript_MetaHandler::~PostScript_MetaHandler() { } // PostScript_MetaHandler::~PostScript_MetaHandler
@@ -885,7 +885,9 @@ void PostScript_MetaHandler::ParsePSFile() if (CheckBytes ( ioBuf.ptr, Uns8Ptr("iler"), 4 )) { ioBuf.ptr+=4; - while(!IsNewline(*ioBuf.ptr)) ++ioBuf.ptr; + while(ioBuf.ptr < ioBuf.limit && + !IsNewline(*ioBuf.ptr)) + ++ioBuf.ptr; setTokenInfo(kPS_Trailer,begStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-begStartpos); } }
CWE-125
null
null
7,951
void TIFF_MetaHandler::CacheFileData() { XMP_IO* fileRef = this->parent->ioRef; XMP_PacketInfo & packetInfo = this->packetInfo; XMP_AbortProc abortProc = this->parent->abortProc; void * abortArg = this->parent->abortArg; const bool checkAbort = (abortProc != 0); XMP_Assert ( ! this->containsXMP ); if ( checkAbort && abortProc(abortArg) ) { XMP_Throw ( "TIFF_MetaHandler::CacheFileData - User abort", kXMPErr_UserAbort ); } this->tiffMgr.ParseFileStream ( fileRef ); TIFF_Manager::TagInfo dngInfo; if ( this->tiffMgr.GetTag ( kTIFF_PrimaryIFD, kTIFF_DNGVersion, &dngInfo ) ) { XMP_Uns8 majorVersion = *((XMP_Uns8*)dngInfo.dataPtr); // Start with DNGVersion. if ( this->tiffMgr.GetTag ( kTIFF_PrimaryIFD, kTIFF_DNGBackwardVersion, &dngInfo ) ) { majorVersion = *((XMP_Uns8*)dngInfo.dataPtr); // Use DNGBackwardVersion if possible. } if ( majorVersion > 1 ) XMP_Throw ( "DNG version beyond 1.x", kXMPErr_BadTIFF ); } TIFF_Manager::TagInfo xmpInfo; bool found = this->tiffMgr.GetTag ( kTIFF_PrimaryIFD, kTIFF_XMP, &xmpInfo ); if ( found ) { this->packetInfo.offset = this->tiffMgr.GetValueOffset ( kTIFF_PrimaryIFD, kTIFF_XMP ); this->packetInfo.length = xmpInfo.dataLen; this->packetInfo.padSize = 0; // Assume for now, set these properly in ProcessXMP. this->packetInfo.charForm = kXMP_CharUnknown; this->packetInfo.writeable = true; this->xmpPacket.assign ( (XMP_StringPtr)xmpInfo.dataPtr, xmpInfo.dataLen ); this->containsXMP = true; } } // TIFF_MetaHandler::CacheFileData
null
0
void TIFF_MetaHandler::CacheFileData() { XMP_IO* fileRef = this->parent->ioRef; XMP_PacketInfo & packetInfo = this->packetInfo; XMP_AbortProc abortProc = this->parent->abortProc; void * abortArg = this->parent->abortArg; const bool checkAbort = (abortProc != 0); XMP_Assert ( ! this->containsXMP ); if ( checkAbort && abortProc(abortArg) ) { XMP_Throw ( "TIFF_MetaHandler::CacheFileData - User abort", kXMPErr_UserAbort ); } this->tiffMgr.ParseFileStream ( fileRef ); TIFF_Manager::TagInfo dngInfo; if ( this->tiffMgr.GetTag ( kTIFF_PrimaryIFD, kTIFF_DNGVersion, &dngInfo ) ) { XMP_Uns8 majorVersion = *((XMP_Uns8*)dngInfo.dataPtr); // Start with DNGVersion. if ( this->tiffMgr.GetTag ( kTIFF_PrimaryIFD, kTIFF_DNGBackwardVersion, &dngInfo ) ) { majorVersion = *((XMP_Uns8*)dngInfo.dataPtr); // Use DNGBackwardVersion if possible. } if ( majorVersion > 1 ) XMP_Throw ( "DNG version beyond 1.x", kXMPErr_BadTIFF ); } TIFF_Manager::TagInfo xmpInfo; bool found = this->tiffMgr.GetTag ( kTIFF_PrimaryIFD, kTIFF_XMP, &xmpInfo ); if ( found ) { this->packetInfo.offset = this->tiffMgr.GetValueOffset ( kTIFF_PrimaryIFD, kTIFF_XMP ); this->packetInfo.length = xmpInfo.dataLen; this->packetInfo.padSize = 0; // Assume for now, set these properly in ProcessXMP. this->packetInfo.charForm = kXMP_CharUnknown; this->packetInfo.writeable = true; this->xmpPacket.assign ( (XMP_StringPtr)xmpInfo.dataPtr, xmpInfo.dataLen ); this->containsXMP = true; } } // TIFF_MetaHandler::CacheFileData
@@ -235,8 +235,9 @@ void TIFF_MetaHandler::ProcessXMP() // zero padding for the IPTC digest. If the full digest differs, recheck without the padding. iptcDigestState = PhotoDataUtils::CheckIPTCDigest ( iptcInfo.dataPtr, iptcInfo.dataLen, digestInfo.dataPtr ); - - if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) ) { + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105205 + // if iptcInfo.dataLen is 0, then there is no digest. + if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) && iptcInfo.dataLen > 0 ) { XMP_Uns8 * endPtr = (XMP_Uns8*)iptcInfo.dataPtr + iptcInfo.dataLen - 1; XMP_Uns8 * minPtr = endPtr - kTIFF_TypeSizes[iptcInfo.type] + 1; while ( (endPtr >= minPtr) && (*endPtr == 0) ) --endPtr;
CWE-125
null
null
7,952
bool TIFF_CheckFormat ( XMP_FileFormat format, XMP_StringPtr filePath, XMP_IO* fileRef, XMPFiles * parent ) { IgnoreParam(format); IgnoreParam(filePath); IgnoreParam(parent); XMP_Assert ( format == kXMP_TIFFFile ); enum { kMinimalTIFFSize = 4+4+2+12+4 }; // Header plus IFD with 1 entry. fileRef->Rewind ( ); if ( ! XIO::CheckFileSpace ( fileRef, kMinimalTIFFSize ) ) return false; XMP_Uns8 buffer [4]; fileRef->Read ( buffer, 4 ); bool leTIFF = CheckBytes ( buffer, "\x49\x49\x2A\x00", 4 ); bool beTIFF = CheckBytes ( buffer, "\x4D\x4D\x00\x2A", 4 ); return (leTIFF | beTIFF); } // TIFF_CheckFormat
null
0
bool TIFF_CheckFormat ( XMP_FileFormat format, XMP_StringPtr filePath, XMP_IO* fileRef, XMPFiles * parent ) { IgnoreParam(format); IgnoreParam(filePath); IgnoreParam(parent); XMP_Assert ( format == kXMP_TIFFFile ); enum { kMinimalTIFFSize = 4+4+2+12+4 }; // Header plus IFD with 1 entry. fileRef->Rewind ( ); if ( ! XIO::CheckFileSpace ( fileRef, kMinimalTIFFSize ) ) return false; XMP_Uns8 buffer [4]; fileRef->Read ( buffer, 4 ); bool leTIFF = CheckBytes ( buffer, "\x49\x49\x2A\x00", 4 ); bool beTIFF = CheckBytes ( buffer, "\x4D\x4D\x00\x2A", 4 ); return (leTIFF | beTIFF); } // TIFF_CheckFormat
@@ -235,8 +235,9 @@ void TIFF_MetaHandler::ProcessXMP() // zero padding for the IPTC digest. If the full digest differs, recheck without the padding. iptcDigestState = PhotoDataUtils::CheckIPTCDigest ( iptcInfo.dataPtr, iptcInfo.dataLen, digestInfo.dataPtr ); - - if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) ) { + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105205 + // if iptcInfo.dataLen is 0, then there is no digest. + if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) && iptcInfo.dataLen > 0 ) { XMP_Uns8 * endPtr = (XMP_Uns8*)iptcInfo.dataPtr + iptcInfo.dataLen - 1; XMP_Uns8 * minPtr = endPtr - kTIFF_TypeSizes[iptcInfo.type] + 1; while ( (endPtr >= minPtr) && (*endPtr == 0) ) --endPtr;
CWE-125
null
null
7,953
TIFF_MetaHandler::TIFF_MetaHandler ( XMPFiles * _parent ) : psirMgr(0), iptcMgr(0) { this->parent = _parent; this->handlerFlags = kTIFF_HandlerFlags; this->stdCharForm = kXMP_Char8Bit; } // TIFF_MetaHandler::TIFF_MetaHandler
null
0
TIFF_MetaHandler::TIFF_MetaHandler ( XMPFiles * _parent ) : psirMgr(0), iptcMgr(0) { this->parent = _parent; this->handlerFlags = kTIFF_HandlerFlags; this->stdCharForm = kXMP_Char8Bit; } // TIFF_MetaHandler::TIFF_MetaHandler
@@ -235,8 +235,9 @@ void TIFF_MetaHandler::ProcessXMP() // zero padding for the IPTC digest. If the full digest differs, recheck without the padding. iptcDigestState = PhotoDataUtils::CheckIPTCDigest ( iptcInfo.dataPtr, iptcInfo.dataLen, digestInfo.dataPtr ); - - if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) ) { + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105205 + // if iptcInfo.dataLen is 0, then there is no digest. + if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) && iptcInfo.dataLen > 0 ) { XMP_Uns8 * endPtr = (XMP_Uns8*)iptcInfo.dataPtr + iptcInfo.dataLen - 1; XMP_Uns8 * minPtr = endPtr - kTIFF_TypeSizes[iptcInfo.type] + 1; while ( (endPtr >= minPtr) && (*endPtr == 0) ) --endPtr;
CWE-125
null
null
7,954
XMPFileHandler * TIFF_MetaHandlerCTor ( XMPFiles * parent ) { return new TIFF_MetaHandler ( parent ); } // TIFF_MetaHandlerCTor
null
0
XMPFileHandler * TIFF_MetaHandlerCTor ( XMPFiles * parent ) { return new TIFF_MetaHandler ( parent ); } // TIFF_MetaHandlerCTor
@@ -235,8 +235,9 @@ void TIFF_MetaHandler::ProcessXMP() // zero padding for the IPTC digest. If the full digest differs, recheck without the padding. iptcDigestState = PhotoDataUtils::CheckIPTCDigest ( iptcInfo.dataPtr, iptcInfo.dataLen, digestInfo.dataPtr ); - - if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) ) { + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105205 + // if iptcInfo.dataLen is 0, then there is no digest. + if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) && iptcInfo.dataLen > 0 ) { XMP_Uns8 * endPtr = (XMP_Uns8*)iptcInfo.dataPtr + iptcInfo.dataLen - 1; XMP_Uns8 * minPtr = endPtr - kTIFF_TypeSizes[iptcInfo.type] + 1; while ( (endPtr >= minPtr) && (*endPtr == 0) ) --endPtr;
CWE-125
null
null
7,955
void TIFF_MetaHandler::UpdateFile ( bool doSafeUpdate ) { XMP_Assert ( ! doSafeUpdate ); // This should only be called for "unsafe" updates. XMP_IO* destRef = this->parent->ioRef; XMP_AbortProc abortProc = this->parent->abortProc; void * abortArg = this->parent->abortArg; XMP_Int64 oldPacketOffset = this->packetInfo.offset; XMP_Int32 oldPacketLength = this->packetInfo.length; if ( oldPacketOffset == kXMPFiles_UnknownOffset ) oldPacketOffset = 0; // ! Simplify checks. if ( oldPacketLength == kXMPFiles_UnknownLength ) oldPacketLength = 0; bool fileHadXMP = ((oldPacketOffset != 0) && (oldPacketLength != 0)); ExportPhotoData ( kXMP_TIFFFile, &this->xmpObj, &this->tiffMgr, this->iptcMgr, this->psirMgr ); try { XMP_OptionBits options = kXMP_UseCompactFormat; if ( fileHadXMP ) options |= kXMP_ExactPacketLength; this->xmpObj.SerializeToBuffer ( &this->xmpPacket, options, oldPacketLength ); } catch ( ... ) { this->xmpObj.SerializeToBuffer ( &this->xmpPacket, kXMP_UseCompactFormat ); } bool doInPlace = (fileHadXMP && (this->xmpPacket.size() <= (size_t)oldPacketLength)); if ( this->tiffMgr.IsLegacyChanged() ) doInPlace = false; bool localProgressTracking = false; XMP_ProgressTracker* progressTracker = this->parent->progressTracker; if ( ! doInPlace ) { #if GatherPerformanceData sAPIPerf->back().extraInfo += ", TIFF append update"; #endif if ( (progressTracker != 0) && (! progressTracker->WorkInProgress()) ) { localProgressTracking = true; progressTracker->BeginWork(); } this->tiffMgr.SetTag ( kTIFF_PrimaryIFD, kTIFF_XMP, kTIFF_UndefinedType, (XMP_Uns32)this->xmpPacket.size(), this->xmpPacket.c_str() ); this->tiffMgr.UpdateFileStream ( destRef, progressTracker ); } else { #if GatherPerformanceData sAPIPerf->back().extraInfo += ", TIFF in-place update"; #endif if ( this->xmpPacket.size() < (size_t)this->packetInfo.length ) { size_t extraSpace = (size_t)this->packetInfo.length - this->xmpPacket.size(); this->xmpPacket.append ( extraSpace, ' ' ); } XMP_IO* liveFile = this->parent->ioRef; XMP_Assert ( this->xmpPacket.size() == (size_t)oldPacketLength ); // ! Done by common PutXMP logic. if ( progressTracker != 0 ) { if ( progressTracker->WorkInProgress() ) { progressTracker->AddTotalWork ( this->xmpPacket.size() ); } else { localProgressTracking = true; progressTracker->BeginWork ( this->xmpPacket.size() ); } } liveFile->Seek ( oldPacketOffset, kXMP_SeekFromStart ); liveFile->Write ( this->xmpPacket.c_str(), (XMP_Int32)this->xmpPacket.size() ); } if ( localProgressTracking ) progressTracker->WorkComplete(); this->needsUpdate = false; } // TIFF_MetaHandler::UpdateFile
null
0
void TIFF_MetaHandler::UpdateFile ( bool doSafeUpdate ) { XMP_Assert ( ! doSafeUpdate ); // This should only be called for "unsafe" updates. XMP_IO* destRef = this->parent->ioRef; XMP_AbortProc abortProc = this->parent->abortProc; void * abortArg = this->parent->abortArg; XMP_Int64 oldPacketOffset = this->packetInfo.offset; XMP_Int32 oldPacketLength = this->packetInfo.length; if ( oldPacketOffset == kXMPFiles_UnknownOffset ) oldPacketOffset = 0; // ! Simplify checks. if ( oldPacketLength == kXMPFiles_UnknownLength ) oldPacketLength = 0; bool fileHadXMP = ((oldPacketOffset != 0) && (oldPacketLength != 0)); ExportPhotoData ( kXMP_TIFFFile, &this->xmpObj, &this->tiffMgr, this->iptcMgr, this->psirMgr ); try { XMP_OptionBits options = kXMP_UseCompactFormat; if ( fileHadXMP ) options |= kXMP_ExactPacketLength; this->xmpObj.SerializeToBuffer ( &this->xmpPacket, options, oldPacketLength ); } catch ( ... ) { this->xmpObj.SerializeToBuffer ( &this->xmpPacket, kXMP_UseCompactFormat ); } bool doInPlace = (fileHadXMP && (this->xmpPacket.size() <= (size_t)oldPacketLength)); if ( this->tiffMgr.IsLegacyChanged() ) doInPlace = false; bool localProgressTracking = false; XMP_ProgressTracker* progressTracker = this->parent->progressTracker; if ( ! doInPlace ) { #if GatherPerformanceData sAPIPerf->back().extraInfo += ", TIFF append update"; #endif if ( (progressTracker != 0) && (! progressTracker->WorkInProgress()) ) { localProgressTracking = true; progressTracker->BeginWork(); } this->tiffMgr.SetTag ( kTIFF_PrimaryIFD, kTIFF_XMP, kTIFF_UndefinedType, (XMP_Uns32)this->xmpPacket.size(), this->xmpPacket.c_str() ); this->tiffMgr.UpdateFileStream ( destRef, progressTracker ); } else { #if GatherPerformanceData sAPIPerf->back().extraInfo += ", TIFF in-place update"; #endif if ( this->xmpPacket.size() < (size_t)this->packetInfo.length ) { size_t extraSpace = (size_t)this->packetInfo.length - this->xmpPacket.size(); this->xmpPacket.append ( extraSpace, ' ' ); } XMP_IO* liveFile = this->parent->ioRef; XMP_Assert ( this->xmpPacket.size() == (size_t)oldPacketLength ); // ! Done by common PutXMP logic. if ( progressTracker != 0 ) { if ( progressTracker->WorkInProgress() ) { progressTracker->AddTotalWork ( this->xmpPacket.size() ); } else { localProgressTracking = true; progressTracker->BeginWork ( this->xmpPacket.size() ); } } liveFile->Seek ( oldPacketOffset, kXMP_SeekFromStart ); liveFile->Write ( this->xmpPacket.c_str(), (XMP_Int32)this->xmpPacket.size() ); } if ( localProgressTracking ) progressTracker->WorkComplete(); this->needsUpdate = false; } // TIFF_MetaHandler::UpdateFile
@@ -235,8 +235,9 @@ void TIFF_MetaHandler::ProcessXMP() // zero padding for the IPTC digest. If the full digest differs, recheck without the padding. iptcDigestState = PhotoDataUtils::CheckIPTCDigest ( iptcInfo.dataPtr, iptcInfo.dataLen, digestInfo.dataPtr ); - - if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) ) { + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105205 + // if iptcInfo.dataLen is 0, then there is no digest. + if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) && iptcInfo.dataLen > 0 ) { XMP_Uns8 * endPtr = (XMP_Uns8*)iptcInfo.dataPtr + iptcInfo.dataLen - 1; XMP_Uns8 * minPtr = endPtr - kTIFF_TypeSizes[iptcInfo.type] + 1; while ( (endPtr >= minPtr) && (*endPtr == 0) ) --endPtr;
CWE-125
null
null
7,956
TIFF_MetaHandler::~TIFF_MetaHandler() { if ( this->psirMgr != 0 ) delete ( this->psirMgr ); if ( this->iptcMgr != 0 ) delete ( this->iptcMgr ); } // TIFF_MetaHandler::~TIFF_MetaHandler
null
0
TIFF_MetaHandler::~TIFF_MetaHandler() { if ( this->psirMgr != 0 ) delete ( this->psirMgr ); if ( this->iptcMgr != 0 ) delete ( this->iptcMgr ); } // TIFF_MetaHandler::~TIFF_MetaHandler
@@ -235,8 +235,9 @@ void TIFF_MetaHandler::ProcessXMP() // zero padding for the IPTC digest. If the full digest differs, recheck without the padding. iptcDigestState = PhotoDataUtils::CheckIPTCDigest ( iptcInfo.dataPtr, iptcInfo.dataLen, digestInfo.dataPtr ); - - if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) ) { + // See bug https://bugs.freedesktop.org/show_bug.cgi?id=105205 + // if iptcInfo.dataLen is 0, then there is no digest. + if ( (iptcDigestState == kDigestDiffers) && (kTIFF_TypeSizes[iptcInfo.type] > 1) && iptcInfo.dataLen > 0 ) { XMP_Uns8 * endPtr = (XMP_Uns8*)iptcInfo.dataPtr + iptcInfo.dataLen - 1; XMP_Uns8 * minPtr = endPtr - kTIFF_TypeSizes[iptcInfo.type] + 1; while ( (endPtr >= minPtr) && (*endPtr == 0) ) --endPtr;
CWE-125
null
null
7,957
_render_state_rescale( RenderState state ) { if ( state->need_rescale && state->size ) { FT_Set_Char_Size( state->face, 0, (FT_F26Dot6)( state->char_size * 64.0 ), 0, state->resolution ); state->need_rescale = 0; } }
DoS Exec Code Overflow
0
_render_state_rescale( RenderState state ) { if ( state->need_rescale && state->size ) { FT_Set_Char_Size( state->face, 0, (FT_F26Dot6)( state->char_size * 64.0 ), 0, state->resolution ); state->need_rescale = 0; } }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,958
adisplay_change_gamma( ADisplay display, double delta ) { display->gamma += delta; if ( display->gamma > 3.0 ) display->gamma = 3.0; else if ( display->gamma < 0.0 ) display->gamma = 0.0; grSetGlyphGamma( display->gamma ); }
DoS Exec Code Overflow
0
adisplay_change_gamma( ADisplay display, double delta ) { display->gamma += delta; if ( display->gamma > 3.0 ) display->gamma = 3.0; else if ( display->gamma < 0.0 ) display->gamma = 0.0; grSetGlyphGamma( display->gamma ); }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,959
adisplay_clear( ADisplay display ) { grBitmap* bit = display->bitmap; int pitch = bit->pitch; if ( pitch < 0 ) pitch = -pitch; if ( bit->mode == gr_pixel_mode_gray ) memset( bit->buffer, display->back_color.value, pitch * bit->rows ); else { unsigned char* p = bit->buffer; int i, j; for ( i = 0; i < bit->rows; i++ ) { for ( j = 0; j < bit->width; j++ ) memcpy( p + 3 * j, display->back_color.chroma, 3 ); p += pitch; } } }
DoS Exec Code Overflow
0
adisplay_clear( ADisplay display ) { grBitmap* bit = display->bitmap; int pitch = bit->pitch; if ( pitch < 0 ) pitch = -pitch; if ( bit->mode == gr_pixel_mode_gray ) memset( bit->buffer, display->back_color.value, pitch * bit->rows ); else { unsigned char* p = bit->buffer; int i, j; for ( i = 0; i < bit->rows; i++ ) { for ( j = 0; j < bit->width; j++ ) memcpy( p + 3 * j, display->back_color.chroma, 3 ); p += pitch; } } }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,960
adisplay_draw_glyph( void* _display, DisplayMode mode, int x, int y, int width, int height, int pitch, void* buffer ) { ADisplay display = (ADisplay)_display; grBitmap glyph; glyph.width = width; glyph.rows = height; glyph.pitch = pitch; glyph.buffer = (unsigned char*)buffer; glyph.grays = 256; glyph.mode = gr_pixel_mode_mono; if ( mode == DISPLAY_MODE_GRAY ) glyph.mode = gr_pixel_mode_gray; else if ( mode == DISPLAY_MODE_LCD ) glyph.mode = gr_pixel_mode_lcd; grBlitGlyphToBitmap( display->bitmap, &glyph, x, y, display->fore_color ); }
DoS Exec Code Overflow
0
adisplay_draw_glyph( void* _display, DisplayMode mode, int x, int y, int width, int height, int pitch, void* buffer ) { ADisplay display = (ADisplay)_display; grBitmap glyph; glyph.width = width; glyph.rows = height; glyph.pitch = pitch; glyph.buffer = (unsigned char*)buffer; glyph.grays = 256; glyph.mode = gr_pixel_mode_mono; if ( mode == DISPLAY_MODE_GRAY ) glyph.mode = gr_pixel_mode_gray; else if ( mode == DISPLAY_MODE_LCD ) glyph.mode = gr_pixel_mode_lcd; grBlitGlyphToBitmap( display->bitmap, &glyph, x, y, display->fore_color ); }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,961
adisplay_draw_text( void* _display, int x, int y, const char* msg ) { ADisplay adisplay = (ADisplay)_display; grWriteCellString( adisplay->bitmap, x, y, msg, adisplay->fore_color ); }
DoS Exec Code Overflow
0
adisplay_draw_text( void* _display, int x, int y, const char* msg ) { ADisplay adisplay = (ADisplay)_display; grWriteCellString( adisplay->bitmap, x, y, msg, adisplay->fore_color ); }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,962
adisplay_init( ADisplay display, grPixelMode mode ) { grSurface* surface; grBitmap bit; if ( mode != gr_pixel_mode_gray && mode != gr_pixel_mode_rgb24 ) return -1; grInitDevices(); bit.mode = mode; bit.width = DIM_X; bit.rows = DIM_Y; bit.grays = 256; surface = grNewSurface( 0, &bit ); if ( !surface ) return -1; display->surface = surface; display->bitmap = &surface->bitmap; display->gamma = 1.0; grSetGlyphGamma( display->gamma ); memset( &display->fore_color, 0, sizeof( grColor ) ); memset( &display->back_color, 0xff, sizeof( grColor ) ); return 0; }
DoS Exec Code Overflow
0
adisplay_init( ADisplay display, grPixelMode mode ) { grSurface* surface; grBitmap bit; if ( mode != gr_pixel_mode_gray && mode != gr_pixel_mode_rgb24 ) return -1; grInitDevices(); bit.mode = mode; bit.width = DIM_X; bit.rows = DIM_Y; bit.grays = 256; surface = grNewSurface( 0, &bit ); if ( !surface ) return -1; display->surface = surface; display->bitmap = &surface->bitmap; display->gamma = 1.0; grSetGlyphGamma( display->gamma ); memset( &display->fore_color, 0, sizeof( grColor ) ); memset( &display->back_color, 0xff, sizeof( grColor ) ); return 0; }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,963
event_change_gamma( RenderState state, double delta ) { ADisplay display = (ADisplay)state->display.disp; adisplay_change_gamma( display, delta ); if ( display->gamma == 0.0 ) sprintf( state->message0, "gamma set to sRGB" ); else sprintf( state->message0, "gamma set to %.1f", display->gamma ); state->message = state->message0; }
DoS Exec Code Overflow
0
event_change_gamma( RenderState state, double delta ) { ADisplay display = (ADisplay)state->display.disp; adisplay_change_gamma( display, delta ); if ( display->gamma == 0.0 ) sprintf( state->message0, "gamma set to sRGB" ); else sprintf( state->message0, "gamma set to %.1f", display->gamma ); state->message = state->message0; }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,964
event_change_size( RenderState state, double delta ) { double char_size = state->char_size; char_size += delta; if ( char_size < 6.0 ) char_size = 6.0; else if ( char_size > 300.0 ) char_size = 300.0; render_state_set_size( state, char_size ); }
DoS Exec Code Overflow
0
event_change_size( RenderState state, double delta ) { double char_size = state->char_size; char_size += delta; if ( char_size < 6.0 ) char_size = 6.0; else if ( char_size > 300.0 ) char_size = 300.0; render_state_set_size( state, char_size ); }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,965
event_help( RenderState state ) { ADisplay display = (ADisplay)state->display.disp; grEvent dummy_event; adisplay_clear( display ); grGotoxy( 0, 0 ); grSetMargin( 2, 1 ); grGotobitmap( display->bitmap ); grWriteln( "Text Viewer - Simple text/font proofer for the FreeType project" ); grLn(); grWriteln( "This program is used to display text using two distinct algorithms." ); grWriteln( "On the left, text is rendered by the TrueType bytecode interpreter." ); grWriteln( "In the middle, text is rendered through the FreeType auto-hinter." ); grWriteln( "On the right, text is rendered unhinted." ); grLn(); grWriteln( "Use the following keys:" ); grLn(); grWriteln( " F1, ? display this help screen" ); grLn(); grWriteln( " n, p select previous/next font" ); grLn(); grWriteln( " 1, 2, 3 select left, middle, or right column" ); grWriteln( " a toggle `ignore global advance width flag'" ); grWriteln( " d toggle lsb/rsb deltas" ); grWriteln( " h toggle hinting mode" ); grWriteln( " k toggle kerning" ); grWriteln( " g, v adjust gamma value" ); grWriteln( " r toggle rendering mode" ); grLn(); grWriteln( " l change LCD filter type" ); grWriteln( " [, ] select custom LCD filter weight" ); grWriteln( " -, +(=) adjust selected custom LCD filter weight"); grLn(); grWriteln( " Up, Down adjust pointsize by 0.5 unit" ); grWriteln( " PgUp, PgDn adjust pointsize by 5 units" ); grLn(); grWriteln( "press any key to exit this help screen" ); grRefreshSurface( display->surface ); grListenSurface( display->surface, gr_event_key, &dummy_event ); }
DoS Exec Code Overflow
0
event_help( RenderState state ) { ADisplay display = (ADisplay)state->display.disp; grEvent dummy_event; adisplay_clear( display ); grGotoxy( 0, 0 ); grSetMargin( 2, 1 ); grGotobitmap( display->bitmap ); grWriteln( "Text Viewer - Simple text/font proofer for the FreeType project" ); grLn(); grWriteln( "This program is used to display text using two distinct algorithms." ); grWriteln( "On the left, text is rendered by the TrueType bytecode interpreter." ); grWriteln( "In the middle, text is rendered through the FreeType auto-hinter." ); grWriteln( "On the right, text is rendered unhinted." ); grLn(); grWriteln( "Use the following keys:" ); grLn(); grWriteln( " F1, ? display this help screen" ); grLn(); grWriteln( " n, p select previous/next font" ); grLn(); grWriteln( " 1, 2, 3 select left, middle, or right column" ); grWriteln( " a toggle `ignore global advance width flag'" ); grWriteln( " d toggle lsb/rsb deltas" ); grWriteln( " h toggle hinting mode" ); grWriteln( " k toggle kerning" ); grWriteln( " g, v adjust gamma value" ); grWriteln( " r toggle rendering mode" ); grLn(); grWriteln( " l change LCD filter type" ); grWriteln( " [, ] select custom LCD filter weight" ); grWriteln( " -, +(=) adjust selected custom LCD filter weight"); grLn(); grWriteln( " Up, Down adjust pointsize by 0.5 unit" ); grWriteln( " PgUp, PgDn adjust pointsize by 5 units" ); grLn(); grWriteln( "press any key to exit this help screen" ); grRefreshSurface( display->surface ); grListenSurface( display->surface, gr_event_key, &dummy_event ); }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,966
get_option_arg( char* option, char** *pargv, char** argend ) { if ( option[2] == 0 ) { char** argv = *pargv; if ( ++argv >= argend ) usage(); option = argv[0]; *pargv = argv; } else option += 2; return option; }
DoS Exec Code Overflow
0
get_option_arg( char* option, char** *pargv, char** argend ) { if ( option[2] == 0 ) { char** argv = *pargv; if ( ++argv >= argend ) usage(); option = argv[0]; *pargv = argv; } else option += 2; return option; }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,967
main( int argc, char** argv ) { char** argend = argv + argc; ADisplayRec adisplay[1]; RenderStateRec state[1]; DisplayRec display[1]; int resolution = -1; double size = -1; const char* textfile = NULL; unsigned char* text = (unsigned char*)default_text; /* Read Options */ ++argv; while ( argv < argend && argv[0][0] == '-' ) { char* arg = argv[0]; switch (arg[1]) { case 'r': arg = get_option_arg( arg, &argv, argend ); resolution = atoi( arg ); break; case 's': arg = get_option_arg( arg, &argv, argend ); size = atof( arg ); break; case 'f': arg = get_option_arg( arg, &argv, argend ); textfile = arg; break; default: usage(); } argv++; } if ( argv >= argend ) usage(); /* Read Text File, if any */ if ( textfile != NULL ) { FILE* tfile = fopen( textfile, "r" ); if ( tfile == NULL ) fprintf( stderr, "could not read textfile '%s'\n", textfile ); else { long tsize; fseek( tfile, 0, SEEK_END ); tsize = ftell( tfile ); fseek( tfile, 0, SEEK_SET ); text = (unsigned char*)malloc( tsize + 1 ); if ( text != NULL ) { fread( text, tsize, 1, tfile ); text[tsize] = 0; } else { fprintf( stderr, "not enough memory to read '%s'\n", textfile ); text = (unsigned char *)default_text; } fclose( tfile ); } } /* Initialize display */ if ( adisplay_init( adisplay, gr_pixel_mode_rgb24 ) < 0 ) { fprintf( stderr, "could not initialize display! Aborting.\n" ); exit( 1 ); } display->disp = adisplay; display->disp_draw = adisplay_draw_glyph; display->disp_text = adisplay_draw_text; render_state_init( state, display ); if ( resolution > 0 ) render_state_set_resolution( state, resolution ); if (size > 0.0) render_state_set_size( state, size ); render_state_set_files( state, argv ); render_state_set_file( state, 0 ); grSetTitle( adisplay->surface, "FreeType Text Proofer, press F1 for help" ); for (;;) { grEvent event; adisplay_clear( adisplay ); render_state_draw( state, text, 0, 10, 10, DIM_X / 3 - 15, DIM_Y - 70 ); render_state_draw( state, text, 1, DIM_X / 3 + 5, 10, DIM_X / 3 - 15, DIM_Y - 70 ); render_state_draw( state, text, 2, DIM_X * 2 / 3 + 5, 10, DIM_X / 3 - 15, DIM_Y - 70 ); write_message( state ); grRefreshSurface( adisplay->surface ); grListenSurface( adisplay->surface, 0, &event ); if ( process_event( state, &event ) ) break; } render_state_done( state ); adisplay_done( adisplay ); exit( 0 ); /* for safety reasons */ return 0; /* never reached */ }
DoS Exec Code Overflow
0
main( int argc, char** argv ) { char** argend = argv + argc; ADisplayRec adisplay[1]; RenderStateRec state[1]; DisplayRec display[1]; int resolution = -1; double size = -1; const char* textfile = NULL; unsigned char* text = (unsigned char*)default_text; /* Read Options */ ++argv; while ( argv < argend && argv[0][0] == '-' ) { char* arg = argv[0]; switch (arg[1]) { case 'r': arg = get_option_arg( arg, &argv, argend ); resolution = atoi( arg ); break; case 's': arg = get_option_arg( arg, &argv, argend ); size = atof( arg ); break; case 'f': arg = get_option_arg( arg, &argv, argend ); textfile = arg; break; default: usage(); } argv++; } if ( argv >= argend ) usage(); /* Read Text File, if any */ if ( textfile != NULL ) { FILE* tfile = fopen( textfile, "r" ); if ( tfile == NULL ) fprintf( stderr, "could not read textfile '%s'\n", textfile ); else { long tsize; fseek( tfile, 0, SEEK_END ); tsize = ftell( tfile ); fseek( tfile, 0, SEEK_SET ); text = (unsigned char*)malloc( tsize + 1 ); if ( text != NULL ) { fread( text, tsize, 1, tfile ); text[tsize] = 0; } else { fprintf( stderr, "not enough memory to read '%s'\n", textfile ); text = (unsigned char *)default_text; } fclose( tfile ); } } /* Initialize display */ if ( adisplay_init( adisplay, gr_pixel_mode_rgb24 ) < 0 ) { fprintf( stderr, "could not initialize display! Aborting.\n" ); exit( 1 ); } display->disp = adisplay; display->disp_draw = adisplay_draw_glyph; display->disp_text = adisplay_draw_text; render_state_init( state, display ); if ( resolution > 0 ) render_state_set_resolution( state, resolution ); if (size > 0.0) render_state_set_size( state, size ); render_state_set_files( state, argv ); render_state_set_file( state, 0 ); grSetTitle( adisplay->surface, "FreeType Text Proofer, press F1 for help" ); for (;;) { grEvent event; adisplay_clear( adisplay ); render_state_draw( state, text, 0, 10, 10, DIM_X / 3 - 15, DIM_Y - 70 ); render_state_draw( state, text, 1, DIM_X / 3 + 5, 10, DIM_X / 3 - 15, DIM_Y - 70 ); render_state_draw( state, text, 2, DIM_X * 2 / 3 + 5, 10, DIM_X / 3 - 15, DIM_Y - 70 ); write_message( state ); grRefreshSurface( adisplay->surface ); grListenSurface( adisplay->surface, 0, &event ); if ( process_event( state, &event ) ) break; } render_state_done( state ); adisplay_done( adisplay ); exit( 0 ); /* for safety reasons */ return 0; /* never reached */ }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,968
panic( const char* fmt, ... ) { va_list args; va_start( args, fmt ); vfprintf( stderr, fmt, args ); va_end( args ); exit( 1 ); }
DoS Exec Code Overflow
0
panic( const char* fmt, ... ) { va_list args; va_start( args, fmt ); vfprintf( stderr, fmt, args ); va_end( args ); exit( 1 ); }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,969
process_event( RenderState state, grEvent* event ) { int ret = 0; ColumnState column = &state->columns[state->col]; switch ( event->key ) { case grKeyEsc: case grKEY( 'q' ): ret = 1; break; case grKeyF1: case grKEY( '?' ): event_help( state ); break; case grKeyLeft: if ( --state->col < 0 ) state->col = 2; state->message = state->message0; sprintf( state->message0, "column %d selected", state->col + 1 ); break; case grKeyRight: if ( ++state->col > 2 ) state->col = 0; state->message = state->message0; sprintf( state->message0, "column %d selected", state->col + 1 ); break; case grKeyUp: event_change_size( state, +0.5 ); break; case grKeyDown: event_change_size( state, -0.5 ); break; case grKeyPageUp: event_change_size( state, +5. ); break; case grKeyPageDown: event_change_size( state, -5. ); break; case grKEY( '1' ): state->col = 0; state->message = (char *)"column 1 selected"; break; case grKEY( '2' ): state->col = 1; state->message = (char *)"column 2 selected"; break; case grKEY( '3' ): state->col = 2; state->message = (char *)"column 3 selected"; break; case grKEY( 'a' ): column->use_global_advance_width = !column->use_global_advance_width; state->message = column->use_global_advance_width ? (char *)"using global advance width" : (char *)"ignoring global advance width"; break; case grKEY( 'd' ): column->use_deltas = !column->use_deltas; state->message = column->use_deltas ? (char *)"using rsb/lsb deltas" : (char *)"ignoring rsb/lsb deltas"; break; case grKEY( 'g' ): event_change_gamma( state, +0.1 ); break; case grKEY( 'h' ): column->hint_mode = (HintMode)( ( column->hint_mode + 1 ) % HINT_MODE_MAX ); state->message = state->message0; sprintf( state->message0, "column %d is %s", state->col + 1, render_mode_names[column->hint_mode] ); break; case grKEY( 'k' ): column->use_kerning = !column->use_kerning; state->message = column->use_kerning ? (char *)"using kerning" : (char *)"ignoring kerning"; break; case grKEY( 'l' ): switch ( column->lcd_filter ) { case FT_LCD_FILTER_NONE: column->lcd_filter = FT_LCD_FILTER_DEFAULT; state->message = (char *)"using default LCD filter"; break; case FT_LCD_FILTER_DEFAULT: if ( !column->use_custom_lcd_filter ) { column->use_custom_lcd_filter = 1; state->message = (char*)"using custom LCD filter"; } else { column->use_custom_lcd_filter = 0; column->lcd_filter = FT_LCD_FILTER_LIGHT; state->message = (char *)"using light LCD filter"; } break; case FT_LCD_FILTER_LIGHT: column->lcd_filter = FT_LCD_FILTER_LEGACY; state->message = (char *)"using legacy LCD filter"; break; case FT_LCD_FILTER_LEGACY: column->lcd_filter = FT_LCD_FILTER_NONE; state->message = (char *)"using no LCD filter"; break; default: /* to satisfy picky compilers */ break; } break; case grKEY( 'n' ): render_state_set_file( state, state->face_index + 1 ); break; case grKEY( 'p' ): render_state_set_file( state, state->face_index - 1 ); break; case grKEY( 'r' ): column->use_lcd_filter = !column->use_lcd_filter; state->message = state->message0; sprintf( state->message0, "column %d is using %s", state->col + 1, column->use_lcd_filter ? "LCD filtering" : "gray rendering" ); break; case grKEY( 'v' ): event_change_gamma( state, -0.1 ); break; case grKEY( '[' ): if ( !column->use_custom_lcd_filter ) break; column->fw_index--; if ( column->fw_index < 0 ) column->fw_index = 4; break; case grKEY( ']' ): if ( !column->use_custom_lcd_filter ) break; column->fw_index++; if ( column->fw_index > 4 ) column->fw_index = 0; break; case grKEY( '-' ): if ( !column->use_custom_lcd_filter ) break; column->filter_weights[column->fw_index]--; break; case grKEY( '+' ): case grKEY( '=' ): if ( !column->use_custom_lcd_filter ) break; column->filter_weights[column->fw_index]++; break; default: break; } return ret; }
DoS Exec Code Overflow
0
process_event( RenderState state, grEvent* event ) { int ret = 0; ColumnState column = &state->columns[state->col]; switch ( event->key ) { case grKeyEsc: case grKEY( 'q' ): ret = 1; break; case grKeyF1: case grKEY( '?' ): event_help( state ); break; case grKeyLeft: if ( --state->col < 0 ) state->col = 2; state->message = state->message0; sprintf( state->message0, "column %d selected", state->col + 1 ); break; case grKeyRight: if ( ++state->col > 2 ) state->col = 0; state->message = state->message0; sprintf( state->message0, "column %d selected", state->col + 1 ); break; case grKeyUp: event_change_size( state, +0.5 ); break; case grKeyDown: event_change_size( state, -0.5 ); break; case grKeyPageUp: event_change_size( state, +5. ); break; case grKeyPageDown: event_change_size( state, -5. ); break; case grKEY( '1' ): state->col = 0; state->message = (char *)"column 1 selected"; break; case grKEY( '2' ): state->col = 1; state->message = (char *)"column 2 selected"; break; case grKEY( '3' ): state->col = 2; state->message = (char *)"column 3 selected"; break; case grKEY( 'a' ): column->use_global_advance_width = !column->use_global_advance_width; state->message = column->use_global_advance_width ? (char *)"using global advance width" : (char *)"ignoring global advance width"; break; case grKEY( 'd' ): column->use_deltas = !column->use_deltas; state->message = column->use_deltas ? (char *)"using rsb/lsb deltas" : (char *)"ignoring rsb/lsb deltas"; break; case grKEY( 'g' ): event_change_gamma( state, +0.1 ); break; case grKEY( 'h' ): column->hint_mode = (HintMode)( ( column->hint_mode + 1 ) % HINT_MODE_MAX ); state->message = state->message0; sprintf( state->message0, "column %d is %s", state->col + 1, render_mode_names[column->hint_mode] ); break; case grKEY( 'k' ): column->use_kerning = !column->use_kerning; state->message = column->use_kerning ? (char *)"using kerning" : (char *)"ignoring kerning"; break; case grKEY( 'l' ): switch ( column->lcd_filter ) { case FT_LCD_FILTER_NONE: column->lcd_filter = FT_LCD_FILTER_DEFAULT; state->message = (char *)"using default LCD filter"; break; case FT_LCD_FILTER_DEFAULT: if ( !column->use_custom_lcd_filter ) { column->use_custom_lcd_filter = 1; state->message = (char*)"using custom LCD filter"; } else { column->use_custom_lcd_filter = 0; column->lcd_filter = FT_LCD_FILTER_LIGHT; state->message = (char *)"using light LCD filter"; } break; case FT_LCD_FILTER_LIGHT: column->lcd_filter = FT_LCD_FILTER_LEGACY; state->message = (char *)"using legacy LCD filter"; break; case FT_LCD_FILTER_LEGACY: column->lcd_filter = FT_LCD_FILTER_NONE; state->message = (char *)"using no LCD filter"; break; default: /* to satisfy picky compilers */ break; } break; case grKEY( 'n' ): render_state_set_file( state, state->face_index + 1 ); break; case grKEY( 'p' ): render_state_set_file( state, state->face_index - 1 ); break; case grKEY( 'r' ): column->use_lcd_filter = !column->use_lcd_filter; state->message = state->message0; sprintf( state->message0, "column %d is using %s", state->col + 1, column->use_lcd_filter ? "LCD filtering" : "gray rendering" ); break; case grKEY( 'v' ): event_change_gamma( state, -0.1 ); break; case grKEY( '[' ): if ( !column->use_custom_lcd_filter ) break; column->fw_index--; if ( column->fw_index < 0 ) column->fw_index = 4; break; case grKEY( ']' ): if ( !column->use_custom_lcd_filter ) break; column->fw_index++; if ( column->fw_index > 4 ) column->fw_index = 0; break; case grKEY( '-' ): if ( !column->use_custom_lcd_filter ) break; column->filter_weights[column->fw_index]--; break; case grKEY( '+' ): case grKEY( '=' ): if ( !column->use_custom_lcd_filter ) break; column->filter_weights[column->fw_index]++; break; default: break; } return ret; }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,970
render_state_done( RenderState state ) { if ( state->filepath != state->filepath0 ) { free( (char*)state->filepath ); state->filepath = state->filepath0; } state->filepath0[0] = 0; state->filename = 0; if ( state->face ) { FT_Done_Face( state->face ); state->face = NULL; state->size = NULL; } if ( state->library ) { FT_Done_FreeType( state->library ); state->library = NULL; } }
DoS Exec Code Overflow
0
render_state_done( RenderState state ) { if ( state->filepath != state->filepath0 ) { free( (char*)state->filepath ); state->filepath = state->filepath0; } state->filepath0[0] = 0; state->filename = 0; if ( state->face ) { FT_Done_Face( state->face ); state->face = NULL; state->size = NULL; } if ( state->library ) { FT_Done_FreeType( state->library ); state->library = NULL; } }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,971
render_state_draw( RenderState state, const unsigned char* text, int idx, int x, int y, int width, int height ) { ColumnState column = &state->columns[idx]; const unsigned char* p = text; long load_flags = FT_LOAD_DEFAULT; FT_Face face = state->face; int left = x; int right = x + width; int bottom = y + height; int line_height; FT_UInt prev_glyph = 0; FT_Pos prev_rsb_delta = 0; FT_Pos x_origin = x << 6; HintMode rmode = column->hint_mode; if ( !face ) return; _render_state_rescale( state ); if ( column->use_lcd_filter ) FT_Library_SetLcdFilter( face->glyph->library, column->lcd_filter ); if ( column->use_custom_lcd_filter ) FT_Library_SetLcdFilterWeights( face->glyph->library, column->filter_weights ); y += state->size->metrics.ascender / 64; line_height = state->size->metrics.height / 64; if ( rmode == HINT_MODE_AUTOHINT ) load_flags = FT_LOAD_FORCE_AUTOHINT; if ( rmode == HINT_MODE_AUTOHINT_LIGHT ) load_flags = FT_LOAD_TARGET_LIGHT; if ( rmode == HINT_MODE_UNHINTED ) load_flags |= FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP; if ( !column->use_global_advance_width ) load_flags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; for ( ; *p; p++ ) { FT_UInt gindex; FT_Error error; FT_GlyphSlot slot = face->glyph; FT_Bitmap* map = &slot->bitmap; int xmax; /* handle newlines */ if ( *p == 0x0A ) { if ( p[1] == 0x0D ) p++; x_origin = left << 6; y += line_height; prev_rsb_delta = 0; if ( y >= bottom ) break; continue; } else if ( *p == 0x0D ) { if ( p[1] == 0x0A ) p++; x_origin = left << 6; y += line_height; prev_rsb_delta = 0; if ( y >= bottom ) break; continue; } gindex = FT_Get_Char_Index( state->face, p[0] ); error = FT_Load_Glyph( face, gindex, load_flags ); if ( error ) continue; if ( column->use_kerning && gindex != 0 && prev_glyph != 0 ) { FT_Vector vec; FT_Int kerning_mode = FT_KERNING_DEFAULT; if ( rmode == HINT_MODE_UNHINTED ) kerning_mode = FT_KERNING_UNFITTED; FT_Get_Kerning( face, prev_glyph, gindex, kerning_mode, &vec ); x_origin += vec.x; } if ( column->use_deltas ) { if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) x_origin -= 64; else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) x_origin += 64; } prev_rsb_delta = face->glyph->rsb_delta; /* implement sub-pixel positining for un-hinted mode */ if ( rmode == HINT_MODE_UNHINTED && slot->format == FT_GLYPH_FORMAT_OUTLINE ) { FT_Pos shift = x_origin & 63; FT_Outline_Translate( &slot->outline, shift, 0 ); } if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { FT_BBox cbox; FT_Outline_Get_CBox( &slot->outline, &cbox ); xmax = ( x_origin + cbox.xMax + 63 ) >> 6; FT_Render_Glyph( slot, column->use_lcd_filter ? FT_RENDER_MODE_LCD : FT_RENDER_MODE_NORMAL ); } else xmax = ( x_origin >> 6 ) + slot->bitmap_left + slot->bitmap.width; if ( xmax >= right ) { x = left; y += line_height; if ( y >= bottom ) break; x_origin = x << 6; prev_rsb_delta = 0; } { DisplayMode mode = DISPLAY_MODE_MONO; if ( slot->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY ) mode = DISPLAY_MODE_GRAY; else if ( slot->bitmap.pixel_mode == FT_PIXEL_MODE_LCD ) mode = DISPLAY_MODE_LCD; state->display.disp_draw( state->display.disp, mode, ( x_origin >> 6 ) + slot->bitmap_left, y - slot->bitmap_top, map->width, map->rows, map->pitch, map->buffer ); } if ( rmode == HINT_MODE_UNHINTED ) x_origin += slot->linearHoriAdvance >> 10; else x_origin += slot->advance.x; prev_glyph = gindex; } /* display footer on this column */ { void* disp = state->display.disp; const char *msg; char temp[64]; msg = render_mode_names[column->hint_mode]; state->display.disp_text( disp, left, bottom + 5, msg ); if ( !column->use_lcd_filter ) msg = "gray rendering"; else if ( column->use_custom_lcd_filter ) { int fwi = column->fw_index; unsigned char *fw = column->filter_weights; msg = ""; sprintf( temp, "%s0x%02X%s0x%02X%s0x%02X%s0x%02X%s0x%02X%s", fwi == 0 ? "[" : " ", fw[0], fwi == 0 ? "]" : ( fwi == 1 ? "[" : " " ), fw[1], fwi == 1 ? "]" : ( fwi == 2 ? "[" : " " ), fw[2], fwi == 2 ? "]" : ( fwi == 3 ? "[" : " " ), fw[3], fwi == 3 ? "]" : ( fwi == 4 ? "[" : " " ), fw[4], fwi == 4 ? "]" : " " ); state->display.disp_text( disp, left, bottom + 15, temp ); } else switch ( column->lcd_filter ) { case FT_LCD_FILTER_NONE: msg = "LCD without filtering"; break; case FT_LCD_FILTER_DEFAULT: msg = "default LCD filter"; break; case FT_LCD_FILTER_LIGHT: msg = "light LCD filter"; break; default: msg = "legacy LCD filter"; } state->display.disp_text( disp, left, bottom + 15, msg ); sprintf(temp, "%s %s %s", column->use_kerning ? "+kern" : "-kern", column->use_deltas ? "+delta" : "-delta", column->use_global_advance_width ? "+advance" : "-advance" ); state->display.disp_text( disp, left, bottom + 25, temp ); if ( state->col == idx ) state->display.disp_text( disp, left, bottom + 35, "**************" ); } }
DoS Exec Code Overflow
0
render_state_draw( RenderState state, const unsigned char* text, int idx, int x, int y, int width, int height ) { ColumnState column = &state->columns[idx]; const unsigned char* p = text; long load_flags = FT_LOAD_DEFAULT; FT_Face face = state->face; int left = x; int right = x + width; int bottom = y + height; int line_height; FT_UInt prev_glyph = 0; FT_Pos prev_rsb_delta = 0; FT_Pos x_origin = x << 6; HintMode rmode = column->hint_mode; if ( !face ) return; _render_state_rescale( state ); if ( column->use_lcd_filter ) FT_Library_SetLcdFilter( face->glyph->library, column->lcd_filter ); if ( column->use_custom_lcd_filter ) FT_Library_SetLcdFilterWeights( face->glyph->library, column->filter_weights ); y += state->size->metrics.ascender / 64; line_height = state->size->metrics.height / 64; if ( rmode == HINT_MODE_AUTOHINT ) load_flags = FT_LOAD_FORCE_AUTOHINT; if ( rmode == HINT_MODE_AUTOHINT_LIGHT ) load_flags = FT_LOAD_TARGET_LIGHT; if ( rmode == HINT_MODE_UNHINTED ) load_flags |= FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP; if ( !column->use_global_advance_width ) load_flags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; for ( ; *p; p++ ) { FT_UInt gindex; FT_Error error; FT_GlyphSlot slot = face->glyph; FT_Bitmap* map = &slot->bitmap; int xmax; /* handle newlines */ if ( *p == 0x0A ) { if ( p[1] == 0x0D ) p++; x_origin = left << 6; y += line_height; prev_rsb_delta = 0; if ( y >= bottom ) break; continue; } else if ( *p == 0x0D ) { if ( p[1] == 0x0A ) p++; x_origin = left << 6; y += line_height; prev_rsb_delta = 0; if ( y >= bottom ) break; continue; } gindex = FT_Get_Char_Index( state->face, p[0] ); error = FT_Load_Glyph( face, gindex, load_flags ); if ( error ) continue; if ( column->use_kerning && gindex != 0 && prev_glyph != 0 ) { FT_Vector vec; FT_Int kerning_mode = FT_KERNING_DEFAULT; if ( rmode == HINT_MODE_UNHINTED ) kerning_mode = FT_KERNING_UNFITTED; FT_Get_Kerning( face, prev_glyph, gindex, kerning_mode, &vec ); x_origin += vec.x; } if ( column->use_deltas ) { if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) x_origin -= 64; else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) x_origin += 64; } prev_rsb_delta = face->glyph->rsb_delta; /* implement sub-pixel positining for un-hinted mode */ if ( rmode == HINT_MODE_UNHINTED && slot->format == FT_GLYPH_FORMAT_OUTLINE ) { FT_Pos shift = x_origin & 63; FT_Outline_Translate( &slot->outline, shift, 0 ); } if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { FT_BBox cbox; FT_Outline_Get_CBox( &slot->outline, &cbox ); xmax = ( x_origin + cbox.xMax + 63 ) >> 6; FT_Render_Glyph( slot, column->use_lcd_filter ? FT_RENDER_MODE_LCD : FT_RENDER_MODE_NORMAL ); } else xmax = ( x_origin >> 6 ) + slot->bitmap_left + slot->bitmap.width; if ( xmax >= right ) { x = left; y += line_height; if ( y >= bottom ) break; x_origin = x << 6; prev_rsb_delta = 0; } { DisplayMode mode = DISPLAY_MODE_MONO; if ( slot->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY ) mode = DISPLAY_MODE_GRAY; else if ( slot->bitmap.pixel_mode == FT_PIXEL_MODE_LCD ) mode = DISPLAY_MODE_LCD; state->display.disp_draw( state->display.disp, mode, ( x_origin >> 6 ) + slot->bitmap_left, y - slot->bitmap_top, map->width, map->rows, map->pitch, map->buffer ); } if ( rmode == HINT_MODE_UNHINTED ) x_origin += slot->linearHoriAdvance >> 10; else x_origin += slot->advance.x; prev_glyph = gindex; } /* display footer on this column */ { void* disp = state->display.disp; const char *msg; char temp[64]; msg = render_mode_names[column->hint_mode]; state->display.disp_text( disp, left, bottom + 5, msg ); if ( !column->use_lcd_filter ) msg = "gray rendering"; else if ( column->use_custom_lcd_filter ) { int fwi = column->fw_index; unsigned char *fw = column->filter_weights; msg = ""; sprintf( temp, "%s0x%02X%s0x%02X%s0x%02X%s0x%02X%s0x%02X%s", fwi == 0 ? "[" : " ", fw[0], fwi == 0 ? "]" : ( fwi == 1 ? "[" : " " ), fw[1], fwi == 1 ? "]" : ( fwi == 2 ? "[" : " " ), fw[2], fwi == 2 ? "]" : ( fwi == 3 ? "[" : " " ), fw[3], fwi == 3 ? "]" : ( fwi == 4 ? "[" : " " ), fw[4], fwi == 4 ? "]" : " " ); state->display.disp_text( disp, left, bottom + 15, temp ); } else switch ( column->lcd_filter ) { case FT_LCD_FILTER_NONE: msg = "LCD without filtering"; break; case FT_LCD_FILTER_DEFAULT: msg = "default LCD filter"; break; case FT_LCD_FILTER_LIGHT: msg = "light LCD filter"; break; default: msg = "legacy LCD filter"; } state->display.disp_text( disp, left, bottom + 15, msg ); sprintf(temp, "%s %s %s", column->use_kerning ? "+kern" : "-kern", column->use_deltas ? "+delta" : "-delta", column->use_global_advance_width ? "+advance" : "-advance" ); state->display.disp_text( disp, left, bottom + 25, temp ); if ( state->col == idx ) state->display.disp_text( disp, left, bottom + 35, "**************" ); } }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,972
render_state_init( RenderState state, Display display ) { memset( state, 0, sizeof ( *state ) ); state->text = default_text; state->filepath = state->filepath0; state->filename = "<none>"; state->filepath0[0] = 0; state->resolution = 72; state->char_size = 16; state->display = display[0]; state->columns[0].use_kerning = 1; state->columns[0].use_deltas = 1; state->columns[0].use_lcd_filter = 1; state->columns[0].use_global_advance_width = 1; state->columns[0].lcd_filter = FT_LCD_FILTER_DEFAULT; state->columns[0].hint_mode = HINT_MODE_BYTECODE; state->columns[0].use_custom_lcd_filter = 0; state->columns[0].fw_index = 2; /* freetype default filter weights */ memcpy( state->columns[0].filter_weights, "\x10\x40\x70\x40\x10", 5); state->columns[1] = state->columns[0]; state->columns[1].hint_mode = HINT_MODE_AUTOHINT; state->columns[1].use_custom_lcd_filter = 1; state->columns[2] = state->columns[0]; state->columns[2].hint_mode = HINT_MODE_UNHINTED; state->col = 1; if ( FT_Init_FreeType( &state->library ) != 0 ) panic( "could not initialize FreeType library. Check your code\n" ); }
DoS Exec Code Overflow
0
render_state_init( RenderState state, Display display ) { memset( state, 0, sizeof ( *state ) ); state->text = default_text; state->filepath = state->filepath0; state->filename = "<none>"; state->filepath0[0] = 0; state->resolution = 72; state->char_size = 16; state->display = display[0]; state->columns[0].use_kerning = 1; state->columns[0].use_deltas = 1; state->columns[0].use_lcd_filter = 1; state->columns[0].use_global_advance_width = 1; state->columns[0].lcd_filter = FT_LCD_FILTER_DEFAULT; state->columns[0].hint_mode = HINT_MODE_BYTECODE; state->columns[0].use_custom_lcd_filter = 0; state->columns[0].fw_index = 2; /* freetype default filter weights */ memcpy( state->columns[0].filter_weights, "\x10\x40\x70\x40\x10", 5); state->columns[1] = state->columns[0]; state->columns[1].hint_mode = HINT_MODE_AUTOHINT; state->columns[1].use_custom_lcd_filter = 1; state->columns[2] = state->columns[0]; state->columns[2].hint_mode = HINT_MODE_UNHINTED; state->col = 1; if ( FT_Init_FreeType( &state->library ) != 0 ) panic( "could not initialize FreeType library. Check your code\n" ); }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,973
render_state_set_file( RenderState state, int idx ) { const char* filepath; if ( idx < 0 ) idx = state->num_faces - 1; else if ( idx >= state->num_faces ) idx = 0; if ( idx >= state->num_faces ) return -2; state->face_index = idx; filepath = state->faces[idx].filepath; if ( state->face ) { FT_Done_Face( state->face ); state->face = NULL; state->size = NULL; state->need_rescale = 1; } if ( filepath != NULL && filepath[0] != 0 ) { FT_Error error; error = FT_New_Face( state->library, filepath, state->faces[idx].index, &state->face ); if ( error ) return -1; { unsigned int len = strlen( filepath ); char* p; if ( len + 1 > sizeof ( state->filepath0 ) ) { state->filepath = (const char*)malloc( len + 1 ); if ( state->filepath == NULL ) { state->filepath = state->filepath0; return -1; } } memcpy( (char*)state->filepath, filepath, len + 1 ); p = strrchr( state->filepath, '\\' ); if ( p == NULL ) p = strrchr( state->filepath, '/' ); state->filename = p ? p + 1 : state->filepath; } state->size = state->face->size; state->need_rescale = 1; } return 0; }
DoS Exec Code Overflow
0
render_state_set_file( RenderState state, int idx ) { const char* filepath; if ( idx < 0 ) idx = state->num_faces - 1; else if ( idx >= state->num_faces ) idx = 0; if ( idx >= state->num_faces ) return -2; state->face_index = idx; filepath = state->faces[idx].filepath; if ( state->face ) { FT_Done_Face( state->face ); state->face = NULL; state->size = NULL; state->need_rescale = 1; } if ( filepath != NULL && filepath[0] != 0 ) { FT_Error error; error = FT_New_Face( state->library, filepath, state->faces[idx].index, &state->face ); if ( error ) return -1; { unsigned int len = strlen( filepath ); char* p; if ( len + 1 > sizeof ( state->filepath0 ) ) { state->filepath = (const char*)malloc( len + 1 ); if ( state->filepath == NULL ) { state->filepath = state->filepath0; return -1; } } memcpy( (char*)state->filepath, filepath, len + 1 ); p = strrchr( state->filepath, '\\' ); if ( p == NULL ) p = strrchr( state->filepath, '/' ); state->filename = p ? p + 1 : state->filepath; } state->size = state->face->size; state->need_rescale = 1; } return 0; }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,974
render_state_set_resolution( RenderState state, int resolution ) { state->resolution = resolution; state->need_rescale = 1; }
DoS Exec Code Overflow
0
render_state_set_resolution( RenderState state, int resolution ) { state->resolution = resolution; state->need_rescale = 1; }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,975
render_state_set_size( RenderState state, float char_size ) { state->char_size = char_size; state->need_rescale = 1; }
DoS Exec Code Overflow
0
render_state_set_size( RenderState state, float char_size ) { state->char_size = char_size; state->need_rescale = 1; }
@@ -1131,11 +1131,11 @@ state->message = state->message0; if ( total > 1 ) - sprintf( state->message0, "%s %d/%d @ %5.1fpt", + sprintf( state->message0, "%.100s %d/%d @ %5.1fpt", state->filename, idx + 1, total, state->char_size ); else - sprintf( state->message0, "%s @ %5.1fpt", + sprintf( state->message0, "%.100s @ %5.1fpt", state->filename, state->char_size ); }
CWE-119
null
null
7,976
Fatal( const char* message ) { FTDemo_Display_Done( display ); FTDemo_Done( handle ); PanicZ( message ); }
DoS Exec Code Overflow
0
Fatal( const char* message ) { FTDemo_Display_Done( display ); FTDemo_Done( handle ); PanicZ( message ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,977
Process_Event( grEvent* event ) { int ret = 0; status.header = NULL; switch ( event->key ) { case grKeyEsc: case grKEY( 'q' ): ret = 1; break; case grKeyF1: case grKEY( '?' ): event_help(); break; case grKEY( 'a' ): handle->antialias = !handle->antialias; status.header = handle->antialias ? "anti-aliasing is now on" : "anti-aliasing is now off"; FTDemo_Update_Current_Flags( handle ); break; case grKEY( '1' ): af_glyph_hints_dump_edges( _af_debug_hints ); break; case grKEY( '2' ): af_glyph_hints_dump_segments( _af_debug_hints ); break; case grKEY( '3' ): af_glyph_hints_dump_points( _af_debug_hints ); break; case grKEY( 'g' ): event_gamma_change( 0.1 ); break; case grKEY( 'v' ): event_gamma_change( -0.1 ); break; case grKEY( 'n' ): event_font_change( 1 ); break; case grKEY( 'h' ): handle->hinted = !handle->hinted; status.header = handle->hinted ? "glyph hinting is now active" : "glyph hinting is now ignored"; FTDemo_Update_Current_Flags( handle ); break; case grKEY( 'd' ): status.do_dots = !status.do_dots; break; case grKEY( 'o' ): status.do_outline = !status.do_outline; break; case grKEY( 'p' ): event_font_change( -1 ); break; case grKEY('H'): status.do_horz_hints = !status.do_horz_hints; status.header = status.do_horz_hints ? "horizontal hinting enabled" : "horizontal hinting disabled"; break; case grKEY('V'): status.do_vert_hints = !status.do_vert_hints; status.header = status.do_vert_hints ? "vertical hinting enabled" : "vertical hinting disabled"; break; case grKEY('B'): status.do_blue_hints = !status.do_blue_hints; status.header = status.do_blue_hints ? "blue zone hinting enabled" : "blue zone hinting disabled"; break; case grKeyLeft: event_index_change( -1 ); break; case grKeyRight: event_index_change( +1 ); break; case grKeyF7: event_index_change( -10 ); break; case grKeyF8: event_index_change( 10 ); break; case grKeyF9: event_index_change( -100 ); break; case grKeyF10: event_index_change( 100 ); break; case grKeyF11: event_index_change( -1000 ); break; case grKeyF12: event_index_change( 1000 ); break; case grKeyUp: event_size_change( +32 ); break; case grKeyDown: event_size_change( -32 ); break; case grKEY( ' ' ): event_grid_reset( &status ); status.do_horz_hints = 1; status.do_vert_hints = 1; break; case grKEY('i'): event_grid_translate( 0, +1 ); break; case grKEY('k'): event_grid_translate( 0, -1 ); break; case grKEY('l'): event_grid_translate( +1, 0 ); break; case grKEY('j'): event_grid_translate( -1, 0 ); break; case grKeyPageUp: event_grid_zoom( 1.25 ); break; case grKeyPageDown: event_grid_zoom( 1/1.25 ); break; default: ; } return ret; }
DoS Exec Code Overflow
0
Process_Event( grEvent* event ) { int ret = 0; status.header = NULL; switch ( event->key ) { case grKeyEsc: case grKEY( 'q' ): ret = 1; break; case grKeyF1: case grKEY( '?' ): event_help(); break; case grKEY( 'a' ): handle->antialias = !handle->antialias; status.header = handle->antialias ? "anti-aliasing is now on" : "anti-aliasing is now off"; FTDemo_Update_Current_Flags( handle ); break; case grKEY( '1' ): af_glyph_hints_dump_edges( _af_debug_hints ); break; case grKEY( '2' ): af_glyph_hints_dump_segments( _af_debug_hints ); break; case grKEY( '3' ): af_glyph_hints_dump_points( _af_debug_hints ); break; case grKEY( 'g' ): event_gamma_change( 0.1 ); break; case grKEY( 'v' ): event_gamma_change( -0.1 ); break; case grKEY( 'n' ): event_font_change( 1 ); break; case grKEY( 'h' ): handle->hinted = !handle->hinted; status.header = handle->hinted ? "glyph hinting is now active" : "glyph hinting is now ignored"; FTDemo_Update_Current_Flags( handle ); break; case grKEY( 'd' ): status.do_dots = !status.do_dots; break; case grKEY( 'o' ): status.do_outline = !status.do_outline; break; case grKEY( 'p' ): event_font_change( -1 ); break; case grKEY('H'): status.do_horz_hints = !status.do_horz_hints; status.header = status.do_horz_hints ? "horizontal hinting enabled" : "horizontal hinting disabled"; break; case grKEY('V'): status.do_vert_hints = !status.do_vert_hints; status.header = status.do_vert_hints ? "vertical hinting enabled" : "vertical hinting disabled"; break; case grKEY('B'): status.do_blue_hints = !status.do_blue_hints; status.header = status.do_blue_hints ? "blue zone hinting enabled" : "blue zone hinting disabled"; break; case grKeyLeft: event_index_change( -1 ); break; case grKeyRight: event_index_change( +1 ); break; case grKeyF7: event_index_change( -10 ); break; case grKeyF8: event_index_change( 10 ); break; case grKeyF9: event_index_change( -100 ); break; case grKeyF10: event_index_change( 100 ); break; case grKeyF11: event_index_change( -1000 ); break; case grKeyF12: event_index_change( 1000 ); break; case grKeyUp: event_size_change( +32 ); break; case grKeyDown: event_size_change( -32 ); break; case grKEY( ' ' ): event_grid_reset( &status ); status.do_horz_hints = 1; status.do_vert_hints = 1; break; case grKEY('i'): event_grid_translate( 0, +1 ); break; case grKEY('k'): event_grid_translate( 0, -1 ); break; case grKEY('l'): event_grid_translate( +1, 0 ); break; case grKEY('j'): event_grid_translate( -1, 0 ); break; case grKeyPageUp: event_grid_zoom( 1.25 ); break; case grKeyPageDown: event_grid_zoom( 1/1.25 ); break; default: ; } return ret; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,978
circle_draw( FT_F26Dot6 center_x, FT_F26Dot6 center_y, FT_F26Dot6 radius, FTDemo_Handle* handle, FTDemo_Display* display, grColor color ) { FT_Outline outline; ft_outline_new_circle( &outline, radius, handle ); FT_Outline_Translate( &outline, center_x & 63, center_y & 63 ); ft_outline_draw( &outline, 1., (center_x >> 6), (center_y >> 6), handle, display, color ); FT_Outline_Done( handle->library, &outline ); }
DoS Exec Code Overflow
0
circle_draw( FT_F26Dot6 center_x, FT_F26Dot6 center_y, FT_F26Dot6 radius, FTDemo_Handle* handle, FTDemo_Display* display, grColor color ) { FT_Outline outline; ft_outline_new_circle( &outline, radius, handle ); FT_Outline_Translate( &outline, center_x & 63, center_y & 63 ); ft_outline_draw( &outline, 1., (center_x >> 6), (center_y >> 6), handle, display, color ); FT_Outline_Done( handle->library, &outline ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,979
event_font_change( int delta ) { int num_indices; if ( status.font_index + delta >= handle->num_fonts || status.font_index + delta < 0 ) return; status.font_index += delta; FTDemo_Set_Current_Font( handle, handle->fonts[status.font_index] ); FTDemo_Set_Current_Charsize( handle, status.ptsize, status.res ); FTDemo_Update_Current_Flags( handle ); num_indices = handle->current_font->num_indices; if ( status.Num >= num_indices ) status.Num = num_indices - 1; }
DoS Exec Code Overflow
0
event_font_change( int delta ) { int num_indices; if ( status.font_index + delta >= handle->num_fonts || status.font_index + delta < 0 ) return; status.font_index += delta; FTDemo_Set_Current_Font( handle, handle->fonts[status.font_index] ); FTDemo_Set_Current_Charsize( handle, status.ptsize, status.res ); FTDemo_Update_Current_Flags( handle ); num_indices = handle->current_font->num_indices; if ( status.Num >= num_indices ) status.Num = num_indices - 1; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,980
event_gamma_change( double delta ) { status.gamma += delta; if ( status.gamma > 3.0 ) status.gamma = 3.0; else if ( status.gamma < 0.0 ) status.gamma = 0.0; grSetGlyphGamma( status.gamma ); sprintf( status.header_buffer, "gamma changed to %.1f%s", status.gamma, status.gamma == 0.0 ? " (sRGB mode)" : "" ); status.header = (const char *)status.header_buffer; }
DoS Exec Code Overflow
0
event_gamma_change( double delta ) { status.gamma += delta; if ( status.gamma > 3.0 ) status.gamma = 3.0; else if ( status.gamma < 0.0 ) status.gamma = 0.0; grSetGlyphGamma( status.gamma ); sprintf( status.header_buffer, "gamma changed to %.1f%s", status.gamma, status.gamma == 0.0 ? " (sRGB mode)" : "" ); status.header = (const char *)status.header_buffer; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,981
event_grid_translate( int dx, int dy ) { status.x_origin += 32*dx; status.y_origin += 32*dy; }
DoS Exec Code Overflow
0
event_grid_translate( int dx, int dy ) { status.x_origin += 32*dx; status.y_origin += 32*dy; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,982
event_grid_zoom( double zoom ) { status.scale *= zoom; sprintf( status.header_buffer, "zoom level %.2f %%\n", status.scale / status.scale_0 ); status.header = (const char *)status.header_buffer; }
DoS Exec Code Overflow
0
event_grid_zoom( double zoom ) { status.scale *= zoom; sprintf( status.header_buffer, "zoom level %.2f %%\n", status.scale / status.scale_0 ); status.header = (const char *)status.header_buffer; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,983
event_size_change( int delta ) { status.ptsize += delta; if ( status.ptsize < 1*64 ) status.ptsize = 1*64; else if ( status.ptsize > MAXPTSIZE*64 ) status.ptsize = MAXPTSIZE*64; FTDemo_Set_Current_Charsize( handle, status.ptsize, status.res ); }
DoS Exec Code Overflow
0
event_size_change( int delta ) { status.ptsize += delta; if ( status.ptsize < 1*64 ) status.ptsize = 1*64; else if ( status.ptsize > MAXPTSIZE*64 ) status.ptsize = MAXPTSIZE*64; FTDemo_Set_Current_Charsize( handle, status.ptsize, status.res ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,984
ft_bitmap_draw( FT_Bitmap* bitmap, int x, int y, FTDemo_Display* display, grColor color) { grBitmap gbit; gbit.width = bitmap->width; gbit.rows = bitmap->rows; gbit.pitch = bitmap->pitch; gbit.buffer = bitmap->buffer; switch ( bitmap->pixel_mode) { case FT_PIXEL_MODE_GRAY: gbit.mode = gr_pixel_mode_gray; gbit.grays = 256; break; case FT_PIXEL_MODE_MONO: gbit.mode = gr_pixel_mode_mono; gbit.grays = 2; break; case FT_PIXEL_MODE_LCD: gbit.mode = gr_pixel_mode_lcd; gbit.grays = 256; break; case FT_PIXEL_MODE_LCD_V: gbit.mode = gr_pixel_mode_lcdv; gbit.grays = 256; break; default: return; } grBlitGlyphToBitmap( display->bitmap, &gbit, x, y, color ); }
DoS Exec Code Overflow
0
ft_bitmap_draw( FT_Bitmap* bitmap, int x, int y, FTDemo_Display* display, grColor color) { grBitmap gbit; gbit.width = bitmap->width; gbit.rows = bitmap->rows; gbit.pitch = bitmap->pitch; gbit.buffer = bitmap->buffer; switch ( bitmap->pixel_mode) { case FT_PIXEL_MODE_GRAY: gbit.mode = gr_pixel_mode_gray; gbit.grays = 256; break; case FT_PIXEL_MODE_MONO: gbit.mode = gr_pixel_mode_mono; gbit.grays = 2; break; case FT_PIXEL_MODE_LCD: gbit.mode = gr_pixel_mode_lcd; gbit.grays = 256; break; case FT_PIXEL_MODE_LCD_V: gbit.mode = gr_pixel_mode_lcdv; gbit.grays = 256; break; default: return; } grBlitGlyphToBitmap( display->bitmap, &gbit, x, y, color ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,985
ft_outline_draw( FT_Outline* outline, double scale, int pen_x, int pen_y, FTDemo_Handle* handle, FTDemo_Display* display, grColor color ) { FT_Outline transformed; FT_BBox cbox; FT_Bitmap bitm; FT_Outline_New( handle->library, outline->n_points, outline->n_contours, &transformed ); FT_Outline_Copy( outline, &transformed ); if ( scale != 1. ) { int nn; for ( nn = 0; nn < transformed.n_points; nn++ ) { FT_Vector* vec = &transformed.points[nn]; vec->x = (FT_F26Dot6)(vec->x*scale); vec->y = (FT_F26Dot6)(vec->y*scale); } } FT_Outline_Get_CBox( &transformed, &cbox ); cbox.xMin &= ~63; cbox.yMin &= ~63; cbox.xMax = (cbox.xMax + 63) & ~63; cbox.yMax = (cbox.yMax + 63) & ~63; bitm.width = (cbox.xMax - cbox.xMin) >> 6; bitm.rows = (cbox.yMax - cbox.yMin) >> 6; bitm.pitch = bitm.width; bitm.num_grays = 256; bitm.pixel_mode = FT_PIXEL_MODE_GRAY; bitm.buffer = (unsigned char*)calloc( bitm.pitch, bitm.rows ); FT_Outline_Translate( &transformed, -cbox.xMin, -cbox.yMin ); FT_Outline_Get_Bitmap( handle->library, &transformed, &bitm ); ft_bitmap_draw( &bitm, pen_x + (cbox.xMin >> 6), pen_y - (cbox.yMax >> 6), display, color ); free( bitm.buffer ); FT_Outline_Done( handle->library, &transformed ); }
DoS Exec Code Overflow
0
ft_outline_draw( FT_Outline* outline, double scale, int pen_x, int pen_y, FTDemo_Handle* handle, FTDemo_Display* display, grColor color ) { FT_Outline transformed; FT_BBox cbox; FT_Bitmap bitm; FT_Outline_New( handle->library, outline->n_points, outline->n_contours, &transformed ); FT_Outline_Copy( outline, &transformed ); if ( scale != 1. ) { int nn; for ( nn = 0; nn < transformed.n_points; nn++ ) { FT_Vector* vec = &transformed.points[nn]; vec->x = (FT_F26Dot6)(vec->x*scale); vec->y = (FT_F26Dot6)(vec->y*scale); } } FT_Outline_Get_CBox( &transformed, &cbox ); cbox.xMin &= ~63; cbox.yMin &= ~63; cbox.xMax = (cbox.xMax + 63) & ~63; cbox.yMax = (cbox.yMax + 63) & ~63; bitm.width = (cbox.xMax - cbox.xMin) >> 6; bitm.rows = (cbox.yMax - cbox.yMin) >> 6; bitm.pitch = bitm.width; bitm.num_grays = 256; bitm.pixel_mode = FT_PIXEL_MODE_GRAY; bitm.buffer = (unsigned char*)calloc( bitm.pitch, bitm.rows ); FT_Outline_Translate( &transformed, -cbox.xMin, -cbox.yMin ); FT_Outline_Get_Bitmap( handle->library, &transformed, &bitm ); ft_bitmap_draw( &bitm, pen_x + (cbox.xMin >> 6), pen_y - (cbox.yMax >> 6), display, color ); free( bitm.buffer ); FT_Outline_Done( handle->library, &transformed ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,986
ft_outline_new_circle( FT_Outline* outline, FT_F26Dot6 radius, FTDemo_Handle* handle ) { char* tag; FT_Vector* vec; FT_F26Dot6 disp = (FT_F26Dot6)( radius * 0.6781 ); FT_Outline_New( handle->library, 12, 1, outline ); outline->n_points = 12; outline->n_contours = 1; outline->contours[0] = outline->n_points-1; vec = outline->points; tag = outline->tags; vec->x = radius; vec->y = 0; vec++; *tag++ = FT_CURVE_TAG_ON; vec->x = radius; vec->y = disp; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = disp; vec->y = radius; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = 0; vec->y = radius; vec++; *tag++ = FT_CURVE_TAG_ON; vec->x = -disp; vec->y = radius; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = -radius; vec->y = disp; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = -radius; vec->y = 0; vec++; *tag++ = FT_CURVE_TAG_ON; vec->x = -radius; vec->y = -disp; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = -disp; vec->y = -radius; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = 0; vec->y = -radius; vec++; *tag++ = FT_CURVE_TAG_ON; vec->x = disp; vec->y = -radius; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = radius; vec->y = -disp; vec++; *tag++ = FT_CURVE_TAG_CUBIC; }
DoS Exec Code Overflow
0
ft_outline_new_circle( FT_Outline* outline, FT_F26Dot6 radius, FTDemo_Handle* handle ) { char* tag; FT_Vector* vec; FT_F26Dot6 disp = (FT_F26Dot6)( radius * 0.6781 ); FT_Outline_New( handle->library, 12, 1, outline ); outline->n_points = 12; outline->n_contours = 1; outline->contours[0] = outline->n_points-1; vec = outline->points; tag = outline->tags; vec->x = radius; vec->y = 0; vec++; *tag++ = FT_CURVE_TAG_ON; vec->x = radius; vec->y = disp; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = disp; vec->y = radius; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = 0; vec->y = radius; vec++; *tag++ = FT_CURVE_TAG_ON; vec->x = -disp; vec->y = radius; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = -radius; vec->y = disp; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = -radius; vec->y = 0; vec++; *tag++ = FT_CURVE_TAG_ON; vec->x = -radius; vec->y = -disp; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = -disp; vec->y = -radius; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = 0; vec->y = -radius; vec++; *tag++ = FT_CURVE_TAG_ON; vec->x = disp; vec->y = -radius; vec++; *tag++ = FT_CURVE_TAG_CUBIC; vec->x = radius; vec->y = -disp; vec++; *tag++ = FT_CURVE_TAG_CUBIC; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,987
grid_status_draw_grid( GridStatus st ) { int x_org = (int)st->x_origin; int y_org = (int)st->y_origin; double xy_incr = 64.0 * st->scale; if ( xy_incr >= 2. ) { double x2 = x_org; double y2 = y_org; for ( ; x2 < st->disp_width; x2 += xy_incr ) grFillVLine( st->disp_bitmap, (int)x2, 0, st->disp_height, st->grid_color ); for ( x2 = x_org - xy_incr; (int)x2 >= 0; x2 -= xy_incr ) grFillVLine( st->disp_bitmap, (int)x2, 0, st->disp_height, st->grid_color ); for ( ; y2 < st->disp_height; y2 += xy_incr ) grFillHLine( st->disp_bitmap, 0, (int)y2, st->disp_width, st->grid_color ); for ( y2 = y_org - xy_incr; (int)y2 >= 0; y2 -= xy_incr ) grFillHLine( st->disp_bitmap, 0, (int)y2, st->disp_width, st->grid_color ); } grFillVLine( st->disp_bitmap, x_org, 0, st->disp_height, st->axis_color ); grFillHLine( st->disp_bitmap, 0, y_org, st->disp_width, st->axis_color ); }
DoS Exec Code Overflow
0
grid_status_draw_grid( GridStatus st ) { int x_org = (int)st->x_origin; int y_org = (int)st->y_origin; double xy_incr = 64.0 * st->scale; if ( xy_incr >= 2. ) { double x2 = x_org; double y2 = y_org; for ( ; x2 < st->disp_width; x2 += xy_incr ) grFillVLine( st->disp_bitmap, (int)x2, 0, st->disp_height, st->grid_color ); for ( x2 = x_org - xy_incr; (int)x2 >= 0; x2 -= xy_incr ) grFillVLine( st->disp_bitmap, (int)x2, 0, st->disp_height, st->grid_color ); for ( ; y2 < st->disp_height; y2 += xy_incr ) grFillHLine( st->disp_bitmap, 0, (int)y2, st->disp_width, st->grid_color ); for ( y2 = y_org - xy_incr; (int)y2 >= 0; y2 -= xy_incr ) grFillHLine( st->disp_bitmap, 0, (int)y2, st->disp_width, st->grid_color ); } grFillVLine( st->disp_bitmap, x_org, 0, st->disp_height, st->axis_color ); grFillHLine( st->disp_bitmap, 0, y_org, st->disp_width, st->axis_color ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,988
grid_status_draw_outline( GridStatus st, FTDemo_Handle* handle, FTDemo_Display* display ) { static FT_Stroker stroker; FT_Size size; FT_GlyphSlot slot; double scale = 64.0 * st->scale; int ox = (int)st->x_origin; int oy = (int)st->y_origin; if ( stroker == NULL ) { FT_Stroker_New( handle->library, &stroker ); FT_Stroker_Set( stroker, 32, FT_STROKER_LINECAP_BUTT, FT_STROKER_LINEJOIN_ROUND, 0x20000 ); } FTDemo_Get_Size( handle, &size ); _af_debug_disable_horz_hints = !st->do_horz_hints; _af_debug_disable_vert_hints = !st->do_vert_hints; if ( FT_Load_Glyph( size->face, st->Num, handle->load_flags | FT_LOAD_NO_BITMAP ) ) return; slot = size->face->glyph; if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { FT_Glyph glyph; FT_Outline* gimage = &slot->outline; int nn; /* scale the outline */ for (nn = 0; nn < gimage->n_points; nn++) { FT_Vector* vec = &gimage->points[nn]; vec->x = (FT_F26Dot6)( vec->x * scale ); vec->y = (FT_F26Dot6)( vec->y * scale ); } /* stroke then draw it */ if ( st->do_outline ) { FT_Get_Glyph( slot, &glyph ); FT_Glyph_Stroke( &glyph, stroker, 1 ); FTDemo_Draw_Glyph_Color( handle, display, glyph, &ox, &oy, st->outline_color ); FT_Done_Glyph( glyph ); } /* now draw the points */ if ( st->do_dots ) { for (nn = 0; nn < gimage->n_points; nn++) circle_draw( (FT_F26Dot6)( st->x_origin * 64 + gimage->points[nn].x ), (FT_F26Dot6)( st->y_origin * 64 - gimage->points[nn].y ), 128, handle, display, ( gimage->tags[nn] & FT_CURVE_TAG_ON ) ? st->on_color : st->conic_color ); } } }
DoS Exec Code Overflow
0
grid_status_draw_outline( GridStatus st, FTDemo_Handle* handle, FTDemo_Display* display ) { static FT_Stroker stroker; FT_Size size; FT_GlyphSlot slot; double scale = 64.0 * st->scale; int ox = (int)st->x_origin; int oy = (int)st->y_origin; if ( stroker == NULL ) { FT_Stroker_New( handle->library, &stroker ); FT_Stroker_Set( stroker, 32, FT_STROKER_LINECAP_BUTT, FT_STROKER_LINEJOIN_ROUND, 0x20000 ); } FTDemo_Get_Size( handle, &size ); _af_debug_disable_horz_hints = !st->do_horz_hints; _af_debug_disable_vert_hints = !st->do_vert_hints; if ( FT_Load_Glyph( size->face, st->Num, handle->load_flags | FT_LOAD_NO_BITMAP ) ) return; slot = size->face->glyph; if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { FT_Glyph glyph; FT_Outline* gimage = &slot->outline; int nn; /* scale the outline */ for (nn = 0; nn < gimage->n_points; nn++) { FT_Vector* vec = &gimage->points[nn]; vec->x = (FT_F26Dot6)( vec->x * scale ); vec->y = (FT_F26Dot6)( vec->y * scale ); } /* stroke then draw it */ if ( st->do_outline ) { FT_Get_Glyph( slot, &glyph ); FT_Glyph_Stroke( &glyph, stroker, 1 ); FTDemo_Draw_Glyph_Color( handle, display, glyph, &ox, &oy, st->outline_color ); FT_Done_Glyph( glyph ); } /* now draw the points */ if ( st->do_dots ) { for (nn = 0; nn < gimage->n_points; nn++) circle_draw( (FT_F26Dot6)( st->x_origin * 64 + gimage->points[nn].x ), (FT_F26Dot6)( st->y_origin * 64 - gimage->points[nn].y ), 128, handle, display, ( gimage->tags[nn] & FT_CURVE_TAG_ON ) ? st->on_color : st->conic_color ); } } }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,989
grid_status_init( GridStatus st, FTDemo_Display* display ) { st->scale = 1.0; st->x_origin = display->bitmap->width / 4; st->y_origin = display->bitmap->rows / 4; st->margin = 0.05; st->axis_color = grFindColor( display->bitmap, 0, 0, 0, 255 ); st->grid_color = grFindColor( display->bitmap, 192, 192, 192, 255 ); st->outline_color = grFindColor( display->bitmap, 255, 0, 0, 255 ); st->on_color = grFindColor( display->bitmap, 64, 64, 255, 255 ); st->conic_color = grFindColor( display->bitmap, 0, 128, 0, 255 ); st->cubic_color = grFindColor( display->bitmap, 255, 64, 255, 255 ); st->disp_width = display->bitmap->width; st->disp_height = display->bitmap->rows; st->disp_bitmap = display->bitmap; st->do_horz_hints = 1; st->do_vert_hints = 1; st->do_blue_hints = 1; st->do_dots = 1; st->do_outline = 1; st->Num = 0; st->gamma = 1.0; st->header = ""; }
DoS Exec Code Overflow
0
grid_status_init( GridStatus st, FTDemo_Display* display ) { st->scale = 1.0; st->x_origin = display->bitmap->width / 4; st->y_origin = display->bitmap->rows / 4; st->margin = 0.05; st->axis_color = grFindColor( display->bitmap, 0, 0, 0, 255 ); st->grid_color = grFindColor( display->bitmap, 192, 192, 192, 255 ); st->outline_color = grFindColor( display->bitmap, 255, 0, 0, 255 ); st->on_color = grFindColor( display->bitmap, 64, 64, 255, 255 ); st->conic_color = grFindColor( display->bitmap, 0, 128, 0, 255 ); st->cubic_color = grFindColor( display->bitmap, 255, 64, 255, 255 ); st->disp_width = display->bitmap->width; st->disp_height = display->bitmap->rows; st->disp_bitmap = display->bitmap; st->do_horz_hints = 1; st->do_vert_hints = 1; st->do_blue_hints = 1; st->do_dots = 1; st->do_outline = 1; st->Num = 0; st->gamma = 1.0; st->header = ""; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,990
parse_cmdline( int* argc, char** argv[] ) { char* execname; int option; execname = ft_basename( (*argv)[0] ); while ( 1 ) { option = getopt( *argc, *argv, "f:r:" ); if ( option == -1 ) break; switch ( option ) { case 'f': status.Num = atoi( optarg ); break; case 'r': status.res = atoi( optarg ); if ( status.res < 1 ) usage( execname ); break; default: usage( execname ); break; } } *argc -= optind; *argv += optind; if ( *argc <= 1 ) usage( execname ); status.ptsize = (int)(atof( *argv[0] ) * 64.0); if ( status.ptsize == 0 ) status.ptsize = 64*10; if ( status.res <= 0 ) status.res = 72; (*argc)--; (*argv)++; }
DoS Exec Code Overflow
0
parse_cmdline( int* argc, char** argv[] ) { char* execname; int option; execname = ft_basename( (*argv)[0] ); while ( 1 ) { option = getopt( *argc, *argv, "f:r:" ); if ( option == -1 ) break; switch ( option ) { case 'f': status.Num = atoi( optarg ); break; case 'r': status.res = atoi( optarg ); if ( status.res < 1 ) usage( execname ); break; default: usage( execname ); break; } } *argc -= optind; *argv += optind; if ( *argc <= 1 ) usage( execname ); status.ptsize = (int)(atof( *argv[0] ) * 64.0); if ( status.ptsize == 0 ) status.ptsize = 64*10; if ( status.res <= 0 ) status.res = 72; (*argc)--; (*argv)++; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,991
usage( char* execname ) { fprintf( stderr, "\n" ); fprintf( stderr, "ftgrid: simple glyph grid viewer -- part of the FreeType project\n" ); fprintf( stderr, "-----------------------------------------------------------\n" ); fprintf( stderr, "\n" ); fprintf( stderr, "Usage: %s [status below] ppem fontname[.ttf|.ttc] ...\n", execname ); fprintf( stderr, "\n" ); fprintf( stderr, " -r R use resolution R dpi (default: 72 dpi)\n" ); fprintf( stderr, " -f index specify first index to display\n" ); fprintf( stderr, "\n" ); exit( 1 ); }
DoS Exec Code Overflow
0
usage( char* execname ) { fprintf( stderr, "\n" ); fprintf( stderr, "ftgrid: simple glyph grid viewer -- part of the FreeType project\n" ); fprintf( stderr, "-----------------------------------------------------------\n" ); fprintf( stderr, "\n" ); fprintf( stderr, "Usage: %s [status below] ppem fontname[.ttf|.ttc] ...\n", execname ); fprintf( stderr, "\n" ); fprintf( stderr, " -r R use resolution R dpi (default: 72 dpi)\n" ); fprintf( stderr, " -f index specify first index to display\n" ); fprintf( stderr, "\n" ); exit( 1 ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -787,22 +787,22 @@ grid_status_draw_outline( GridStatus st, switch ( error_code ) { case FT_Err_Ok: - sprintf( status.header_buffer, "%s %s (file `%s')", + sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')", face->family_name, face->style_name, basename ); break; case FT_Err_Invalid_Pixel_Size: - sprintf( status.header_buffer, "Invalid pixel size (file `%s')", + sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')", basename ); break; case FT_Err_Invalid_PPem: - sprintf( status.header_buffer, "Invalid ppem value (file `%s')", + sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')", basename ); break; default: - sprintf( status.header_buffer, "File `%s': error 0x%04x", + sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename, (FT_UShort)error_code ); break; }
CWE-119
null
null
7,992
Clear_Display( void ) { long bitmap_size = (long)bit.pitch * bit.rows; if ( bitmap_size < 0 ) bitmap_size = -bitmap_size; memset( bit.buffer, 0, bitmap_size ); }
DoS Exec Code Overflow
0
Clear_Display( void ) { long bitmap_size = (long)bit.pitch * bit.rows; if ( bitmap_size < 0 ) bitmap_size = -bitmap_size; memset( bit.buffer, 0, bitmap_size ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -34,7 +34,7 @@ #define MAXPTSIZE 500 /* dtp */ - char Header[128]; + char Header[256]; char* new_header = 0; const unsigned char* Text = (unsigned char*) @@ -795,7 +795,7 @@ Render_All( Num, ptsize ); } - sprintf( Header, "%s %s (file %s)", + sprintf( Header, "%.50s %.50s (file %.100s)", face->family_name, face->style_name, ft_basename( argv[file] ) ); @@ -830,7 +830,7 @@ } else { - sprintf( Header, "%s: not an MM font file, or could not be opened", + sprintf( Header, "%.100s: not an MM font file, or could not be opened", ft_basename( argv[file] ) ); }
CWE-119
null
null
7,993
Help( void ) { grEvent dummy_event; Clear_Display(); grGotoxy( 0, 0 ); grSetMargin( 2, 1 ); grGotobitmap( &bit ); grWriteln( "FreeType Multiple Masters Glyph Viewer - part of the FreeType test suite" ); grLn(); grWriteln( "This program is used to display all glyphs from one or" ); grWriteln( "several Multiple Masters font files, with the FreeType library."); grLn(); grWriteln( "Use the following keys:"); grLn(); grWriteln( " F1 or ? : display this help screen" ); grWriteln( " a : toggle anti-aliasing" ); grWriteln( " h : toggle outline hinting" ); grWriteln( " b : toggle embedded bitmaps" ); grWriteln( " l : toggle low precision rendering" ); grWriteln( " space : toggle rendering mode" ); grLn(); grWriteln( " n : next font" ); grWriteln( " p : previous font" ); grLn(); grWriteln( " Up : increase pointsize by 1 unit" ); grWriteln( " Down : decrease pointsize by 1 unit" ); grWriteln( " Page Up : increase pointsize by 10 units" ); grWriteln( " Page Down : decrease pointsize by 10 units" ); grLn(); grWriteln( " Right : increment first glyph index" ); grWriteln( " Left : decrement first glyph index" ); grLn(); grWriteln( " F3 : decrement first axis pos by 1/50th of its range" ); grWriteln( " F4 : increment first axis pos by 1/50th of its range" ); grWriteln( " F5 : decrement second axis pos by 1/50th of its range" ); grWriteln( " F6 : increment second axis pos by 1/50th of its range" ); grWriteln( " F7 : decrement third axis pos by 1/50th of its range" ); grWriteln( " F8 : increment third axis pos by 1/50th of its range" ); grWriteln( " F9 : decrement index by 100" ); grWriteln( " F10 : increment index by 100" ); grWriteln( " F11 : decrement index by 1000" ); grWriteln( " F12 : increment index by 1000" ); grLn(); grWriteln( "press any key to exit this help screen" ); grRefreshSurface( surface ); grListenSurface( surface, gr_event_key, &dummy_event ); }
DoS Exec Code Overflow
0
Help( void ) { grEvent dummy_event; Clear_Display(); grGotoxy( 0, 0 ); grSetMargin( 2, 1 ); grGotobitmap( &bit ); grWriteln( "FreeType Multiple Masters Glyph Viewer - part of the FreeType test suite" ); grLn(); grWriteln( "This program is used to display all glyphs from one or" ); grWriteln( "several Multiple Masters font files, with the FreeType library."); grLn(); grWriteln( "Use the following keys:"); grLn(); grWriteln( " F1 or ? : display this help screen" ); grWriteln( " a : toggle anti-aliasing" ); grWriteln( " h : toggle outline hinting" ); grWriteln( " b : toggle embedded bitmaps" ); grWriteln( " l : toggle low precision rendering" ); grWriteln( " space : toggle rendering mode" ); grLn(); grWriteln( " n : next font" ); grWriteln( " p : previous font" ); grLn(); grWriteln( " Up : increase pointsize by 1 unit" ); grWriteln( " Down : decrease pointsize by 1 unit" ); grWriteln( " Page Up : increase pointsize by 10 units" ); grWriteln( " Page Down : decrease pointsize by 10 units" ); grLn(); grWriteln( " Right : increment first glyph index" ); grWriteln( " Left : decrement first glyph index" ); grLn(); grWriteln( " F3 : decrement first axis pos by 1/50th of its range" ); grWriteln( " F4 : increment first axis pos by 1/50th of its range" ); grWriteln( " F5 : decrement second axis pos by 1/50th of its range" ); grWriteln( " F6 : increment second axis pos by 1/50th of its range" ); grWriteln( " F7 : decrement third axis pos by 1/50th of its range" ); grWriteln( " F8 : increment third axis pos by 1/50th of its range" ); grWriteln( " F9 : decrement index by 100" ); grWriteln( " F10 : increment index by 100" ); grWriteln( " F11 : decrement index by 1000" ); grWriteln( " F12 : increment index by 1000" ); grLn(); grWriteln( "press any key to exit this help screen" ); grRefreshSurface( surface ); grListenSurface( surface, gr_event_key, &dummy_event ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -34,7 +34,7 @@ #define MAXPTSIZE 500 /* dtp */ - char Header[128]; + char Header[256]; char* new_header = 0; const unsigned char* Text = (unsigned char*) @@ -795,7 +795,7 @@ Render_All( Num, ptsize ); } - sprintf( Header, "%s %s (file %s)", + sprintf( Header, "%.50s %.50s (file %.100s)", face->family_name, face->style_name, ft_basename( argv[file] ) ); @@ -830,7 +830,7 @@ } else { - sprintf( Header, "%s: not an MM font file, or could not be opened", + sprintf( Header, "%.100s: not an MM font file, or could not be opened", ft_basename( argv[file] ) ); }
CWE-119
null
null
7,994
Init_Display( void ) { grInitDevices(); bit.mode = gr_pixel_mode_gray; bit.width = DIM_X; bit.rows = DIM_Y; bit.grays = 256; surface = grNewSurface( 0, &bit ); if ( !surface ) PanicZ( "could not allocate display surface\n" ); graph_init = 1; }
DoS Exec Code Overflow
0
Init_Display( void ) { grInitDevices(); bit.mode = gr_pixel_mode_gray; bit.width = DIM_X; bit.rows = DIM_Y; bit.grays = 256; surface = grNewSurface( 0, &bit ); if ( !surface ) PanicZ( "could not allocate display surface\n" ); graph_init = 1; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -34,7 +34,7 @@ #define MAXPTSIZE 500 /* dtp */ - char Header[128]; + char Header[256]; char* new_header = 0; const unsigned char* Text = (unsigned char*) @@ -795,7 +795,7 @@ Render_All( Num, ptsize ); } - sprintf( Header, "%s %s (file %s)", + sprintf( Header, "%.50s %.50s (file %.100s)", face->family_name, face->style_name, ft_basename( argv[file] ) ); @@ -830,7 +830,7 @@ } else { - sprintf( Header, "%s: not an MM font file, or could not be opened", + sprintf( Header, "%.100s: not an MM font file, or could not be opened", ft_basename( argv[file] ) ); }
CWE-119
null
null
7,995
LoadChar( int idx, int hint ) { int flags; flags = FT_LOAD_DEFAULT | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; if ( !hint ) flags |= FT_LOAD_NO_HINTING; if ( !use_sbits ) flags |= FT_LOAD_NO_BITMAP; return FT_Load_Glyph( face, idx, flags ); }
DoS Exec Code Overflow
0
LoadChar( int idx, int hint ) { int flags; flags = FT_LOAD_DEFAULT | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; if ( !hint ) flags |= FT_LOAD_NO_HINTING; if ( !use_sbits ) flags |= FT_LOAD_NO_BITMAP; return FT_Load_Glyph( face, idx, flags ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -34,7 +34,7 @@ #define MAXPTSIZE 500 /* dtp */ - char Header[128]; + char Header[256]; char* new_header = 0; const unsigned char* Text = (unsigned char*) @@ -795,7 +795,7 @@ Render_All( Num, ptsize ); } - sprintf( Header, "%s %s (file %s)", + sprintf( Header, "%.50s %.50s (file %.100s)", face->family_name, face->style_name, ft_basename( argv[file] ) ); @@ -830,7 +830,7 @@ } else { - sprintf( Header, "%s: not an MM font file, or could not be opened", + sprintf( Header, "%.100s: not an MM font file, or could not be opened", ft_basename( argv[file] ) ); }
CWE-119
null
null
7,996
LogMessage( const char* fmt, ... ) { va_list ap; va_start( ap, fmt ); vfprintf( stderr, fmt, ap ); va_end( ap ); }
DoS Exec Code Overflow
0
LogMessage( const char* fmt, ... ) { va_list ap; va_start( ap, fmt ); vfprintf( stderr, fmt, ap ); va_end( ap ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -34,7 +34,7 @@ #define MAXPTSIZE 500 /* dtp */ - char Header[128]; + char Header[256]; char* new_header = 0; const unsigned char* Text = (unsigned char*) @@ -795,7 +795,7 @@ Render_All( Num, ptsize ); } - sprintf( Header, "%s %s (file %s)", + sprintf( Header, "%.50s %.50s (file %.100s)", face->family_name, face->style_name, ft_basename( argv[file] ) ); @@ -830,7 +830,7 @@ } else { - sprintf( Header, "%s: not an MM font file, or could not be opened", + sprintf( Header, "%.100s: not an MM font file, or could not be opened", ft_basename( argv[file] ) ); }
CWE-119
null
null
7,997
PanicZ( const char* message ) { fprintf( stderr, "%s\n error = 0x%04x\n", message, error ); exit( 1 ); }
DoS Exec Code Overflow
0
PanicZ( const char* message ) { fprintf( stderr, "%s\n error = 0x%04x\n", message, error ); exit( 1 ); }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -34,7 +34,7 @@ #define MAXPTSIZE 500 /* dtp */ - char Header[128]; + char Header[256]; char* new_header = 0; const unsigned char* Text = (unsigned char*) @@ -795,7 +795,7 @@ Render_All( Num, ptsize ); } - sprintf( Header, "%s %s (file %s)", + sprintf( Header, "%.50s %.50s (file %.100s)", face->family_name, face->style_name, ft_basename( argv[file] ) ); @@ -830,7 +830,7 @@ } else { - sprintf( Header, "%s: not an MM font file, or could not be opened", + sprintf( Header, "%.100s: not an MM font file, or could not be opened", ft_basename( argv[file] ) ); }
CWE-119
null
null
7,998
Process_Event( grEvent* event ) { int i, axis; switch ( event->key ) { case grKeyEsc: /* ESC or q */ case grKEY( 'q' ): return 0; case grKeyF1: case grKEY( '?' ): Help(); return 1; /* mode keys */ case grKEY( 'a' ): antialias = !antialias; new_header = antialias ? (char *)"anti-aliasing is now on" : (char *)"anti-aliasing is now off"; return 1; case grKEY( 'b' ): use_sbits = !use_sbits; new_header = use_sbits ? (char *)"embedded bitmaps are now used if available" : (char *)"embedded bitmaps are now ignored"; return 1; case grKEY( 'n' ): case grKEY( 'p' ): return (int)event->key; case grKEY( 'l' ): low_prec = !low_prec; new_header = low_prec ? (char *)"rendering precision is now forced to low" : (char *)"rendering precision is now normal"; break; case grKEY( 'h' ): hinted = !hinted; new_header = hinted ? (char *)"glyph hinting is now active" : (char *)"glyph hinting is now ignored"; break; case grKEY( ' ' ): render_mode ^= 1; new_header = render_mode ? (char *)"rendering all glyphs in font" : (char *)"rendering test text string"; break; /* MM related keys */ case grKeyF3: i = -20; axis = 0; goto Do_Axis; case grKeyF4: i = 20; axis = 0; goto Do_Axis; case grKeyF5: i = -20; axis = 1; goto Do_Axis; case grKeyF6: i = 20; axis = 1; goto Do_Axis; case grKeyF7: i = -20; axis = 2; goto Do_Axis; case grKeyF8: i = 20; axis = 2; goto Do_Axis; /* scaling related keys */ case grKeyPageUp: i = 10; goto Do_Scale; case grKeyPageDown: i = -10; goto Do_Scale; case grKeyUp: i = 1; goto Do_Scale; case grKeyDown: i = -1; goto Do_Scale; /* glyph index related keys */ case grKeyLeft: i = -1; goto Do_Glyph; case grKeyRight: i = 1; goto Do_Glyph; case grKeyF9: i = -100; goto Do_Glyph; case grKeyF10: i = 100; goto Do_Glyph; case grKeyF11: i = -1000; goto Do_Glyph; case grKeyF12: i = 1000; goto Do_Glyph; default: ; } return 1; Do_Axis: if ( axis < (int)multimaster->num_axis ) { FT_Var_Axis* a = multimaster->axis + axis; FT_Fixed pos = design_pos[axis]; /* Normalize i. changing by 20 is all very well for PostScript fonts */ /* which tend to have a range of ~1000 per axis, but it's not useful */ /* for mac fonts which have a range of ~3. */ /* And it's rather extreme for optical size even in PS */ pos += FT_MulDiv( i, a->maximum-a->minimum, 1000 ); if ( pos < a->minimum ) pos = a->minimum; if ( pos > a->maximum ) pos = a->maximum; design_pos[axis] = pos; FT_Set_Var_Design_Coordinates( face, multimaster->num_axis, design_pos ); } return 1; Do_Scale: ptsize += i; if ( ptsize < 1 ) ptsize = 1; if ( ptsize > MAXPTSIZE ) ptsize = MAXPTSIZE; return 1; Do_Glyph: Num += i; if ( Num < 0 ) Num = 0; if ( Num >= num_glyphs ) Num = num_glyphs - 1; return 1; }
DoS Exec Code Overflow
0
Process_Event( grEvent* event ) { int i, axis; switch ( event->key ) { case grKeyEsc: /* ESC or q */ case grKEY( 'q' ): return 0; case grKeyF1: case grKEY( '?' ): Help(); return 1; /* mode keys */ case grKEY( 'a' ): antialias = !antialias; new_header = antialias ? (char *)"anti-aliasing is now on" : (char *)"anti-aliasing is now off"; return 1; case grKEY( 'b' ): use_sbits = !use_sbits; new_header = use_sbits ? (char *)"embedded bitmaps are now used if available" : (char *)"embedded bitmaps are now ignored"; return 1; case grKEY( 'n' ): case grKEY( 'p' ): return (int)event->key; case grKEY( 'l' ): low_prec = !low_prec; new_header = low_prec ? (char *)"rendering precision is now forced to low" : (char *)"rendering precision is now normal"; break; case grKEY( 'h' ): hinted = !hinted; new_header = hinted ? (char *)"glyph hinting is now active" : (char *)"glyph hinting is now ignored"; break; case grKEY( ' ' ): render_mode ^= 1; new_header = render_mode ? (char *)"rendering all glyphs in font" : (char *)"rendering test text string"; break; /* MM related keys */ case grKeyF3: i = -20; axis = 0; goto Do_Axis; case grKeyF4: i = 20; axis = 0; goto Do_Axis; case grKeyF5: i = -20; axis = 1; goto Do_Axis; case grKeyF6: i = 20; axis = 1; goto Do_Axis; case grKeyF7: i = -20; axis = 2; goto Do_Axis; case grKeyF8: i = 20; axis = 2; goto Do_Axis; /* scaling related keys */ case grKeyPageUp: i = 10; goto Do_Scale; case grKeyPageDown: i = -10; goto Do_Scale; case grKeyUp: i = 1; goto Do_Scale; case grKeyDown: i = -1; goto Do_Scale; /* glyph index related keys */ case grKeyLeft: i = -1; goto Do_Glyph; case grKeyRight: i = 1; goto Do_Glyph; case grKeyF9: i = -100; goto Do_Glyph; case grKeyF10: i = 100; goto Do_Glyph; case grKeyF11: i = -1000; goto Do_Glyph; case grKeyF12: i = 1000; goto Do_Glyph; default: ; } return 1; Do_Axis: if ( axis < (int)multimaster->num_axis ) { FT_Var_Axis* a = multimaster->axis + axis; FT_Fixed pos = design_pos[axis]; /* Normalize i. changing by 20 is all very well for PostScript fonts */ /* which tend to have a range of ~1000 per axis, but it's not useful */ /* for mac fonts which have a range of ~3. */ /* And it's rather extreme for optical size even in PS */ pos += FT_MulDiv( i, a->maximum-a->minimum, 1000 ); if ( pos < a->minimum ) pos = a->minimum; if ( pos > a->maximum ) pos = a->maximum; design_pos[axis] = pos; FT_Set_Var_Design_Coordinates( face, multimaster->num_axis, design_pos ); } return 1; Do_Scale: ptsize += i; if ( ptsize < 1 ) ptsize = 1; if ( ptsize > MAXPTSIZE ) ptsize = MAXPTSIZE; return 1; Do_Glyph: Num += i; if ( Num < 0 ) Num = 0; if ( Num >= num_glyphs ) Num = num_glyphs - 1; return 1; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -34,7 +34,7 @@ #define MAXPTSIZE 500 /* dtp */ - char Header[128]; + char Header[256]; char* new_header = 0; const unsigned char* Text = (unsigned char*) @@ -795,7 +795,7 @@ Render_All( Num, ptsize ); } - sprintf( Header, "%s %s (file %s)", + sprintf( Header, "%.50s %.50s (file %.100s)", face->family_name, face->style_name, ft_basename( argv[file] ) ); @@ -830,7 +830,7 @@ } else { - sprintf( Header, "%s: not an MM font file, or could not be opened", + sprintf( Header, "%.100s: not an MM font file, or could not be opened", ft_basename( argv[file] ) ); }
CWE-119
null
null
7,999
Render_Glyph( int x_offset, int y_offset ) { grBitmap bit3; FT_Pos x_top, y_top; /* first, render the glyph image into a bitmap */ if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) { error = FT_Render_Glyph( glyph, antialias ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO ); if ( error ) return error; } /* now blit it to our display screen */ bit3.rows = glyph->bitmap.rows; bit3.width = glyph->bitmap.width; bit3.pitch = glyph->bitmap.pitch; bit3.buffer = glyph->bitmap.buffer; switch ( glyph->bitmap.pixel_mode ) { case FT_PIXEL_MODE_MONO: bit3.mode = gr_pixel_mode_mono; bit3.grays = 0; break; case FT_PIXEL_MODE_GRAY: bit3.mode = gr_pixel_mode_gray; bit3.grays = glyph->bitmap.num_grays; } /* Then, blit the image to the target surface */ x_top = x_offset + glyph->bitmap_left; y_top = y_offset - glyph->bitmap_top; grBlitGlyphToBitmap( &bit, &bit3, x_top, y_top, fore_color ); return 0; }
DoS Exec Code Overflow
0
Render_Glyph( int x_offset, int y_offset ) { grBitmap bit3; FT_Pos x_top, y_top; /* first, render the glyph image into a bitmap */ if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) { error = FT_Render_Glyph( glyph, antialias ? FT_RENDER_MODE_NORMAL : FT_RENDER_MODE_MONO ); if ( error ) return error; } /* now blit it to our display screen */ bit3.rows = glyph->bitmap.rows; bit3.width = glyph->bitmap.width; bit3.pitch = glyph->bitmap.pitch; bit3.buffer = glyph->bitmap.buffer; switch ( glyph->bitmap.pixel_mode ) { case FT_PIXEL_MODE_MONO: bit3.mode = gr_pixel_mode_mono; bit3.grays = 0; break; case FT_PIXEL_MODE_GRAY: bit3.mode = gr_pixel_mode_gray; bit3.grays = glyph->bitmap.num_grays; } /* Then, blit the image to the target surface */ x_top = x_offset + glyph->bitmap_left; y_top = y_offset - glyph->bitmap_top; grBlitGlyphToBitmap( &bit, &bit3, x_top, y_top, fore_color ); return 0; }
@@ -2,7 +2,7 @@ /* */ /* The FreeType project -- a free and portable quality TrueType renderer. */ /* */ -/* Copyright 1996-2000, 2003, 2004, 2005 by */ +/* Copyright 1996-2000, 2003, 2004, 2005, 2010 by */ /* D. Turner, R.Wilhelm, and W. Lemberg */ /* */ /* */ @@ -34,7 +34,7 @@ #define MAXPTSIZE 500 /* dtp */ - char Header[128]; + char Header[256]; char* new_header = 0; const unsigned char* Text = (unsigned char*) @@ -795,7 +795,7 @@ Render_All( Num, ptsize ); } - sprintf( Header, "%s %s (file %s)", + sprintf( Header, "%.50s %.50s (file %.100s)", face->family_name, face->style_name, ft_basename( argv[file] ) ); @@ -830,7 +830,7 @@ } else { - sprintf( Header, "%s: not an MM font file, or could not be opened", + sprintf( Header, "%.100s: not an MM font file, or could not be opened", ft_basename( argv[file] ) ); }
CWE-119
null
null