idx
int64 | func_before
string | Vulnerability Classification
string | vul
int64 | func_after
string | patch
string | CWE ID
string | lines_before
string | lines_after
string |
|---|---|---|---|---|---|---|---|---|
5,200
|
bool Smb4KGlobal::coreIsRunning()
{
return (Smb4KScanner::self()->isRunning() ||
Smb4KMounter::self()->isRunning() ||
Smb4KPrint::self()->isRunning() ||
Smb4KSynchronizer::self()->isRunning() ||
Smb4KPreviewer::self()->isRunning() ||
Smb4KSearch::self()->isRunning());
}
|
+Priv
| 0
|
bool Smb4KGlobal::coreIsRunning()
{
return (Smb4KScanner::self()->isRunning() ||
Smb4KMounter::self()->isRunning() ||
Smb4KPrint::self()->isRunning() ||
Smb4KSynchronizer::self()->isRunning() ||
Smb4KPreviewer::self()->isRunning() ||
Smb4KSearch::self()->isRunning());
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,201
|
Smb4KHost *Smb4KGlobal::findHost( const QString &name, const QString &workgroup )
{
Smb4KHost *host = NULL;
mutex.lock();
for ( int i = 0; i < p->hostsList.size(); ++i )
{
if ( (workgroup.isEmpty() ||
QString::compare( p->hostsList.at( i )->workgroupName(),
workgroup, Qt::CaseInsensitive ) == 0) &&
QString::compare( p->hostsList.at( i )->hostName(), name,
Qt::CaseInsensitive ) == 0 )
{
host = p->hostsList.at( i );
break;
}
else
{
continue;
}
}
mutex.unlock();
return host;
}
|
+Priv
| 0
|
Smb4KHost *Smb4KGlobal::findHost( const QString &name, const QString &workgroup )
{
Smb4KHost *host = NULL;
mutex.lock();
for ( int i = 0; i < p->hostsList.size(); ++i )
{
if ( (workgroup.isEmpty() ||
QString::compare( p->hostsList.at( i )->workgroupName(),
workgroup, Qt::CaseInsensitive ) == 0) &&
QString::compare( p->hostsList.at( i )->hostName(), name,
Qt::CaseInsensitive ) == 0 )
{
host = p->hostsList.at( i );
break;
}
else
{
continue;
}
}
mutex.unlock();
return host;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,202
|
QList<Smb4KShare*> Smb4KGlobal::findInaccessibleShares()
{
QList<Smb4KShare *> inaccessible_shares;
mutex.lock();
for ( int i = 0; i < p->mountedSharesList.size(); ++i )
{
if ( p->mountedSharesList.at( i )->isInaccessible() )
{
inaccessible_shares.append( p->mountedSharesList.at( i ) );
continue;
}
else
{
continue;
}
}
mutex.unlock();
return inaccessible_shares;
}
|
+Priv
| 0
|
QList<Smb4KShare*> Smb4KGlobal::findInaccessibleShares()
{
QList<Smb4KShare *> inaccessible_shares;
mutex.lock();
for ( int i = 0; i < p->mountedSharesList.size(); ++i )
{
if ( p->mountedSharesList.at( i )->isInaccessible() )
{
inaccessible_shares.append( p->mountedSharesList.at( i ) );
continue;
}
else
{
continue;
}
}
mutex.unlock();
return inaccessible_shares;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,203
|
Smb4KShare* Smb4KGlobal::findShareByPath( const QString &path )
{
Smb4KShare *share = NULL;
mutex.lock();
if ( !path.isEmpty() && !p->mountedSharesList.isEmpty() )
{
for ( int i = 0; i < p->mountedSharesList.size(); ++i )
{
if ( QString::compare( path, p->mountedSharesList.at( i )->path(), Qt::CaseInsensitive ) == 0 ||
QString::compare( path, p->mountedSharesList.at( i )->canonicalPath(), Qt::CaseInsensitive ) == 0 )
{
share = p->mountedSharesList.at( i );
break;
}
else
{
continue;
}
}
}
else
{
}
mutex.unlock();
return share;
}
|
+Priv
| 0
|
Smb4KShare* Smb4KGlobal::findShareByPath( const QString &path )
{
Smb4KShare *share = NULL;
mutex.lock();
if ( !path.isEmpty() && !p->mountedSharesList.isEmpty() )
{
for ( int i = 0; i < p->mountedSharesList.size(); ++i )
{
if ( QString::compare( path, p->mountedSharesList.at( i )->path(), Qt::CaseInsensitive ) == 0 ||
QString::compare( path, p->mountedSharesList.at( i )->canonicalPath(), Qt::CaseInsensitive ) == 0 )
{
share = p->mountedSharesList.at( i );
break;
}
else
{
continue;
}
}
}
else
{
}
mutex.unlock();
return share;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,204
|
QList<Smb4KShare *> Smb4KGlobal::findShareByUNC( const QString &unc )
{
QList<Smb4KShare *> list;
mutex.lock();
if ( !unc.isEmpty() && !p->mountedSharesList.isEmpty() )
{
for ( int i = 0; i < p->mountedSharesList.size(); ++i )
{
if ( QString::compare( unc, p->mountedSharesList.at( i )->unc(), Qt::CaseInsensitive ) == 0 ||
QString::compare( QString( unc ).replace( ' ', '_' ), p->mountedSharesList.at( i )->unc(), Qt::CaseInsensitive ) == 0 )
{
list.append( p->mountedSharesList.at( i ) );
continue;
}
else
{
continue;
}
}
}
else
{
}
mutex.unlock();
return list;
}
|
+Priv
| 0
|
QList<Smb4KShare *> Smb4KGlobal::findShareByUNC( const QString &unc )
{
QList<Smb4KShare *> list;
mutex.lock();
if ( !unc.isEmpty() && !p->mountedSharesList.isEmpty() )
{
for ( int i = 0; i < p->mountedSharesList.size(); ++i )
{
if ( QString::compare( unc, p->mountedSharesList.at( i )->unc(), Qt::CaseInsensitive ) == 0 ||
QString::compare( QString( unc ).replace( ' ', '_' ), p->mountedSharesList.at( i )->unc(), Qt::CaseInsensitive ) == 0 )
{
list.append( p->mountedSharesList.at( i ) );
continue;
}
else
{
continue;
}
}
}
else
{
}
mutex.unlock();
return list;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,205
|
Smb4KWorkgroup *Smb4KGlobal::findWorkgroup( const QString &name )
{
Smb4KWorkgroup *workgroup = NULL;
mutex.lock();
for ( int i = 0; i < p->workgroupsList.size(); ++i )
{
if ( QString::compare( p->workgroupsList.at( i )->workgroupName(),
name, Qt::CaseInsensitive ) == 0 )
{
workgroup = p->workgroupsList.at( i );
break;
}
else
{
continue;
}
}
mutex.unlock();
return workgroup;
}
|
+Priv
| 0
|
Smb4KWorkgroup *Smb4KGlobal::findWorkgroup( const QString &name )
{
Smb4KWorkgroup *workgroup = NULL;
mutex.lock();
for ( int i = 0; i < p->workgroupsList.size(); ++i )
{
if ( QString::compare( p->workgroupsList.at( i )->workgroupName(),
name, Qt::CaseInsensitive ) == 0 )
{
workgroup = p->workgroupsList.at( i );
break;
}
else
{
continue;
}
}
mutex.unlock();
return workgroup;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,206
|
const QList<Smb4KHost *> &Smb4KGlobal::hostsList()
{
return p->hostsList;
}
|
+Priv
| 0
|
const QList<Smb4KHost *> &Smb4KGlobal::hostsList()
{
return p->hostsList;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,207
|
void Smb4KGlobal::initCore(bool modifyCursor, bool initClasses)
{
p->modifyCursor = modifyCursor;
p->setDefaultSettings();
if (initClasses)
{
Smb4KScanner::self()->start();
Smb4KMounter::self()->start();
}
else
{
}
p->makeConnections();
p->coreInitialized = true;
}
|
+Priv
| 0
|
void Smb4KGlobal::initCore(bool modifyCursor, bool initClasses)
{
p->modifyCursor = modifyCursor;
p->setDefaultSettings();
if (initClasses)
{
Smb4KScanner::self()->start();
Smb4KMounter::self()->start();
}
else
{
}
p->makeConnections();
p->coreInitialized = true;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,208
|
const QList<Smb4KShare *> &Smb4KGlobal::mountedSharesList()
{
return p->mountedSharesList;
}
|
+Priv
| 0
|
const QList<Smb4KShare *> &Smb4KGlobal::mountedSharesList()
{
return p->mountedSharesList;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,209
|
bool Smb4KGlobal::onlyForeignMountedShares()
{
return p->onlyForeignShares;
}
|
+Priv
| 0
|
bool Smb4KGlobal::onlyForeignMountedShares()
{
return p->onlyForeignShares;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,210
|
void Smb4KGlobal::openShare( Smb4KShare *share, OpenWith openWith )
{
if ( !share || share->isInaccessible() )
{
return;
}
switch ( openWith )
{
case FileManager:
{
KUrl url;
url.setPath( share->canonicalPath() );
(void) new KRun( url, 0, 0, true );
break;
}
case Konsole:
{
QString konsole = KGlobal::dirs()->findResource( "exe", "konsole" );
if ( konsole.isEmpty() )
{
Smb4KNotification::commandNotFound("konsole");
}
else
{
KRun::runCommand( konsole+" --workdir "+KShell::quoteArg( share->canonicalPath() ), 0 );
}
break;
}
default:
{
break;
}
}
}
|
+Priv
| 0
|
void Smb4KGlobal::openShare( Smb4KShare *share, OpenWith openWith )
{
if ( !share || share->isInaccessible() )
{
return;
}
switch ( openWith )
{
case FileManager:
{
KUrl url;
url.setPath( share->canonicalPath() );
(void) new KRun( url, 0, 0, true );
break;
}
case Konsole:
{
QString konsole = KGlobal::dirs()->findResource( "exe", "konsole" );
if ( konsole.isEmpty() )
{
Smb4KNotification::commandNotFound("konsole");
}
else
{
KRun::runCommand( konsole+" --workdir "+KShell::quoteArg( share->canonicalPath() ), 0 );
}
break;
}
default:
{
break;
}
}
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,211
|
bool Smb4KGlobal::removeMountedShare( Smb4KShare *share )
{
Q_ASSERT( share );
bool removed = false;
mutex.lock();
int index = p->mountedSharesList.indexOf( share );
if ( index != -1 )
{
delete p->mountedSharesList.takeAt( index );
removed = true;
p->onlyForeignShares = true;
for ( int i = 0; i < p->mountedSharesList.size(); ++i )
{
if ( !p->mountedSharesList.at( i )->isForeign() )
{
p->onlyForeignShares = false;
break;
}
else
{
continue;
}
}
}
else
{
Smb4KShare *s = findShareByPath( share->path() );
if ( s )
{
index = p->mountedSharesList.indexOf( s );
if ( index != -1 )
{
delete p->mountedSharesList.takeAt( index );
removed = true;
p->onlyForeignShares = true;
for ( int i = 0; i < p->mountedSharesList.size(); ++i )
{
if ( !p->mountedSharesList.at( i )->isForeign() )
{
p->onlyForeignShares = false;
break;
}
else
{
continue;
}
}
}
else
{
}
}
else
{
}
delete share;
}
mutex.unlock();
return removed;
}
|
+Priv
| 0
|
bool Smb4KGlobal::removeMountedShare( Smb4KShare *share )
{
Q_ASSERT( share );
bool removed = false;
mutex.lock();
int index = p->mountedSharesList.indexOf( share );
if ( index != -1 )
{
delete p->mountedSharesList.takeAt( index );
removed = true;
p->onlyForeignShares = true;
for ( int i = 0; i < p->mountedSharesList.size(); ++i )
{
if ( !p->mountedSharesList.at( i )->isForeign() )
{
p->onlyForeignShares = false;
break;
}
else
{
continue;
}
}
}
else
{
Smb4KShare *s = findShareByPath( share->path() );
if ( s )
{
index = p->mountedSharesList.indexOf( s );
if ( index != -1 )
{
delete p->mountedSharesList.takeAt( index );
removed = true;
p->onlyForeignShares = true;
for ( int i = 0; i < p->mountedSharesList.size(); ++i )
{
if ( !p->mountedSharesList.at( i )->isForeign() )
{
p->onlyForeignShares = false;
break;
}
else
{
continue;
}
}
}
else
{
}
}
else
{
}
delete share;
}
mutex.unlock();
return removed;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,212
|
bool Smb4KGlobal::removeShare( Smb4KShare *share )
{
Q_ASSERT( share );
bool removed = false;
mutex.lock();
int index = p->sharesList.indexOf( share );
if ( index != -1 )
{
delete p->sharesList.takeAt( index );
removed = true;
}
else
{
Smb4KShare *s = findShare( share->shareName(), share->hostName(), share->workgroupName() );
if ( s )
{
index = p->sharesList.indexOf( s );
if ( index != -1 )
{
delete p->sharesList.takeAt( index );
removed = true;
}
else
{
}
}
else
{
}
delete share;
}
mutex.unlock();
return removed;
}
|
+Priv
| 0
|
bool Smb4KGlobal::removeShare( Smb4KShare *share )
{
Q_ASSERT( share );
bool removed = false;
mutex.lock();
int index = p->sharesList.indexOf( share );
if ( index != -1 )
{
delete p->sharesList.takeAt( index );
removed = true;
}
else
{
Smb4KShare *s = findShare( share->shareName(), share->hostName(), share->workgroupName() );
if ( s )
{
index = p->sharesList.indexOf( s );
if ( index != -1 )
{
delete p->sharesList.takeAt( index );
removed = true;
}
else
{
}
}
else
{
}
delete share;
}
mutex.unlock();
return removed;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,213
|
bool Smb4KGlobal::removeWorkgroup( Smb4KWorkgroup *workgroup )
{
Q_ASSERT( workgroup );
bool removed = false;
mutex.lock();
int index = p->workgroupsList.indexOf( workgroup );
if ( index != -1 )
{
delete p->workgroupsList.takeAt( index );
removed = true;
}
else
{
Smb4KWorkgroup *wg = findWorkgroup( workgroup->workgroupName() );
if ( wg )
{
index = p->workgroupsList.indexOf( wg );
if ( index != -1 )
{
delete p->workgroupsList.takeAt( index );
removed = true;
}
else
{
}
}
else
{
}
delete workgroup;
}
mutex.unlock();
return removed;
}
|
+Priv
| 0
|
bool Smb4KGlobal::removeWorkgroup( Smb4KWorkgroup *workgroup )
{
Q_ASSERT( workgroup );
bool removed = false;
mutex.lock();
int index = p->workgroupsList.indexOf( workgroup );
if ( index != -1 )
{
delete p->workgroupsList.takeAt( index );
removed = true;
}
else
{
Smb4KWorkgroup *wg = findWorkgroup( workgroup->workgroupName() );
if ( wg )
{
index = p->workgroupsList.indexOf( wg );
if ( index != -1 )
{
delete p->workgroupsList.takeAt( index );
removed = true;
}
else
{
}
}
else
{
}
delete workgroup;
}
mutex.unlock();
return removed;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,214
|
void Smb4KGlobal::setDefaultSettings()
{
p->setDefaultSettings();
}
|
+Priv
| 0
|
void Smb4KGlobal::setDefaultSettings()
{
p->setDefaultSettings();
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,215
|
QList<Smb4KShare *> Smb4KGlobal::sharedResources( Smb4KHost *host )
{
QList<Smb4KShare *> shares;
mutex.lock();
for ( int i = 0; i < p->sharesList.size(); ++i )
{
if ( QString::compare( p->sharesList.at( i )->hostName(), host->hostName(), Qt::CaseInsensitive ) == 0 &&
QString::compare( p->sharesList.at( i )->workgroupName(), host->workgroupName(), Qt::CaseInsensitive ) == 0 )
{
shares += p->sharesList.at( i );
continue;
}
else
{
continue;
}
}
mutex.unlock();
return shares;
}
|
+Priv
| 0
|
QList<Smb4KShare *> Smb4KGlobal::sharedResources( Smb4KHost *host )
{
QList<Smb4KShare *> shares;
mutex.lock();
for ( int i = 0; i < p->sharesList.size(); ++i )
{
if ( QString::compare( p->sharesList.at( i )->hostName(), host->hostName(), Qt::CaseInsensitive ) == 0 &&
QString::compare( p->sharesList.at( i )->workgroupName(), host->workgroupName(), Qt::CaseInsensitive ) == 0 )
{
shares += p->sharesList.at( i );
continue;
}
else
{
continue;
}
}
mutex.unlock();
return shares;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,216
|
const QList<Smb4KShare *> &Smb4KGlobal::sharesList()
{
return p->sharesList;
}
|
+Priv
| 0
|
const QList<Smb4KShare *> &Smb4KGlobal::sharesList()
{
return p->sharesList;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,217
|
QStringList Smb4KGlobal::whitelistedMountArguments()
{
return p->whitelistedMountArguments;
}
|
+Priv
| 0
|
QStringList Smb4KGlobal::whitelistedMountArguments()
{
return p->whitelistedMountArguments;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,218
|
const QString Smb4KGlobal::winsServer()
{
QMap<QString,QString> global_opts = p->globalSambaOptions( false );
QString wins_server;
if ( global_opts.contains( "wins server" ) )
{
wins_server = global_opts.value( "wins server" );
}
else
{
if ( global_opts.contains( "wins support" ) &&
(QString::compare( global_opts.value( "wins support" ), "yes", Qt::CaseInsensitive ) == 0 ||
QString::compare( global_opts.value( "wins support" ), "true", Qt::CaseInsensitive ) == 0) )
{
wins_server = "127.0.0.1";
}
else
{
}
}
return wins_server;
}
|
+Priv
| 0
|
const QString Smb4KGlobal::winsServer()
{
QMap<QString,QString> global_opts = p->globalSambaOptions( false );
QString wins_server;
if ( global_opts.contains( "wins server" ) )
{
wins_server = global_opts.value( "wins server" );
}
else
{
if ( global_opts.contains( "wins support" ) &&
(QString::compare( global_opts.value( "wins support" ), "yes", Qt::CaseInsensitive ) == 0 ||
QString::compare( global_opts.value( "wins support" ), "true", Qt::CaseInsensitive ) == 0) )
{
wins_server = "127.0.0.1";
}
else
{
}
}
return wins_server;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,219
|
QList<Smb4KHost *> Smb4KGlobal::workgroupMembers( Smb4KWorkgroup *workgroup )
{
QList<Smb4KHost *> hosts;
mutex.lock();
for ( int i = 0; i < p->hostsList.size(); ++i )
{
if ( QString::compare( p->hostsList.at( i )->workgroupName(), workgroup->workgroupName(), Qt::CaseInsensitive ) == 0 )
{
hosts += p->hostsList.at( i );
continue;
}
else
{
continue;
}
}
mutex.unlock();
return hosts;
}
|
+Priv
| 0
|
QList<Smb4KHost *> Smb4KGlobal::workgroupMembers( Smb4KWorkgroup *workgroup )
{
QList<Smb4KHost *> hosts;
mutex.lock();
for ( int i = 0; i < p->hostsList.size(); ++i )
{
if ( QString::compare( p->hostsList.at( i )->workgroupName(), workgroup->workgroupName(), Qt::CaseInsensitive ) == 0 )
{
hosts += p->hostsList.at( i );
continue;
}
else
{
continue;
}
}
mutex.unlock();
return hosts;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,220
|
const QList<Smb4KWorkgroup *> &Smb4KGlobal::workgroupsList()
{
return p->workgroupsList;
}
|
+Priv
| 0
|
const QList<Smb4KWorkgroup *> &Smb4KGlobal::workgroupsList()
{
return p->workgroupsList;
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,221
|
Smb4KGlobal::Smb4KEvent::~Smb4KEvent()
{
}
|
+Priv
| 0
|
Smb4KGlobal::Smb4KEvent::~Smb4KEvent()
{
}
|
@@ -2,7 +2,7 @@
smb4kglobal - This is the global namespace for Smb4K.
-------------------
begin : Sa Apr 2 2005
- copyright : (C) 2005-2014 by Alexander Reinholdt
+ copyright : (C) 2005-2017 by Alexander Reinholdt
email : alexander.reinholdt@kdemail.net
***************************************************************************/
@@ -851,3 +851,66 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QString mount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for (int i = 0; i < paths.size(); ++i)
+ {
+#if defined(Q_OS_LINUX)
+ mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
+#endif
+
+ if (!mount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return mount;
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ // Find the umount program.
+ QString umount;
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ for ( int i = 0; i < paths.size(); ++i )
+ {
+ umount = KGlobal::dirs()->findExe("umount", paths.at(i));
+
+ if (!umount.isEmpty())
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
+ return umount;
+}
+
+
|
CWE-20
| null | null |
5,222
|
Smb4KMountJob::Smb4KMountJob( QObject *parent ) : KJob( parent ),
m_started( false ), m_parent_widget( NULL ), m_processed( 0 )
{
setCapabilities( KJob::Killable );
}
|
+Priv
| 0
|
Smb4KMountJob::Smb4KMountJob( QObject *parent ) : KJob( parent ),
m_started( false ), m_parent_widget( NULL ), m_processed( 0 )
{
setCapabilities( KJob::Killable );
}
|
@@ -207,30 +207,7 @@ bool Smb4KMountJob::createMountAction(Smb4KShare *share, Action *action)
//
bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
{
- // Find the mount program.
- QString mount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for (int i = 0; i < paths.size(); ++i)
- {
- mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
-
- if (!mount.isEmpty())
- {
- map.insert("mh_command", mount);
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString mount = findMountExecutable();
if (mount.isEmpty())
{
@@ -242,6 +219,8 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
// Do nothing
}
+ map.insert("mh_command", mount);
+
// Mount arguments.
QMap<QString, QString> global_options = globalSambaOptions();
Smb4KCustomOptions *options = Smb4KCustomOptionsManager::self()->findOptions(share);
@@ -729,30 +708,7 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
//
bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
{
- // Find the mount program.
- QString mount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for (int i = 0; i < paths.size(); ++i)
- {
- mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
-
- if (!mount.isEmpty())
- {
- map.insert("mh_command", mount);
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString mount = findMountExecutable();
if (mount.isEmpty())
{
@@ -764,6 +720,8 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
// Do nothing
}
+ map.insert("mh_command", mount);
+
// Mount arguments.
QMap<QString, QString> global_options = globalSambaOptions();
Smb4KCustomOptions *options = Smb4KCustomOptionsManager::self()->findOptions(share);
@@ -1253,29 +1211,7 @@ bool Smb4KUnmountJob::createUnmountAction(Smb4KShare *share, Action *action)
// Do nothing
}
- // Find the umount program.
- QString umount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for ( int i = 0; i < paths.size(); ++i )
- {
- umount = KGlobal::dirs()->findExe("umount", paths.at(i));
-
- if (!umount.isEmpty())
- {
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString umount = findUmountExecutable();
if (umount.isEmpty() && !m_silent)
{
|
CWE-20
| null | null |
5,223
|
void Smb4KMountJob::setupMount( Smb4KShare *share, QWidget *parent )
{
Q_ASSERT( share );
m_shares << new Smb4KShare( *share );
m_parent_widget = parent;
}
|
+Priv
| 0
|
void Smb4KMountJob::setupMount( Smb4KShare *share, QWidget *parent )
{
Q_ASSERT( share );
m_shares << new Smb4KShare( *share );
m_parent_widget = parent;
}
|
@@ -207,30 +207,7 @@ bool Smb4KMountJob::createMountAction(Smb4KShare *share, Action *action)
//
bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
{
- // Find the mount program.
- QString mount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for (int i = 0; i < paths.size(); ++i)
- {
- mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
-
- if (!mount.isEmpty())
- {
- map.insert("mh_command", mount);
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString mount = findMountExecutable();
if (mount.isEmpty())
{
@@ -242,6 +219,8 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
// Do nothing
}
+ map.insert("mh_command", mount);
+
// Mount arguments.
QMap<QString, QString> global_options = globalSambaOptions();
Smb4KCustomOptions *options = Smb4KCustomOptionsManager::self()->findOptions(share);
@@ -729,30 +708,7 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
//
bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
{
- // Find the mount program.
- QString mount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for (int i = 0; i < paths.size(); ++i)
- {
- mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
-
- if (!mount.isEmpty())
- {
- map.insert("mh_command", mount);
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString mount = findMountExecutable();
if (mount.isEmpty())
{
@@ -764,6 +720,8 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
// Do nothing
}
+ map.insert("mh_command", mount);
+
// Mount arguments.
QMap<QString, QString> global_options = globalSambaOptions();
Smb4KCustomOptions *options = Smb4KCustomOptionsManager::self()->findOptions(share);
@@ -1253,29 +1211,7 @@ bool Smb4KUnmountJob::createUnmountAction(Smb4KShare *share, Action *action)
// Do nothing
}
- // Find the umount program.
- QString umount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for ( int i = 0; i < paths.size(); ++i )
- {
- umount = KGlobal::dirs()->findExe("umount", paths.at(i));
-
- if (!umount.isEmpty())
- {
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString umount = findUmountExecutable();
if (umount.isEmpty() && !m_silent)
{
|
CWE-20
| null | null |
5,224
|
void Smb4KMountJob::start()
{
m_started = true;
QTimer::singleShot( 50, this, SLOT(slotStartMount()) );
}
|
+Priv
| 0
|
void Smb4KMountJob::start()
{
m_started = true;
QTimer::singleShot( 50, this, SLOT(slotStartMount()) );
}
|
@@ -207,30 +207,7 @@ bool Smb4KMountJob::createMountAction(Smb4KShare *share, Action *action)
//
bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
{
- // Find the mount program.
- QString mount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for (int i = 0; i < paths.size(); ++i)
- {
- mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
-
- if (!mount.isEmpty())
- {
- map.insert("mh_command", mount);
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString mount = findMountExecutable();
if (mount.isEmpty())
{
@@ -242,6 +219,8 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
// Do nothing
}
+ map.insert("mh_command", mount);
+
// Mount arguments.
QMap<QString, QString> global_options = globalSambaOptions();
Smb4KCustomOptions *options = Smb4KCustomOptionsManager::self()->findOptions(share);
@@ -729,30 +708,7 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
//
bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
{
- // Find the mount program.
- QString mount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for (int i = 0; i < paths.size(); ++i)
- {
- mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
-
- if (!mount.isEmpty())
- {
- map.insert("mh_command", mount);
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString mount = findMountExecutable();
if (mount.isEmpty())
{
@@ -764,6 +720,8 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
// Do nothing
}
+ map.insert("mh_command", mount);
+
// Mount arguments.
QMap<QString, QString> global_options = globalSambaOptions();
Smb4KCustomOptions *options = Smb4KCustomOptionsManager::self()->findOptions(share);
@@ -1253,29 +1211,7 @@ bool Smb4KUnmountJob::createUnmountAction(Smb4KShare *share, Action *action)
// Do nothing
}
- // Find the umount program.
- QString umount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for ( int i = 0; i < paths.size(); ++i )
- {
- umount = KGlobal::dirs()->findExe("umount", paths.at(i));
-
- if (!umount.isEmpty())
- {
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString umount = findUmountExecutable();
if (umount.isEmpty() && !m_silent)
{
|
CWE-20
| null | null |
5,225
|
Smb4KMountJob::~Smb4KMountJob()
{
while ( !m_shares.isEmpty() )
{
delete m_shares.takeFirst();
}
while ( !m_auth_errors.isEmpty() )
{
delete m_auth_errors.takeFirst();
}
while ( !m_retries.isEmpty() )
{
delete m_retries.takeFirst();
}
}
|
+Priv
| 0
|
Smb4KMountJob::~Smb4KMountJob()
{
while ( !m_shares.isEmpty() )
{
delete m_shares.takeFirst();
}
while ( !m_auth_errors.isEmpty() )
{
delete m_auth_errors.takeFirst();
}
while ( !m_retries.isEmpty() )
{
delete m_retries.takeFirst();
}
}
|
@@ -207,30 +207,7 @@ bool Smb4KMountJob::createMountAction(Smb4KShare *share, Action *action)
//
bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
{
- // Find the mount program.
- QString mount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for (int i = 0; i < paths.size(); ++i)
- {
- mount = KGlobal::dirs()->findExe("mount.cifs", paths.at(i));
-
- if (!mount.isEmpty())
- {
- map.insert("mh_command", mount);
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString mount = findMountExecutable();
if (mount.isEmpty())
{
@@ -242,6 +219,8 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
// Do nothing
}
+ map.insert("mh_command", mount);
+
// Mount arguments.
QMap<QString, QString> global_options = globalSambaOptions();
Smb4KCustomOptions *options = Smb4KCustomOptionsManager::self()->findOptions(share);
@@ -729,30 +708,7 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
//
bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
{
- // Find the mount program.
- QString mount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for (int i = 0; i < paths.size(); ++i)
- {
- mount = KGlobal::dirs()->findExe("mount_smbfs", paths.at(i));
-
- if (!mount.isEmpty())
- {
- map.insert("mh_command", mount);
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString mount = findMountExecutable();
if (mount.isEmpty())
{
@@ -764,6 +720,8 @@ bool Smb4KMountJob::fillArgs(Smb4KShare *share, QMap<QString, QVariant>& map)
// Do nothing
}
+ map.insert("mh_command", mount);
+
// Mount arguments.
QMap<QString, QString> global_options = globalSambaOptions();
Smb4KCustomOptions *options = Smb4KCustomOptionsManager::self()->findOptions(share);
@@ -1253,29 +1211,7 @@ bool Smb4KUnmountJob::createUnmountAction(Smb4KShare *share, Action *action)
// Do nothing
}
- // Find the umount program.
- QString umount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- for ( int i = 0; i < paths.size(); ++i )
- {
- umount = KGlobal::dirs()->findExe("umount", paths.at(i));
-
- if (!umount.isEmpty())
- {
- break;
- }
- else
- {
- continue;
- }
- }
+ const QString umount = findUmountExecutable();
if (umount.isEmpty() && !m_silent)
{
|
CWE-20
| null | null |
5,226
|
Smb4KGlobal::Smb4KEvent::Smb4KEvent(QEvent::Type type): QEvent(type)
{
}
|
+Priv
| 0
|
Smb4KGlobal::Smb4KEvent::Smb4KEvent(QEvent::Type type): QEvent(type)
{
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,227
|
bool Smb4KGlobal::addHost(Smb4KHost *host)
{
Q_ASSERT(host);
bool added = false;
mutex.lock();
if (!findHost(host->hostName(), host->workgroupName()))
{
p->hostsList.append(host);
added = true;
}
else
{
}
mutex.unlock();
return added;
}
|
+Priv
| 0
|
bool Smb4KGlobal::addHost(Smb4KHost *host)
{
Q_ASSERT(host);
bool added = false;
mutex.lock();
if (!findHost(host->hostName(), host->workgroupName()))
{
p->hostsList.append(host);
added = true;
}
else
{
}
mutex.unlock();
return added;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,228
|
bool Smb4KGlobal::addMountedShare(Smb4KShare *share)
{
Q_ASSERT(share);
bool added = false;
if (share)
{
mutex.lock();
if (!findShareByPath(share->path()))
{
p->mountedSharesList.append(share);
added = true;
p->onlyForeignShares = true;
for (Smb4KShare *s : p->mountedSharesList)
{
if (!s->isForeign())
{
p->onlyForeignShares = false;
break;
}
else
{
}
}
}
else
{
}
mutex.unlock();
}
else
{
}
return added;
}
|
+Priv
| 0
|
bool Smb4KGlobal::addMountedShare(Smb4KShare *share)
{
Q_ASSERT(share);
bool added = false;
if (share)
{
mutex.lock();
if (!findShareByPath(share->path()))
{
p->mountedSharesList.append(share);
added = true;
p->onlyForeignShares = true;
for (Smb4KShare *s : p->mountedSharesList)
{
if (!s->isForeign())
{
p->onlyForeignShares = false;
break;
}
else
{
}
}
}
else
{
}
mutex.unlock();
}
else
{
}
return added;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,229
|
bool Smb4KGlobal::addShare(Smb4KShare *share)
{
Q_ASSERT(share);
bool added = false;
if (share)
{
mutex.lock();
if (!findShare(share->unc(), share->workgroupName()))
{
p->sharesList.append(share);
added = true;
}
else
{
}
}
else
{
}
mutex.unlock();
return added;
}
|
+Priv
| 0
|
bool Smb4KGlobal::addShare(Smb4KShare *share)
{
Q_ASSERT(share);
bool added = false;
if (share)
{
mutex.lock();
if (!findShare(share->unc(), share->workgroupName()))
{
p->sharesList.append(share);
added = true;
}
else
{
}
}
else
{
}
mutex.unlock();
return added;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,230
|
bool Smb4KGlobal::addWorkgroup(Smb4KWorkgroup *workgroup)
{
Q_ASSERT(workgroup);
bool added = false;
mutex.lock();
if (!findWorkgroup(workgroup->workgroupName()))
{
p->workgroupsList.append(workgroup);
added = true;
}
else
{
}
mutex.unlock();
return added;
}
|
+Priv
| 0
|
bool Smb4KGlobal::addWorkgroup(Smb4KWorkgroup *workgroup)
{
Q_ASSERT(workgroup);
bool added = false;
mutex.lock();
if (!findWorkgroup(workgroup->workgroupName()))
{
p->workgroupsList.append(workgroup);
added = true;
}
else
{
}
mutex.unlock();
return added;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,231
|
void Smb4KGlobal::clearHostsList()
{
mutex.lock();
while (!p->hostsList.isEmpty())
{
delete p->hostsList.takeFirst();
}
mutex.unlock();
}
|
+Priv
| 0
|
void Smb4KGlobal::clearHostsList()
{
mutex.lock();
while (!p->hostsList.isEmpty())
{
delete p->hostsList.takeFirst();
}
mutex.unlock();
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,232
|
void Smb4KGlobal::clearSharesList()
{
mutex.lock();
while (!p->sharesList.isEmpty())
{
delete p->sharesList.takeFirst();
}
mutex.unlock();
}
|
+Priv
| 0
|
void Smb4KGlobal::clearSharesList()
{
mutex.lock();
while (!p->sharesList.isEmpty())
{
delete p->sharesList.takeFirst();
}
mutex.unlock();
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,233
|
void Smb4KGlobal::clearWorkgroupsList()
{
mutex.lock();
while (!p->workgroupsList.isEmpty())
{
delete p->workgroupsList.takeFirst();
}
mutex.unlock();
}
|
+Priv
| 0
|
void Smb4KGlobal::clearWorkgroupsList()
{
mutex.lock();
while (!p->workgroupsList.isEmpty())
{
delete p->workgroupsList.takeFirst();
}
mutex.unlock();
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,234
|
QList<Smb4KShare*> Smb4KGlobal::findInaccessibleShares()
{
QList<Smb4KShare *> inaccessibleShares;
mutex.lock();
for (Smb4KShare *s : p->mountedSharesList)
{
if (s->isInaccessible())
{
inaccessibleShares += s;
}
else
{
}
}
mutex.unlock();
return inaccessibleShares;
}
|
+Priv
| 0
|
QList<Smb4KShare*> Smb4KGlobal::findInaccessibleShares()
{
QList<Smb4KShare *> inaccessibleShares;
mutex.lock();
for (Smb4KShare *s : p->mountedSharesList)
{
if (s->isInaccessible())
{
inaccessibleShares += s;
}
else
{
}
}
mutex.unlock();
return inaccessibleShares;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,235
|
Smb4KShare *Smb4KGlobal::findShare(const QString& unc, const QString& workgroup)
{
Smb4KShare *share = 0;
mutex.lock();
for (Smb4KShare *s : p->sharesList)
{
if (QString::compare(s->unc(), unc, Qt::CaseInsensitive) == 0 &&
(workgroup.isEmpty() || QString::compare(s->workgroupName(), workgroup, Qt::CaseInsensitive) == 0))
{
share = s;
break;
}
else
{
}
}
mutex.unlock();
return share;
}
|
+Priv
| 0
|
Smb4KShare *Smb4KGlobal::findShare(const QString& unc, const QString& workgroup)
{
Smb4KShare *share = 0;
mutex.lock();
for (Smb4KShare *s : p->sharesList)
{
if (QString::compare(s->unc(), unc, Qt::CaseInsensitive) == 0 &&
(workgroup.isEmpty() || QString::compare(s->workgroupName(), workgroup, Qt::CaseInsensitive) == 0))
{
share = s;
break;
}
else
{
}
}
mutex.unlock();
return share;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,236
|
Smb4KShare* Smb4KGlobal::findShareByPath(const QString &path)
{
Smb4KShare *share = 0;
mutex.lock();
if (!path.isEmpty() && !p->mountedSharesList.isEmpty())
{
for (Smb4KShare *s : p->mountedSharesList)
{
if (QString::compare(s->path(), path, Qt::CaseInsensitive) == 0 ||
QString::compare(s->canonicalPath(), path, Qt::CaseInsensitive) == 0)
{
share = s;
break;
}
else
{
}
}
}
else
{
}
mutex.unlock();
return share;
}
|
+Priv
| 0
|
Smb4KShare* Smb4KGlobal::findShareByPath(const QString &path)
{
Smb4KShare *share = 0;
mutex.lock();
if (!path.isEmpty() && !p->mountedSharesList.isEmpty())
{
for (Smb4KShare *s : p->mountedSharesList)
{
if (QString::compare(s->path(), path, Qt::CaseInsensitive) == 0 ||
QString::compare(s->canonicalPath(), path, Qt::CaseInsensitive) == 0)
{
share = s;
break;
}
else
{
}
}
}
else
{
}
mutex.unlock();
return share;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,237
|
QList<Smb4KShare *> Smb4KGlobal::findShareByUNC(const QString &unc)
{
QList<Smb4KShare *> shares;
mutex.lock();
if (!unc.isEmpty() && !p->mountedSharesList.isEmpty())
{
for (Smb4KShare *s : p->mountedSharesList)
{
if (QString::compare(s->unc(), unc, Qt::CaseInsensitive) == 0)
{
shares += s;
}
else
{
}
}
}
else
{
}
mutex.unlock();
return shares;
}
|
+Priv
| 0
|
QList<Smb4KShare *> Smb4KGlobal::findShareByUNC(const QString &unc)
{
QList<Smb4KShare *> shares;
mutex.lock();
if (!unc.isEmpty() && !p->mountedSharesList.isEmpty())
{
for (Smb4KShare *s : p->mountedSharesList)
{
if (QString::compare(s->unc(), unc, Qt::CaseInsensitive) == 0)
{
shares += s;
}
else
{
}
}
}
else
{
}
mutex.unlock();
return shares;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,238
|
const QMap<QString,QString> &Smb4KGlobal::globalSambaOptions(bool read)
{
return p->globalSambaOptions(read);
}
|
+Priv
| 0
|
const QMap<QString,QString> &Smb4KGlobal::globalSambaOptions(bool read)
{
return p->globalSambaOptions(read);
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,239
|
void Smb4KGlobal::openShare(Smb4KShare *share, OpenWith openWith)
{
if (!share || share->isInaccessible())
{
return;
}
switch (openWith)
{
case FileManager:
{
QUrl url = QUrl::fromLocalFile(share->canonicalPath());
(void) new KRun(url, 0);
break;
}
case Konsole:
{
QString konsole = QStandardPaths::findExecutable("konsole");
if (konsole.isEmpty())
{
Smb4KNotification::commandNotFound("konsole");
}
else
{
KRun::runCommand(konsole+" --workdir "+KShell::quoteArg(share->canonicalPath()), 0);
}
break;
}
default:
{
break;
}
}
}
|
+Priv
| 0
|
void Smb4KGlobal::openShare(Smb4KShare *share, OpenWith openWith)
{
if (!share || share->isInaccessible())
{
return;
}
switch (openWith)
{
case FileManager:
{
QUrl url = QUrl::fromLocalFile(share->canonicalPath());
(void) new KRun(url, 0);
break;
}
case Konsole:
{
QString konsole = QStandardPaths::findExecutable("konsole");
if (konsole.isEmpty())
{
Smb4KNotification::commandNotFound("konsole");
}
else
{
KRun::runCommand(konsole+" --workdir "+KShell::quoteArg(share->canonicalPath()), 0);
}
break;
}
default:
{
break;
}
}
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,240
|
bool Smb4KGlobal::removeHost(Smb4KHost *host)
{
Q_ASSERT(host);
bool removed = false;
mutex.lock();
int index = p->hostsList.indexOf(host);
if (index != -1)
{
delete p->hostsList.takeAt(index);
removed = true;
}
else
{
Smb4KHost *h = findHost(host->hostName(), host->workgroupName());
if (h)
{
index = p->hostsList.indexOf(h);
if (index != -1)
{
delete p->hostsList.takeAt(index);
removed = true;
}
else
{
}
}
else
{
}
delete host;
}
mutex.unlock();
return removed;
}
|
+Priv
| 0
|
bool Smb4KGlobal::removeHost(Smb4KHost *host)
{
Q_ASSERT(host);
bool removed = false;
mutex.lock();
int index = p->hostsList.indexOf(host);
if (index != -1)
{
delete p->hostsList.takeAt(index);
removed = true;
}
else
{
Smb4KHost *h = findHost(host->hostName(), host->workgroupName());
if (h)
{
index = p->hostsList.indexOf(h);
if (index != -1)
{
delete p->hostsList.takeAt(index);
removed = true;
}
else
{
}
}
else
{
}
delete host;
}
mutex.unlock();
return removed;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,241
|
bool Smb4KGlobal::removeMountedShare(Smb4KShare *share)
{
Q_ASSERT(share);
bool removed = false;
if (share)
{
mutex.lock();
QMutableListIterator<Smb4KShare *> it(p->mountedSharesList);
while (it.hasNext())
{
Smb4KShare *s = it.next();
if (QString::compare(s->path(), share->path(), Qt::CaseInsensitive) == 0 ||
QString::compare(s->canonicalPath(), share->canonicalPath(), Qt::CaseInsensitive) == 0)
{
it.remove();
removed = true;
break;
}
else
{
}
}
for (Smb4KShare *s : p->mountedSharesList)
{
if (!s->isForeign())
{
p->onlyForeignShares = false;
break;
}
else
{
}
}
delete share;
mutex.unlock();
}
else
{
}
return removed;
}
|
+Priv
| 0
|
bool Smb4KGlobal::removeMountedShare(Smb4KShare *share)
{
Q_ASSERT(share);
bool removed = false;
if (share)
{
mutex.lock();
QMutableListIterator<Smb4KShare *> it(p->mountedSharesList);
while (it.hasNext())
{
Smb4KShare *s = it.next();
if (QString::compare(s->path(), share->path(), Qt::CaseInsensitive) == 0 ||
QString::compare(s->canonicalPath(), share->canonicalPath(), Qt::CaseInsensitive) == 0)
{
it.remove();
removed = true;
break;
}
else
{
}
}
for (Smb4KShare *s : p->mountedSharesList)
{
if (!s->isForeign())
{
p->onlyForeignShares = false;
break;
}
else
{
}
}
delete share;
mutex.unlock();
}
else
{
}
return removed;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,242
|
bool Smb4KGlobal::removeWorkgroup(Smb4KWorkgroup *workgroup)
{
Q_ASSERT(workgroup);
bool removed = false;
mutex.lock();
int index = p->workgroupsList.indexOf(workgroup);
if (index != -1)
{
delete p->workgroupsList.takeAt(index);
removed = true;
}
else
{
Smb4KWorkgroup *wg = findWorkgroup(workgroup->workgroupName());
if (wg)
{
index = p->workgroupsList.indexOf(wg);
if (index != -1)
{
delete p->workgroupsList.takeAt(index);
removed = true;
}
else
{
}
}
else
{
}
delete workgroup;
}
mutex.unlock();
return removed;
}
|
+Priv
| 0
|
bool Smb4KGlobal::removeWorkgroup(Smb4KWorkgroup *workgroup)
{
Q_ASSERT(workgroup);
bool removed = false;
mutex.lock();
int index = p->workgroupsList.indexOf(workgroup);
if (index != -1)
{
delete p->workgroupsList.takeAt(index);
removed = true;
}
else
{
Smb4KWorkgroup *wg = findWorkgroup(workgroup->workgroupName());
if (wg)
{
index = p->workgroupsList.indexOf(wg);
if (index != -1)
{
delete p->workgroupsList.takeAt(index);
removed = true;
}
else
{
}
}
else
{
}
delete workgroup;
}
mutex.unlock();
return removed;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,243
|
QList<Smb4KShare *> Smb4KGlobal::sharedResources(Smb4KHost *host)
{
QList<Smb4KShare *> shares;
mutex.lock();
for (Smb4KShare *s : p->sharesList)
{
if (QString::compare(s->hostName(), host->hostName(), Qt::CaseInsensitive) == 0 &&
QString::compare(s->workgroupName(), host->workgroupName(), Qt::CaseInsensitive) == 0)
{
shares += s;
}
else
{
}
}
mutex.unlock();
return shares;
}
|
+Priv
| 0
|
QList<Smb4KShare *> Smb4KGlobal::sharedResources(Smb4KHost *host)
{
QList<Smb4KShare *> shares;
mutex.lock();
for (Smb4KShare *s : p->sharesList)
{
if (QString::compare(s->hostName(), host->hostName(), Qt::CaseInsensitive) == 0 &&
QString::compare(s->workgroupName(), host->workgroupName(), Qt::CaseInsensitive) == 0)
{
shares += s;
}
else
{
}
}
mutex.unlock();
return shares;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,244
|
const QString Smb4KGlobal::winsServer()
{
QMap<QString,QString> global_opts = p->globalSambaOptions(false);
QString wins_server;
if (global_opts.contains("wins server"))
{
wins_server = global_opts.value("wins server");
}
else
{
if (global_opts.contains("wins support") &&
(QString::compare(global_opts.value("wins support"), "yes", Qt::CaseInsensitive) == 0 ||
QString::compare(global_opts.value("wins support"), "true", Qt::CaseInsensitive) == 0))
{
wins_server = "127.0.0.1";
}
else
{
}
}
return wins_server;
}
|
+Priv
| 0
|
const QString Smb4KGlobal::winsServer()
{
QMap<QString,QString> global_opts = p->globalSambaOptions(false);
QString wins_server;
if (global_opts.contains("wins server"))
{
wins_server = global_opts.value("wins server");
}
else
{
if (global_opts.contains("wins support") &&
(QString::compare(global_opts.value("wins support"), "yes", Qt::CaseInsensitive) == 0 ||
QString::compare(global_opts.value("wins support"), "true", Qt::CaseInsensitive) == 0))
{
wins_server = "127.0.0.1";
}
else
{
}
}
return wins_server;
}
|
@@ -864,3 +864,35 @@ QStringList Smb4KGlobal::whitelistedMountArguments()
#endif
+const QString Smb4KGlobal::findMountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+#if defined(Q_OS_LINUX)
+ return QStandardPaths::findExecutable("mount.cifs", paths);
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
+ return QStandardPaths::findExecutable("mount_smbfs", paths);
+#else
+ return QString();
+#endif
+}
+
+
+const QString Smb4KGlobal::findUmountExecutable()
+{
+ QStringList paths;
+ paths << "/bin";
+ paths << "/sbin";
+ paths << "/usr/bin";
+ paths << "/usr/sbin";
+ paths << "/usr/local/bin";
+ paths << "/usr/local/sbin";
+
+ return QStandardPaths::findExecutable("umount", paths);
+}
|
CWE-20
| null | null |
5,245
|
void Smb4KMounter::abortAll()
{
if (!QCoreApplication::closingDown())
{
QListIterator<KJob *> it(subjobs());
while (it.hasNext())
{
it.next()->kill(KJob::EmitResult);
}
}
else
{
}
}
|
+Priv
| 0
|
void Smb4KMounter::abortAll()
{
if (!QCoreApplication::closingDown())
{
QListIterator<KJob *> it(subjobs());
while (it.hasNext())
{
it.next()->kill(KJob::EmitResult);
}
}
else
{
}
}
|
@@ -1104,16 +1104,7 @@ void Smb4KMounter::timerEvent(QTimerEvent *)
bool Smb4KMounter::fillMountActionArgs(Smb4KShare *share, QVariantMap& map)
{
// Find the mount program.
- QString mount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- mount = QStandardPaths::findExecutable("mount.cifs", paths);
+ const QString mount = findMountExecutable();
if (!mount.isEmpty())
{
@@ -1645,16 +1636,7 @@ bool Smb4KMounter::fillMountActionArgs(Smb4KShare *share, QVariantMap& map)
bool Smb4KMounter::fillMountActionArgs(Smb4KShare *share, QVariantMap& map)
{
// Find the mount program.
- QString mount;
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- mount = QStandardPaths::findExecutable("mount_smbfs", paths);
+ const QString mount = findMountExecutable();
if (!mount.isEmpty())
{
@@ -1823,15 +1805,7 @@ bool Smb4KMounter::fillUnmountActionArgs(Smb4KShare *share, bool force, bool sil
//
// The umount program
//
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- QString umount = QStandardPaths::findExecutable("umount", paths);
+ const QString umount = findUmountExecutable();
if (umount.isEmpty() && !silent)
{
@@ -1884,15 +1858,7 @@ bool Smb4KMounter::fillUnmountActionArgs(Smb4KShare *share, bool force, bool sil
//
// The umount program
//
- QStringList paths;
- paths << "/bin";
- paths << "/sbin";
- paths << "/usr/bin";
- paths << "/usr/sbin";
- paths << "/usr/local/bin";
- paths << "/usr/local/sbin";
-
- QString umount = QStandardPaths::findExecutable("umount", paths);
+ const QString umount = findUmountExecutable();
if (umount.isEmpty() && !silent)
{
|
CWE-20
| null | null |
5,246
|
check_file_permissions(i_ctx_t *i_ctx_p, const char *fname, int len,
const char *permitgroup)
{
char fname_reduced[gp_file_name_sizeof];
uint rlen = sizeof(fname_reduced);
if (gp_file_name_reduce(fname, len, fname_reduced, &rlen) != gp_combine_success)
return gs_error_invalidaccess; /* fail if we couldn't reduce */
return check_file_permissions_reduced(i_ctx_p, fname_reduced, rlen, permitgroup);
}
|
+Info
| 0
|
check_file_permissions(i_ctx_t *i_ctx_p, const char *fname, int len,
const char *permitgroup)
{
char fname_reduced[gp_file_name_sizeof];
uint rlen = sizeof(fname_reduced);
if (gp_file_name_reduce(fname, len, fname_reduced, &rlen) != gp_combine_success)
return gs_error_invalidaccess; /* fail if we couldn't reduce */
return check_file_permissions_reduced(i_ctx_p, fname_reduced, rlen, permitgroup);
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,247
|
check_file_permissions_aux(i_ctx_t *i_ctx_p, char *fname, uint flen)
{ /* i_ctx_p is NULL running init files. */
/* fname must be reduced. */
if (i_ctx_p == NULL)
return 0;
if (check_file_permissions_reduced(i_ctx_p, fname, flen, "PermitFileReading") < 0)
return_error(gs_error_invalidfileaccess);
return 0;
}
|
+Info
| 0
|
check_file_permissions_aux(i_ctx_t *i_ctx_p, char *fname, uint flen)
{ /* i_ctx_p is NULL running init files. */
/* fname must be reduced. */
if (i_ctx_p == NULL)
return 0;
if (check_file_permissions_reduced(i_ctx_p, fname, flen, "PermitFileReading") < 0)
return_error(gs_error_invalidfileaccess);
return 0;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,248
|
check_file_permissions_reduced(i_ctx_t *i_ctx_p, const char *fname, int len,
const char *permitgroup)
{
long i;
ref *permitlist = NULL;
/* an empty string (first character == 0) if '\' character is */
/* recognized as a file name separator as on DOS & Windows */
const char *win_sep2 = "\\";
bool use_windows_pathsep = (gs_file_name_check_separator(win_sep2, 1, win_sep2) == 1);
uint plen = gp_file_name_parents(fname, len);
/* Assuming a reduced file name. */
if (dict_find_string(&(i_ctx_p->userparams), permitgroup, &permitlist) <= 0)
return 0; /* if Permissions not found, just allow access */
for (i=0; i<r_size(permitlist); i++) {
ref permitstring;
const string_match_params win_filename_params = {
'*', '?', '\\', true, true /* ignore case & '/' == '\\' */
};
const byte *permstr;
uint permlen;
int cwd_len = 0;
if (array_get(imemory, permitlist, i, &permitstring) < 0 ||
r_type(&permitstring) != t_string
)
break; /* any problem, just fail */
permstr = permitstring.value.bytes;
permlen = r_size(&permitstring);
/*
* Check if any file name is permitted with "*".
*/
if (permlen == 1 && permstr[0] == '*')
return 0; /* success */
/*
* If the filename starts with parent references,
* the permission element must start with same number of parent references.
*/
if (plen != 0 && plen != gp_file_name_parents((const char *)permstr, permlen))
continue;
cwd_len = gp_file_name_cwds((const char *)permstr, permlen);
/*
* If the permission starts with "./", absolute paths
* are not permitted.
*/
if (cwd_len > 0 && gp_file_name_is_absolute(fname, len))
continue;
/*
* If the permission starts with "./", relative paths
* with no "./" are allowed as well as with "./".
* 'fname' has no "./" because it is reduced.
*/
if (string_match( (const unsigned char*) fname, len,
permstr + cwd_len, permlen - cwd_len,
use_windows_pathsep ? &win_filename_params : NULL))
return 0; /* success */
}
/* not found */
return gs_error_invalidfileaccess;
}
|
+Info
| 0
|
check_file_permissions_reduced(i_ctx_t *i_ctx_p, const char *fname, int len,
const char *permitgroup)
{
long i;
ref *permitlist = NULL;
/* an empty string (first character == 0) if '\' character is */
/* recognized as a file name separator as on DOS & Windows */
const char *win_sep2 = "\\";
bool use_windows_pathsep = (gs_file_name_check_separator(win_sep2, 1, win_sep2) == 1);
uint plen = gp_file_name_parents(fname, len);
/* Assuming a reduced file name. */
if (dict_find_string(&(i_ctx_p->userparams), permitgroup, &permitlist) <= 0)
return 0; /* if Permissions not found, just allow access */
for (i=0; i<r_size(permitlist); i++) {
ref permitstring;
const string_match_params win_filename_params = {
'*', '?', '\\', true, true /* ignore case & '/' == '\\' */
};
const byte *permstr;
uint permlen;
int cwd_len = 0;
if (array_get(imemory, permitlist, i, &permitstring) < 0 ||
r_type(&permitstring) != t_string
)
break; /* any problem, just fail */
permstr = permitstring.value.bytes;
permlen = r_size(&permitstring);
/*
* Check if any file name is permitted with "*".
*/
if (permlen == 1 && permstr[0] == '*')
return 0; /* success */
/*
* If the filename starts with parent references,
* the permission element must start with same number of parent references.
*/
if (plen != 0 && plen != gp_file_name_parents((const char *)permstr, permlen))
continue;
cwd_len = gp_file_name_cwds((const char *)permstr, permlen);
/*
* If the permission starts with "./", absolute paths
* are not permitted.
*/
if (cwd_len > 0 && gp_file_name_is_absolute(fname, len))
continue;
/*
* If the permission starts with "./", relative paths
* with no "./" are allowed as well as with "./".
* 'fname' has no "./" because it is reduced.
*/
if (string_match( (const unsigned char*) fname, len,
permstr + cwd_len, permlen - cwd_len,
use_windows_pathsep ? &win_filename_params : NULL))
return 0; /* success */
}
/* not found */
return gs_error_invalidfileaccess;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,249
|
file_close(ref * pfile)
{
stream *s;
if (file_is_valid(s, pfile)) { /* closing a closed file is a no-op */
if (sclose(s))
return_error(gs_error_ioerror);
}
return 0;
}
|
+Info
| 0
|
file_close(ref * pfile)
{
stream *s;
if (file_is_valid(s, pfile)) { /* closing a closed file is a no-op */
if (sclose(s))
return_error(gs_error_ioerror);
}
return 0;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,250
|
file_continue(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
es_ptr pscratch = esp - 2;
file_enum *pfen = r_ptr(esp - 1, file_enum);
int devlen = esp[-3].value.intval;
gx_io_device *iodev = r_ptr(esp - 4, gx_io_device);
uint len = r_size(pscratch);
uint code;
if (len < devlen)
return_error(gs_error_rangecheck); /* not even room for device len */
do {
memcpy((char *)pscratch->value.bytes, iodev->dname, devlen);
code = iodev->procs.enumerate_next(pfen, (char *)pscratch->value.bytes + devlen,
len - devlen);
if (code == ~(uint) 0) { /* all done */
esp -= 5; /* pop proc, pfen, devlen, iodev , mark */
return o_pop_estack;
} else if (code > len) /* overran string */
return_error(gs_error_rangecheck);
else if (iodev != iodev_default(imemory)
|| (check_file_permissions_reduced(i_ctx_p, (char *)pscratch->value.bytes, code + devlen, "PermitFileReading")) == 0) {
push(1);
ref_assign(op, pscratch);
r_set_size(op, code + devlen);
push_op_estack(file_continue); /* come again */
*++esp = pscratch[2]; /* proc */
return o_push_estack;
}
} while(1);
}
|
+Info
| 0
|
file_continue(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
es_ptr pscratch = esp - 2;
file_enum *pfen = r_ptr(esp - 1, file_enum);
int devlen = esp[-3].value.intval;
gx_io_device *iodev = r_ptr(esp - 4, gx_io_device);
uint len = r_size(pscratch);
uint code;
if (len < devlen)
return_error(gs_error_rangecheck); /* not even room for device len */
do {
memcpy((char *)pscratch->value.bytes, iodev->dname, devlen);
code = iodev->procs.enumerate_next(pfen, (char *)pscratch->value.bytes + devlen,
len - devlen);
if (code == ~(uint) 0) { /* all done */
esp -= 5; /* pop proc, pfen, devlen, iodev , mark */
return o_pop_estack;
} else if (code > len) /* overran string */
return_error(gs_error_rangecheck);
else if (iodev != iodev_default(imemory)
|| (check_file_permissions_reduced(i_ctx_p, (char *)pscratch->value.bytes, code + devlen, "PermitFileReading")) == 0) {
push(1);
ref_assign(op, pscratch);
r_set_size(op, code + devlen);
push_op_estack(file_continue); /* come again */
*++esp = pscratch[2]; /* proc */
return o_push_estack;
}
} while(1);
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,251
|
file_read_string(const byte *str, uint len, ref *pfile, gs_ref_memory_t *imem)
{
stream *s = file_alloc_stream((gs_memory_t *)imem, "file_read_string");
if (s == 0)
return_error(gs_error_VMerror);
sread_string(s, str, len);
s->foreign = 1;
s->write_id = 0;
make_file(pfile, a_readonly | imemory_space(imem), s->read_id, s);
s->save_close = s->procs.close;
s->procs.close = file_close_disable;
return 0;
}
|
+Info
| 0
|
file_read_string(const byte *str, uint len, ref *pfile, gs_ref_memory_t *imem)
{
stream *s = file_alloc_stream((gs_memory_t *)imem, "file_read_string");
if (s == 0)
return_error(gs_error_VMerror);
sread_string(s, str, len);
s->foreign = 1;
s->write_id = 0;
make_file(pfile, a_readonly | imemory_space(imem), s->read_id, s);
s->save_close = s->procs.close;
s->procs.close = file_close_disable;
return 0;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,252
|
filter_open(const char *file_access, uint buffer_size, ref * pfile,
const stream_procs * procs, const stream_template * templat,
const stream_state * st, gs_memory_t *mem)
{
stream *s;
uint ssize = gs_struct_type_size(templat->stype);
stream_state *sst = 0;
int code;
if (templat->stype != &st_stream_state) {
sst = s_alloc_state(mem, templat->stype, "filter_open(stream_state)");
if (sst == 0)
return_error(gs_error_VMerror);
}
code = file_open_stream((char *)0, 0, file_access, buffer_size, &s,
(gx_io_device *)0, (iodev_proc_fopen_t)0, mem);
if (code < 0) {
gs_free_object(mem, sst, "filter_open(stream_state)");
return code;
}
s_std_init(s, s->cbuf, s->bsize, procs,
(*file_access == 'r' ? s_mode_read : s_mode_write));
s->procs.process = templat->process;
s->save_close = s->procs.close;
s->procs.close = file_close_file;
if (sst == 0) {
/* This stream doesn't have any state of its own. */
/* Hack: use the stream itself as the state. */
sst = (stream_state *) s;
} else if (st != 0) /* might not have client parameters */
memcpy(sst, st, ssize);
s->state = sst;
s_init_state(sst, templat, mem);
sst->report_error = filter_report_error;
if (templat->init != 0) {
code = (*templat->init)(sst);
if (code < 0) {
gs_free_object(mem, sst, "filter_open(stream_state)");
gs_free_object(mem, s->cbuf, "filter_open(buffer)");
return code;
}
}
make_stream_file(pfile, s, file_access);
return 0;
}
|
+Info
| 0
|
filter_open(const char *file_access, uint buffer_size, ref * pfile,
const stream_procs * procs, const stream_template * templat,
const stream_state * st, gs_memory_t *mem)
{
stream *s;
uint ssize = gs_struct_type_size(templat->stype);
stream_state *sst = 0;
int code;
if (templat->stype != &st_stream_state) {
sst = s_alloc_state(mem, templat->stype, "filter_open(stream_state)");
if (sst == 0)
return_error(gs_error_VMerror);
}
code = file_open_stream((char *)0, 0, file_access, buffer_size, &s,
(gx_io_device *)0, (iodev_proc_fopen_t)0, mem);
if (code < 0) {
gs_free_object(mem, sst, "filter_open(stream_state)");
return code;
}
s_std_init(s, s->cbuf, s->bsize, procs,
(*file_access == 'r' ? s_mode_read : s_mode_write));
s->procs.process = templat->process;
s->save_close = s->procs.close;
s->procs.close = file_close_file;
if (sst == 0) {
/* This stream doesn't have any state of its own. */
/* Hack: use the stream itself as the state. */
sst = (stream_state *) s;
} else if (st != 0) /* might not have client parameters */
memcpy(sst, st, ssize);
s->state = sst;
s_init_state(sst, templat, mem);
sst->report_error = filter_report_error;
if (templat->init != 0) {
code = (*templat->init)(sst);
if (code < 0) {
gs_free_object(mem, sst, "filter_open(stream_state)");
gs_free_object(mem, s->cbuf, "filter_open(buffer)");
return code;
}
}
make_stream_file(pfile, s, file_access);
return 0;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,253
|
filter_report_error(stream_state * st, const char *str)
{
if_debug1m('s', st->memory, "[s]stream error: %s\n", str);
strncpy(st->error_string, str, STREAM_MAX_ERROR_STRING);
/* Ensure null termination. */
st->error_string[STREAM_MAX_ERROR_STRING] = 0;
return 0;
}
|
+Info
| 0
|
filter_report_error(stream_state * st, const char *str)
{
if_debug1m('s', st->memory, "[s]stream error: %s\n", str);
strncpy(st->error_string, str, STREAM_MAX_ERROR_STRING);
/* Ensure null termination. */
st->error_string[STREAM_MAX_ERROR_STRING] = 0;
return 0;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,254
|
iodev_os_open_file(gx_io_device * iodev, const char *fname, uint len,
const char *file_access, stream ** ps, gs_memory_t * mem)
{
return file_open_stream(fname, len, file_access,
file_default_buffer_size, ps,
iodev, iodev->procs.gp_fopen, mem);
}
|
+Info
| 0
|
iodev_os_open_file(gx_io_device * iodev, const char *fname, uint len,
const char *file_access, stream ** ps, gs_memory_t * mem)
{
return file_open_stream(fname, len, file_access,
file_default_buffer_size, ps,
iodev, iodev->procs.gp_fopen, mem);
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,255
|
lib_file_open(gs_file_path_ptr lib_path, const gs_memory_t *mem, i_ctx_t *i_ctx_p,
const char *fname, uint flen, char *buffer, int blen, uint *pclen, ref *pfile)
{ /* i_ctx_p is NULL running arg (@) files.
* lib_path and mem are never NULL
*/
bool starting_arg_file = (i_ctx_p == NULL) ? true : i_ctx_p->starting_arg_file;
bool search_with_no_combine = false;
bool search_with_combine = false;
char fmode[2] = { 'r', 0};
gx_io_device *iodev = iodev_default(mem);
gs_main_instance *minst = get_minst_from_memory(mem);
int code;
if (i_ctx_p && starting_arg_file)
i_ctx_p->starting_arg_file = false;
/* when starting arg files (@ files) iodev_default is not yet set */
if (iodev == 0)
iodev = (gx_io_device *)gx_io_device_table[0];
if (gp_file_name_is_absolute(fname, flen)) {
search_with_no_combine = true;
search_with_combine = false;
} else {
search_with_no_combine = starting_arg_file;
search_with_combine = true;
}
if (minst->search_here_first) {
if (search_with_no_combine) {
code = lib_file_open_search_with_no_combine(lib_path, mem, i_ctx_p,
fname, flen, buffer, blen, pclen, pfile,
iodev, starting_arg_file, fmode);
if (code <= 0) /* +ve means continue continue */
return code;
}
if (search_with_combine) {
code = lib_file_open_search_with_combine(lib_path, mem, i_ctx_p,
fname, flen, buffer, blen, pclen, pfile,
iodev, starting_arg_file, fmode);
if (code <= 0) /* +ve means continue searching */
return code;
}
} else {
if (search_with_combine) {
code = lib_file_open_search_with_combine(lib_path, mem, i_ctx_p,
fname, flen, buffer, blen, pclen, pfile,
iodev, starting_arg_file, fmode);
if (code <= 0) /* +ve means continue searching */
return code;
}
if (search_with_no_combine) {
code = lib_file_open_search_with_no_combine(lib_path, mem, i_ctx_p,
fname, flen, buffer, blen, pclen, pfile,
iodev, starting_arg_file, fmode);
if (code <= 0) /* +ve means continue searching */
return code;
}
}
return_error(gs_error_undefinedfilename);
}
|
+Info
| 0
|
lib_file_open(gs_file_path_ptr lib_path, const gs_memory_t *mem, i_ctx_t *i_ctx_p,
const char *fname, uint flen, char *buffer, int blen, uint *pclen, ref *pfile)
{ /* i_ctx_p is NULL running arg (@) files.
* lib_path and mem are never NULL
*/
bool starting_arg_file = (i_ctx_p == NULL) ? true : i_ctx_p->starting_arg_file;
bool search_with_no_combine = false;
bool search_with_combine = false;
char fmode[2] = { 'r', 0};
gx_io_device *iodev = iodev_default(mem);
gs_main_instance *minst = get_minst_from_memory(mem);
int code;
if (i_ctx_p && starting_arg_file)
i_ctx_p->starting_arg_file = false;
/* when starting arg files (@ files) iodev_default is not yet set */
if (iodev == 0)
iodev = (gx_io_device *)gx_io_device_table[0];
if (gp_file_name_is_absolute(fname, flen)) {
search_with_no_combine = true;
search_with_combine = false;
} else {
search_with_no_combine = starting_arg_file;
search_with_combine = true;
}
if (minst->search_here_first) {
if (search_with_no_combine) {
code = lib_file_open_search_with_no_combine(lib_path, mem, i_ctx_p,
fname, flen, buffer, blen, pclen, pfile,
iodev, starting_arg_file, fmode);
if (code <= 0) /* +ve means continue continue */
return code;
}
if (search_with_combine) {
code = lib_file_open_search_with_combine(lib_path, mem, i_ctx_p,
fname, flen, buffer, blen, pclen, pfile,
iodev, starting_arg_file, fmode);
if (code <= 0) /* +ve means continue searching */
return code;
}
} else {
if (search_with_combine) {
code = lib_file_open_search_with_combine(lib_path, mem, i_ctx_p,
fname, flen, buffer, blen, pclen, pfile,
iodev, starting_arg_file, fmode);
if (code <= 0) /* +ve means continue searching */
return code;
}
if (search_with_no_combine) {
code = lib_file_open_search_with_no_combine(lib_path, mem, i_ctx_p,
fname, flen, buffer, blen, pclen, pfile,
iodev, starting_arg_file, fmode);
if (code <= 0) /* +ve means continue searching */
return code;
}
}
return_error(gs_error_undefinedfilename);
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,256
|
lib_file_open_search_with_combine(gs_file_path_ptr lib_path, const gs_memory_t *mem, i_ctx_t *i_ctx_p,
const char *fname, uint flen, char *buffer, int blen, uint *pclen, ref *pfile,
gx_io_device *iodev, bool starting_arg_file, char *fmode)
{
stream *s;
const gs_file_path *pfpath = lib_path;
uint pi;
for (pi = 0; pi < r_size(&pfpath->list); ++pi) {
const ref *prdir = pfpath->list.value.refs + pi;
const char *pstr = (const char *)prdir->value.const_bytes;
uint plen = r_size(prdir), blen1 = blen;
gs_parsed_file_name_t pname;
gp_file_name_combine_result r;
/* We need to concatenate and parse the file name here
* if this path has a %device% prefix. */
if (pstr[0] == '%') {
int code;
/* We concatenate directly since gp_file_name_combine_*
* rules are not correct for other devices such as %rom% */
code = gs_parse_file_name(&pname, pstr, plen, mem);
if (code < 0)
continue;
if (blen < max(pname.len, plen) + flen)
return_error(gs_error_limitcheck);
memcpy(buffer, pname.fname, pname.len);
memcpy(buffer+pname.len, fname, flen);
code = pname.iodev->procs.open_file(pname.iodev, buffer, pname.len + flen, fmode,
&s, (gs_memory_t *)mem);
if (code < 0)
continue;
make_stream_file(pfile, s, "r");
/* fill in the buffer with the device concatenated */
memcpy(buffer, pstr, plen);
memcpy(buffer+plen, fname, flen);
*pclen = plen + flen;
return 0;
} else {
r = gp_file_name_combine(pstr, plen,
fname, flen, false, buffer, &blen1);
if (r != gp_combine_success)
continue;
if (iodev_os_open_file(iodev, (const char *)buffer, blen1, (const char *)fmode,
&s, (gs_memory_t *)mem) == 0) {
if (starting_arg_file ||
check_file_permissions_aux(i_ctx_p, buffer, blen1) >= 0) {
*pclen = blen1;
make_stream_file(pfile, s, "r");
return 0;
}
sclose(s);
return_error(gs_error_invalidfileaccess);
}
}
}
return 1;
}
|
+Info
| 0
|
lib_file_open_search_with_combine(gs_file_path_ptr lib_path, const gs_memory_t *mem, i_ctx_t *i_ctx_p,
const char *fname, uint flen, char *buffer, int blen, uint *pclen, ref *pfile,
gx_io_device *iodev, bool starting_arg_file, char *fmode)
{
stream *s;
const gs_file_path *pfpath = lib_path;
uint pi;
for (pi = 0; pi < r_size(&pfpath->list); ++pi) {
const ref *prdir = pfpath->list.value.refs + pi;
const char *pstr = (const char *)prdir->value.const_bytes;
uint plen = r_size(prdir), blen1 = blen;
gs_parsed_file_name_t pname;
gp_file_name_combine_result r;
/* We need to concatenate and parse the file name here
* if this path has a %device% prefix. */
if (pstr[0] == '%') {
int code;
/* We concatenate directly since gp_file_name_combine_*
* rules are not correct for other devices such as %rom% */
code = gs_parse_file_name(&pname, pstr, plen, mem);
if (code < 0)
continue;
if (blen < max(pname.len, plen) + flen)
return_error(gs_error_limitcheck);
memcpy(buffer, pname.fname, pname.len);
memcpy(buffer+pname.len, fname, flen);
code = pname.iodev->procs.open_file(pname.iodev, buffer, pname.len + flen, fmode,
&s, (gs_memory_t *)mem);
if (code < 0)
continue;
make_stream_file(pfile, s, "r");
/* fill in the buffer with the device concatenated */
memcpy(buffer, pstr, plen);
memcpy(buffer+plen, fname, flen);
*pclen = plen + flen;
return 0;
} else {
r = gp_file_name_combine(pstr, plen,
fname, flen, false, buffer, &blen1);
if (r != gp_combine_success)
continue;
if (iodev_os_open_file(iodev, (const char *)buffer, blen1, (const char *)fmode,
&s, (gs_memory_t *)mem) == 0) {
if (starting_arg_file ||
check_file_permissions_aux(i_ctx_p, buffer, blen1) >= 0) {
*pclen = blen1;
make_stream_file(pfile, s, "r");
return 0;
}
sclose(s);
return_error(gs_error_invalidfileaccess);
}
}
}
return 1;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,257
|
lib_fopen(const gs_file_path_ptr pfpath, const gs_memory_t *mem, const char *fname)
{
/* We need a buffer to hold the expanded file name. */
char filename_found[DEFAULT_BUFFER_SIZE];
FILE *file = NULL;
uint fnamelen;
ref obj;
int code;
/* open the usual 'stream', then if successful, return the file */
code = lib_file_open(pfpath, mem, NULL, fname, strlen(fname),
filename_found, sizeof(filename_found), &fnamelen, &obj);
if (code < 0)
return NULL;
file = ((stream *)(obj.value.pfile))->file;
return file;
}
|
+Info
| 0
|
lib_fopen(const gs_file_path_ptr pfpath, const gs_memory_t *mem, const char *fname)
{
/* We need a buffer to hold the expanded file name. */
char filename_found[DEFAULT_BUFFER_SIZE];
FILE *file = NULL;
uint fnamelen;
ref obj;
int code;
/* open the usual 'stream', then if successful, return the file */
code = lib_file_open(pfpath, mem, NULL, fname, strlen(fname),
filename_found, sizeof(filename_found), &fnamelen, &obj);
if (code < 0)
return NULL;
file = ((stream *)(obj.value.pfile))->file;
return file;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,258
|
make_stream_file(ref * pfile, stream * s, const char *access)
{
uint attrs =
(access[1] == '+' ? a_write + a_read + a_execute : 0) |
imemory_space((gs_ref_memory_t *) s->memory);
if (access[0] == 'r') {
make_file(pfile, attrs | (a_read | a_execute), s->read_id, s);
s->write_id = 0;
} else {
make_file(pfile, attrs | a_write, s->write_id, s);
s->read_id = 0;
}
}
|
+Info
| 0
|
make_stream_file(ref * pfile, stream * s, const char *access)
{
uint attrs =
(access[1] == '+' ? a_write + a_read + a_execute : 0) |
imemory_space((gs_ref_memory_t *) s->memory);
if (access[0] == 'r') {
make_file(pfile, attrs | (a_read | a_execute), s->read_id, s);
s->write_id = 0;
} else {
make_file(pfile, attrs | a_write, s->write_id, s);
s->read_id = 0;
}
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,259
|
parse_real_file_name(const ref *op, gs_parsed_file_name_t *pfn,
gs_memory_t *mem, client_name_t cname)
{
check_read_type(*op, t_string);
return gs_parse_real_file_name(pfn, (const char *)op->value.const_bytes,
r_size(op), mem, cname);
}
|
+Info
| 0
|
parse_real_file_name(const ref *op, gs_parsed_file_name_t *pfn,
gs_memory_t *mem, client_name_t cname)
{
check_read_type(*op, t_string);
return gs_parse_real_file_name(pfn, (const char *)op->value.const_bytes,
r_size(op), mem, cname);
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,260
|
zdeletefile(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gs_parsed_file_name_t pname;
int code = parse_real_file_name(op, &pname, imemory, "deletefile");
if (code < 0)
return code;
if (pname.iodev == iodev_default(imemory)) {
if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
"PermitFileControl")) < 0 &&
!file_is_tempfile(i_ctx_p, op->value.bytes, r_size(op))) {
return code;
}
}
code = (*pname.iodev->procs.delete_file)(pname.iodev, pname.fname);
gs_free_file_name(&pname, "deletefile");
if (code < 0)
return code;
pop(1);
return 0;
}
|
+Info
| 0
|
zdeletefile(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gs_parsed_file_name_t pname;
int code = parse_real_file_name(op, &pname, imemory, "deletefile");
if (code < 0)
return code;
if (pname.iodev == iodev_default(imemory)) {
if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
"PermitFileControl")) < 0 &&
!file_is_tempfile(i_ctx_p, op->value.bytes, r_size(op))) {
return code;
}
}
code = (*pname.iodev->procs.delete_file)(pname.iodev, pname.fname);
gs_free_file_name(&pname, "deletefile");
if (code < 0)
return code;
pop(1);
return 0;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,261
|
static int zgetfilename(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
uint fnlen;
gs_const_string pfname;
stream *s;
byte *sbody;
int code;
check_ostack(1);
check_read_type(*op, t_file);
s = (op)->value.pfile;
code = sfilename(s, &pfname);
if (code < 0) {
pfname.size = 0;
}
fnlen = pfname.size;
sbody = ialloc_string(fnlen, ".getfilename");
if (sbody == 0) {
code = gs_note_error(gs_error_VMerror);
return code;
}
memcpy(sbody, pfname.data, fnlen);
make_string(op, a_readonly | icurrent_space, fnlen, sbody);
return 0;
}
|
+Info
| 0
|
static int zgetfilename(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
uint fnlen;
gs_const_string pfname;
stream *s;
byte *sbody;
int code;
check_ostack(1);
check_read_type(*op, t_file);
s = (op)->value.pfile;
code = sfilename(s, &pfname);
if (code < 0) {
pfname.size = 0;
}
fnlen = pfname.size;
sbody = ialloc_string(fnlen, ".getfilename");
if (sbody == 0) {
code = gs_note_error(gs_error_VMerror);
return code;
}
memcpy(sbody, pfname.data, fnlen);
make_string(op, a_readonly | icurrent_space, fnlen, sbody);
return 0;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,262
|
zrenamefile(i_ctx_t *i_ctx_p)
{
int code;
os_ptr op = osp;
gs_parsed_file_name_t pname1, pname2;
code = parse_real_file_name(op, &pname2, imemory, "renamefile(to)");
if (code < 0)
return code;
pname1.fname = 0;
code = parse_real_file_name(op - 1, &pname1, imemory, "renamefile(from)");
if (code >= 0) {
gx_io_device *iodev_dflt = iodev_default(imemory);
if (pname1.iodev != pname2.iodev ) {
if (pname1.iodev == iodev_dflt)
pname1.iodev = pname2.iodev;
if (pname2.iodev == iodev_dflt)
pname2.iodev = pname1.iodev;
}
if (pname1.iodev != pname2.iodev ||
(pname1.iodev == iodev_dflt &&
/*
* We require FileControl permissions on the source path
* unless it is a temporary file. Also, we require FileControl
* and FileWriting permissions to the destination file/path.
*/
((check_file_permissions(i_ctx_p, pname1.fname, pname1.len,
"PermitFileControl") < 0 &&
!file_is_tempfile(i_ctx_p, op[-1].value.bytes, r_size(op - 1))) ||
(check_file_permissions(i_ctx_p, pname2.fname, pname2.len,
"PermitFileControl") < 0 ||
check_file_permissions(i_ctx_p, pname2.fname, pname2.len,
"PermitFileWriting") < 0 )))) {
code = gs_note_error(gs_error_invalidfileaccess);
} else {
code = (*pname1.iodev->procs.rename_file)(pname1.iodev,
pname1.fname, pname2.fname);
}
}
gs_free_file_name(&pname2, "renamefile(to)");
gs_free_file_name(&pname1, "renamefile(from)");
if (code < 0)
return code;
pop(2);
return 0;
}
|
+Info
| 0
|
zrenamefile(i_ctx_t *i_ctx_p)
{
int code;
os_ptr op = osp;
gs_parsed_file_name_t pname1, pname2;
code = parse_real_file_name(op, &pname2, imemory, "renamefile(to)");
if (code < 0)
return code;
pname1.fname = 0;
code = parse_real_file_name(op - 1, &pname1, imemory, "renamefile(from)");
if (code >= 0) {
gx_io_device *iodev_dflt = iodev_default(imemory);
if (pname1.iodev != pname2.iodev ) {
if (pname1.iodev == iodev_dflt)
pname1.iodev = pname2.iodev;
if (pname2.iodev == iodev_dflt)
pname2.iodev = pname1.iodev;
}
if (pname1.iodev != pname2.iodev ||
(pname1.iodev == iodev_dflt &&
/*
* We require FileControl permissions on the source path
* unless it is a temporary file. Also, we require FileControl
* and FileWriting permissions to the destination file/path.
*/
((check_file_permissions(i_ctx_p, pname1.fname, pname1.len,
"PermitFileControl") < 0 &&
!file_is_tempfile(i_ctx_p, op[-1].value.bytes, r_size(op - 1))) ||
(check_file_permissions(i_ctx_p, pname2.fname, pname2.len,
"PermitFileControl") < 0 ||
check_file_permissions(i_ctx_p, pname2.fname, pname2.len,
"PermitFileWriting") < 0 )))) {
code = gs_note_error(gs_error_invalidfileaccess);
} else {
code = (*pname1.iodev->procs.rename_file)(pname1.iodev,
pname1.fname, pname2.fname);
}
}
gs_free_file_name(&pname2, "renamefile(to)");
gs_free_file_name(&pname1, "renamefile(from)");
if (code < 0)
return code;
pop(2);
return 0;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,263
|
ztempfile(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
const char *pstr;
char fmode[4];
int code = parse_file_access_string(op, fmode);
char *prefix = NULL;
char *fname= NULL;
uint fnlen;
FILE *sfile;
stream *s;
byte *buf, *sbody;
if (code < 0)
return code;
prefix = (char *)gs_alloc_bytes(imemory, gp_file_name_sizeof, "ztempfile(prefix)");
fname = (char *)gs_alloc_bytes(imemory, gp_file_name_sizeof, "ztempfile(fname)");
if (!prefix || !fname) {
code = gs_note_error(gs_error_VMerror);
goto done;
}
strcat(fmode, gp_fmode_binary_suffix);
if (r_has_type(op - 1, t_null))
pstr = gp_scratch_file_name_prefix;
else {
uint psize;
check_read_type(op[-1], t_string);
psize = r_size(op - 1);
if (psize >= gp_file_name_sizeof) {
code = gs_note_error(gs_error_rangecheck);
goto done;
}
memcpy(prefix, op[-1].value.const_bytes, psize);
prefix[psize] = 0;
pstr = prefix;
}
if (gp_file_name_is_absolute(pstr, strlen(pstr))) {
if (check_file_permissions(i_ctx_p, pstr, strlen(pstr),
"PermitFileWriting") < 0) {
code = gs_note_error(gs_error_invalidfileaccess);
goto done;
}
} else if (!prefix_is_simple(pstr)) {
code = gs_note_error(gs_error_invalidfileaccess);
goto done;
}
s = file_alloc_stream(imemory, "ztempfile(stream)");
if (s == 0) {
code = gs_note_error(gs_error_VMerror);
goto done;
}
buf = gs_alloc_bytes(imemory, file_default_buffer_size,
"ztempfile(buffer)");
if (buf == 0) {
code = gs_note_error(gs_error_VMerror);
goto done;
}
sfile = gp_open_scratch_file(imemory, pstr, fname, fmode);
if (sfile == 0) {
gs_free_object(imemory, buf, "ztempfile(buffer)");
code = gs_note_error(gs_error_invalidfileaccess);
goto done;
}
fnlen = strlen(fname);
sbody = ialloc_string(fnlen, ".tempfile(fname)");
if (sbody == 0) {
gs_free_object(imemory, buf, "ztempfile(buffer)");
code = gs_note_error(gs_error_VMerror);
goto done;
}
memcpy(sbody, fname, fnlen);
file_init_stream(s, sfile, fmode, buf, file_default_buffer_size);
code = ssetfilename(s, (const unsigned char*) fname, fnlen);
if (code < 0) {
gx_io_device *iodev_dflt = iodev_default(imemory);
sclose(s);
iodev_dflt->procs.delete_file(iodev_dflt, fname);
ifree_string(sbody, fnlen, ".tempfile(fname)");
code = gs_note_error(gs_error_VMerror);
goto done;
}
make_string(op - 1, a_readonly | icurrent_space, fnlen, sbody);
make_stream_file(op, s, fmode);
done:
if (prefix)
gs_free_object(imemory, prefix, "ztempfile(prefix)");
if (fname)
gs_free_object(imemory, fname, "ztempfile(fname)");
return code;
}
|
+Info
| 0
|
ztempfile(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
const char *pstr;
char fmode[4];
int code = parse_file_access_string(op, fmode);
char *prefix = NULL;
char *fname= NULL;
uint fnlen;
FILE *sfile;
stream *s;
byte *buf, *sbody;
if (code < 0)
return code;
prefix = (char *)gs_alloc_bytes(imemory, gp_file_name_sizeof, "ztempfile(prefix)");
fname = (char *)gs_alloc_bytes(imemory, gp_file_name_sizeof, "ztempfile(fname)");
if (!prefix || !fname) {
code = gs_note_error(gs_error_VMerror);
goto done;
}
strcat(fmode, gp_fmode_binary_suffix);
if (r_has_type(op - 1, t_null))
pstr = gp_scratch_file_name_prefix;
else {
uint psize;
check_read_type(op[-1], t_string);
psize = r_size(op - 1);
if (psize >= gp_file_name_sizeof) {
code = gs_note_error(gs_error_rangecheck);
goto done;
}
memcpy(prefix, op[-1].value.const_bytes, psize);
prefix[psize] = 0;
pstr = prefix;
}
if (gp_file_name_is_absolute(pstr, strlen(pstr))) {
if (check_file_permissions(i_ctx_p, pstr, strlen(pstr),
"PermitFileWriting") < 0) {
code = gs_note_error(gs_error_invalidfileaccess);
goto done;
}
} else if (!prefix_is_simple(pstr)) {
code = gs_note_error(gs_error_invalidfileaccess);
goto done;
}
s = file_alloc_stream(imemory, "ztempfile(stream)");
if (s == 0) {
code = gs_note_error(gs_error_VMerror);
goto done;
}
buf = gs_alloc_bytes(imemory, file_default_buffer_size,
"ztempfile(buffer)");
if (buf == 0) {
code = gs_note_error(gs_error_VMerror);
goto done;
}
sfile = gp_open_scratch_file(imemory, pstr, fname, fmode);
if (sfile == 0) {
gs_free_object(imemory, buf, "ztempfile(buffer)");
code = gs_note_error(gs_error_invalidfileaccess);
goto done;
}
fnlen = strlen(fname);
sbody = ialloc_string(fnlen, ".tempfile(fname)");
if (sbody == 0) {
gs_free_object(imemory, buf, "ztempfile(buffer)");
code = gs_note_error(gs_error_VMerror);
goto done;
}
memcpy(sbody, fname, fnlen);
file_init_stream(s, sfile, fmode, buf, file_default_buffer_size);
code = ssetfilename(s, (const unsigned char*) fname, fnlen);
if (code < 0) {
gx_io_device *iodev_dflt = iodev_default(imemory);
sclose(s);
iodev_dflt->procs.delete_file(iodev_dflt, fname);
ifree_string(sbody, fnlen, ".tempfile(fname)");
code = gs_note_error(gs_error_VMerror);
goto done;
}
make_string(op - 1, a_readonly | icurrent_space, fnlen, sbody);
make_stream_file(op, s, fmode);
done:
if (prefix)
gs_free_object(imemory, prefix, "ztempfile(prefix)");
if (fname)
gs_free_object(imemory, fname, "ztempfile(fname)");
return code;
}
|
@@ -209,10 +209,13 @@ z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, con
if (code < 0)
return code;
- if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0)
- return gs_error_invalidfileaccess;
-
- code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ if (pname.iodev && i_ctx_p->LockFilePermissions
+ && strcmp(pname.iodev->dname, "%pipe%") == 0) {
+ code = gs_note_error(gs_error_invalidfileaccess);
+ }
+ else {
+ code = check_file_permissions(i_ctx_p, fname, len, permitgroup);
+ }
return code;
}
@@ -503,8 +506,11 @@ zstatus(i_ctx_t *i_ctx_p)
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
- code = (*pname.iodev->procs.file_status)(pname.iodev,
+ if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
+ "PermitFileReading")) >= 0) {
+ code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
+ }
switch (code) {
case 0:
check_ostack(4);
|
CWE-200
| null | null |
5,264
|
AviaryScheddPlugin::earlyInitialize()
{
static bool skip = false;
if (skip) return; skip = true;
string log_name;
sprintf(log_name,"aviary_job.log");
string myname = "job@" + getScheddName();
provider = AviaryProviderFactory::create(log_name,myname,
"SCHEDULER","JOB","services/job/");
if (!provider) {
EXCEPT("Unable to configure AviaryProvider. Exiting...");
}
schedulerObj = SchedulerObject::getInstance();
dirtyJobs = new DirtyJobsType();
isHandlerRegistered = false;
ReliSock *sock = new ReliSock;
if (!sock) {
EXCEPT("Failed to allocate transport socket");
}
if (!sock->assign(provider->getListenerSocket())) {
EXCEPT("Failed to bind transport socket");
}
int index;
if (-1 == (index =
daemonCore->Register_Socket((Stream *) sock,
"Aviary Method Socket",
(SocketHandlercpp) ( &AviaryScheddPlugin::handleTransportSocket ),
"Handler for Aviary Methods.",
this))) {
EXCEPT("Failed to register transport socket");
}
m_initialized = false;
}
|
DoS
| 0
|
AviaryScheddPlugin::earlyInitialize()
{
static bool skip = false;
if (skip) return; skip = true;
string log_name;
sprintf(log_name,"aviary_job.log");
string myname = "job@" + getScheddName();
provider = AviaryProviderFactory::create(log_name,myname,
"SCHEDULER","JOB","services/job/");
if (!provider) {
EXCEPT("Unable to configure AviaryProvider. Exiting...");
}
schedulerObj = SchedulerObject::getInstance();
dirtyJobs = new DirtyJobsType();
isHandlerRegistered = false;
ReliSock *sock = new ReliSock;
if (!sock) {
EXCEPT("Failed to allocate transport socket");
}
if (!sock->assign(provider->getListenerSocket())) {
EXCEPT("Failed to bind transport socket");
}
int index;
if (-1 == (index =
daemonCore->Register_Socket((Stream *) sock,
"Aviary Method Socket",
(SocketHandlercpp) ( &AviaryScheddPlugin::handleTransportSocket ),
"Handler for Aviary Methods.",
this))) {
EXCEPT("Failed to register transport socket");
}
m_initialized = false;
}
|
@@ -268,7 +268,7 @@ AviaryScheddPlugin::processJob(const char *key,
// dprintf(D_FULLDEBUG, "Processing: %s\n", key);
id = getProcByString(key);
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Failed to parse key: %s - skipping\n", key);
return false;
}
|
CWE-20
| null | null |
5,265
|
AviaryScheddPlugin::markDirty(const char *key,
const char *name,
const char *value)
{
if (!IS_JOB(key)) return;
if (!(strcasecmp(name, ATTR_JOB_STATUS) == 0 ||
strcasecmp(name, ATTR_LAST_JOB_STATUS) == 0)) return;
DirtyJobStatus status(name, atoi(value));
DirtyJobEntry entry(key, status);
dirtyJobs->push_back(DirtyJobEntry(key, DirtyJobStatus(name, atoi(value))));
if (!isHandlerRegistered) {
daemonCore->Register_Timer(0,
(TimerHandlercpp)
&AviaryScheddPlugin::processDirtyJobs,
"Process Dirty",
this);
isHandlerRegistered = true;
}
}
|
DoS
| 0
|
AviaryScheddPlugin::markDirty(const char *key,
const char *name,
const char *value)
{
if (!IS_JOB(key)) return;
if (!(strcasecmp(name, ATTR_JOB_STATUS) == 0 ||
strcasecmp(name, ATTR_LAST_JOB_STATUS) == 0)) return;
DirtyJobStatus status(name, atoi(value));
DirtyJobEntry entry(key, status);
dirtyJobs->push_back(DirtyJobEntry(key, DirtyJobStatus(name, atoi(value))));
if (!isHandlerRegistered) {
daemonCore->Register_Timer(0,
(TimerHandlercpp)
&AviaryScheddPlugin::processDirtyJobs,
"Process Dirty",
this);
isHandlerRegistered = true;
}
}
|
@@ -268,7 +268,7 @@ AviaryScheddPlugin::processJob(const char *key,
// dprintf(D_FULLDEBUG, "Processing: %s\n", key);
id = getProcByString(key);
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Failed to parse key: %s - skipping\n", key);
return false;
}
|
CWE-20
| null | null |
5,266
|
AviaryScheddPlugin::shutdown()
{
static bool skip = false;
if (skip) return; skip = true;
dprintf(D_FULLDEBUG, "AviaryScheddPlugin: shutting down...\n");
if (schedulerObj) {
delete schedulerObj;
schedulerObj = NULL;
}
if (provider) {
provider->invalidate();
delete provider;
provider = NULL;
}
}
|
DoS
| 0
|
AviaryScheddPlugin::shutdown()
{
static bool skip = false;
if (skip) return; skip = true;
dprintf(D_FULLDEBUG, "AviaryScheddPlugin: shutting down...\n");
if (schedulerObj) {
delete schedulerObj;
schedulerObj = NULL;
}
if (provider) {
provider->invalidate();
delete provider;
provider = NULL;
}
}
|
@@ -268,7 +268,7 @@ AviaryScheddPlugin::processJob(const char *key,
// dprintf(D_FULLDEBUG, "Processing: %s\n", key);
id = getProcByString(key);
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Failed to parse key: %s - skipping\n", key);
return false;
}
|
CWE-20
| null | null |
5,267
|
AviaryScheddPlugin::update(int cmd, const ClassAd *ad)
{
MyString hashKey;
switch (cmd) {
case UPDATE_SCHEDD_AD:
dprintf(D_FULLDEBUG, "Received UPDATE_SCHEDD_AD\n");
schedulerObj->update(*ad);
break;
default:
dprintf(D_FULLDEBUG, "Unsupported command: %s\n",
getCollectorCommandString(cmd));
}
}
|
DoS
| 0
|
AviaryScheddPlugin::update(int cmd, const ClassAd *ad)
{
MyString hashKey;
switch (cmd) {
case UPDATE_SCHEDD_AD:
dprintf(D_FULLDEBUG, "Received UPDATE_SCHEDD_AD\n");
schedulerObj->update(*ad);
break;
default:
dprintf(D_FULLDEBUG, "Unsupported command: %s\n",
getCollectorCommandString(cmd));
}
}
|
@@ -268,7 +268,7 @@ AviaryScheddPlugin::processJob(const char *key,
// dprintf(D_FULLDEBUG, "Processing: %s\n", key);
id = getProcByString(key);
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Failed to parse key: %s - skipping\n", key);
return false;
}
|
CWE-20
| null | null |
5,268
|
SchedulerObject::SchedulerObject()
{
m_pool = getPoolName();
m_name = getScheddName();
m_codec = new BaseCodec();
}
|
DoS
| 0
|
SchedulerObject::SchedulerObject()
{
m_pool = getPoolName();
m_name = getScheddName();
m_codec = new BaseCodec();
}
|
@@ -263,7 +263,7 @@ SchedulerObject::setAttribute(std::string key,
std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "SetAttribute: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -303,7 +303,7 @@ bool
SchedulerObject::hold(std::string key, std::string &reason, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Hold: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -329,7 +329,7 @@ bool
SchedulerObject::release(std::string key, std::string &reason, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Release: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -353,7 +353,7 @@ bool
SchedulerObject::remove(std::string key, std::string &reason, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Remove: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -375,7 +375,7 @@ bool
SchedulerObject::suspend(std::string key, std::string &/*reason*/, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Remove: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -390,7 +390,7 @@ bool
SchedulerObject::_continue(std::string key, std::string &/*reason*/, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Remove: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
|
CWE-20
| null | null |
5,269
|
SchedulerObject* SchedulerObject::getInstance()
{
if (!m_instance) {
m_instance = new SchedulerObject();
}
return m_instance;
}
|
DoS
| 0
|
SchedulerObject* SchedulerObject::getInstance()
{
if (!m_instance) {
m_instance = new SchedulerObject();
}
return m_instance;
}
|
@@ -263,7 +263,7 @@ SchedulerObject::setAttribute(std::string key,
std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "SetAttribute: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -303,7 +303,7 @@ bool
SchedulerObject::hold(std::string key, std::string &reason, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Hold: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -329,7 +329,7 @@ bool
SchedulerObject::release(std::string key, std::string &reason, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Release: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -353,7 +353,7 @@ bool
SchedulerObject::remove(std::string key, std::string &reason, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Remove: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -375,7 +375,7 @@ bool
SchedulerObject::suspend(std::string key, std::string &/*reason*/, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Remove: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -390,7 +390,7 @@ bool
SchedulerObject::_continue(std::string key, std::string &/*reason*/, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Remove: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
|
CWE-20
| null | null |
5,270
|
SchedulerObject::~SchedulerObject()
{
delete m_codec;
}
|
DoS
| 0
|
SchedulerObject::~SchedulerObject()
{
delete m_codec;
}
|
@@ -263,7 +263,7 @@ SchedulerObject::setAttribute(std::string key,
std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "SetAttribute: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -303,7 +303,7 @@ bool
SchedulerObject::hold(std::string key, std::string &reason, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Hold: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -329,7 +329,7 @@ bool
SchedulerObject::release(std::string key, std::string &reason, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Release: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -353,7 +353,7 @@ bool
SchedulerObject::remove(std::string key, std::string &reason, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Remove: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -375,7 +375,7 @@ bool
SchedulerObject::suspend(std::string key, std::string &/*reason*/, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Remove: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
@@ -390,7 +390,7 @@ bool
SchedulerObject::_continue(std::string key, std::string &/*reason*/, std::string &text)
{
PROC_ID id = getProcByString(key.c_str());
- if (id.cluster < 0 || id.proc < 0) {
+ if (id.cluster <= 0 || id.proc < 0) {
dprintf(D_FULLDEBUG, "Remove: Failed to parse id: %s\n", key.c_str());
text = "Invalid Id";
return false;
|
CWE-20
| null | null |
5,271
|
T1_Done_Blend( T1_Face face )
{
FT_Memory memory = face->root.memory;
PS_Blend blend = face->blend;
if ( blend )
{
FT_UInt num_designs = blend->num_designs;
FT_UInt num_axis = blend->num_axis;
FT_UInt n;
/* release design pos table */
FT_FREE( blend->design_pos[0] );
for ( n = 1; n < num_designs; n++ )
blend->design_pos[n] = NULL;
/* release blend `private' and `font info' dictionaries */
FT_FREE( blend->privates[1] );
FT_FREE( blend->font_infos[1] );
FT_FREE( blend->bboxes[1] );
for ( n = 0; n < num_designs; n++ )
{
blend->privates [n] = NULL;
blend->font_infos[n] = NULL;
blend->bboxes [n] = NULL;
}
/* release weight vectors */
FT_FREE( blend->weight_vector );
blend->default_weight_vector = NULL;
/* release axis names */
for ( n = 0; n < num_axis; n++ )
FT_FREE( blend->axis_names[n] );
/* release design map */
for ( n = 0; n < num_axis; n++ )
{
PS_DesignMap dmap = blend->design_map + n;
FT_FREE( dmap->design_points );
dmap->num_points = 0;
}
FT_FREE( face->blend );
}
}
|
DoS
| 0
|
T1_Done_Blend( T1_Face face )
{
FT_Memory memory = face->root.memory;
PS_Blend blend = face->blend;
if ( blend )
{
FT_UInt num_designs = blend->num_designs;
FT_UInt num_axis = blend->num_axis;
FT_UInt n;
/* release design pos table */
FT_FREE( blend->design_pos[0] );
for ( n = 1; n < num_designs; n++ )
blend->design_pos[n] = NULL;
/* release blend `private' and `font info' dictionaries */
FT_FREE( blend->privates[1] );
FT_FREE( blend->font_infos[1] );
FT_FREE( blend->bboxes[1] );
for ( n = 0; n < num_designs; n++ )
{
blend->privates [n] = NULL;
blend->font_infos[n] = NULL;
blend->bboxes [n] = NULL;
}
/* release weight vectors */
FT_FREE( blend->weight_vector );
blend->default_weight_vector = NULL;
/* release axis names */
for ( n = 0; n < num_axis; n++ )
FT_FREE( blend->axis_names[n] );
/* release design map */
for ( n = 0; n < num_axis; n++ )
{
PS_DesignMap dmap = blend->design_map + n;
FT_FREE( dmap->design_points );
dmap->num_points = 0;
}
FT_FREE( face->blend );
}
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,272
|
T1_Get_MM_Var( T1_Face face,
FT_MM_Var* *master )
{
FT_Memory memory = face->root.memory;
FT_MM_Var *mmvar = NULL;
FT_Multi_Master mmaster;
FT_Error error;
FT_UInt i;
FT_Fixed axiscoords[T1_MAX_MM_AXIS];
PS_Blend blend = face->blend;
error = T1_Get_Multi_Master( face, &mmaster );
if ( error )
goto Exit;
if ( FT_ALLOC( mmvar,
sizeof ( FT_MM_Var ) +
mmaster.num_axis * sizeof ( FT_Var_Axis ) ) )
goto Exit;
mmvar->num_axis = mmaster.num_axis;
mmvar->num_designs = mmaster.num_designs;
mmvar->num_namedstyles = ~0U; /* Does not apply */
mmvar->axis = (FT_Var_Axis*)&mmvar[1];
/* Point to axes after MM_Var struct */
mmvar->namedstyle = NULL;
for ( i = 0 ; i < mmaster.num_axis; ++i )
{
mmvar->axis[i].name = mmaster.axis[i].name;
mmvar->axis[i].minimum = INT_TO_FIXED( mmaster.axis[i].minimum);
mmvar->axis[i].maximum = INT_TO_FIXED( mmaster.axis[i].maximum);
mmvar->axis[i].def = ( mmvar->axis[i].minimum +
mmvar->axis[i].maximum ) / 2;
/* Does not apply. But this value is in range */
mmvar->axis[i].strid = ~0U; /* Does not apply */
mmvar->axis[i].tag = ~0U; /* Does not apply */
if ( ft_strcmp( mmvar->axis[i].name, "Weight" ) == 0 )
mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'g', 'h', 't' );
else if ( ft_strcmp( mmvar->axis[i].name, "Width" ) == 0 )
mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'd', 't', 'h' );
else if ( ft_strcmp( mmvar->axis[i].name, "OpticalSize" ) == 0 )
mmvar->axis[i].tag = FT_MAKE_TAG( 'o', 'p', 's', 'z' );
}
if ( blend->num_designs == ( 1U << blend->num_axis ) )
{
mm_weights_unmap( blend->default_weight_vector,
axiscoords,
blend->num_axis );
for ( i = 0; i < mmaster.num_axis; ++i )
mmvar->axis[i].def = mm_axis_unmap( &blend->design_map[i],
axiscoords[i] );
}
*master = mmvar;
Exit:
return error;
}
|
DoS
| 0
|
T1_Get_MM_Var( T1_Face face,
FT_MM_Var* *master )
{
FT_Memory memory = face->root.memory;
FT_MM_Var *mmvar = NULL;
FT_Multi_Master mmaster;
FT_Error error;
FT_UInt i;
FT_Fixed axiscoords[T1_MAX_MM_AXIS];
PS_Blend blend = face->blend;
error = T1_Get_Multi_Master( face, &mmaster );
if ( error )
goto Exit;
if ( FT_ALLOC( mmvar,
sizeof ( FT_MM_Var ) +
mmaster.num_axis * sizeof ( FT_Var_Axis ) ) )
goto Exit;
mmvar->num_axis = mmaster.num_axis;
mmvar->num_designs = mmaster.num_designs;
mmvar->num_namedstyles = ~0U; /* Does not apply */
mmvar->axis = (FT_Var_Axis*)&mmvar[1];
/* Point to axes after MM_Var struct */
mmvar->namedstyle = NULL;
for ( i = 0 ; i < mmaster.num_axis; ++i )
{
mmvar->axis[i].name = mmaster.axis[i].name;
mmvar->axis[i].minimum = INT_TO_FIXED( mmaster.axis[i].minimum);
mmvar->axis[i].maximum = INT_TO_FIXED( mmaster.axis[i].maximum);
mmvar->axis[i].def = ( mmvar->axis[i].minimum +
mmvar->axis[i].maximum ) / 2;
/* Does not apply. But this value is in range */
mmvar->axis[i].strid = ~0U; /* Does not apply */
mmvar->axis[i].tag = ~0U; /* Does not apply */
if ( ft_strcmp( mmvar->axis[i].name, "Weight" ) == 0 )
mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'g', 'h', 't' );
else if ( ft_strcmp( mmvar->axis[i].name, "Width" ) == 0 )
mmvar->axis[i].tag = FT_MAKE_TAG( 'w', 'd', 't', 'h' );
else if ( ft_strcmp( mmvar->axis[i].name, "OpticalSize" ) == 0 )
mmvar->axis[i].tag = FT_MAKE_TAG( 'o', 'p', 's', 'z' );
}
if ( blend->num_designs == ( 1U << blend->num_axis ) )
{
mm_weights_unmap( blend->default_weight_vector,
axiscoords,
blend->num_axis );
for ( i = 0; i < mmaster.num_axis; ++i )
mmvar->axis[i].def = mm_axis_unmap( &blend->design_map[i],
axiscoords[i] );
}
*master = mmvar;
Exit:
return error;
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,273
|
T1_Set_Var_Design( T1_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Long lcoords[4]; /* maximum axis count is 4 */
FT_UInt i;
FT_Error error;
error = FT_ERR( Invalid_Argument );
if ( num_coords <= 4 && num_coords > 0 )
{
for ( i = 0; i < num_coords; ++i )
lcoords[i] = FIXED_TO_INT( coords[i] );
error = T1_Set_MM_Design( face, num_coords, lcoords );
}
return error;
}
|
DoS
| 0
|
T1_Set_Var_Design( T1_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Long lcoords[4]; /* maximum axis count is 4 */
FT_UInt i;
FT_Error error;
error = FT_ERR( Invalid_Argument );
if ( num_coords <= 4 && num_coords > 0 )
{
for ( i = 0; i < num_coords; ++i )
lcoords[i] = FIXED_TO_INT( coords[i] );
error = T1_Set_MM_Design( face, num_coords, lcoords );
}
return error;
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,274
|
mm_axis_unmap( PS_DesignMap axismap,
FT_Fixed ncv )
{
int j;
if ( ncv <= axismap->blend_points[0] )
return INT_TO_FIXED( axismap->design_points[0] );
for ( j = 1; j < axismap->num_points; ++j )
{
if ( ncv <= axismap->blend_points[j] )
return INT_TO_FIXED( axismap->design_points[j - 1] ) +
( axismap->design_points[j] - axismap->design_points[j - 1] ) *
FT_DivFix( ncv - axismap->blend_points[j - 1],
axismap->blend_points[j] -
axismap->blend_points[j - 1] );
}
return INT_TO_FIXED( axismap->design_points[axismap->num_points - 1] );
}
|
DoS
| 0
|
mm_axis_unmap( PS_DesignMap axismap,
FT_Fixed ncv )
{
int j;
if ( ncv <= axismap->blend_points[0] )
return INT_TO_FIXED( axismap->design_points[0] );
for ( j = 1; j < axismap->num_points; ++j )
{
if ( ncv <= axismap->blend_points[j] )
return INT_TO_FIXED( axismap->design_points[j - 1] ) +
( axismap->design_points[j] - axismap->design_points[j - 1] ) *
FT_DivFix( ncv - axismap->blend_points[j - 1],
axismap->blend_points[j] -
axismap->blend_points[j - 1] );
}
return INT_TO_FIXED( axismap->design_points[axismap->num_points - 1] );
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,275
|
mm_weights_unmap( FT_Fixed* weights,
FT_Fixed* axiscoords,
FT_UInt axis_count )
{
FT_ASSERT( axis_count <= T1_MAX_MM_AXIS );
if ( axis_count == 1 )
axiscoords[0] = weights[1];
else if ( axis_count == 2 )
{
axiscoords[0] = weights[3] + weights[1];
axiscoords[1] = weights[3] + weights[2];
}
else if ( axis_count == 3 )
{
axiscoords[0] = weights[7] + weights[5] + weights[3] + weights[1];
axiscoords[1] = weights[7] + weights[6] + weights[3] + weights[2];
axiscoords[2] = weights[7] + weights[6] + weights[5] + weights[4];
}
else
{
axiscoords[0] = weights[15] + weights[13] + weights[11] + weights[9] +
weights[7] + weights[5] + weights[3] + weights[1];
axiscoords[1] = weights[15] + weights[14] + weights[11] + weights[10] +
weights[7] + weights[6] + weights[3] + weights[2];
axiscoords[2] = weights[15] + weights[14] + weights[13] + weights[12] +
weights[7] + weights[6] + weights[5] + weights[4];
axiscoords[3] = weights[15] + weights[14] + weights[13] + weights[12] +
weights[11] + weights[10] + weights[9] + weights[8];
}
}
|
DoS
| 0
|
mm_weights_unmap( FT_Fixed* weights,
FT_Fixed* axiscoords,
FT_UInt axis_count )
{
FT_ASSERT( axis_count <= T1_MAX_MM_AXIS );
if ( axis_count == 1 )
axiscoords[0] = weights[1];
else if ( axis_count == 2 )
{
axiscoords[0] = weights[3] + weights[1];
axiscoords[1] = weights[3] + weights[2];
}
else if ( axis_count == 3 )
{
axiscoords[0] = weights[7] + weights[5] + weights[3] + weights[1];
axiscoords[1] = weights[7] + weights[6] + weights[3] + weights[2];
axiscoords[2] = weights[7] + weights[6] + weights[5] + weights[4];
}
else
{
axiscoords[0] = weights[15] + weights[13] + weights[11] + weights[9] +
weights[7] + weights[5] + weights[3] + weights[1];
axiscoords[1] = weights[15] + weights[14] + weights[11] + weights[10] +
weights[7] + weights[6] + weights[3] + weights[2];
axiscoords[2] = weights[15] + weights[14] + weights[13] + weights[12] +
weights[7] + weights[6] + weights[5] + weights[4];
axiscoords[3] = weights[15] + weights[14] + weights[13] + weights[12] +
weights[11] + weights[10] + weights[9] + weights[8];
}
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,276
|
parse_blend_design_map( T1_Face face,
T1_Loader loader )
{
FT_Error error = FT_Err_Ok;
T1_Parser parser = &loader->parser;
PS_Blend blend;
T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
FT_Int n, num_axis;
FT_Byte* old_cursor;
FT_Byte* old_limit;
FT_Memory memory = face->root.memory;
T1_ToTokenArray( parser, axis_tokens,
T1_MAX_MM_AXIS, &num_axis );
if ( num_axis < 0 )
{
error = FT_ERR( Ignore );
goto Exit;
}
if ( num_axis == 0 || num_axis > T1_MAX_MM_AXIS )
{
FT_ERROR(( "parse_blend_design_map: incorrect number of axes: %d\n",
num_axis ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
old_cursor = parser->root.cursor;
old_limit = parser->root.limit;
error = t1_allocate_blend( face, 0, num_axis );
if ( error )
goto Exit;
blend = face->blend;
/* now read each axis design map */
for ( n = 0; n < num_axis; n++ )
{
PS_DesignMap map = blend->design_map + n;
T1_Token axis_token;
T1_TokenRec point_tokens[T1_MAX_MM_MAP_POINTS];
FT_Int p, num_points;
axis_token = axis_tokens + n;
parser->root.cursor = axis_token->start;
parser->root.limit = axis_token->limit;
T1_ToTokenArray( parser, point_tokens,
T1_MAX_MM_MAP_POINTS, &num_points );
if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS )
{
FT_ERROR(( "parse_blend_design_map: incorrect table\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
/* allocate design map data */
if ( FT_NEW_ARRAY( map->design_points, num_points * 2 ) )
goto Exit;
map->blend_points = map->design_points + num_points;
map->num_points = (FT_Byte)num_points;
for ( p = 0; p < num_points; p++ )
{
T1_Token point_token;
point_token = point_tokens + p;
/* don't include delimiting brackets */
parser->root.cursor = point_token->start + 1;
parser->root.limit = point_token->limit - 1;
map->design_points[p] = T1_ToInt( parser );
map->blend_points [p] = T1_ToFixed( parser, 0 );
}
}
parser->root.cursor = old_cursor;
parser->root.limit = old_limit;
Exit:
parser->root.error = error;
}
|
DoS
| 0
|
parse_blend_design_map( T1_Face face,
T1_Loader loader )
{
FT_Error error = FT_Err_Ok;
T1_Parser parser = &loader->parser;
PS_Blend blend;
T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
FT_Int n, num_axis;
FT_Byte* old_cursor;
FT_Byte* old_limit;
FT_Memory memory = face->root.memory;
T1_ToTokenArray( parser, axis_tokens,
T1_MAX_MM_AXIS, &num_axis );
if ( num_axis < 0 )
{
error = FT_ERR( Ignore );
goto Exit;
}
if ( num_axis == 0 || num_axis > T1_MAX_MM_AXIS )
{
FT_ERROR(( "parse_blend_design_map: incorrect number of axes: %d\n",
num_axis ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
old_cursor = parser->root.cursor;
old_limit = parser->root.limit;
error = t1_allocate_blend( face, 0, num_axis );
if ( error )
goto Exit;
blend = face->blend;
/* now read each axis design map */
for ( n = 0; n < num_axis; n++ )
{
PS_DesignMap map = blend->design_map + n;
T1_Token axis_token;
T1_TokenRec point_tokens[T1_MAX_MM_MAP_POINTS];
FT_Int p, num_points;
axis_token = axis_tokens + n;
parser->root.cursor = axis_token->start;
parser->root.limit = axis_token->limit;
T1_ToTokenArray( parser, point_tokens,
T1_MAX_MM_MAP_POINTS, &num_points );
if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS )
{
FT_ERROR(( "parse_blend_design_map: incorrect table\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
/* allocate design map data */
if ( FT_NEW_ARRAY( map->design_points, num_points * 2 ) )
goto Exit;
map->blend_points = map->design_points + num_points;
map->num_points = (FT_Byte)num_points;
for ( p = 0; p < num_points; p++ )
{
T1_Token point_token;
point_token = point_tokens + p;
/* don't include delimiting brackets */
parser->root.cursor = point_token->start + 1;
parser->root.limit = point_token->limit - 1;
map->design_points[p] = T1_ToInt( parser );
map->blend_points [p] = T1_ToFixed( parser, 0 );
}
}
parser->root.cursor = old_cursor;
parser->root.limit = old_limit;
Exit:
parser->root.error = error;
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,277
|
parse_blend_design_positions( T1_Face face,
T1_Loader loader )
{
T1_TokenRec design_tokens[T1_MAX_MM_DESIGNS];
FT_Int num_designs;
FT_Int num_axis;
T1_Parser parser = &loader->parser;
FT_Error error = FT_Err_Ok;
PS_Blend blend;
/* get the array of design tokens -- compute number of designs */
T1_ToTokenArray( parser, design_tokens,
T1_MAX_MM_DESIGNS, &num_designs );
if ( num_designs < 0 )
{
error = FT_ERR( Ignore );
goto Exit;
}
if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS )
{
FT_ERROR(( "parse_blend_design_positions:"
" incorrect number of designs: %d\n",
num_designs ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
{
FT_Byte* old_cursor = parser->root.cursor;
FT_Byte* old_limit = parser->root.limit;
FT_Int n;
blend = face->blend;
num_axis = 0; /* make compiler happy */
for ( n = 0; n < num_designs; n++ )
{
T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
T1_Token token;
FT_Int axis, n_axis;
/* read axis/coordinates tokens */
token = design_tokens + n;
parser->root.cursor = token->start;
parser->root.limit = token->limit;
T1_ToTokenArray( parser, axis_tokens, T1_MAX_MM_AXIS, &n_axis );
if ( n == 0 )
{
if ( n_axis <= 0 || n_axis > T1_MAX_MM_AXIS )
{
FT_ERROR(( "parse_blend_design_positions:"
" invalid number of axes: %d\n",
n_axis ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
num_axis = n_axis;
error = t1_allocate_blend( face, num_designs, num_axis );
if ( error )
goto Exit;
blend = face->blend;
}
else if ( n_axis != num_axis )
{
FT_ERROR(( "parse_blend_design_positions: incorrect table\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
/* now read each axis token into the design position */
for ( axis = 0; axis < n_axis; axis++ )
{
T1_Token token2 = axis_tokens + axis;
parser->root.cursor = token2->start;
parser->root.limit = token2->limit;
blend->design_pos[n][axis] = T1_ToFixed( parser, 0 );
}
}
loader->parser.root.cursor = old_cursor;
loader->parser.root.limit = old_limit;
}
Exit:
loader->parser.root.error = error;
}
|
DoS
| 0
|
parse_blend_design_positions( T1_Face face,
T1_Loader loader )
{
T1_TokenRec design_tokens[T1_MAX_MM_DESIGNS];
FT_Int num_designs;
FT_Int num_axis;
T1_Parser parser = &loader->parser;
FT_Error error = FT_Err_Ok;
PS_Blend blend;
/* get the array of design tokens -- compute number of designs */
T1_ToTokenArray( parser, design_tokens,
T1_MAX_MM_DESIGNS, &num_designs );
if ( num_designs < 0 )
{
error = FT_ERR( Ignore );
goto Exit;
}
if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS )
{
FT_ERROR(( "parse_blend_design_positions:"
" incorrect number of designs: %d\n",
num_designs ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
{
FT_Byte* old_cursor = parser->root.cursor;
FT_Byte* old_limit = parser->root.limit;
FT_Int n;
blend = face->blend;
num_axis = 0; /* make compiler happy */
for ( n = 0; n < num_designs; n++ )
{
T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
T1_Token token;
FT_Int axis, n_axis;
/* read axis/coordinates tokens */
token = design_tokens + n;
parser->root.cursor = token->start;
parser->root.limit = token->limit;
T1_ToTokenArray( parser, axis_tokens, T1_MAX_MM_AXIS, &n_axis );
if ( n == 0 )
{
if ( n_axis <= 0 || n_axis > T1_MAX_MM_AXIS )
{
FT_ERROR(( "parse_blend_design_positions:"
" invalid number of axes: %d\n",
n_axis ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
num_axis = n_axis;
error = t1_allocate_blend( face, num_designs, num_axis );
if ( error )
goto Exit;
blend = face->blend;
}
else if ( n_axis != num_axis )
{
FT_ERROR(( "parse_blend_design_positions: incorrect table\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
/* now read each axis token into the design position */
for ( axis = 0; axis < n_axis; axis++ )
{
T1_Token token2 = axis_tokens + axis;
parser->root.cursor = token2->start;
parser->root.limit = token2->limit;
blend->design_pos[n][axis] = T1_ToFixed( parser, 0 );
}
}
loader->parser.root.cursor = old_cursor;
loader->parser.root.limit = old_limit;
}
Exit:
loader->parser.root.error = error;
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,278
|
parse_buildchar( T1_Face face,
T1_Loader loader )
{
face->len_buildchar = T1_ToFixedArray( &loader->parser, 0, NULL, 0 );
return;
}
|
DoS
| 0
|
parse_buildchar( T1_Face face,
T1_Loader loader )
{
face->len_buildchar = T1_ToFixedArray( &loader->parser, 0, NULL, 0 );
return;
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,279
|
parse_private( T1_Face face,
T1_Loader loader )
{
FT_UNUSED( face );
loader->keywords_encountered |= T1_PRIVATE;
}
|
DoS
| 0
|
parse_private( T1_Face face,
T1_Loader loader )
{
FT_UNUSED( face );
loader->keywords_encountered |= T1_PRIVATE;
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,280
|
parse_weight_vector( T1_Face face,
T1_Loader loader )
{
T1_TokenRec design_tokens[T1_MAX_MM_DESIGNS];
FT_Int num_designs;
FT_Error error = FT_Err_Ok;
T1_Parser parser = &loader->parser;
PS_Blend blend = face->blend;
T1_Token token;
FT_Int n;
FT_Byte* old_cursor;
FT_Byte* old_limit;
T1_ToTokenArray( parser, design_tokens,
T1_MAX_MM_DESIGNS, &num_designs );
if ( num_designs < 0 )
{
error = FT_ERR( Ignore );
goto Exit;
}
if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS )
{
FT_ERROR(( "parse_weight_vector:"
" incorrect number of designs: %d\n",
num_designs ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
if ( !blend || !blend->num_designs )
{
error = t1_allocate_blend( face, num_designs, 0 );
if ( error )
goto Exit;
blend = face->blend;
}
else if ( blend->num_designs != (FT_UInt)num_designs )
{
FT_ERROR(( "parse_weight_vector:"
" /BlendDesignPosition and /WeightVector have\n"
" "
" different number of elements\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
old_cursor = parser->root.cursor;
old_limit = parser->root.limit;
for ( n = 0; n < num_designs; n++ )
{
token = design_tokens + n;
parser->root.cursor = token->start;
parser->root.limit = token->limit;
blend->default_weight_vector[n] =
blend->weight_vector[n] = T1_ToFixed( parser, 0 );
}
parser->root.cursor = old_cursor;
parser->root.limit = old_limit;
Exit:
parser->root.error = error;
}
|
DoS
| 0
|
parse_weight_vector( T1_Face face,
T1_Loader loader )
{
T1_TokenRec design_tokens[T1_MAX_MM_DESIGNS];
FT_Int num_designs;
FT_Error error = FT_Err_Ok;
T1_Parser parser = &loader->parser;
PS_Blend blend = face->blend;
T1_Token token;
FT_Int n;
FT_Byte* old_cursor;
FT_Byte* old_limit;
T1_ToTokenArray( parser, design_tokens,
T1_MAX_MM_DESIGNS, &num_designs );
if ( num_designs < 0 )
{
error = FT_ERR( Ignore );
goto Exit;
}
if ( num_designs == 0 || num_designs > T1_MAX_MM_DESIGNS )
{
FT_ERROR(( "parse_weight_vector:"
" incorrect number of designs: %d\n",
num_designs ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
if ( !blend || !blend->num_designs )
{
error = t1_allocate_blend( face, num_designs, 0 );
if ( error )
goto Exit;
blend = face->blend;
}
else if ( blend->num_designs != (FT_UInt)num_designs )
{
FT_ERROR(( "parse_weight_vector:"
" /BlendDesignPosition and /WeightVector have\n"
" "
" different number of elements\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
old_cursor = parser->root.cursor;
old_limit = parser->root.limit;
for ( n = 0; n < num_designs; n++ )
{
token = design_tokens + n;
parser->root.cursor = token->start;
parser->root.limit = token->limit;
blend->default_weight_vector[n] =
blend->weight_vector[n] = T1_ToFixed( parser, 0 );
}
parser->root.cursor = old_cursor;
parser->root.limit = old_limit;
Exit:
parser->root.error = error;
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,281
|
t1_allocate_blend( T1_Face face,
FT_UInt num_designs,
FT_UInt num_axis )
{
PS_Blend blend;
FT_Memory memory = face->root.memory;
FT_Error error = FT_Err_Ok;
blend = face->blend;
if ( !blend )
{
if ( FT_NEW( blend ) )
goto Exit;
blend->num_default_design_vector = 0;
face->blend = blend;
}
/* allocate design data if needed */
if ( num_designs > 0 )
{
if ( blend->num_designs == 0 )
{
FT_UInt nn;
/* allocate the blend `private' and `font_info' dictionaries */
if ( FT_NEW_ARRAY( blend->font_infos[1], num_designs ) ||
FT_NEW_ARRAY( blend->privates [1], num_designs ) ||
FT_NEW_ARRAY( blend->bboxes [1], num_designs ) ||
FT_NEW_ARRAY( blend->weight_vector, num_designs * 2 ) )
goto Exit;
blend->default_weight_vector = blend->weight_vector + num_designs;
blend->font_infos[0] = &face->type1.font_info;
blend->privates [0] = &face->type1.private_dict;
blend->bboxes [0] = &face->type1.font_bbox;
for ( nn = 2; nn <= num_designs; nn++ )
{
blend->font_infos[nn] = blend->font_infos[nn - 1] + 1;
blend->privates [nn] = blend->privates [nn - 1] + 1;
blend->bboxes [nn] = blend->bboxes [nn - 1] + 1;
}
blend->num_designs = num_designs;
}
else if ( blend->num_designs != num_designs )
goto Fail;
}
/* allocate axis data if needed */
if ( num_axis > 0 )
{
if ( blend->num_axis != 0 && blend->num_axis != num_axis )
goto Fail;
blend->num_axis = num_axis;
}
/* allocate the blend design pos table if needed */
num_designs = blend->num_designs;
num_axis = blend->num_axis;
if ( num_designs && num_axis && blend->design_pos[0] == 0 )
{
FT_UInt n;
if ( FT_NEW_ARRAY( blend->design_pos[0], num_designs * num_axis ) )
goto Exit;
for ( n = 1; n < num_designs; n++ )
blend->design_pos[n] = blend->design_pos[0] + num_axis * n;
}
Exit:
return error;
Fail:
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
|
DoS
| 0
|
t1_allocate_blend( T1_Face face,
FT_UInt num_designs,
FT_UInt num_axis )
{
PS_Blend blend;
FT_Memory memory = face->root.memory;
FT_Error error = FT_Err_Ok;
blend = face->blend;
if ( !blend )
{
if ( FT_NEW( blend ) )
goto Exit;
blend->num_default_design_vector = 0;
face->blend = blend;
}
/* allocate design data if needed */
if ( num_designs > 0 )
{
if ( blend->num_designs == 0 )
{
FT_UInt nn;
/* allocate the blend `private' and `font_info' dictionaries */
if ( FT_NEW_ARRAY( blend->font_infos[1], num_designs ) ||
FT_NEW_ARRAY( blend->privates [1], num_designs ) ||
FT_NEW_ARRAY( blend->bboxes [1], num_designs ) ||
FT_NEW_ARRAY( blend->weight_vector, num_designs * 2 ) )
goto Exit;
blend->default_weight_vector = blend->weight_vector + num_designs;
blend->font_infos[0] = &face->type1.font_info;
blend->privates [0] = &face->type1.private_dict;
blend->bboxes [0] = &face->type1.font_bbox;
for ( nn = 2; nn <= num_designs; nn++ )
{
blend->font_infos[nn] = blend->font_infos[nn - 1] + 1;
blend->privates [nn] = blend->privates [nn - 1] + 1;
blend->bboxes [nn] = blend->bboxes [nn - 1] + 1;
}
blend->num_designs = num_designs;
}
else if ( blend->num_designs != num_designs )
goto Fail;
}
/* allocate axis data if needed */
if ( num_axis > 0 )
{
if ( blend->num_axis != 0 && blend->num_axis != num_axis )
goto Fail;
blend->num_axis = num_axis;
}
/* allocate the blend design pos table if needed */
num_designs = blend->num_designs;
num_axis = blend->num_axis;
if ( num_designs && num_axis && blend->design_pos[0] == 0 )
{
FT_UInt n;
if ( FT_NEW_ARRAY( blend->design_pos[0], num_designs * num_axis ) )
goto Exit;
for ( n = 1; n < num_designs; n++ )
blend->design_pos[n] = blend->design_pos[0] + num_axis * n;
}
Exit:
return error;
Fail:
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,282
|
t1_load_keyword( T1_Face face,
T1_Loader loader,
const T1_Field field )
{
FT_Error error;
void* dummy_object;
void** objects;
FT_UInt max_objects;
PS_Blend blend = face->blend;
if ( blend && blend->num_designs == 0 )
blend = NULL;
/* if the keyword has a dedicated callback, call it */
if ( field->type == T1_FIELD_TYPE_CALLBACK )
{
field->reader( (FT_Face)face, loader );
error = loader->parser.root.error;
goto Exit;
}
/* now, the keyword is either a simple field, or a table of fields; */
/* we are now going to take care of it */
switch ( field->location )
{
case T1_FIELD_LOCATION_FONT_INFO:
dummy_object = &face->type1.font_info;
objects = &dummy_object;
max_objects = 0;
if ( blend )
{
objects = (void**)blend->font_infos;
max_objects = blend->num_designs;
}
break;
case T1_FIELD_LOCATION_FONT_EXTRA:
dummy_object = &face->type1.font_extra;
objects = &dummy_object;
max_objects = 0;
break;
case T1_FIELD_LOCATION_PRIVATE:
dummy_object = &face->type1.private_dict;
objects = &dummy_object;
max_objects = 0;
if ( blend )
{
objects = (void**)blend->privates;
max_objects = blend->num_designs;
}
break;
case T1_FIELD_LOCATION_BBOX:
dummy_object = &face->type1.font_bbox;
objects = &dummy_object;
max_objects = 0;
if ( blend )
{
objects = (void**)blend->bboxes;
max_objects = blend->num_designs;
}
break;
case T1_FIELD_LOCATION_LOADER:
dummy_object = loader;
objects = &dummy_object;
max_objects = 0;
break;
case T1_FIELD_LOCATION_FACE:
dummy_object = face;
objects = &dummy_object;
max_objects = 0;
break;
#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
case T1_FIELD_LOCATION_BLEND:
dummy_object = face->blend;
objects = &dummy_object;
max_objects = 0;
break;
#endif
default:
dummy_object = &face->type1;
objects = &dummy_object;
max_objects = 0;
}
if ( *objects )
{
if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
field->type == T1_FIELD_TYPE_FIXED_ARRAY )
error = T1_Load_Field_Table( &loader->parser, field,
objects, max_objects, 0 );
else
error = T1_Load_Field( &loader->parser, field,
objects, max_objects, 0 );
}
else
{
FT_TRACE1(( "t1_load_keyword: ignoring keyword `%s'"
" which is not valid at this point\n"
" (probably due to missing keywords)\n",
field->ident ));
error = FT_Err_Ok;
}
Exit:
return error;
}
|
DoS
| 0
|
t1_load_keyword( T1_Face face,
T1_Loader loader,
const T1_Field field )
{
FT_Error error;
void* dummy_object;
void** objects;
FT_UInt max_objects;
PS_Blend blend = face->blend;
if ( blend && blend->num_designs == 0 )
blend = NULL;
/* if the keyword has a dedicated callback, call it */
if ( field->type == T1_FIELD_TYPE_CALLBACK )
{
field->reader( (FT_Face)face, loader );
error = loader->parser.root.error;
goto Exit;
}
/* now, the keyword is either a simple field, or a table of fields; */
/* we are now going to take care of it */
switch ( field->location )
{
case T1_FIELD_LOCATION_FONT_INFO:
dummy_object = &face->type1.font_info;
objects = &dummy_object;
max_objects = 0;
if ( blend )
{
objects = (void**)blend->font_infos;
max_objects = blend->num_designs;
}
break;
case T1_FIELD_LOCATION_FONT_EXTRA:
dummy_object = &face->type1.font_extra;
objects = &dummy_object;
max_objects = 0;
break;
case T1_FIELD_LOCATION_PRIVATE:
dummy_object = &face->type1.private_dict;
objects = &dummy_object;
max_objects = 0;
if ( blend )
{
objects = (void**)blend->privates;
max_objects = blend->num_designs;
}
break;
case T1_FIELD_LOCATION_BBOX:
dummy_object = &face->type1.font_bbox;
objects = &dummy_object;
max_objects = 0;
if ( blend )
{
objects = (void**)blend->bboxes;
max_objects = blend->num_designs;
}
break;
case T1_FIELD_LOCATION_LOADER:
dummy_object = loader;
objects = &dummy_object;
max_objects = 0;
break;
case T1_FIELD_LOCATION_FACE:
dummy_object = face;
objects = &dummy_object;
max_objects = 0;
break;
#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
case T1_FIELD_LOCATION_BLEND:
dummy_object = face->blend;
objects = &dummy_object;
max_objects = 0;
break;
#endif
default:
dummy_object = &face->type1;
objects = &dummy_object;
max_objects = 0;
}
if ( *objects )
{
if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
field->type == T1_FIELD_TYPE_FIXED_ARRAY )
error = T1_Load_Field_Table( &loader->parser, field,
objects, max_objects, 0 );
else
error = T1_Load_Field( &loader->parser, field,
objects, max_objects, 0 );
}
else
{
FT_TRACE1(( "t1_load_keyword: ignoring keyword `%s'"
" which is not valid at this point\n"
" (probably due to missing keywords)\n",
field->ident ));
error = FT_Err_Ok;
}
Exit:
return error;
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,283
|
t1_parse_font_matrix( T1_Face face,
T1_Loader loader )
{
T1_Parser parser = &loader->parser;
FT_Matrix* matrix = &face->type1.font_matrix;
FT_Vector* offset = &face->type1.font_offset;
FT_Face root = (FT_Face)&face->root;
FT_Fixed temp[6];
FT_Fixed temp_scale;
FT_Int result;
result = T1_ToFixedArray( parser, 6, temp, 3 );
if ( result < 6 )
{
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
temp_scale = FT_ABS( temp[3] );
if ( temp_scale == 0 )
{
FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
/* Set Units per EM based on FontMatrix values. We set the value to */
/* 1000 / temp_scale, because temp_scale was already multiplied by */
/* 1000 (in t1_tofixed, from psobjs.c). */
root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
/* we need to scale the values by 1.0/temp_scale */
if ( temp_scale != 0x10000L )
{
temp[0] = FT_DivFix( temp[0], temp_scale );
temp[1] = FT_DivFix( temp[1], temp_scale );
temp[2] = FT_DivFix( temp[2], temp_scale );
temp[4] = FT_DivFix( temp[4], temp_scale );
temp[5] = FT_DivFix( temp[5], temp_scale );
temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
}
matrix->xx = temp[0];
matrix->yx = temp[1];
matrix->xy = temp[2];
matrix->yy = temp[3];
/* note that the offsets must be expressed in integer font units */
offset->x = temp[4] >> 16;
offset->y = temp[5] >> 16;
}
|
DoS
| 0
|
t1_parse_font_matrix( T1_Face face,
T1_Loader loader )
{
T1_Parser parser = &loader->parser;
FT_Matrix* matrix = &face->type1.font_matrix;
FT_Vector* offset = &face->type1.font_offset;
FT_Face root = (FT_Face)&face->root;
FT_Fixed temp[6];
FT_Fixed temp_scale;
FT_Int result;
result = T1_ToFixedArray( parser, 6, temp, 3 );
if ( result < 6 )
{
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
temp_scale = FT_ABS( temp[3] );
if ( temp_scale == 0 )
{
FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
parser->root.error = FT_THROW( Invalid_File_Format );
return;
}
/* Set Units per EM based on FontMatrix values. We set the value to */
/* 1000 / temp_scale, because temp_scale was already multiplied by */
/* 1000 (in t1_tofixed, from psobjs.c). */
root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
/* we need to scale the values by 1.0/temp_scale */
if ( temp_scale != 0x10000L )
{
temp[0] = FT_DivFix( temp[0], temp_scale );
temp[1] = FT_DivFix( temp[1], temp_scale );
temp[2] = FT_DivFix( temp[2], temp_scale );
temp[4] = FT_DivFix( temp[4], temp_scale );
temp[5] = FT_DivFix( temp[5], temp_scale );
temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
}
matrix->xx = temp[0];
matrix->yx = temp[1];
matrix->xy = temp[2];
matrix->yy = temp[3];
/* note that the offsets must be expressed in integer font units */
offset->x = temp[4] >> 16;
offset->y = temp[5] >> 16;
}
|
@@ -1274,6 +1274,13 @@
{
charcode = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
+
+ /* protect against invalid charcode */
+ if ( cur == parser->root.cursor )
+ {
+ parser->root.error = FT_THROW( Unknown_File_Format );
+ return;
+ }
}
cur = parser->root.cursor;
|
CWE-399
| null | null |
5,284
|
static void ahci_init_d2h(AHCIDevice *ad)
{
uint8_t init_fis[20];
IDEState *ide_state = &ad->port.ifs[0];
memset(init_fis, 0, sizeof(init_fis));
init_fis[4] = 1;
init_fis[12] = 1;
if (ide_state->drive_kind == IDE_CD) {
init_fis[5] = ide_state->lcyl;
init_fis[6] = ide_state->hcyl;
}
ahci_write_fis_d2h(ad, init_fis);
}
|
DoS
| 0
|
static void ahci_init_d2h(AHCIDevice *ad)
{
uint8_t init_fis[20];
IDEState *ide_state = &ad->port.ifs[0];
memset(init_fis, 0, sizeof(init_fis));
init_fis[4] = 1;
init_fis[12] = 1;
if (ide_state->drive_kind == IDE_CD) {
init_fis[5] = ide_state->lcyl;
init_fis[6] = ide_state->hcyl;
}
ahci_write_fis_d2h(ad, init_fis);
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,285
|
static void ahci_irq_lower(AHCIState *s, AHCIDevice *dev)
{
AHCIPCIState *d = container_of(s, AHCIPCIState, ahci);
PCIDevice *pci_dev =
(PCIDevice *)object_dynamic_cast(OBJECT(d), TYPE_PCI_DEVICE);
DPRINTF(0, "lower irq\n");
if (!pci_dev || !msi_enabled(pci_dev)) {
qemu_irq_lower(s->irq);
}
}
|
DoS
| 0
|
static void ahci_irq_lower(AHCIState *s, AHCIDevice *dev)
{
AHCIPCIState *d = container_of(s, AHCIPCIState, ahci);
PCIDevice *pci_dev =
(PCIDevice *)object_dynamic_cast(OBJECT(d), TYPE_PCI_DEVICE);
DPRINTF(0, "lower irq\n");
if (!pci_dev || !msi_enabled(pci_dev)) {
qemu_irq_lower(s->irq);
}
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,286
|
static void ahci_irq_raise(AHCIState *s, AHCIDevice *dev)
{
AHCIPCIState *d = container_of(s, AHCIPCIState, ahci);
PCIDevice *pci_dev =
(PCIDevice *)object_dynamic_cast(OBJECT(d), TYPE_PCI_DEVICE);
DPRINTF(0, "raise irq\n");
if (pci_dev && msi_enabled(pci_dev)) {
msi_notify(pci_dev, 0);
} else {
qemu_irq_raise(s->irq);
}
}
|
DoS
| 0
|
static void ahci_irq_raise(AHCIState *s, AHCIDevice *dev)
{
AHCIPCIState *d = container_of(s, AHCIPCIState, ahci);
PCIDevice *pci_dev =
(PCIDevice *)object_dynamic_cast(OBJECT(d), TYPE_PCI_DEVICE);
DPRINTF(0, "raise irq\n");
if (pci_dev && msi_enabled(pci_dev)) {
msi_notify(pci_dev, 0);
} else {
qemu_irq_raise(s->irq);
}
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,287
|
static uint64_t ahci_mem_read(void *opaque, hwaddr addr,
unsigned size)
{
AHCIState *s = opaque;
uint32_t val = 0;
if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) {
switch (addr) {
case HOST_CAP:
val = s->control_regs.cap;
break;
case HOST_CTL:
val = s->control_regs.ghc;
break;
case HOST_IRQ_STAT:
val = s->control_regs.irqstatus;
break;
case HOST_PORTS_IMPL:
val = s->control_regs.impl;
break;
case HOST_VERSION:
val = s->control_regs.version;
break;
}
DPRINTF(-1, "(addr 0x%08X), val 0x%08X\n", (unsigned) addr, val);
} else if ((addr >= AHCI_PORT_REGS_START_ADDR) &&
(addr < (AHCI_PORT_REGS_START_ADDR +
(s->ports * AHCI_PORT_ADDR_OFFSET_LEN)))) {
val = ahci_port_read(s, (addr - AHCI_PORT_REGS_START_ADDR) >> 7,
addr & AHCI_PORT_ADDR_OFFSET_MASK);
}
return val;
}
|
DoS
| 0
|
static uint64_t ahci_mem_read(void *opaque, hwaddr addr,
unsigned size)
{
AHCIState *s = opaque;
uint32_t val = 0;
if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) {
switch (addr) {
case HOST_CAP:
val = s->control_regs.cap;
break;
case HOST_CTL:
val = s->control_regs.ghc;
break;
case HOST_IRQ_STAT:
val = s->control_regs.irqstatus;
break;
case HOST_PORTS_IMPL:
val = s->control_regs.impl;
break;
case HOST_VERSION:
val = s->control_regs.version;
break;
}
DPRINTF(-1, "(addr 0x%08X), val 0x%08X\n", (unsigned) addr, val);
} else if ((addr >= AHCI_PORT_REGS_START_ADDR) &&
(addr < (AHCI_PORT_REGS_START_ADDR +
(s->ports * AHCI_PORT_ADDR_OFFSET_LEN)))) {
val = ahci_port_read(s, (addr - AHCI_PORT_REGS_START_ADDR) >> 7,
addr & AHCI_PORT_ADDR_OFFSET_MASK);
}
return val;
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,288
|
static void ahci_mem_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
AHCIState *s = opaque;
/* Only aligned reads are allowed on AHCI */
if (addr & 3) {
fprintf(stderr, "ahci: Mis-aligned write to addr 0x"
TARGET_FMT_plx "\n", addr);
return;
}
if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) {
DPRINTF(-1, "(addr 0x%08X), val 0x%08"PRIX64"\n", (unsigned) addr, val);
switch (addr) {
case HOST_CAP: /* R/WO, RO */
/* FIXME handle R/WO */
break;
case HOST_CTL: /* R/W */
if (val & HOST_CTL_RESET) {
DPRINTF(-1, "HBA Reset\n");
ahci_reset(s);
} else {
s->control_regs.ghc = (val & 0x3) | HOST_CTL_AHCI_EN;
ahci_check_irq(s);
}
break;
case HOST_IRQ_STAT: /* R/WC, RO */
s->control_regs.irqstatus &= ~val;
ahci_check_irq(s);
break;
case HOST_PORTS_IMPL: /* R/WO, RO */
/* FIXME handle R/WO */
break;
case HOST_VERSION: /* RO */
/* FIXME report write? */
break;
default:
DPRINTF(-1, "write to unknown register 0x%x\n", (unsigned)addr);
}
} else if ((addr >= AHCI_PORT_REGS_START_ADDR) &&
(addr < (AHCI_PORT_REGS_START_ADDR +
(s->ports * AHCI_PORT_ADDR_OFFSET_LEN)))) {
ahci_port_write(s, (addr - AHCI_PORT_REGS_START_ADDR) >> 7,
addr & AHCI_PORT_ADDR_OFFSET_MASK, val);
}
}
|
DoS
| 0
|
static void ahci_mem_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
AHCIState *s = opaque;
/* Only aligned reads are allowed on AHCI */
if (addr & 3) {
fprintf(stderr, "ahci: Mis-aligned write to addr 0x"
TARGET_FMT_plx "\n", addr);
return;
}
if (addr < AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR) {
DPRINTF(-1, "(addr 0x%08X), val 0x%08"PRIX64"\n", (unsigned) addr, val);
switch (addr) {
case HOST_CAP: /* R/WO, RO */
/* FIXME handle R/WO */
break;
case HOST_CTL: /* R/W */
if (val & HOST_CTL_RESET) {
DPRINTF(-1, "HBA Reset\n");
ahci_reset(s);
} else {
s->control_regs.ghc = (val & 0x3) | HOST_CTL_AHCI_EN;
ahci_check_irq(s);
}
break;
case HOST_IRQ_STAT: /* R/WC, RO */
s->control_regs.irqstatus &= ~val;
ahci_check_irq(s);
break;
case HOST_PORTS_IMPL: /* R/WO, RO */
/* FIXME handle R/WO */
break;
case HOST_VERSION: /* RO */
/* FIXME report write? */
break;
default:
DPRINTF(-1, "write to unknown register 0x%x\n", (unsigned)addr);
}
} else if ((addr >= AHCI_PORT_REGS_START_ADDR) &&
(addr < (AHCI_PORT_REGS_START_ADDR +
(s->ports * AHCI_PORT_ADDR_OFFSET_LEN)))) {
ahci_port_write(s, (addr - AHCI_PORT_REGS_START_ADDR) >> 7,
addr & AHCI_PORT_ADDR_OFFSET_MASK, val);
}
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,289
|
static uint32_t ahci_port_read(AHCIState *s, int port, int offset)
{
uint32_t val;
AHCIPortRegs *pr;
pr = &s->dev[port].port_regs;
switch (offset) {
case PORT_LST_ADDR:
val = pr->lst_addr;
break;
case PORT_LST_ADDR_HI:
val = pr->lst_addr_hi;
break;
case PORT_FIS_ADDR:
val = pr->fis_addr;
break;
case PORT_FIS_ADDR_HI:
val = pr->fis_addr_hi;
break;
case PORT_IRQ_STAT:
val = pr->irq_stat;
break;
case PORT_IRQ_MASK:
val = pr->irq_mask;
break;
case PORT_CMD:
val = pr->cmd;
break;
case PORT_TFDATA:
val = pr->tfdata;
break;
case PORT_SIG:
val = pr->sig;
break;
case PORT_SCR_STAT:
if (s->dev[port].port.ifs[0].blk) {
val = SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP |
SATA_SCR_SSTATUS_SPD_GEN1 | SATA_SCR_SSTATUS_IPM_ACTIVE;
} else {
val = SATA_SCR_SSTATUS_DET_NODEV;
}
break;
case PORT_SCR_CTL:
val = pr->scr_ctl;
break;
case PORT_SCR_ERR:
val = pr->scr_err;
break;
case PORT_SCR_ACT:
pr->scr_act &= ~s->dev[port].finished;
s->dev[port].finished = 0;
val = pr->scr_act;
break;
case PORT_CMD_ISSUE:
val = pr->cmd_issue;
break;
case PORT_RESERVED:
default:
val = 0;
}
DPRINTF(port, "offset: 0x%x val: 0x%x\n", offset, val);
return val;
}
|
DoS
| 0
|
static uint32_t ahci_port_read(AHCIState *s, int port, int offset)
{
uint32_t val;
AHCIPortRegs *pr;
pr = &s->dev[port].port_regs;
switch (offset) {
case PORT_LST_ADDR:
val = pr->lst_addr;
break;
case PORT_LST_ADDR_HI:
val = pr->lst_addr_hi;
break;
case PORT_FIS_ADDR:
val = pr->fis_addr;
break;
case PORT_FIS_ADDR_HI:
val = pr->fis_addr_hi;
break;
case PORT_IRQ_STAT:
val = pr->irq_stat;
break;
case PORT_IRQ_MASK:
val = pr->irq_mask;
break;
case PORT_CMD:
val = pr->cmd;
break;
case PORT_TFDATA:
val = pr->tfdata;
break;
case PORT_SIG:
val = pr->sig;
break;
case PORT_SCR_STAT:
if (s->dev[port].port.ifs[0].blk) {
val = SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP |
SATA_SCR_SSTATUS_SPD_GEN1 | SATA_SCR_SSTATUS_IPM_ACTIVE;
} else {
val = SATA_SCR_SSTATUS_DET_NODEV;
}
break;
case PORT_SCR_CTL:
val = pr->scr_ctl;
break;
case PORT_SCR_ERR:
val = pr->scr_err;
break;
case PORT_SCR_ACT:
pr->scr_act &= ~s->dev[port].finished;
s->dev[port].finished = 0;
val = pr->scr_act;
break;
case PORT_CMD_ISSUE:
val = pr->cmd_issue;
break;
case PORT_RESERVED:
default:
val = 0;
}
DPRINTF(port, "offset: 0x%x val: 0x%x\n", offset, val);
return val;
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,290
|
static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val)
{
AHCIPortRegs *pr = &s->dev[port].port_regs;
DPRINTF(port, "offset: 0x%x val: 0x%x\n", offset, val);
switch (offset) {
case PORT_LST_ADDR:
pr->lst_addr = val;
map_page(s->as, &s->dev[port].lst,
((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
s->dev[port].cur_cmd = NULL;
break;
case PORT_LST_ADDR_HI:
pr->lst_addr_hi = val;
map_page(s->as, &s->dev[port].lst,
((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
s->dev[port].cur_cmd = NULL;
break;
case PORT_FIS_ADDR:
pr->fis_addr = val;
map_page(s->as, &s->dev[port].res_fis,
((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
break;
case PORT_FIS_ADDR_HI:
pr->fis_addr_hi = val;
map_page(s->as, &s->dev[port].res_fis,
((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
break;
case PORT_IRQ_STAT:
pr->irq_stat &= ~val;
ahci_check_irq(s);
break;
case PORT_IRQ_MASK:
pr->irq_mask = val & 0xfdc000ff;
ahci_check_irq(s);
break;
case PORT_CMD:
pr->cmd = val & ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON);
if (pr->cmd & PORT_CMD_START) {
pr->cmd |= PORT_CMD_LIST_ON;
}
if (pr->cmd & PORT_CMD_FIS_RX) {
pr->cmd |= PORT_CMD_FIS_ON;
}
/* XXX usually the FIS would be pending on the bus here and
issuing deferred until the OS enables FIS receival.
Instead, we only submit it once - which works in most
cases, but is a hack. */
if ((pr->cmd & PORT_CMD_FIS_ON) &&
!s->dev[port].init_d2h_sent) {
ahci_init_d2h(&s->dev[port]);
s->dev[port].init_d2h_sent = true;
}
check_cmd(s, port);
break;
case PORT_TFDATA:
/* Read Only. */
break;
case PORT_SIG:
/* Read Only */
break;
case PORT_SCR_STAT:
/* Read Only */
break;
case PORT_SCR_CTL:
if (((pr->scr_ctl & AHCI_SCR_SCTL_DET) == 1) &&
((val & AHCI_SCR_SCTL_DET) == 0)) {
ahci_reset_port(s, port);
}
pr->scr_ctl = val;
break;
case PORT_SCR_ERR:
pr->scr_err &= ~val;
break;
case PORT_SCR_ACT:
/* RW1 */
pr->scr_act |= val;
break;
case PORT_CMD_ISSUE:
pr->cmd_issue |= val;
check_cmd(s, port);
break;
default:
break;
}
}
|
DoS
| 0
|
static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val)
{
AHCIPortRegs *pr = &s->dev[port].port_regs;
DPRINTF(port, "offset: 0x%x val: 0x%x\n", offset, val);
switch (offset) {
case PORT_LST_ADDR:
pr->lst_addr = val;
map_page(s->as, &s->dev[port].lst,
((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
s->dev[port].cur_cmd = NULL;
break;
case PORT_LST_ADDR_HI:
pr->lst_addr_hi = val;
map_page(s->as, &s->dev[port].lst,
((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024);
s->dev[port].cur_cmd = NULL;
break;
case PORT_FIS_ADDR:
pr->fis_addr = val;
map_page(s->as, &s->dev[port].res_fis,
((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
break;
case PORT_FIS_ADDR_HI:
pr->fis_addr_hi = val;
map_page(s->as, &s->dev[port].res_fis,
((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256);
break;
case PORT_IRQ_STAT:
pr->irq_stat &= ~val;
ahci_check_irq(s);
break;
case PORT_IRQ_MASK:
pr->irq_mask = val & 0xfdc000ff;
ahci_check_irq(s);
break;
case PORT_CMD:
pr->cmd = val & ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON);
if (pr->cmd & PORT_CMD_START) {
pr->cmd |= PORT_CMD_LIST_ON;
}
if (pr->cmd & PORT_CMD_FIS_RX) {
pr->cmd |= PORT_CMD_FIS_ON;
}
/* XXX usually the FIS would be pending on the bus here and
issuing deferred until the OS enables FIS receival.
Instead, we only submit it once - which works in most
cases, but is a hack. */
if ((pr->cmd & PORT_CMD_FIS_ON) &&
!s->dev[port].init_d2h_sent) {
ahci_init_d2h(&s->dev[port]);
s->dev[port].init_d2h_sent = true;
}
check_cmd(s, port);
break;
case PORT_TFDATA:
/* Read Only. */
break;
case PORT_SIG:
/* Read Only */
break;
case PORT_SCR_STAT:
/* Read Only */
break;
case PORT_SCR_CTL:
if (((pr->scr_ctl & AHCI_SCR_SCTL_DET) == 1) &&
((val & AHCI_SCR_SCTL_DET) == 0)) {
ahci_reset_port(s, port);
}
pr->scr_ctl = val;
break;
case PORT_SCR_ERR:
pr->scr_err &= ~val;
break;
case PORT_SCR_ACT:
/* RW1 */
pr->scr_act |= val;
break;
case PORT_CMD_ISSUE:
pr->cmd_issue |= val;
check_cmd(s, port);
break;
default:
break;
}
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,291
|
static void ahci_reg_init(AHCIState *s)
{
int i;
s->control_regs.cap = (s->ports - 1) |
(AHCI_NUM_COMMAND_SLOTS << 8) |
(AHCI_SUPPORTED_SPEED_GEN1 << AHCI_SUPPORTED_SPEED) |
HOST_CAP_NCQ | HOST_CAP_AHCI;
s->control_regs.impl = (1 << s->ports) - 1;
s->control_regs.version = AHCI_VERSION_1_0;
for (i = 0; i < s->ports; i++) {
s->dev[i].port_state = STATE_RUN;
}
}
|
DoS
| 0
|
static void ahci_reg_init(AHCIState *s)
{
int i;
s->control_regs.cap = (s->ports - 1) |
(AHCI_NUM_COMMAND_SLOTS << 8) |
(AHCI_SUPPORTED_SPEED_GEN1 << AHCI_SUPPORTED_SPEED) |
HOST_CAP_NCQ | HOST_CAP_AHCI;
s->control_regs.impl = (1 << s->ports) - 1;
s->control_regs.version = AHCI_VERSION_1_0;
for (i = 0; i < s->ports; i++) {
s->dev[i].port_state = STATE_RUN;
}
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,292
|
static void ahci_reset_port(AHCIState *s, int port)
{
AHCIDevice *d = &s->dev[port];
AHCIPortRegs *pr = &d->port_regs;
IDEState *ide_state = &d->port.ifs[0];
int i;
DPRINTF(port, "reset port\n");
ide_bus_reset(&d->port);
ide_state->ncq_queues = AHCI_MAX_CMDS;
pr->scr_stat = 0;
pr->scr_err = 0;
pr->scr_act = 0;
pr->tfdata = 0x7F;
pr->sig = 0xFFFFFFFF;
d->busy_slot = -1;
d->init_d2h_sent = false;
ide_state = &s->dev[port].port.ifs[0];
if (!ide_state->blk) {
return;
}
/* reset ncq queue */
for (i = 0; i < AHCI_MAX_CMDS; i++) {
NCQTransferState *ncq_tfs = &s->dev[port].ncq_tfs[i];
if (!ncq_tfs->used) {
continue;
}
if (ncq_tfs->aiocb) {
blk_aio_cancel(ncq_tfs->aiocb);
ncq_tfs->aiocb = NULL;
}
/* Maybe we just finished the request thanks to blk_aio_cancel() */
if (!ncq_tfs->used) {
continue;
}
qemu_sglist_destroy(&ncq_tfs->sglist);
ncq_tfs->used = 0;
}
s->dev[port].port_state = STATE_RUN;
if (!ide_state->blk) {
pr->sig = 0;
ide_state->status = SEEK_STAT | WRERR_STAT;
} else if (ide_state->drive_kind == IDE_CD) {
pr->sig = SATA_SIGNATURE_CDROM;
ide_state->lcyl = 0x14;
ide_state->hcyl = 0xeb;
DPRINTF(port, "set lcyl = %d\n", ide_state->lcyl);
ide_state->status = SEEK_STAT | WRERR_STAT | READY_STAT;
} else {
pr->sig = SATA_SIGNATURE_DISK;
ide_state->status = SEEK_STAT | WRERR_STAT;
}
ide_state->error = 1;
ahci_init_d2h(d);
}
|
DoS
| 0
|
static void ahci_reset_port(AHCIState *s, int port)
{
AHCIDevice *d = &s->dev[port];
AHCIPortRegs *pr = &d->port_regs;
IDEState *ide_state = &d->port.ifs[0];
int i;
DPRINTF(port, "reset port\n");
ide_bus_reset(&d->port);
ide_state->ncq_queues = AHCI_MAX_CMDS;
pr->scr_stat = 0;
pr->scr_err = 0;
pr->scr_act = 0;
pr->tfdata = 0x7F;
pr->sig = 0xFFFFFFFF;
d->busy_slot = -1;
d->init_d2h_sent = false;
ide_state = &s->dev[port].port.ifs[0];
if (!ide_state->blk) {
return;
}
/* reset ncq queue */
for (i = 0; i < AHCI_MAX_CMDS; i++) {
NCQTransferState *ncq_tfs = &s->dev[port].ncq_tfs[i];
if (!ncq_tfs->used) {
continue;
}
if (ncq_tfs->aiocb) {
blk_aio_cancel(ncq_tfs->aiocb);
ncq_tfs->aiocb = NULL;
}
/* Maybe we just finished the request thanks to blk_aio_cancel() */
if (!ncq_tfs->used) {
continue;
}
qemu_sglist_destroy(&ncq_tfs->sglist);
ncq_tfs->used = 0;
}
s->dev[port].port_state = STATE_RUN;
if (!ide_state->blk) {
pr->sig = 0;
ide_state->status = SEEK_STAT | WRERR_STAT;
} else if (ide_state->drive_kind == IDE_CD) {
pr->sig = SATA_SIGNATURE_CDROM;
ide_state->lcyl = 0x14;
ide_state->hcyl = 0xeb;
DPRINTF(port, "set lcyl = %d\n", ide_state->lcyl);
ide_state->status = SEEK_STAT | WRERR_STAT | READY_STAT;
} else {
pr->sig = SATA_SIGNATURE_DISK;
ide_state->status = SEEK_STAT | WRERR_STAT;
}
ide_state->error = 1;
ahci_init_d2h(d);
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,293
|
static void ahci_write_fis_d2h(AHCIDevice *ad, uint8_t *cmd_fis)
{
AHCIPortRegs *pr = &ad->port_regs;
uint8_t *d2h_fis;
int i;
dma_addr_t cmd_len = 0x80;
int cmd_mapped = 0;
IDEState *s = &ad->port.ifs[0];
if (!ad->res_fis || !(pr->cmd & PORT_CMD_FIS_RX)) {
return;
}
if (!cmd_fis) {
/* map cmd_fis */
uint64_t tbl_addr = le64_to_cpu(ad->cur_cmd->tbl_addr);
cmd_fis = dma_memory_map(ad->hba->as, tbl_addr, &cmd_len,
DMA_DIRECTION_TO_DEVICE);
cmd_mapped = 1;
}
d2h_fis = &ad->res_fis[RES_FIS_RFIS];
d2h_fis[0] = 0x34;
d2h_fis[1] = (ad->hba->control_regs.irqstatus ? (1 << 6) : 0);
d2h_fis[2] = s->status;
d2h_fis[3] = s->error;
d2h_fis[4] = s->sector;
d2h_fis[5] = s->lcyl;
d2h_fis[6] = s->hcyl;
d2h_fis[7] = s->select;
d2h_fis[8] = s->hob_sector;
d2h_fis[9] = s->hob_lcyl;
d2h_fis[10] = s->hob_hcyl;
d2h_fis[11] = 0;
d2h_fis[12] = cmd_fis[12];
d2h_fis[13] = cmd_fis[13];
for (i = 14; i < 20; i++) {
d2h_fis[i] = 0;
}
/* Update shadow registers: */
pr->tfdata = (ad->port.ifs[0].error << 8) |
ad->port.ifs[0].status;
if (d2h_fis[2] & ERR_STAT) {
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_TF_ERR);
}
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_D2H_REG_FIS);
if (cmd_mapped) {
dma_memory_unmap(ad->hba->as, cmd_fis, cmd_len,
DMA_DIRECTION_TO_DEVICE, cmd_len);
}
}
|
DoS
| 0
|
static void ahci_write_fis_d2h(AHCIDevice *ad, uint8_t *cmd_fis)
{
AHCIPortRegs *pr = &ad->port_regs;
uint8_t *d2h_fis;
int i;
dma_addr_t cmd_len = 0x80;
int cmd_mapped = 0;
IDEState *s = &ad->port.ifs[0];
if (!ad->res_fis || !(pr->cmd & PORT_CMD_FIS_RX)) {
return;
}
if (!cmd_fis) {
/* map cmd_fis */
uint64_t tbl_addr = le64_to_cpu(ad->cur_cmd->tbl_addr);
cmd_fis = dma_memory_map(ad->hba->as, tbl_addr, &cmd_len,
DMA_DIRECTION_TO_DEVICE);
cmd_mapped = 1;
}
d2h_fis = &ad->res_fis[RES_FIS_RFIS];
d2h_fis[0] = 0x34;
d2h_fis[1] = (ad->hba->control_regs.irqstatus ? (1 << 6) : 0);
d2h_fis[2] = s->status;
d2h_fis[3] = s->error;
d2h_fis[4] = s->sector;
d2h_fis[5] = s->lcyl;
d2h_fis[6] = s->hcyl;
d2h_fis[7] = s->select;
d2h_fis[8] = s->hob_sector;
d2h_fis[9] = s->hob_lcyl;
d2h_fis[10] = s->hob_hcyl;
d2h_fis[11] = 0;
d2h_fis[12] = cmd_fis[12];
d2h_fis[13] = cmd_fis[13];
for (i = 14; i < 20; i++) {
d2h_fis[i] = 0;
}
/* Update shadow registers: */
pr->tfdata = (ad->port.ifs[0].error << 8) |
ad->port.ifs[0].status;
if (d2h_fis[2] & ERR_STAT) {
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_TF_ERR);
}
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_D2H_REG_FIS);
if (cmd_mapped) {
dma_memory_unmap(ad->hba->as, cmd_fis, cmd_len,
DMA_DIRECTION_TO_DEVICE, cmd_len);
}
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,294
|
static void ahci_write_fis_pio(AHCIDevice *ad, uint16_t len)
{
AHCIPortRegs *pr = &ad->port_regs;
uint8_t *pio_fis, *cmd_fis;
uint64_t tbl_addr;
dma_addr_t cmd_len = 0x80;
IDEState *s = &ad->port.ifs[0];
if (!ad->res_fis || !(pr->cmd & PORT_CMD_FIS_RX)) {
return;
}
/* map cmd_fis */
tbl_addr = le64_to_cpu(ad->cur_cmd->tbl_addr);
cmd_fis = dma_memory_map(ad->hba->as, tbl_addr, &cmd_len,
DMA_DIRECTION_TO_DEVICE);
if (cmd_fis == NULL) {
DPRINTF(ad->port_no, "dma_memory_map failed in ahci_write_fis_pio");
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_HBUS_ERR);
return;
}
if (cmd_len != 0x80) {
DPRINTF(ad->port_no,
"dma_memory_map mapped too few bytes in ahci_write_fis_pio");
dma_memory_unmap(ad->hba->as, cmd_fis, cmd_len,
DMA_DIRECTION_TO_DEVICE, cmd_len);
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_HBUS_ERR);
return;
}
pio_fis = &ad->res_fis[RES_FIS_PSFIS];
pio_fis[0] = 0x5f;
pio_fis[1] = (ad->hba->control_regs.irqstatus ? (1 << 6) : 0);
pio_fis[2] = s->status;
pio_fis[3] = s->error;
pio_fis[4] = s->sector;
pio_fis[5] = s->lcyl;
pio_fis[6] = s->hcyl;
pio_fis[7] = s->select;
pio_fis[8] = s->hob_sector;
pio_fis[9] = s->hob_lcyl;
pio_fis[10] = s->hob_hcyl;
pio_fis[11] = 0;
pio_fis[12] = cmd_fis[12];
pio_fis[13] = cmd_fis[13];
pio_fis[14] = 0;
pio_fis[15] = s->status;
pio_fis[16] = len & 255;
pio_fis[17] = len >> 8;
pio_fis[18] = 0;
pio_fis[19] = 0;
/* Update shadow registers: */
pr->tfdata = (ad->port.ifs[0].error << 8) |
ad->port.ifs[0].status;
if (pio_fis[2] & ERR_STAT) {
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_TF_ERR);
}
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_PIOS_FIS);
dma_memory_unmap(ad->hba->as, cmd_fis, cmd_len,
DMA_DIRECTION_TO_DEVICE, cmd_len);
}
|
DoS
| 0
|
static void ahci_write_fis_pio(AHCIDevice *ad, uint16_t len)
{
AHCIPortRegs *pr = &ad->port_regs;
uint8_t *pio_fis, *cmd_fis;
uint64_t tbl_addr;
dma_addr_t cmd_len = 0x80;
IDEState *s = &ad->port.ifs[0];
if (!ad->res_fis || !(pr->cmd & PORT_CMD_FIS_RX)) {
return;
}
/* map cmd_fis */
tbl_addr = le64_to_cpu(ad->cur_cmd->tbl_addr);
cmd_fis = dma_memory_map(ad->hba->as, tbl_addr, &cmd_len,
DMA_DIRECTION_TO_DEVICE);
if (cmd_fis == NULL) {
DPRINTF(ad->port_no, "dma_memory_map failed in ahci_write_fis_pio");
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_HBUS_ERR);
return;
}
if (cmd_len != 0x80) {
DPRINTF(ad->port_no,
"dma_memory_map mapped too few bytes in ahci_write_fis_pio");
dma_memory_unmap(ad->hba->as, cmd_fis, cmd_len,
DMA_DIRECTION_TO_DEVICE, cmd_len);
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_HBUS_ERR);
return;
}
pio_fis = &ad->res_fis[RES_FIS_PSFIS];
pio_fis[0] = 0x5f;
pio_fis[1] = (ad->hba->control_regs.irqstatus ? (1 << 6) : 0);
pio_fis[2] = s->status;
pio_fis[3] = s->error;
pio_fis[4] = s->sector;
pio_fis[5] = s->lcyl;
pio_fis[6] = s->hcyl;
pio_fis[7] = s->select;
pio_fis[8] = s->hob_sector;
pio_fis[9] = s->hob_lcyl;
pio_fis[10] = s->hob_hcyl;
pio_fis[11] = 0;
pio_fis[12] = cmd_fis[12];
pio_fis[13] = cmd_fis[13];
pio_fis[14] = 0;
pio_fis[15] = s->status;
pio_fis[16] = len & 255;
pio_fis[17] = len >> 8;
pio_fis[18] = 0;
pio_fis[19] = 0;
/* Update shadow registers: */
pr->tfdata = (ad->port.ifs[0].error << 8) |
ad->port.ifs[0].status;
if (pio_fis[2] & ERR_STAT) {
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_TF_ERR);
}
ahci_trigger_irq(ad->hba, ad, PORT_IRQ_PIOS_FIS);
dma_memory_unmap(ad->hba->as, cmd_fis, cmd_len,
DMA_DIRECTION_TO_DEVICE, cmd_len);
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,295
|
static void ahci_write_fis_sdb(AHCIState *s, int port, uint32_t finished)
{
AHCIDevice *ad = &s->dev[port];
AHCIPortRegs *pr = &ad->port_regs;
IDEState *ide_state;
SDBFIS *sdb_fis;
if (!s->dev[port].res_fis ||
!(pr->cmd & PORT_CMD_FIS_RX)) {
return;
}
sdb_fis = (SDBFIS *)&ad->res_fis[RES_FIS_SDBFIS];
ide_state = &ad->port.ifs[0];
sdb_fis->type = 0xA1;
/* Interrupt pending & Notification bit */
sdb_fis->flags = (ad->hba->control_regs.irqstatus ? (1 << 6) : 0);
sdb_fis->status = ide_state->status & 0x77;
sdb_fis->error = ide_state->error;
/* update SAct field in SDB_FIS */
s->dev[port].finished |= finished;
sdb_fis->payload = cpu_to_le32(ad->finished);
/* Update shadow registers (except BSY 0x80 and DRQ 0x08) */
pr->tfdata = (ad->port.ifs[0].error << 8) |
(ad->port.ifs[0].status & 0x77) |
(pr->tfdata & 0x88);
ahci_trigger_irq(s, ad, PORT_IRQ_SDB_FIS);
}
|
DoS
| 0
|
static void ahci_write_fis_sdb(AHCIState *s, int port, uint32_t finished)
{
AHCIDevice *ad = &s->dev[port];
AHCIPortRegs *pr = &ad->port_regs;
IDEState *ide_state;
SDBFIS *sdb_fis;
if (!s->dev[port].res_fis ||
!(pr->cmd & PORT_CMD_FIS_RX)) {
return;
}
sdb_fis = (SDBFIS *)&ad->res_fis[RES_FIS_SDBFIS];
ide_state = &ad->port.ifs[0];
sdb_fis->type = 0xA1;
/* Interrupt pending & Notification bit */
sdb_fis->flags = (ad->hba->control_regs.irqstatus ? (1 << 6) : 0);
sdb_fis->status = ide_state->status & 0x77;
sdb_fis->error = ide_state->error;
/* update SAct field in SDB_FIS */
s->dev[port].finished |= finished;
sdb_fis->payload = cpu_to_le32(ad->finished);
/* Update shadow registers (except BSY 0x80 and DRQ 0x08) */
pr->tfdata = (ad->port.ifs[0].error << 8) |
(ad->port.ifs[0].status & 0x77) |
(pr->tfdata & 0x88);
ahci_trigger_irq(s, ad, PORT_IRQ_SDB_FIS);
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,296
|
static void check_cmd(AHCIState *s, int port)
{
AHCIPortRegs *pr = &s->dev[port].port_regs;
int slot;
if ((pr->cmd & PORT_CMD_START) && pr->cmd_issue) {
for (slot = 0; (slot < 32) && pr->cmd_issue; slot++) {
if ((pr->cmd_issue & (1U << slot)) &&
!handle_cmd(s, port, slot)) {
pr->cmd_issue &= ~(1U << slot);
}
}
}
}
|
DoS
| 0
|
static void check_cmd(AHCIState *s, int port)
{
AHCIPortRegs *pr = &s->dev[port].port_regs;
int slot;
if ((pr->cmd & PORT_CMD_START) && pr->cmd_issue) {
for (slot = 0; (slot < 32) && pr->cmd_issue; slot++) {
if ((pr->cmd_issue & (1U << slot)) &&
!handle_cmd(s, port, slot)) {
pr->cmd_issue &= ~(1U << slot);
}
}
}
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,297
|
static void debug_print_fis(uint8_t *fis, int cmd_len)
{
#ifdef DEBUG_AHCI
int i;
fprintf(stderr, "fis:");
for (i = 0; i < cmd_len; i++) {
if ((i & 0xf) == 0) {
fprintf(stderr, "\n%02x:",i);
}
fprintf(stderr, "%02x ",fis[i]);
}
fprintf(stderr, "\n");
#endif
}
|
DoS
| 0
|
static void debug_print_fis(uint8_t *fis, int cmd_len)
{
#ifdef DEBUG_AHCI
int i;
fprintf(stderr, "fis:");
for (i = 0; i < cmd_len; i++) {
if ((i & 0xf) == 0) {
fprintf(stderr, "\n%02x:",i);
}
fprintf(stderr, "%02x ",fis[i]);
}
fprintf(stderr, "\n");
#endif
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,298
|
static int prdt_tbl_entry_size(const AHCI_SG *tbl)
{
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
|
DoS
| 0
|
static int prdt_tbl_entry_size(const AHCI_SG *tbl)
{
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
|
@@ -730,7 +730,8 @@ static int prdt_tbl_entry_size(const AHCI_SG *tbl)
return (le32_to_cpu(tbl->flags_size) & AHCI_PRDT_SIZE_MASK) + 1;
}
-static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
+static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
+ int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint32_t opts = le32_to_cpu(cmd->opts);
@@ -741,13 +742,21 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
uint8_t *prdt;
int i;
int r = 0;
- int sum = 0;
+ uint64_t sum = 0;
int off_idx = -1;
- int off_pos = -1;
+ int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
+ /*
+ * Note: AHCI PRDT can describe up to 256GiB. SATA/ATA only support
+ * transactions of up to 32MiB as of ATA8-ACS3 rev 1b, assuming a
+ * 512 byte sector size. We limit the PRDT in this implementation to
+ * a reasonably large 2GiB, which can accommodate the maximum transfer
+ * request for sector sizes up to 32K.
+ */
+
if (!sglist_alloc_hint) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
@@ -782,7 +791,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
- "off_idx: %d, off_pos: %d\n",
+ "off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
@@ -797,6 +806,13 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist, int offset)
/* flags_size is zero-based */
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
+ if (sglist->size > INT32_MAX) {
+ error_report("AHCI Physical Region Descriptor Table describes "
+ "more than 2 GiB.\n");
+ qemu_sglist_destroy(sglist);
+ r = -1;
+ goto out;
+ }
}
}
@@ -1140,16 +1156,19 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s,
* Not currently invoked by PIO R/W chains,
* which invoke ahci_populate_sglist via ahci_start_transfer.
*/
-static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
+static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
IDEState *s = &ad->port.ifs[0];
- ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset);
+ if (ahci_populate_sglist(ad, &s->sg, s->io_buffer_offset) == -1) {
+ DPRINTF(ad->port_no, "ahci_dma_prepare_buf failed.\n");
+ return -1;
+ }
s->io_buffer_size = s->sg.size;
DPRINTF(ad->port_no, "len=%#x\n", s->io_buffer_size);
- return s->io_buffer_size != 0;
+ return s->io_buffer_size;
}
/**
|
CWE-399
| null | null |
5,299
|
static bool cmd_cfa_access_metadata_storage(IDEState *s, uint8_t cmd)
{
switch (s->feature) {
case 0x02: /* Inquiry Metadata Storage */
ide_cfata_metadata_inquiry(s);
break;
case 0x03: /* Read Metadata Storage */
ide_cfata_metadata_read(s);
break;
case 0x04: /* Write Metadata Storage */
ide_cfata_metadata_write(s);
break;
default:
ide_abort_command(s);
return true;
}
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
s->status = 0x00; /* NOTE: READY is _not_ set */
ide_set_irq(s->bus);
return false;
}
|
DoS
| 0
|
static bool cmd_cfa_access_metadata_storage(IDEState *s, uint8_t cmd)
{
switch (s->feature) {
case 0x02: /* Inquiry Metadata Storage */
ide_cfata_metadata_inquiry(s);
break;
case 0x03: /* Read Metadata Storage */
ide_cfata_metadata_read(s);
break;
case 0x04: /* Write Metadata Storage */
ide_cfata_metadata_write(s);
break;
default:
ide_abort_command(s);
return true;
}
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
s->status = 0x00; /* NOTE: READY is _not_ set */
ide_set_irq(s->bus);
return false;
}
|
@@ -731,10 +731,11 @@ void ide_dma_cb(void *opaque, int ret)
n = s->nsector;
s->io_buffer_index = 0;
s->io_buffer_size = n * 512;
- if (s->bus->dma->ops->prepare_buf(s->bus->dma, ide_cmd_is_read(s)) == 0) {
+ if (s->bus->dma->ops->prepare_buf(s->bus->dma, ide_cmd_is_read(s)) < 512) {
/* The PRDs were too short. Reset the Active bit, but don't raise an
* interrupt. */
s->status = READY_STAT | SEEK_STAT;
+ dma_buf_commit(s, 0);
goto eot;
}
@@ -2313,12 +2314,17 @@ static int ide_nop_int(IDEDMA *dma, int x)
return 0;
}
+static int32_t ide_nop_int32(IDEDMA *dma, int x)
+{
+ return 0;
+}
+
static void ide_nop_restart(void *opaque, int x, RunState y)
{
}
static const IDEDMAOps ide_dma_nop_ops = {
- .prepare_buf = ide_nop_int,
+ .prepare_buf = ide_nop_int32,
.rw_buf = ide_nop_int,
.set_unit = ide_nop_int,
.restart_cb = ide_nop_restart,
|
CWE-399
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.