project
stringclasses
633 values
commit_id
stringlengths
7
81
target
int64
0
1
func
stringlengths
5
484k
cwe
stringclasses
131 values
big_vul_idx
float64
0
189k
idx
int64
0
522k
hash
stringlengths
34
39
size
float64
1
24k
message
stringlengths
0
11.5k
dataset
stringclasses
1 value
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
static void stream_int_chk_rcv(struct stream_interface *si) { struct channel *ib = si->ib; DPRINTF(stderr, "%s: si=%p, si->state=%d ib->flags=%08x ob->flags=%08x\n", __FUNCTION__, si, si->state, si->ib->flags, si->ob->flags); if (unlikely(si->state != SI_ST_EST || (ib->flags & (CF_SHUTR|CF_DONT_READ)))) return; if (channel_full(ib)) { /* stop reading */ si->flags |= SI_FL_WAIT_ROOM; } else { /* (re)start reading */ si->flags &= ~SI_FL_WAIT_ROOM; if (!(si->flags & SI_FL_DONT_WAKE) && si->owner) task_wakeup(si->owner, TASK_WOKEN_IO); } }
CWE-189
9,878
16,634
156785053247529879881421528522362708168
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
static void stream_int_chk_rcv_conn(struct stream_interface *si) { struct channel *ib = si->ib; struct connection *conn = __objt_conn(si->end); if (unlikely(si->state > SI_ST_EST || (ib->flags & CF_SHUTR))) return; conn_refresh_polling_flags(conn); if ((ib->flags & CF_DONT_READ) || channel_full(ib)) { /* stop reading */ if (!(ib->flags & CF_DONT_READ)) /* full */ si->flags |= SI_FL_WAIT_ROOM; __conn_data_stop_recv(conn); } else { /* (re)start reading */ si->flags &= ~SI_FL_WAIT_ROOM; __conn_data_want_recv(conn); } conn_cond_update_data_polling(conn); }
CWE-189
9,879
16,635
261472872092206851969103133336922683702
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
static void stream_int_chk_snd(struct stream_interface *si) { struct channel *ob = si->ob; DPRINTF(stderr, "%s: si=%p, si->state=%d ib->flags=%08x ob->flags=%08x\n", __FUNCTION__, si, si->state, si->ib->flags, si->ob->flags); if (unlikely(si->state != SI_ST_EST || (si->ob->flags & CF_SHUTW))) return; if (!(si->flags & SI_FL_WAIT_DATA) || /* not waiting for data */ channel_is_empty(ob)) /* called with nothing to send ! */ return; /* Otherwise there are remaining data to be sent in the buffer, * so we tell the handler. */ si->flags &= ~SI_FL_WAIT_DATA; if (!tick_isset(ob->wex)) ob->wex = tick_add_ifset(now_ms, ob->wto); if (!(si->flags & SI_FL_DONT_WAKE) && si->owner) task_wakeup(si->owner, TASK_WOKEN_IO); }
CWE-189
9,880
16,636
178268301692853154445184681438535207508
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
static void stream_int_chk_snd_conn(struct stream_interface *si) { struct channel *ob = si->ob; struct connection *conn = __objt_conn(si->end); if (unlikely(si->state > SI_ST_EST || (ob->flags & CF_SHUTW))) return; if (unlikely(channel_is_empty(ob))) /* called with nothing to send ! */ return; if (!ob->pipe && /* spliced data wants to be forwarded ASAP */ !(si->flags & SI_FL_WAIT_DATA)) /* not waiting for data */ return; if (conn->flags & (CO_FL_DATA_WR_ENA|CO_FL_CURR_WR_ENA)) { /* already subscribed to write notifications, will be called * anyway, so let's avoid calling it especially if the reader * is not ready. */ return; } /* Before calling the data-level operations, we have to prepare * the polling flags to ensure we properly detect changes. */ conn_refresh_polling_flags(conn); __conn_data_want_send(conn); if (!(conn->flags & (CO_FL_HANDSHAKE|CO_FL_WAIT_L4_CONN|CO_FL_WAIT_L6_CONN))) { si_conn_send(conn); if (conn->flags & CO_FL_ERROR) { /* Write error on the file descriptor */ __conn_data_stop_both(conn); si->flags |= SI_FL_ERR; goto out_wakeup; } } /* OK, so now we know that some data might have been sent, and that we may * have to poll first. We have to do that too if the buffer is not empty. */ if (channel_is_empty(ob)) { /* the connection is established but we can't write. Either the * buffer is empty, or we just refrain from sending because the * ->o limit was reached. Maybe we just wrote the last * chunk and need to close. */ __conn_data_stop_send(conn); if (((ob->flags & (CF_SHUTW|CF_AUTO_CLOSE|CF_SHUTW_NOW)) == (CF_AUTO_CLOSE|CF_SHUTW_NOW)) && (si->state == SI_ST_EST)) { si_shutw(si); goto out_wakeup; } if ((ob->flags & (CF_SHUTW|CF_SHUTW_NOW)) == 0) si->flags |= SI_FL_WAIT_DATA; ob->wex = TICK_ETERNITY; } else { /* Otherwise there are remaining data to be sent in the buffer, * which means we have to poll before doing so. */ __conn_data_want_send(conn); si->flags &= ~SI_FL_WAIT_DATA; if (!tick_isset(ob->wex)) ob->wex = tick_add_ifset(now_ms, ob->wto); } if (likely(ob->flags & CF_WRITE_ACTIVITY)) { /* update timeout if we have written something */ if ((ob->flags & (CF_SHUTW|CF_WRITE_PARTIAL)) == CF_WRITE_PARTIAL && !channel_is_empty(ob)) ob->wex = tick_add_ifset(now_ms, ob->wto); if (tick_isset(si->ib->rex) && !(si->flags & SI_FL_INDEP_STR)) { /* Note: to prevent the client from expiring read timeouts * during writes, we refresh it. We only do this if the * interface is not configured for "independent streams", * because for some applications it's better not to do this, * for instance when continuously exchanging small amounts * of data which can full the socket buffers long before a * write timeout is detected. */ si->ib->rex = tick_add_ifset(now_ms, si->ib->rto); } } /* in case of special condition (error, shutdown, end of write...), we * have to notify the task. */ if (likely((ob->flags & (CF_WRITE_NULL|CF_WRITE_ERROR|CF_SHUTW)) || ((ob->flags & CF_WAKE_WRITE) && ((channel_is_empty(si->ob) && !ob->to_forward) || si->state != SI_ST_EST)))) { out_wakeup: if (!(si->flags & SI_FL_DONT_WAKE) && si->owner) task_wakeup(si->owner, TASK_WOKEN_IO); } /* commit possible polling changes */ conn_cond_update_polling(conn); }
CWE-189
9,881
16,637
8558186338250673191788517178764650237
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
struct appctx *stream_int_register_handler(struct stream_interface *si, struct si_applet *app) { struct appctx *appctx; DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", app, si, si->owner); appctx = si_alloc_appctx(si); if (!si) return NULL; appctx_set_applet(appctx, app); si->flags |= SI_FL_WAIT_DATA; return si_appctx(si); }
CWE-189
9,882
16,638
322510286589632070643477295697175837599
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
void stream_int_report_error(struct stream_interface *si) { if (!si->err_type) si->err_type = SI_ET_DATA_ERR; si->ob->flags |= CF_WRITE_ERROR; si->ib->flags |= CF_READ_ERROR; }
CWE-189
9,883
16,639
34735072298281026962717264853376802034
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
static void stream_int_shutr(struct stream_interface *si) { si->ib->flags &= ~CF_SHUTR_NOW; if (si->ib->flags & CF_SHUTR) return; si->ib->flags |= CF_SHUTR; si->ib->rex = TICK_ETERNITY; si->flags &= ~SI_FL_WAIT_ROOM; if (si->state != SI_ST_EST && si->state != SI_ST_CON) return; if (si->ob->flags & CF_SHUTW) { si->state = SI_ST_DIS; si->exp = TICK_ETERNITY; si_applet_release(si); } else if (si->flags & SI_FL_NOHALF) { /* we want to immediately forward this close to the write side */ return stream_int_shutw(si); } /* note that if the task exists, it must unregister itself once it runs */ if (!(si->flags & SI_FL_DONT_WAKE) && si->owner) task_wakeup(si->owner, TASK_WOKEN_IO); }
CWE-189
9,885
16,640
317441180397121329651417965087249246501
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
static void stream_int_shutr_conn(struct stream_interface *si) { struct connection *conn = __objt_conn(si->end); si->ib->flags &= ~CF_SHUTR_NOW; if (si->ib->flags & CF_SHUTR) return; si->ib->flags |= CF_SHUTR; si->ib->rex = TICK_ETERNITY; si->flags &= ~SI_FL_WAIT_ROOM; if (si->state != SI_ST_EST && si->state != SI_ST_CON) return; if (si->ob->flags & CF_SHUTW) { conn_full_close(conn); si->state = SI_ST_DIS; si->exp = TICK_ETERNITY; } else if (si->flags & SI_FL_NOHALF) { /* we want to immediately forward this close to the write side */ return stream_int_shutw_conn(si); } else if (conn->ctrl) { /* we want the caller to disable polling on this FD */ conn_data_stop_recv(conn); } }
CWE-189
9,886
16,641
49890463138424335582557145538412254056
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
static void stream_int_shutw(struct stream_interface *si) { si->ob->flags &= ~CF_SHUTW_NOW; if (si->ob->flags & CF_SHUTW) return; si->ob->flags |= CF_SHUTW; si->ob->wex = TICK_ETERNITY; si->flags &= ~SI_FL_WAIT_DATA; switch (si->state) { case SI_ST_EST: /* we have to shut before closing, otherwise some short messages * may never leave the system, especially when there are remaining * unread data in the socket input buffer, or when nolinger is set. * However, if SI_FL_NOLINGER is explicitly set, we know there is * no risk so we close both sides immediately. */ if (!(si->flags & (SI_FL_ERR | SI_FL_NOLINGER)) && !(si->ib->flags & (CF_SHUTR|CF_DONT_READ))) return; /* fall through */ case SI_ST_CON: case SI_ST_CER: case SI_ST_QUE: case SI_ST_TAR: /* Note that none of these states may happen with applets */ si->state = SI_ST_DIS; si_applet_release(si); default: si->flags &= ~(SI_FL_WAIT_ROOM | SI_FL_NOLINGER); si->ib->flags &= ~CF_SHUTR_NOW; si->ib->flags |= CF_SHUTR; si->ib->rex = TICK_ETERNITY; si->exp = TICK_ETERNITY; } /* note that if the task exists, it must unregister itself once it runs */ if (!(si->flags & SI_FL_DONT_WAKE) && si->owner) task_wakeup(si->owner, TASK_WOKEN_IO); }
CWE-189
9,887
16,642
168866335188442827935468307573088575127
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
static void stream_int_shutw_conn(struct stream_interface *si) { struct connection *conn = __objt_conn(si->end); si->ob->flags &= ~CF_SHUTW_NOW; if (si->ob->flags & CF_SHUTW) return; si->ob->flags |= CF_SHUTW; si->ob->wex = TICK_ETERNITY; si->flags &= ~SI_FL_WAIT_DATA; switch (si->state) { case SI_ST_EST: /* we have to shut before closing, otherwise some short messages * may never leave the system, especially when there are remaining * unread data in the socket input buffer, or when nolinger is set. * However, if SI_FL_NOLINGER is explicitly set, we know there is * no risk so we close both sides immediately. */ if (si->flags & SI_FL_ERR) { /* quick close, the socket is alredy shut anyway */ } else if (si->flags & SI_FL_NOLINGER) { /* unclean data-layer shutdown */ if (conn->xprt && conn->xprt->shutw) conn->xprt->shutw(conn, 0); } else { /* clean data-layer shutdown */ if (conn->xprt && conn->xprt->shutw) conn->xprt->shutw(conn, 1); /* If the stream interface is configured to disable half-open * connections, we'll skip the shutdown(), but only if the * read size is already closed. Otherwise we can't support * closed write with pending read (eg: abortonclose while * waiting for the server). */ if (!(si->flags & SI_FL_NOHALF) || !(si->ib->flags & (CF_SHUTR|CF_DONT_READ))) { /* We shutdown transport layer */ if (conn_ctrl_ready(conn)) shutdown(conn->t.sock.fd, SHUT_WR); if (!(si->ib->flags & (CF_SHUTR|CF_DONT_READ))) { /* OK just a shutw, but we want the caller * to disable polling on this FD if exists. */ if (conn->ctrl) conn_data_stop_send(conn); return; } } } /* fall through */ case SI_ST_CON: /* we may have to close a pending connection, and mark the * response buffer as shutr */ conn_full_close(conn); /* fall through */ case SI_ST_CER: case SI_ST_QUE: case SI_ST_TAR: si->state = SI_ST_DIS; /* fall through */ default: si->flags &= ~(SI_FL_WAIT_ROOM | SI_FL_NOLINGER); si->ib->flags &= ~CF_SHUTR_NOW; si->ib->flags |= CF_SHUTR; si->ib->rex = TICK_ETERNITY; si->exp = TICK_ETERNITY; } }
CWE-189
9,888
16,643
97472517591484329961933712741633876691
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
void stream_int_unregister_handler(struct stream_interface *si) { si_detach(si); }
CWE-189
9,889
16,644
204216124176024134848510606472192713013
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
static void stream_int_update_embedded(struct stream_interface *si) { int old_flags = si->flags; DPRINTF(stderr, "%s: si=%p, si->state=%d ib->flags=%08x ob->flags=%08x\n", __FUNCTION__, si, si->state, si->ib->flags, si->ob->flags); if (si->state != SI_ST_EST) return; if ((si->ob->flags & (CF_SHUTW|CF_SHUTW_NOW)) == CF_SHUTW_NOW && channel_is_empty(si->ob)) si_shutw(si); if ((si->ob->flags & (CF_SHUTW|CF_SHUTW_NOW)) == 0 && !channel_full(si->ob)) si->flags |= SI_FL_WAIT_DATA; /* we're almost sure that we need some space if the buffer is not * empty, even if it's not full, because the applets can't fill it. */ if ((si->ib->flags & (CF_SHUTR|CF_DONT_READ)) == 0 && !channel_is_empty(si->ib)) si->flags |= SI_FL_WAIT_ROOM; if (si->ob->flags & CF_WRITE_ACTIVITY) { if (tick_isset(si->ob->wex)) si->ob->wex = tick_add_ifset(now_ms, si->ob->wto); } if (si->ib->flags & CF_READ_ACTIVITY || (si->ob->flags & CF_WRITE_ACTIVITY && !(si->flags & SI_FL_INDEP_STR))) { if (tick_isset(si->ib->rex)) si->ib->rex = tick_add_ifset(now_ms, si->ib->rto); } /* save flags to detect changes */ old_flags = si->flags; if (likely((si->ob->flags & (CF_SHUTW|CF_WRITE_PARTIAL|CF_DONT_READ)) == CF_WRITE_PARTIAL && !channel_full(si->ob) && (si->ob->prod->flags & SI_FL_WAIT_ROOM))) si_chk_rcv(si->ob->prod); if (((si->ib->flags & CF_READ_PARTIAL) && !channel_is_empty(si->ib)) && (si->ib->cons->flags & SI_FL_WAIT_DATA)) { si_chk_snd(si->ib->cons); /* check if the consumer has freed some space */ if (!channel_full(si->ib)) si->flags &= ~SI_FL_WAIT_ROOM; } /* Note that we're trying to wake up in two conditions here : * - special event, which needs the holder task attention * - status indicating that the applet can go on working. This * is rather hard because we might be blocking on output and * don't want to wake up on input and vice-versa. The idea is * to only rely on the changes the chk_* might have performed. */ if (/* check stream interface changes */ ((old_flags & ~si->flags) & (SI_FL_WAIT_ROOM|SI_FL_WAIT_DATA)) || /* changes on the production side */ (si->ib->flags & (CF_READ_NULL|CF_READ_ERROR)) || si->state != SI_ST_EST || (si->flags & SI_FL_ERR) || ((si->ib->flags & CF_READ_PARTIAL) && (!si->ib->to_forward || si->ib->cons->state != SI_ST_EST)) || /* changes on the consumption side */ (si->ob->flags & (CF_WRITE_NULL|CF_WRITE_ERROR)) || ((si->ob->flags & CF_WRITE_ACTIVITY) && ((si->ob->flags & CF_SHUTW) || ((si->ob->flags & CF_WAKE_WRITE) && (si->ob->prod->state != SI_ST_EST || (channel_is_empty(si->ob) && !si->ob->to_forward)))))) { if (!(si->flags & SI_FL_DONT_WAKE) && si->owner) task_wakeup(si->owner, TASK_WOKEN_IO); } if (si->ib->flags & CF_READ_ACTIVITY) si->ib->flags &= ~CF_READ_DONTWAIT; }
CWE-189
9,890
16,645
69962292764006164956341714510968901736
null
null
null
haproxy
b4d05093bc89f71377230228007e69a1434c1a0c
0
void stream_sock_read0(struct stream_interface *si) { struct connection *conn = __objt_conn(si->end); si->ib->flags &= ~CF_SHUTR_NOW; if (si->ib->flags & CF_SHUTR) return; si->ib->flags |= CF_SHUTR; si->ib->rex = TICK_ETERNITY; si->flags &= ~SI_FL_WAIT_ROOM; if (si->state != SI_ST_EST && si->state != SI_ST_CON) return; if (si->ob->flags & CF_SHUTW) goto do_close; if (si->flags & SI_FL_NOHALF) { /* we want to immediately forward this close to the write side */ /* force flag on ssl to keep session in cache */ if (conn->xprt->shutw) conn->xprt->shutw(conn, 0); goto do_close; } /* otherwise that's just a normal read shutdown */ if (conn_ctrl_ready(conn)) fdtab[conn->t.sock.fd].linger_risk = 0; __conn_data_stop_recv(conn); return; do_close: /* OK we completely close the socket here just as if we went through si_shut[rw]() */ conn_full_close(conn); si->ib->flags &= ~CF_SHUTR_NOW; si->ib->flags |= CF_SHUTR; si->ib->rex = TICK_ETERNITY; si->ob->flags &= ~CF_SHUTW_NOW; si->ob->flags |= CF_SHUTW; si->ob->wex = TICK_ETERNITY; si->flags &= ~(SI_FL_WAIT_DATA | SI_FL_WAIT_ROOM); si->state = SI_ST_DIS; si->exp = TICK_ETERNITY; return; }
CWE-189
9,891
16,646
166947135910959992921930593699134786633
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList& args) : KParts::ReadWritePart(parent), m_splitter(Q_NULLPTR), m_busy(false), m_jobTracker(Q_NULLPTR) { Q_UNUSED(args) KAboutData aboutData(QStringLiteral("ark"), i18n("ArkPart"), QStringLiteral("3.0")); setComponentData(aboutData, false); new DndExtractAdaptor(this); const QString pathName = QStringLiteral("/DndExtract/%1").arg(s_instanceCounter++); if (!QDBusConnection::sessionBus().registerObject(pathName, this)) { qCCritical(ARK) << "Could not register a D-Bus object for drag'n'drop"; } QWidget *mainWidget = new QWidget; m_vlayout = new QVBoxLayout; m_model = new ArchiveModel(pathName, this); m_splitter = new QSplitter(Qt::Horizontal, parentWidget); m_view = new ArchiveView; m_infoPanel = new InfoPanel(m_model); m_commentView = new QPlainTextEdit(); m_commentView->setReadOnly(true); m_commentView->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); m_commentBox = new QGroupBox(i18n("Comment")); m_commentBox->hide(); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(m_commentView); m_commentBox->setLayout(vbox); m_messageWidget = new KMessageWidget(parentWidget); m_messageWidget->setWordWrap(true); m_messageWidget->hide(); m_commentMsgWidget = new KMessageWidget(); m_commentMsgWidget->setText(i18n("Comment has been modified.")); m_commentMsgWidget->setMessageType(KMessageWidget::Information); m_commentMsgWidget->setCloseButtonVisible(false); m_commentMsgWidget->hide(); QAction *saveAction = new QAction(i18n("Save"), m_commentMsgWidget); m_commentMsgWidget->addAction(saveAction); connect(saveAction, &QAction::triggered, this, &Part::slotAddComment); m_commentBox->layout()->addWidget(m_commentMsgWidget); connect(m_commentView, &QPlainTextEdit::textChanged, this, &Part::slotCommentChanged); setWidget(mainWidget); mainWidget->setLayout(m_vlayout); m_vlayout->setContentsMargins(0,0,0,0); m_vlayout->addWidget(m_messageWidget); m_vlayout->addWidget(m_splitter); m_commentSplitter = new QSplitter(Qt::Vertical, parentWidget); m_commentSplitter->setOpaqueResize(false); m_commentSplitter->addWidget(m_view); m_commentSplitter->addWidget(m_commentBox); m_commentSplitter->setCollapsible(0, false); m_splitter->addWidget(m_commentSplitter); m_splitter->addWidget(m_infoPanel); if (!ArkSettings::showInfoPanel()) { m_infoPanel->hide(); } else { m_splitter->setSizes(ArkSettings::splitterSizes()); } setupView(); setupActions(); connect(m_view, &ArchiveView::entryChanged, this, &Part::slotRenameFile); connect(m_model, &ArchiveModel::loadingStarted, this, &Part::slotLoadingStarted); connect(m_model, &ArchiveModel::loadingFinished, this, &Part::slotLoadingFinished); connect(m_model, &ArchiveModel::droppedFiles, this, static_cast<void (Part::*)(const QStringList&, const Archive::Entry*, const QString&)>(&Part::slotAddFiles)); connect(m_model, &ArchiveModel::error, this, &Part::slotError); connect(m_model, &ArchiveModel::messageWidget, this, &Part::displayMsgWidget); connect(this, &Part::busy, this, &Part::setBusyGui); connect(this, &Part::ready, this, &Part::setReadyGui); connect(this, static_cast<void (KParts::ReadOnlyPart::*)()>(&KParts::ReadOnlyPart::completed), this, &Part::setFileNameFromArchive); m_statusBarExtension = new KParts::StatusBarExtension(this); setXMLFile(QStringLiteral("ark_part.rc")); }
CWE-78
9,892
16,647
251468034058775189618177406677764149431
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
QModelIndexList Part::addChildren(const QModelIndexList &list) const { Q_ASSERT(m_model); QModelIndexList ret = list; for (int i = 0; i < ret.size(); ++i) { QModelIndex index = ret.at(i); for (int j = 0; j < m_model->rowCount(index); ++j) { QModelIndex child = m_model->index(j, 0, index); if (!ret.contains(child)) { ret << child; } } } return ret; }
CWE-78
9,893
16,648
331206385497380652851308231856413780004
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
KConfigSkeleton *Part::config() const { return ArkSettings::self(); }
CWE-78
9,894
16,649
201749481635651974056047842332516652223
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
bool Part::confirmAndDelete(const QString &targetFile) { QFileInfo targetInfo(targetFile); const auto buttonCode = KMessageBox::warningYesNo(widget(), xi18nc("@info", "The archive <filename>%1</filename> already exists. Do you wish to overwrite it?", targetInfo.fileName()), i18nc("@title:window", "File Exists"), KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()); if (buttonCode != KMessageBox::Yes || !targetInfo.isWritable()) { return false; } qCDebug(ARK) << "Removing file" << targetFile; return QFile(targetFile).remove(); }
CWE-78
9,895
16,650
221977610546509241265021250426078950649
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::createArchive() { const QString fixedMimeType = arguments().metaData()[QStringLiteral("fixedMimeType")]; m_model->createEmptyArchive(localFilePath(), fixedMimeType, m_model); if (arguments().metaData().contains(QStringLiteral("volumeSize"))) { m_model->archive()->setMultiVolume(true); } const QString password = arguments().metaData()[QStringLiteral("encryptionPassword")]; if (!password.isEmpty()) { m_model->encryptArchive(password, arguments().metaData()[QStringLiteral("encryptHeader")] == QLatin1String("true")); } updateActions(); m_view->setDropsEnabled(true); }
CWE-78
9,896
16,651
95379347884272814435595234451991166472
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
QString Part::detectSubfolder() const { if (!m_model) { return QString(); } return m_model->archive()->subfolderName(); }
CWE-78
9,897
16,652
134109075615103606994589711749154843537
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::displayMsgWidget(KMessageWidget::MessageType type, const QString& msg) { m_messageWidget->hide(); m_messageWidget->setText(msg); m_messageWidget->setMessageType(type); m_messageWidget->animatedShow(); }
CWE-78
9,898
16,653
202055690159534472302972530961011765214
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::extractSelectedFilesTo(const QString& localPath) { if (!m_model) { return; } const QUrl url = QUrl::fromUserInput(localPath, QString()); KIO::StatJob* statJob = nullptr; if (!url.isLocalFile() && !url.scheme().isEmpty()) { statJob = KIO::mostLocalUrl(url); if (!statJob->exec() || statJob->error() != 0) { return; } } const QString destination = statJob ? statJob->statResult().stringValue(KIO::UDSEntry::UDS_LOCAL_PATH) : localPath; delete statJob; if (!url.isLocalFile() && destination.isEmpty()) { qCWarning(ARK) << "Ark cannot extract to non-local destination:" << localPath; KMessageBox::sorry(widget(), xi18nc("@info", "Ark can only extract to local destinations.")); return; } qCDebug(ARK) << "Extract to" << destination; Kerfuffle::ExtractionOptions options; options.setDragAndDropEnabled(true); ExtractJob *job = m_model->extractFiles(filesAndRootNodesForIndexes(addChildren(m_view->selectionModel()->selectedRows())), destination, options); registerJob(job); connect(job, &KJob::result, this, &Part::slotExtractionDone); job->start(); }
CWE-78
9,899
16,654
337326601073562327295210386022420721440
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
QVector<Kerfuffle::Archive::Entry*> Part::filesAndRootNodesForIndexes(const QModelIndexList& list) const { QVector<Kerfuffle::Archive::Entry*> fileList; QStringList fullPathsList; foreach (const QModelIndex& index, list) { QModelIndex selectionRoot = index.parent(); while (m_view->selectionModel()->isSelected(selectionRoot) || list.contains(selectionRoot)) { selectionRoot = selectionRoot.parent(); } const QString rootFileName = selectionRoot.isValid() ? m_model->entryForIndex(selectionRoot)->fullPath() : QString(); QModelIndexList alist = QModelIndexList() << index; foreach (Archive::Entry *entry, filesForIndexes(alist)) { const QString fullPath = entry->fullPath(); if (!fullPathsList.contains(fullPath)) { entry->rootNode = rootFileName; fileList.append(entry); fullPathsList.append(fullPath); } } } return fileList; }
CWE-78
9,900
16,655
124645271099178354267582243124560098323
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
QVector<Archive::Entry*> Part::filesForIndexes(const QModelIndexList& list) const { QVector<Archive::Entry*> ret; foreach(const QModelIndex& index, list) { ret << m_model->entryForIndex(index); } return ret; }
CWE-78
9,901
16,656
3194488017731978974805315018480434163
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::guiActivateEvent(KParts::GUIActivateEvent *event) { Q_UNUSED(event) }
CWE-78
9,902
16,657
268184291205119231814846075159239637493
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
bool Part::isBusy() const { return m_busy; }
CWE-78
9,903
16,658
232151582637560430416244844631899134911
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
bool Part::isLocalFileValid() { const QString localFile = localFilePath(); const QFileInfo localFileInfo(localFile); const bool creatingNewArchive = arguments().metaData()[QStringLiteral("createNewArchive")] == QLatin1String("true"); if (localFileInfo.isDir()) { displayMsgWidget(KMessageWidget::Error, xi18nc("@info", "<filename>%1</filename> is a directory.", localFile)); return false; } if (creatingNewArchive) { if (localFileInfo.exists()) { if (!confirmAndDelete(localFile)) { displayMsgWidget(KMessageWidget::Error, xi18nc("@info", "Could not overwrite <filename>%1</filename>. Check whether you have write permission.", localFile)); return false; } } displayMsgWidget(KMessageWidget::Information, xi18nc("@info", "The archive <filename>%1</filename> will be created as soon as you add a file.", localFile)); } else { if (!localFileInfo.exists()) { displayMsgWidget(KMessageWidget::Error, xi18nc("@info", "The archive <filename>%1</filename> was not found.", localFile)); return false; } if (!localFileInfo.isReadable()) { displayMsgWidget(KMessageWidget::Error, xi18nc("@info", "The archive <filename>%1</filename> could not be loaded, as it was not possible to read from it.", localFile)); return false; } } return true; }
CWE-78
9,904
16,659
122623617478436056215288694814243840510
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
bool Part::isSingleFolderArchive() const { return m_model->archive()->isSingleFolder(); }
CWE-78
9,905
16,660
255153970750368712403354263564359703320
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::loadArchive() { const QString fixedMimeType = arguments().metaData()[QStringLiteral("fixedMimeType")]; auto job = m_model->loadArchive(localFilePath(), fixedMimeType, m_model); if (job) { registerJob(job); job->start(); } else { updateActions(); } }
CWE-78
9,906
16,661
337187212192758451114229563299984193296
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
bool Part::openFile() { qCDebug(ARK) << "Attempting to open archive" << localFilePath(); resetGui(); if (!isLocalFileValid()) { return false; } const bool creatingNewArchive = arguments().metaData()[QStringLiteral("createNewArchive")] == QLatin1String("true"); if (creatingNewArchive) { createArchive(); } else { loadArchive(); } return true; }
CWE-78
9,907
16,662
76369592583999329456199202292568070340
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::registerJob(KJob* job) { if (!m_jobTracker) { m_jobTracker = new JobTracker(widget()); m_statusBarExtension->addStatusBarItem(m_jobTracker->widget(0), 0, true); m_jobTracker->widget(job)->show(); } m_jobTracker->registerJob(job); emit busy(); connect(job, &KJob::result, this, &Part::ready); }
CWE-78
9,908
16,663
337785651142644537092072386528846242478
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::resetGui() { m_messageWidget->hide(); m_commentView->clear(); m_commentBox->hide(); m_infoPanel->setIndex(QModelIndex()); m_compressionOptions = CompressionOptions(); }
CWE-78
9,909
16,664
39020248617986066619787863059255793778
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
bool Part::saveFile() { return true; }
CWE-78
9,910
16,665
295245351582778437853482322816268761795
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::selectionChanged() { m_infoPanel->setIndexes(m_view->selectionModel()->selectedRows()); }
CWE-78
9,911
16,666
58485768481358752711454362076224152026
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::setFileNameFromArchive() { const QString prettyName = url().fileName(); m_infoPanel->setPrettyFileName(prettyName); m_infoPanel->updateWithDefaults(); emit setWindowCaption(prettyName); }
CWE-78
9,912
16,667
93654102534329153398513781993348387225
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::setReadyGui() { QApplication::restoreOverrideCursor(); m_busy = false; if (m_statusBarExtension->statusBar()) { m_statusBarExtension->statusBar()->hide(); } m_view->setEnabled(true); updateActions(); }
CWE-78
9,913
16,668
249884088607259021965072771623259146501
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
QList<Kerfuffle::SettingsPage*> Part::settingsPages(QWidget *parent) const { QList<SettingsPage*> pages; pages.append(new GeneralSettingsPage(parent, i18nc("@title:tab", "General Settings"), QStringLiteral("go-home"))); pages.append(new ExtractionSettingsPage(parent, i18nc("@title:tab", "Extraction Settings"), QStringLiteral("archive-extract"))); pages.append(new PreviewSettingsPage(parent, i18nc("@title:tab", "Preview Settings"), QStringLiteral("document-preview-archive"))); return pages; }
CWE-78
9,914
16,669
20244579530741860704162514457606832467
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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); }
CWE-78
9,915
16,670
205920556013402330460171641351876148797
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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); }
CWE-78
9,916
16,671
273822624414863574922228791867321401158
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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); } }
CWE-78
9,917
16,672
85342590545574111033304177070472746760
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); } }
CWE-78
9,918
16,673
150078216208209497940503507719288460442
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::slotAddFiles(const QStringList& filesToAdd, const Archive::Entry *destination, const QString &relPath) { if (!m_model->archive() || filesToAdd.isEmpty()) { return; } QStringList withChildPaths; foreach (const QString& file, filesToAdd) { m_jobTempEntries.push_back(new Archive::Entry(Q_NULLPTR, file)); if (QFileInfo(file).isDir()) { withChildPaths << file + QLatin1Char('/'); QDirIterator it(file, QDir::AllEntries | QDir::Readable | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); while (it.hasNext()) { QString path = it.next(); if (it.fileInfo().isDir()) { path += QLatin1Char('/'); } withChildPaths << path; } } else { withChildPaths << file; } } withChildPaths = ReadOnlyArchiveInterface::entryPathsFromDestination(withChildPaths, destination, 0); QList<const Archive::Entry*> conflictingEntries; bool error = m_model->conflictingEntries(conflictingEntries, withChildPaths, true); 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) { qDeleteAll(m_jobTempEntries); m_jobTempEntries.clear(); return; } } QString globalWorkDir = filesToAdd.first(); if (!relPath.isEmpty()) { globalWorkDir.remove(relPath); qCDebug(ARK) << "Adding" << filesToAdd << "to" << relPath; } else { qCDebug(ARK) << "Adding " << filesToAdd << ((destination == Q_NULLPTR) ? QString() : QStringLiteral("to ") + destination->fullPath()); } if (globalWorkDir.right(1) == QLatin1String("/")) { globalWorkDir.chop(1); } CompressionOptions compOptions = m_compressionOptions; globalWorkDir = QFileInfo(globalWorkDir).dir().absolutePath(); qCDebug(ARK) << "Detected GlobalWorkDir to be " << globalWorkDir; compOptions.setGlobalWorkDir(globalWorkDir); AddJob *job = m_model->addFiles(m_jobTempEntries, destination, compOptions); if (!job) { qDeleteAll(m_jobTempEntries); m_jobTempEntries.clear(); return; } connect(job, &KJob::result, this, &Part::slotAddFilesDone); registerJob(job); job->start(); }
CWE-78
9,919
16,674
189379588791022574542641342216241824376
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::slotAddFilesDone(KJob* job) { qDeleteAll(m_jobTempEntries); m_jobTempEntries.clear(); if (job->error() && job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); } else { m_messageWidget->hide(); if (m_model->archive()->isMultiVolume()) { qCDebug(ARK) << "Multi-volume archive detected, re-opening..."; KParts::OpenUrlArguments args = arguments(); args.metaData()[QStringLiteral("createNewArchive")] = QStringLiteral("false"); setArguments(args); openUrl(QUrl::fromLocalFile(m_model->archive()->multiVolumeName())); } } m_cutIndexes.clear(); m_model->filesToMove.clear(); m_model->filesToCopy.clear(); }
CWE-78
9,921
16,675
236183445773498997591632858284153624723
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); } }
CWE-78
9,922
16,676
210766502926358419401880927164718272782
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); }
CWE-78
9,923
16,677
331015044188167786492182747794992857705
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); }
CWE-78
9,925
16,678
206718776533498492510107543477638431658
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); }
CWE-78
9,926
16,679
306607895263864702420449051215797720772
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::slotEditFileName() { QModelIndex currentIndex = m_view->selectionModel()->currentIndex(); currentIndex = (currentIndex.parent().isValid()) ? currentIndex.parent().child(currentIndex.row(), 0) : m_model->index(currentIndex.row(), 0); m_view->openEntryEditor(currentIndex); }
CWE-78
9,927
16,680
219412717134370973246845892342084751838
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::slotError(const QString& errorMessage, const QString& details) { if (details.isEmpty()) { KMessageBox::error(widget(), errorMessage); } else { KMessageBox::detailedError(widget(), errorMessage, details); } }
CWE-78
9,928
16,681
236236345399879333588037787319234880741
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::slotExtractArchive() { if (m_view->selectionModel()->selectedRows().count() > 0) { m_view->selectionModel()->clear(); } slotShowExtractionDialog(); }
CWE-78
9,929
16,682
116875489443600606983944055908298001408
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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); } }
CWE-78
9,931
16,683
65180666147236510339060842475232011148
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::slotLoadingStarted() { m_model->filesToMove.clear(); m_model->filesToCopy.clear(); }
CWE-78
9,932
16,684
294968719249401630456566979359018974168
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); } }
CWE-78
9,933
16,685
313611442854563008486945927943506684056
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); }
CWE-78
9,934
16,686
70927575475231607805171936400039031150
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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; } }
CWE-78
9,935
16,687
91346977806768363927399919355815085669
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); }
CWE-78
9,936
16,688
120536190608235735528550202482499138330
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); }
CWE-78
9,937
16,689
33678586226890668447597157425589395580
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); } }
CWE-78
9,938
16,690
84042918451698742959268264512918997777
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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); }
CWE-78
9,939
16,691
29103770260471560059831607587661819512
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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())); } } }
CWE-78
9,940
16,692
107869376159393555341666326888175158027
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
void Part::slotShowContextMenu() { if (!factory()) { return; } QMenu *popup = static_cast<QMenu *>(factory()->container(QStringLiteral("context_menu"), this)); popup->popup(QCursor::pos()); }
CWE-78
9,941
16,693
158993356255057291403110931446060784120
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); }
CWE-78
9,942
16,694
246745807302693094413536035550582400514
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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")); } }
CWE-78
9,945
16,695
135006033156209346347729431076208123117
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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(); } }
CWE-78
9,946
16,696
48169798124784175104638689158234959271
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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); }
CWE-78
9,947
16,697
146675568808700331420860382375583249307
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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")); } }
CWE-78
9,948
16,698
283531091775457220216771265891276771018
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
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); } } }
CWE-78
9,949
16,699
240874699117064236693136835106540147833
null
null
null
kde
82fdfd24d46966a117fa625b68784735a40f9065
0
Part::~Part() { qDeleteAll(m_tmpExtractDirList); if (m_showInfoPanelAction->isChecked()) { ArkSettings::setSplitterSizes(m_splitter->sizes()); } ArkSettings::setShowInfoPanel(m_showInfoPanelAction->isChecked()); ArkSettings::self()->save(); m_extractArchiveAction->menu()->deleteLater(); m_extractAction->menu()->deleteLater(); }
CWE-78
9,950
16,700
118849620974151511902799719925245405227
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Compute_Funcs( EXEC_OP ) { #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING if ( CUR.face->unpatented_hinting ) { /* If both vectors point rightwards along the x axis, set */ /* `both-x-axis' true, otherwise set it false. The x values only */ /* need be tested because the vector has been normalised to a unit */ /* vector of length 0x4000 = unity. */ CUR.GS.both_x_axis = (FT_Bool)( CUR.GS.projVector.x == 0x4000 && CUR.GS.freeVector.x == 0x4000 ); /* Throw away projection and freedom vector information */ /* because the patents don't allow them to be stored. */ /* The relevant US Patents are 5155805 and 5325479. */ CUR.GS.projVector.x = 0; CUR.GS.projVector.y = 0; CUR.GS.freeVector.x = 0; CUR.GS.freeVector.y = 0; if ( CUR.GS.both_x_axis ) { CUR.func_project = Project_x; CUR.func_move = Direct_Move_X; CUR.func_move_orig = Direct_Move_Orig_X; } else { CUR.func_project = Project_y; CUR.func_move = Direct_Move_Y; CUR.func_move_orig = Direct_Move_Orig_Y; } if ( CUR.GS.dualVector.x == 0x4000 ) CUR.func_dualproj = Project_x; else { if ( CUR.GS.dualVector.y == 0x4000 ) CUR.func_dualproj = Project_y; else CUR.func_dualproj = Dual_Project; } /* Force recalculation of cached aspect ratio */ CUR.tt_metrics.ratio = 0; return; } #endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING */ if ( CUR.GS.freeVector.x == 0x4000 ) CUR.F_dot_P = CUR.GS.projVector.x * 0x10000L; else { if ( CUR.GS.freeVector.y == 0x4000 ) CUR.F_dot_P = CUR.GS.projVector.y * 0x10000L; else CUR.F_dot_P = (FT_Long)CUR.GS.projVector.x * CUR.GS.freeVector.x * 4 + (FT_Long)CUR.GS.projVector.y * CUR.GS.freeVector.y * 4; } if ( CUR.GS.projVector.x == 0x4000 ) CUR.func_project = (TT_Project_Func)Project_x; else { if ( CUR.GS.projVector.y == 0x4000 ) CUR.func_project = (TT_Project_Func)Project_y; else CUR.func_project = (TT_Project_Func)Project; } if ( CUR.GS.dualVector.x == 0x4000 ) CUR.func_dualproj = (TT_Project_Func)Project_x; else { if ( CUR.GS.dualVector.y == 0x4000 ) CUR.func_dualproj = (TT_Project_Func)Project_y; else CUR.func_dualproj = (TT_Project_Func)Dual_Project; } CUR.func_move = (TT_Move_Func)Direct_Move; CUR.func_move_orig = (TT_Move_Func)Direct_Move_Orig; if ( CUR.F_dot_P == 0x40000000L ) { if ( CUR.GS.freeVector.x == 0x4000 ) { CUR.func_move = (TT_Move_Func)Direct_Move_X; CUR.func_move_orig = (TT_Move_Func)Direct_Move_Orig_X; } else { if ( CUR.GS.freeVector.y == 0x4000 ) { CUR.func_move = (TT_Move_Func)Direct_Move_Y; CUR.func_move_orig = (TT_Move_Func)Direct_Move_Orig_Y; } } } /* at small sizes, F_dot_P can become too small, resulting */ /* in overflows and `spikes' in a number of glyphs like `w'. */ if ( FT_ABS( CUR.F_dot_P ) < 0x4000000L ) CUR.F_dot_P = 0x40000000L; /* Disable cached aspect ratio */ CUR.tt_metrics.ratio = 0; }
CWE-119
10,071
16,772
147774501879270555514624221111055930823
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Compute_Point_Displacement( EXEC_OP_ FT_F26Dot6* x, FT_F26Dot6* y, TT_GlyphZone zone, FT_UShort* refp ) { TT_GlyphZoneRec zp; FT_UShort p; FT_F26Dot6 d; if ( CUR.opcode & 1 ) { zp = CUR.zp0; p = CUR.GS.rp1; } else { zp = CUR.zp1; p = CUR.GS.rp2; } if ( BOUNDS( p, zp.n_points ) ) { if ( CUR.pedantic_hinting ) CUR.error = TT_Err_Invalid_Reference; *refp = 0; return FAILURE; } *zone = zp; *refp = p; d = CUR_Func_project( zp.cur + p, zp.org + p ); #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING if ( CUR.face->unpatented_hinting ) { if ( CUR.GS.both_x_axis ) { *x = d; *y = 0; } else { *x = 0; *y = d; } } else #endif { *x = TT_MULDIV( d, (FT_Long)CUR.GS.freeVector.x * 0x10000L, CUR.F_dot_P ); *y = TT_MULDIV( d, (FT_Long)CUR.GS.freeVector.y * 0x10000L, CUR.F_dot_P ); } return SUCCESS; }
CWE-119
10,072
16,773
69573323490834917989823328789723692317
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Compute_Round( EXEC_OP_ FT_Byte round_mode ) { switch ( round_mode ) { case TT_Round_Off: CUR.func_round = (TT_Round_Func)Round_None; break; case TT_Round_To_Grid: CUR.func_round = (TT_Round_Func)Round_To_Grid; break; case TT_Round_Up_To_Grid: CUR.func_round = (TT_Round_Func)Round_Up_To_Grid; break; case TT_Round_Down_To_Grid: CUR.func_round = (TT_Round_Func)Round_Down_To_Grid; break; case TT_Round_To_Half_Grid: CUR.func_round = (TT_Round_Func)Round_To_Half_Grid; break; case TT_Round_To_Double_Grid: CUR.func_round = (TT_Round_Func)Round_To_Double_Grid; break; case TT_Round_Super: CUR.func_round = (TT_Round_Func)Round_Super; break; case TT_Round_Super_45: CUR.func_round = (TT_Round_Func)Round_Super_45; break; } }
CWE-119
10,073
16,774
118887187068887479134313562917626217543
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Current_Ppem( EXEC_OP ) { return TT_MULFIX( CUR.tt_metrics.ppem, CURRENT_Ratio() ); }
CWE-119
10,074
16,775
234450057747079670913917230282597449107
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Direct_Move( EXEC_OP_ TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { FT_F26Dot6 v; #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING FT_ASSERT( !CUR.face->unpatented_hinting ); #endif v = CUR.GS.freeVector.x; if ( v != 0 ) { zone->cur[point].x += TT_MULDIV( distance, v * 0x10000L, CUR.F_dot_P ); zone->tags[point] |= FT_CURVE_TAG_TOUCH_X; } v = CUR.GS.freeVector.y; if ( v != 0 ) { zone->cur[point].y += TT_MULDIV( distance, v * 0x10000L, CUR.F_dot_P ); zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y; } }
CWE-119
10,075
16,776
173075100007308216730919262098712897919
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Direct_Move_Orig( EXEC_OP_ TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { FT_F26Dot6 v; #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING FT_ASSERT( !CUR.face->unpatented_hinting ); #endif v = CUR.GS.freeVector.x; if ( v != 0 ) zone->org[point].x += TT_MULDIV( distance, v * 0x10000L, CUR.F_dot_P ); v = CUR.GS.freeVector.y; if ( v != 0 ) zone->org[point].y += TT_MULDIV( distance, v * 0x10000L, CUR.F_dot_P ); }
CWE-119
10,076
16,777
115328060235239448032630523239872238350
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Direct_Move_Orig_X( EXEC_OP_ TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { FT_UNUSED_EXEC; zone->org[point].x += distance; }
CWE-119
10,077
16,778
149890833964219746204889438813835044261
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Direct_Move_Orig_Y( EXEC_OP_ TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { FT_UNUSED_EXEC; zone->org[point].y += distance; }
CWE-119
10,078
16,779
202693659171452472095211804165368941917
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Direct_Move_Y( EXEC_OP_ TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { FT_UNUSED_EXEC; zone->cur[point].y += distance; zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y; }
CWE-119
10,079
16,780
138549412100293145220545168086668231825
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Dual_Project( EXEC_OP_ FT_Pos dx, FT_Pos dy ) { return TT_DotFix14( (FT_UInt32)dx, (FT_UInt32)dy, CUR.GS.dualVector.x, CUR.GS.dualVector.y ); }
CWE-119
10,080
16,781
253557196161345528796194654339655398806
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
GetShortIns( EXEC_OP ) { /* Reading a byte stream so there is no endianess (DaveP) */ CUR.IP += 2; return (FT_Short)( ( CUR.code[CUR.IP - 2] << 8 ) + CUR.code[CUR.IP - 1] ); }
CWE-119
10,081
16,782
54436406764873558443206920183491578201
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_ABS( INS_ARG ) { DO_ABS }
CWE-119
10,083
16,783
3152149191227371469609108696859409612
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_ADD( INS_ARG ) { DO_ADD }
CWE-119
10,084
16,784
180646341201924163000630302587760353199
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_ALIGNPTS( INS_ARG ) { FT_UShort p1, p2; FT_F26Dot6 distance; p1 = (FT_UShort)args[0]; p2 = (FT_UShort)args[1]; if ( BOUNDS( args[0], CUR.zp1.n_points ) || BOUNDS( args[1], CUR.zp0.n_points ) ) { if ( CUR.pedantic_hinting ) CUR.error = TT_Err_Invalid_Reference; return; } distance = CUR_Func_project( CUR.zp0.cur + p2, CUR.zp1.cur + p1 ) / 2; CUR_Func_move( &CUR.zp1, p1, distance ); CUR_Func_move( &CUR.zp0, p2, -distance ); }
CWE-119
10,085
16,785
235056026014116507700973071437676713509
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_ALIGNRP( INS_ARG ) { FT_UShort point; FT_F26Dot6 distance; FT_UNUSED_ARG; if ( CUR.top < CUR.GS.loop || BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) ) { if ( CUR.pedantic_hinting ) CUR.error = TT_Err_Invalid_Reference; return; } while ( CUR.GS.loop > 0 ) { CUR.args--; point = (FT_UShort)CUR.stack[CUR.args]; if ( BOUNDS( point, CUR.zp1.n_points ) ) { if ( CUR.pedantic_hinting ) { CUR.error = TT_Err_Invalid_Reference; return; } } else { distance = CUR_Func_project( CUR.zp1.cur + point, CUR.zp0.cur + CUR.GS.rp0 ); CUR_Func_move( &CUR.zp1, point, -distance ); } CUR.GS.loop--; } CUR.GS.loop = 1; CUR.new_top = CUR.args; }
CWE-119
10,086
16,786
118441631930269958926753469261967998096
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_AND( INS_ARG ) { DO_AND }
CWE-119
10,087
16,787
43636974186518355845957324545542794424
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_CALL( INS_ARG ) { FT_ULong F; TT_CallRec* pCrec; TT_DefRecord* def; /* first of all, check the index */ F = args[0]; if ( BOUNDS( F, CUR.maxFunc + 1 ) ) goto Fail; /* Except for some old Apple fonts, all functions in a TrueType */ /* font are defined in increasing order, starting from 0. This */ /* means that we normally have */ /* */ /* CUR.maxFunc+1 == CUR.numFDefs */ /* CUR.FDefs[n].opc == n for n in 0..CUR.maxFunc */ /* */ /* If this isn't true, we need to look up the function table. */ def = CUR.FDefs + F; if ( CUR.maxFunc + 1 != CUR.numFDefs || def->opc != F ) { /* look up the FDefs table */ TT_DefRecord* limit; def = CUR.FDefs; limit = def + CUR.numFDefs; while ( def < limit && def->opc != F ) def++; if ( def == limit ) goto Fail; } /* check that the function is active */ if ( !def->active ) goto Fail; /* check the call stack */ if ( CUR.callTop >= CUR.callSize ) { CUR.error = TT_Err_Stack_Overflow; return; } pCrec = CUR.callStack + CUR.callTop; pCrec->Caller_Range = CUR.curRange; pCrec->Caller_IP = CUR.IP + 1; pCrec->Cur_Count = 1; pCrec->Cur_Restart = def->start; CUR.callTop++; INS_Goto_CodeRange( def->range, def->start ); CUR.step_ins = FALSE; return; Fail: CUR.error = TT_Err_Invalid_Reference; }
CWE-119
10,088
16,788
163954103415549823729090921731479964301
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_CEILING( INS_ARG ) { DO_CEILING }
CWE-119
10,089
16,789
275651053594954059933705009890560256465
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_CINDEX( INS_ARG ) { DO_CINDEX }
CWE-119
10,090
16,790
47694059742221437398242543012058971064
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_CLEAR( INS_ARG ) { DO_CLEAR }
CWE-119
10,091
16,791
213117548065931832865908725891283306577
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_DEBUG( INS_ARG ) { DO_DEBUG }
CWE-119
10,092
16,792
196150324400191398278446319038181589739
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_DELTAC( INS_ARG ) { FT_ULong nump, k; FT_ULong A, C; FT_Long B; #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING /* Delta hinting is covered by US Patent 5159668. */ if ( CUR.face->unpatented_hinting ) { FT_Long n = args[0] * 2; if ( CUR.args < n ) { CUR.error = TT_Err_Too_Few_Arguments; return; } CUR.args -= n; CUR.new_top = CUR.args; return; } #endif nump = (FT_ULong)args[0]; for ( k = 1; k <= nump; k++ ) { if ( CUR.args < 2 ) { CUR.error = TT_Err_Too_Few_Arguments; return; } CUR.args -= 2; A = (FT_ULong)CUR.stack[CUR.args + 1]; B = CUR.stack[CUR.args]; if ( BOUNDS( A, CUR.cvtSize ) ) { if ( CUR.pedantic_hinting ) { CUR.error = TT_Err_Invalid_Reference; return; } } else { C = ( (FT_ULong)B & 0xF0 ) >> 4; switch ( CUR.opcode ) { case 0x73: break; case 0x74: C += 16; break; case 0x75: C += 32; break; } C += CUR.GS.delta_base; if ( CURRENT_Ppem() == (FT_Long)C ) { B = ( (FT_ULong)B & 0xF ) - 8; if ( B >= 0 ) B++; B = B * 64 / ( 1L << CUR.GS.delta_shift ); CUR_Func_move_cvt( A, B ); } } } CUR.new_top = CUR.args; }
CWE-119
10,093
16,793
31870655262835918040304695027292424170
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_DELTAP( INS_ARG ) { FT_ULong k, nump; FT_UShort A; FT_ULong C; FT_Long B; #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING /* Delta hinting is covered by US Patent 5159668. */ if ( CUR.face->unpatented_hinting ) { FT_Long n = args[0] * 2; if ( CUR.args < n ) { CUR.error = TT_Err_Too_Few_Arguments; return; } CUR.args -= n; CUR.new_top = CUR.args; return; } #endif nump = (FT_ULong)args[0]; /* some points theoretically may occur more than once, thus UShort isn't enough */ for ( k = 1; k <= nump; k++ ) { if ( CUR.args < 2 ) { CUR.error = TT_Err_Too_Few_Arguments; return; } CUR.args -= 2; A = (FT_UShort)CUR.stack[CUR.args + 1]; B = CUR.stack[CUR.args]; /* XXX: Because some popular fonts contain some invalid DeltaP */ /* instructions, we simply ignore them when the stacked */ /* point reference is off limit, rather than returning an */ /* error. As a delta instruction doesn't change a glyph */ /* in great ways, this shouldn't be a problem. */ if ( !BOUNDS( A, CUR.zp0.n_points ) ) { C = ( (FT_ULong)B & 0xF0 ) >> 4; switch ( CUR.opcode ) { case 0x5D: break; case 0x71: C += 16; break; case 0x72: C += 32; break; } C += CUR.GS.delta_base; if ( CURRENT_Ppem() == (FT_Long)C ) { B = ( (FT_ULong)B & 0xF ) - 8; if ( B >= 0 ) B++; B = B * 64 / ( 1L << CUR.GS.delta_shift ); CUR_Func_move( &CUR.zp0, A, B ); } } else if ( CUR.pedantic_hinting ) CUR.error = TT_Err_Invalid_Reference; } CUR.new_top = CUR.args; }
CWE-119
10,094
16,794
22186881185493677874023720151968872250
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_DEPTH( INS_ARG ) { DO_DEPTH }
CWE-119
10,095
16,795
286136067489831896876719358764889611995
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_DIV( INS_ARG ) { DO_DIV }
CWE-119
10,096
16,796
295457019904008232004086527654940199937
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_EIF( INS_ARG ) { /* nothing to do */ }
CWE-119
10,098
16,797
75558262218112035070350663277839274073
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_ELSE( INS_ARG ) { FT_Int nIfs; FT_UNUSED_ARG; nIfs = 1; do { if ( SKIP_Code() == FAILURE ) return; switch ( CUR.opcode ) { case 0x58: /* IF */ nIfs++; break; case 0x59: /* EIF */ nIfs--; break; } } while ( nIfs != 0 ); }
CWE-119
10,099
16,798
129730768623938990273007240545596926929
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_ENDF( INS_ARG ) { TT_CallRec* pRec; FT_UNUSED_ARG; if ( CUR.callTop <= 0 ) /* We encountered an ENDF without a call */ { CUR.error = TT_Err_ENDF_In_Exec_Stream; return; } CUR.callTop--; pRec = &CUR.callStack[CUR.callTop]; pRec->Cur_Count--; CUR.step_ins = FALSE; if ( pRec->Cur_Count > 0 ) { CUR.callTop++; CUR.IP = pRec->Cur_Restart; } else /* Loop through the current function */ INS_Goto_CodeRange( pRec->Caller_Range, pRec->Caller_IP ); /* Exit the current call frame. */ /* NOTE: If the last instruction of a program is a */ /* CALL or LOOPCALL, the return address is */ /* always out of the code range. This is a */ /* valid address, and it is why we do not test */ /* the result of Ins_Goto_CodeRange() here! */ }
CWE-119
10,100
16,799
209506411270458118004872474577523073276
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_EVEN( INS_ARG ) { DO_EVEN }
CWE-119
10,102
16,800
33924159045430981255452911127899935091
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_FLIPPT( INS_ARG ) { FT_UShort point; FT_UNUSED_ARG; if ( CUR.top < CUR.GS.loop ) { CUR.error = TT_Err_Too_Few_Arguments; return; } while ( CUR.GS.loop > 0 ) { CUR.args--; point = (FT_UShort)CUR.stack[CUR.args]; if ( BOUNDS( point, CUR.pts.n_points ) ) { if ( CUR.pedantic_hinting ) { CUR.error = TT_Err_Invalid_Reference; return; } } else CUR.pts.tags[point] ^= FT_CURVE_TAG_ON; CUR.GS.loop--; } CUR.GS.loop = 1; CUR.new_top = CUR.args; }
CWE-119
10,104
16,801
303825062692596718387632269730101886774
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_FLIPRGOFF( INS_ARG ) { FT_UShort I, K, L; K = (FT_UShort)args[1]; L = (FT_UShort)args[0]; if ( BOUNDS( K, CUR.pts.n_points ) || BOUNDS( L, CUR.pts.n_points ) ) { if ( CUR.pedantic_hinting ) CUR.error = TT_Err_Invalid_Reference; return; } for ( I = L; I <= K; I++ ) CUR.pts.tags[I] &= ~FT_CURVE_TAG_ON; }
CWE-119
10,105
16,802
45609317444776152792782470617449143309
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_FLIPRGON( INS_ARG ) { FT_UShort I, K, L; K = (FT_UShort)args[1]; L = (FT_UShort)args[0]; if ( BOUNDS( K, CUR.pts.n_points ) || BOUNDS( L, CUR.pts.n_points ) ) { if ( CUR.pedantic_hinting ) CUR.error = TT_Err_Invalid_Reference; return; } for ( I = L; I <= K; I++ ) CUR.pts.tags[I] |= FT_CURVE_TAG_ON; }
CWE-119
10,106
16,803
166884910499290173778595305067037641095
null
null
null
savannah
888cd1843e935fe675cf2ac303116d4ed5b9d54b
0
Ins_FLOOR( INS_ARG ) { DO_FLOOR }
CWE-119
10,107
16,804
116645092990469697440926931193172893064
null
null
null