Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
0c516d06
Commit
0c516d06
authored
Sep 11, 2017
by
richmidwinter
Committed by
daryl herzmann
Sep 11, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OF-1021: Admin Console Arbitrary File Upload (#866)
parent
ef2ec40a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
PluginManager.java
...va/org/jivesoftware/openfire/container/PluginManager.java
+10
-5
No files found.
src/java/org/jivesoftware/openfire/container/PluginManager.java
View file @
0c516d06
...
@@ -38,6 +38,8 @@ import java.nio.file.attribute.BasicFileAttributes;
...
@@ -38,6 +38,8 @@ import java.nio.file.attribute.BasicFileAttributes;
import
java.nio.file.attribute.FileTime
;
import
java.nio.file.attribute.FileTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.CopyOnWriteArraySet
;
import
java.util.concurrent.CopyOnWriteArraySet
;
import
java.util.jar.JarFile
;
import
java.util.zip.ZipException
;
/**
/**
* Manages plugins.
* Manages plugins.
...
@@ -184,17 +186,20 @@ public class PluginManager
...
@@ -184,17 +186,20 @@ public class PluginManager
try
try
{
{
// If pluginFilename is a path instead of a simple file name, we only want the file name
// If pluginFilename is a path instead of a simple file name, we only want the file name
int
index
=
pluginFilename
.
lastIndexOf
(
File
.
separator
);
pluginFilename
=
Paths
.
get
(
pluginFilename
).
getFileName
().
toString
();
if
(
index
!=
-
1
)
{
pluginFilename
=
pluginFilename
.
substring
(
index
+
1
);
}
// Absolute path to the plugin file
// Absolute path to the plugin file
Path
absolutePath
=
pluginDirectory
.
resolve
(
pluginFilename
);
Path
absolutePath
=
pluginDirectory
.
resolve
(
pluginFilename
);
Path
partFile
=
pluginDirectory
.
resolve
(
pluginFilename
+
".part"
);
Path
partFile
=
pluginDirectory
.
resolve
(
pluginFilename
+
".part"
);
// Save input stream contents to a temp file
// Save input stream contents to a temp file
Files
.
copy
(
in
,
partFile
,
StandardCopyOption
.
REPLACE_EXISTING
);
Files
.
copy
(
in
,
partFile
,
StandardCopyOption
.
REPLACE_EXISTING
);
// Check if zip file, else ZipException caught below.
try
(
JarFile
file
=
new
JarFile
(
partFile
.
toFile
()))
{
}
catch
(
ZipException
e
)
{
Files
.
deleteIfExists
(
partFile
);
throw
e
;
};
// Rename temp file to .jar
// Rename temp file to .jar
Files
.
move
(
partFile
,
absolutePath
,
StandardCopyOption
.
REPLACE_EXISTING
);
Files
.
move
(
partFile
,
absolutePath
,
StandardCopyOption
.
REPLACE_EXISTING
);
// Ask the plugin monitor to update the plugin immediately.
// Ask the plugin monitor to update the plugin immediately.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment